3 ms·
If you pre-allocate a large enough buffer, you can keep a pointer to mark the boundary between the part where you have already stored data and the part still em
by teo_zero 3y ago
If you pre-allocate a large enough buffer, you can keep a pointer to mark the boundary between the part where you have already stored data and the part still empty. Then re-implement malloc() to just move such pointer. Of course you must check for running out of allocated memory, etc. This simple approach assumes that you seldom delete entries, because it never reclaims the room occupied by deleted entries.
- williamcotton 3y agoHere's a simple example of the bump allocator part of this! https://gist.github.com/williamcotton/99ab6e8efa3c4b6c07a149d1262dfccf https://gist.github.com/williamcotton/99ab6e8efa3c4b6c07a149...