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

Method allocate

src/misc/memory_model.cpp:118–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116 }
117
118 char * MemoryModel::allocate ( uint64_t size ) {
119 if ( !size ) return nullptr;
120 size = (size + alignMask) & ~alignMask;
121 totalAllocated += size;
122 maxAllocated = das::max(maxAllocated, totalAllocated);
123 if ( size > maxShoeAllocation ) {
124 char * ptr = (char *) das_aligned_alloc16(size);
125 bigStuff[ptr] = size;
126#if DAS_TRACK_ALLOCATIONS
127 if ( trackAllocations ) {
128 INSCRIBE_INSANE_POINTER(ptr, this);
129 if ( g_tracker==g_breakpoint ) os_debug_break();
130 bigStuffId[ptr] = g_tracker ++;
131 }
132#endif
133 return ptr;
134 } else {
135 if ( char * res = shoe.allocate(uint32_t(size)) ) {
136 return res;
137 }
138 size = (size + 15) & ~15;
139 DAS_ASSERT(size && size<=DAS_MAX_SHOE_ALLOCATION);
140 uint32_t si = uint32_t((size >> 4) - 1);
141 uint64_t total = grow(si);
142 shoe.chunks[si] = new Deck(total, uint32_t(size), shoe.chunks[si]);
143 return shoe.chunks[si]->allocate();
144 }
145 }
146
147 bool MemoryModel::free ( char * ptr, uint64_t size ) {
148 if ( !size ) return true;

Callers 15

array_reserveFunction · 0.45
beforeLambdaMethod · 0.45
copyNodeMethod · 0.45
allocateForMethod · 0.45
impl_allocateMethod · 0.45
scanPointerMethod · 0.45
updateTypeInfoMethod · 0.45
simulateMethod · 0.45
visitMethod · 0.45
sv_simulateFinalMethod · 0.45
sv_simulateBlockMethod · 0.45
sv_simulateLabelsMethod · 0.45

Calls 2

das_aligned_alloc16Function · 0.85
os_debug_breakFunction · 0.85

Tested by 1

mainFunction · 0.36