`dealloc` definition in `GlobalAlloc`

Is there a reason why the dealloc method in GlobalAlloc takes a layout as an argument and not simply the size of the block to be freed? It seems to me that the size is sufficient to free the memory region
I could not think of or find a satisfying answer on the Internet

An allocation algorithm is free to group allocations by size, alignment requirement, and various other properties – in fact everything that is contained in the Layout (currently only these two). Thus, if the entire Layout was required for allocation, it is logical that the entire Layout must be passed for deallocation, too. (This also spares the allocator having to maintain an internal pointer-to-metadata map, which can be a performance benefit.)


Why not just free(ptr) for deallocation?

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.