MCPcopy Create free account
hub / github.com/codenameone/CodenameOne / _memory_deallocate

Function _memory_deallocate

vm/ByteCodeTranslator/src/rpmalloc.c:1151–1175  ·  view source on GitHub ↗

Deallocate the given block

Source from the content-addressed store, hash-verified

1149
1150//! Deallocate the given block
1151static void
1152_memory_deallocate(void* p) {
1153 if (!p)
1154 return;
1155
1156 //Grab the span (always at start of span, using 64KiB alignment)
1157 span_t* span = (void*)((uintptr_t)p & SPAN_MASK);
1158 int32_t heap_id = atomic_load32(&span->heap_id);
1159 heap_t* heap = _memory_thread_heap;
1160 //Check if block belongs to this heap or if deallocation should be deferred
1161 if (heap_id == heap->id) {
1162 if (span->size_class < SIZE_CLASS_COUNT)
1163 _memory_deallocate_to_heap(heap, span, p);
1164 else
1165 _memory_deallocate_large_to_heap(heap, span);
1166 }
1167 else if (heap_id > 0) {
1168 _memory_deallocate_defer(heap_id, p);
1169 }
1170 else {
1171 //Oversized allocation, page count is stored in next_span
1172 size_t num_pages = (size_t)span->next_span;
1173 _memory_unmap(span, num_pages);
1174 }
1175}
1176
1177//! Reallocate the given block to the given size
1178static void*

Callers 2

_memory_reallocateFunction · 0.85
rpfreeFunction · 0.85

Calls 5

atomic_load32Function · 0.85
_memory_deallocate_deferFunction · 0.85
_memory_unmapFunction · 0.85

Tested by

no test coverage detected