MCPcopy Create free account
hub / github.com/HaxeFoundation/hxcpp / __SetSizeExact

Method __SetSizeExact

src/Array.cpp:287–329  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

285
286
287void 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
332Dynamic ArrayBase::__unsafe_get(const Dynamic &i)

Callers 5

runVoidMethod · 0.45
runVoidMethod · 0.45
runSetSizeExactMethod · 0.45

Calls 9

InternalReleaseMemFunction · 0.85
AllocAtomicFunction · 0.85
NewGCPrivateFunction · 0.85
NewGCBytesFunction · 0.85
memcpyFunction · 0.85
minFunction · 0.85
InternalReallocFunction · 0.85
GetElementSizeFunction · 0.50
__hxt_new_arrayFunction · 0.50

Tested by

no test coverage detected