LLD
LLD copied to clipboard
fix malloc mmap implementation's header size
Hey!
I am working on a similar project and am taking some guidance. I was looking through your malloc implementation and found a logical error. In the mmap call, you seem to have mixed up HEADER_SIZE_MASK and HEADER_SIZE This probably hasn't been tested. (as allocations over 128kb are rare)
old header size: 4294967288 bytes new header size: 4 bytes diff: -4294967284 bytes (:D)
Let me be clear, I'm a newcomer to memory management.
I found another logical error: In the comment, you explain, that mmap chunk consists of only start header and data. But in the next calls to set size and flags for the mmap chunk, it writes to both start header and end header. The End header doesn't exist? (isn't allocated for & doesn't comply with comment).
So my proposals are:
- change mmap chunk's implementation to allocate for the end header
- check for FLAG_MEM_MAPPED in all header modifier functions