MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / reallocate

Method reallocate

src/misc/memory_model.cpp:190–211  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188 }
189
190 char * MemoryModel::reallocate ( char * ptr, uint64_t size, uint64_t nsize ) {
191 if ( !ptr ) return allocate(nsize);
192 size = (size + alignMask) & ~alignMask;
193 nsize = (nsize + alignMask) & ~alignMask;
194 char * nptr = allocate(nsize);
195 DAS_VERIFYF(nptr,"out of memory?");
196 memcpy ( nptr, ptr, das::min(size,nsize) );
197#if DAS_TRACK_ALLOCATIONS
198 if ( trackAllocations ) {
199 auto pAt = bigStuffAt.find(ptr);
200 if ( pAt != bigStuffAt.end() ) {
201 bigStuffAt[nptr] = pAt->second;
202 }
203 auto pCm = bigStuffComment.find(ptr);
204 if ( pCm != bigStuffComment.end() ) {
205 bigStuffComment[nptr] = pCm->second;
206 }
207 }
208#endif
209 free(ptr, size);
210 return nptr;
211 }
212
213 void MemoryModel::reset() {
214 for ( auto & itb : bigStuff ) {

Callers 6

array_reserveFunction · 0.45
writeMethod · 0.45
closeMethod · 0.45
impl_reallocateMethod · 0.45
das_context_reallocateFunction · 0.45

Calls 4

allocateFunction · 0.85
freeFunction · 0.50
findMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected