gmem: Add g_free_sized() and g_aligned_free_sized()

These wrap `free_sized()` and `free_aligned_sized()`, which are present
in C23[1]. This means that user code can start to use them without checking
for C23 support everywhere first.

It also means we can use them internally in GSlice to get a bit of
performance for the code which still uses it.

See https://en.cppreference.com/w/c/memory/free_aligned_sized and
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2699.htm.

[1]: Specifically, section 7.24.3.4 of the latest C23 draft at
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3088.pdf.

Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
Philip Withnall
2023-01-25 14:12:20 +00:00
parent 0f7797d76d
commit 329843f682
5 changed files with 107 additions and 1 deletions

View File

@@ -1082,6 +1082,7 @@ g_try_realloc_n
<SUBSECTION>
g_free
g_free_sized
g_clear_pointer
g_steal_pointer
g_mem_gc_friendly
@@ -1096,6 +1097,7 @@ g_newa0
g_aligned_alloc
g_aligned_alloc0
g_aligned_free
g_aligned_free_sized
<SUBSECTION>
g_memmove