summaryrefslogtreecommitdiffstats
path: root/man3/malloc_usable_size.3
diff options
context:
space:
mode:
Diffstat (limited to 'man3/malloc_usable_size.3')
-rw-r--r--man3/malloc_usable_size.343
1 files changed, 19 insertions, 24 deletions
diff --git a/man3/malloc_usable_size.3 b/man3/malloc_usable_size.3
index 11598a471..91d22d8dd 100644
--- a/man3/malloc_usable_size.3
+++ b/man3/malloc_usable_size.3
@@ -3,7 +3,7 @@
.\"
.\" SPDX-License-Identifier: Linux-man-pages-copyleft
.\"
-.TH malloc_usable_size 3 2022-12-15 "Linux man-pages 6.03"
+.TH malloc_usable_size 3 2023-07-20 "Linux man-pages 6.05.01"
.SH NAME
malloc_usable_size \- obtain size of block of memory allocated from heap
.SH LIBRARY
@@ -13,20 +13,17 @@ Standard C library
.nf
.B #include <malloc.h>
.PP
-.BI "size_t malloc_usable_size(void *" ptr );
+.BI "size_t malloc_usable_size(void *_Nullable " ptr );
.fi
.SH DESCRIPTION
-The
-.BR malloc_usable_size ()
-function returns the number of usable bytes in the block pointed to by
-.IR ptr ,
-a pointer to a block of memory allocated by
+This function can be used for
+diagnostics or statistics about allocations from
.BR malloc (3)
or a related function.
.SH RETURN VALUE
.BR malloc_usable_size ()
-returns the number of usable bytes in
-the block of allocated memory pointed to by
+returns a value no less than
+the size of the block of allocated memory pointed to by
.IR ptr .
If
.I ptr
@@ -34,33 +31,31 @@ is NULL, 0 is returned.
.SH ATTRIBUTES
For an explanation of the terms used in this section, see
.BR attributes (7).
-.ad l
-.nh
.TS
allbox;
lbx lb lb
l l l.
Interface Attribute Value
T{
+.na
+.nh
.BR malloc_usable_size ()
T} Thread safety MT-Safe
.TE
-.hy
-.ad
.sp 1
.SH STANDARDS
-This function is a GNU extension.
-.SH NOTES
+GNU.
+.SH CAVEATS
The value returned by
.BR malloc_usable_size ()
-may be greater than the requested size of the allocation because
-of alignment and minimum size constraints.
-Although the excess bytes can be overwritten by the application
-without ill effects,
-this is not good programming practice:
-the number of excess bytes in an allocation depends on
-the underlying implementation.
-.PP
-The main use of this function is for debugging and introspection.
+may be greater than the requested size of the allocation
+because of various internal implementation details,
+none of which the programmer should rely on.
+This function is intended to only be used
+for diagnostics and statistics;
+writing to the excess memory without first calling
+.BR realloc (3)
+to resize the allocation is not supported.
+The returned value is only valid at the time of the call.
.SH SEE ALSO
.BR malloc (3)