Reallocate the storage for the buffer to be newSize and copy exisiting contents to the new buffer. Must not be used to decrease the size of the buffer.
| 81 | /// copy exisiting contents to the new buffer. |
| 82 | /// Must not be used to decrease the size of the buffer. |
| 83 | void ReAllocate(int newSize) { |
| 84 | if (newSize > size) { |
| 85 | // Move the gap to the end |
| 86 | GapTo(lengthBody); |
| 87 | T *newBody = new T[newSize]; |
| 88 | if ((size != 0) && (body != 0)) { |
| 89 | memmove(newBody, body, sizeof(T) * lengthBody); |
| 90 | delete []body; |
| 91 | } |
| 92 | body = newBody; |
| 93 | gapLength += newSize - size; |
| 94 | size = newSize; |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | /// Retrieve the character at a particular position. |
| 99 | /// Retrieving positions outside the range of the buffer returns 0. |