10 // Is this still needed? (Lgb)
12 void * my_memcpy(void * ps_in, void const * pt_in, size_t n)
14 char * ps = static_cast<char *>(ps_in);
15 char const * pt = static_cast<char const *>(pt_in);
16 while (n--) *ps++ = *pt++;
21 int MathedArray::empty() const
27 int MathedArray::last() const
33 void MathedArray::last(int l)
39 int MathedArray::maxsize() const
41 return static_cast<int>(bf_.size());
45 void MathedArray::need_size(int needed)
47 if (needed >= maxsize())
52 void MathedArray::resize(int newsize)
54 if (newsize < ARRAY_MIN_SIZE)
55 newsize = ARRAY_MIN_SIZE;
56 newsize += ARRAY_STEP - (newsize % ARRAY_STEP);
58 if (last_ >= newsize) last_ = newsize - 1;
63 MathedArray::MathedArray(int size)
65 int newsize = (size < ARRAY_MIN_SIZE) ? ARRAY_MIN_SIZE : size;
71 void MathedArray::move(int p, int shift)
74 need_size(last_ + shift);
75 memmove(&bf_[p + shift], &bf_[p], last_ - p);
82 void MathedArray::mergeF(MathedArray * a, int p, int dx)
84 my_memcpy(&bf_[p], &a->bf_[0], dx);
88 void MathedArray::raw_pointer_copy(MathedInset ** p, int pos) const
90 my_memcpy(p, &bf_[pos], sizeof(MathedInset*));
94 void MathedArray::raw_pointer_insert(void * p, int pos, int len)
96 my_memcpy(&bf_[pos], &p, len);
100 void MathedArray::strange_copy(MathedArray * dest, int dpos,
103 my_memcpy(&dest->bf_[dpos], &bf_[spos], len);
107 byte MathedArray::operator[](int i) const
113 byte & MathedArray::operator[](int i)
119 void MathedArray::insert(int pos, byte c)
121 if (pos < 0) pos = last_;
123 // I think this should be replaced by need_size(pos). Note that the
124 // current code looks troublesome if pos > maxsize() + ARRAY_STEP.
125 if (pos >= maxsize())
126 resize(maxsize() + ARRAY_STEP);