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

Method reserve

src/Array.cpp:117–147  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

115
116
117void 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
150void ArrayBase::Realloc(int inSize) const

Callers 2

__newFunction · 0.45
reserveFunction · 0.45

Calls 5

InternalNewFunction · 0.85
memcpyFunction · 0.85
InternalReallocFunction · 0.85
GetElementSizeFunction · 0.50
__hxt_new_arrayFunction · 0.50

Tested by

no test coverage detected