| 1 |
'\" t |
| 2 |
.\" Copyright (c) 2012 by Michael Kerrisk <[email protected]> |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 5 |
.\" |
| 6 |
.TH malloc_usable_size 3 2024-05-02 "Linux man-pages 6.9.1" |
| 7 |
.SH NAME |
| 8 |
malloc_usable_size \- obtain size of block of memory allocated from heap |
| 9 |
.SH LIBRARY |
| 10 |
Standard C library |
| 11 |
.RI ( libc ", " \-lc ) |
| 12 |
.SH SYNOPSIS |
| 13 |
.nf |
| 14 |
.B #include <malloc.h> |
| 15 |
.P |
| 16 |
.BI "size_t malloc_usable_size(void *_Nullable " ptr ); |
| 17 |
.fi |
| 18 |
.SH DESCRIPTION |
| 19 |
This function can be used for |
| 20 |
diagnostics or statistics about allocations from |
| 21 |
.BR malloc (3) |
| 22 |
or a related function. |
| 23 |
.SH RETURN VALUE |
| 24 |
.BR malloc_usable_size () |
| 25 |
returns a value no less than |
| 26 |
the size of the block of allocated memory pointed to by |
| 27 |
.IR ptr . |
| 28 |
If |
| 29 |
.I ptr |
| 30 |
is NULL, 0 is returned. |
| 31 |
.SH ATTRIBUTES |
| 32 |
For an explanation of the terms used in this section, see |
| 33 |
.BR attributes (7). |
| 34 |
.TS |
| 35 |
allbox; |
| 36 |
lbx lb lb |
| 37 |
l l l. |
| 38 |
Interface Attribute Value |
| 39 |
T{ |
| 40 |
.na |
| 41 |
.nh |
| 42 |
.BR malloc_usable_size () |
| 43 |
T} Thread safety MT-Safe |
| 44 |
.TE |
| 45 |
.SH STANDARDS |
| 46 |
GNU. |
| 47 |
.SH CAVEATS |
| 48 |
The value returned by |
| 49 |
.BR malloc_usable_size () |
| 50 |
may be greater than the requested size of the allocation |
| 51 |
because of various internal implementation details, |
| 52 |
none of which the programmer should rely on. |
| 53 |
This function is intended to only be used |
| 54 |
for diagnostics and statistics; |
| 55 |
writing to the excess memory without first calling |
| 56 |
.BR realloc (3) |
| 57 |
to resize the allocation is not supported. |
| 58 |
The returned value is only valid at the time of the call. |
| 59 |
.SH SEE ALSO |
| 60 |
.BR malloc (3) |