| 115 | |
| 116 | |
| 117 | void ArrayBase::reserve(int inSize) const |
| 118 | { |
| 119 | if (mAlloc<inSize) |
| 120 | { |
| 121 | int elemSize = GetElementSize(); |
| 122 | int bytes = inSize * elemSize; |
| 123 | |
| 124 | if (mBase) |
| 125 | { |
| 126 | bool wasUnamanaged = mAlloc<0; |
| 127 | if (wasUnamanaged) |
| 128 | { |
| 129 | char *base=(char *)hx::InternalNew(bytes,false); |
| 130 | memcpy(base,mBase,length*elemSize); |
| 131 | mBase = base; |
| 132 | } |
| 133 | else |
| 134 | mBase = (char *)hx::InternalRealloc(length*elemSize,mBase, bytes ); |
| 135 | } |
| 136 | else |
| 137 | { |
| 138 | mBase = (char *)hx::InternalNew(bytes,false); |
| 139 | #ifdef HXCPP_TELEMETRY |
| 140 | __hxt_new_array(mBase, bytes); |
| 141 | #endif |
| 142 | } |
| 143 | |
| 144 | mAlloc = inSize; |
| 145 | HX_OBJ_WB_GET(const_cast<ArrayBase *>(this),mBase); |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | |
| 150 | void ArrayBase::Realloc(int inSize) const |
no test coverage detected