libc: Add free_sized() and free_aligned_sized() as per C23#2201
Open
kfv wants to merge 1 commit into
Open
Conversation
6e3ad77 to
1632cc4
Compare
Contributor
|
Please bump the man page date when you update a man page. CC @bsdimp for additional review, though LGTM from my side. |
1632cc4 to
7c95dd7
Compare
Contributor
Author
Sure, my apologies. Done. |
bsdimp
reviewed
May 16, 2026
bsdimp
reviewed
May 16, 2026
Add C23 sized deallocation entry points as thin wrappers around free(3). Implementations may ignore size and alignment hints, so behaviour stays correct for existing allocations without validating caller metadata yet. When jemalloc is updated to 5.3.1, rewire these to je_free_sized() and je_free_aligned_sized() so deallocation can use the allocator's sized deallocation (free_sized for fast paths and free_aligned_sized for correct aligned hints.) Please note this change satisfies the standard interface only. Both functions should be delegated to jemalloc after the upgrade so callers get the intended allocator behaviour; until then, hints are unused and neither sized nor aligned-sized deallocation optimizations apply. Signed-off-by: Faraz Vahedi <kfv@kfv.io>
7c95dd7 to
43c0c4c
Compare
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.
Add
free_sized()(§7.24.3.4) andfree_aligned_sized()(§7.24.3.5) as per C23.For now they're simply thin wrappers around
free(3)as the standard allows implementations to ignore the size and alignment hints (§7.24.3.4.3, §7.24.3.5.3,) so the behaviour is correct and conformant.Once jemalloc is bumped to 5.3.1, it'd be well worth rewiring these to use the allocator's sized deallocation for the performance and security benefits.