| 285 | |
| 286 | |
| 287 | void ArrayBase::__SetSizeExact(int inSize) |
| 288 | { |
| 289 | if (inSize==0) |
| 290 | { |
| 291 | InternalReleaseMem(mBase); |
| 292 | mBase = 0; |
| 293 | mAlloc = length = 0; |
| 294 | } |
| 295 | else if (inSize!=length || inSize!=mAlloc) |
| 296 | { |
| 297 | int elemSize = GetElementSize(); |
| 298 | int bytes = inSize * elemSize; |
| 299 | if (mBase) |
| 300 | { |
| 301 | bool wasUnamanaged = mAlloc<0; |
| 302 | |
| 303 | if (wasUnamanaged) |
| 304 | { |
| 305 | char *base=(char *)(AllocAtomic() ? hx::NewGCPrivate(0,bytes) : hx::NewGCBytes(0,bytes)); |
| 306 | memcpy(base,mBase,std::min(length,inSize)*elemSize); |
| 307 | mBase = base; |
| 308 | } |
| 309 | else |
| 310 | mBase = (char *)hx::InternalRealloc(length*elemSize,mBase, bytes ); |
| 311 | } |
| 312 | else if (AllocAtomic()) |
| 313 | { |
| 314 | mBase = (char *)hx::NewGCPrivate(0,bytes); |
| 315 | #ifdef HXCPP_TELEMETRY |
| 316 | __hxt_new_array(mBase, bytes); |
| 317 | #endif |
| 318 | } |
| 319 | else |
| 320 | { |
| 321 | mBase = (char *)hx::NewGCBytes(0,bytes); |
| 322 | #ifdef HXCPP_TELEMETRY |
| 323 | __hxt_new_array(mBase, bytes); |
| 324 | #endif |
| 325 | } |
| 326 | mAlloc = length = inSize; |
| 327 | HX_OBJ_WB_GET(this,mBase); |
| 328 | } |
| 329 | } |
| 330 | |
| 331 | |
| 332 | Dynamic ArrayBase::__unsafe_get(const Dynamic &i) |
no test coverage detected