1.\" 2.\" Copyright (c) 2026 Faraz Vahedi <kfv@kfv.io> 3.\" 4.\" SPDX-License-Identifier: BSD-2-Clause 5.\" 6.Dd May 17, 2026 7.Dt FREE_SIZED 3 8.Os 9.Sh NAME 10.Nm free_sized , 11.Nm free_aligned_sized 12.Nd C23 sized deallocation functions 13.Sh SYNOPSIS 14.Lb libc 15.In stdlib.h 16.Ft void 17.Fn free_sized "void *ptr" "size_t size" 18.Ft void 19.Fn free_aligned_sized "void *ptr" "size_t alignment" "size_t size" 20.Sh DESCRIPTION 21The 22.Fn free_sized 23function deallocates the memory referenced by 24.Fa ptr 25that was previously allocated by 26.Xr malloc 3 , 27.Xr realloc 3 , 28or 29.Xr calloc 3 . 30The 31.Fa size 32argument shall equal the size passed to the allocation function. 33The result of an 34.Xr aligned_alloc 3 35may not be passed to 36.Fn free_sized . 37.Pp 38The 39.Fn free_aligned_sized 40function deallocates memory referenced by 41.Fa ptr 42that was previously allocated by 43.Xr aligned_alloc 3 . 44The 45.Fa alignment 46and 47.Fa size 48arguments shall equal the values supplied to the allocation function. 49The result of an 50.Xr malloc 3 , 51.Xr calloc 3 , 52or 53.Xr realloc 3 54may not be passed to 55.Fn free_aligned_sized . 56.Pp 57If 58.Fa ptr 59is neither a null pointer nor a pointer returned by the allocation functions 60described above for the corresponding deallocation function, the behaviour is 61undefined, and so is supplying a 62.Fa size 63or 64.Fa alignment 65that does not match the original allocation. 66.Sh IMPLEMENTATION NOTES 67The C standard permits an implementation to ignore the 68.Fa size 69and 70.Fa alignment 71hints. 72The current implementation forwards to 73.Xr free 3 74without validating these arguments, so behaviour remains correct for 75well-formed use. 76.Pp 77These functions will be wired to the system allocator's sized deallocation, 78once supported, as with the rest of the memory allocation API, so that 79.Fa size 80and 81.Fa alignment 82hints are used for performance and security benefits. 83That behaviour conforms to the practice recommended for each function in the 84C standard. 85.Sh SEE ALSO 86.Xr free 3 , 87.Xr malloc 3 , 88.Xr calloc 3 , 89.Xr realloc 3 , 90.Xr aligned_alloc 3 , 91.Xr jemalloc 3 92.Sh STANDARDS 93The 94.Fn free_sized 95and 96.Fn free_aligned_sized 97functions conform to 98.St -isoC-2023 . 99.Sh AUTHOR 100.An Faraz Vahedi Aq Mt kfv@kfv.io 101