mem: various arena fixes#10
Merged
Merged
Conversation
The allocator interface now requires a size for realloc() and free(). This was always an error; sp_sys_free() required a size, and all of our allocators implemented headers to track allocation sizes. The glue between them, the interface, simply omitted it. In doing this, we were able to get rid of the headers that all the allocators had to implement. This drastically simplified the arena allocator, as well as fixed most of the longstanding issues that I have had with it. Likewise for the page allocator. I also added some small things: - test: Updated the tracking allocator used for leak testing to now verify what was actually allocated and find mismatches - io: Added sp_io_dyn_mem_writer_take_str(), which reallocates the buffer so its length and capacity match, allowing it to be returned as a string which can be freed without the writer. - io: sp_io_read_file() shrinks the buffer when a file reads short - mem: Unrelated overflow checks in the arena - mem: Arenas no longer crash on OOM - test: Rewrote arena tests declaratively - test: Added tests for the fixed allocator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The allocator interface now requires a size for realloc() and free(). This was always an error; sp_sys_free() required a size, and all of our allocators implemented headers to track allocation sizes. The glue between them, the interface, simply omitted it.
In doing this, we were able to get rid of the headers that all the allocators had to implement. This drastically simplified the arena allocator, as well as fixed most of the longstanding issues that I have had with it. Likewise for the page allocator.
I also added some small things: