]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/malloc_usable_size.3
Various pages: [Linux-man-pages-copyleft] Use SPDX-License-Identifier
[thirdparty/man-pages.git] / man3 / malloc_usable_size.3
CommitLineData
6978778c
MK
1.\" Copyright (c) 2012 by Michael Kerrisk <mtk.manpages@gmail.com>
2.\"
5fbde956 3.\" SPDX-License-Identifier: Linux-man-pages-copyleft
6978778c 4.\"
1d767b55 5.TH MALLOC_USABLE_SIZE 3 2021-03-22 "GNU" "Linux Programmer's Manual"
6978778c
MK
6.SH NAME
7malloc_usable_size \- obtain size of block of memory allocated from heap
8.SH SYNOPSIS
c7db92b9 9.nf
6978778c 10.B #include <malloc.h>
dbfe9c70 11.PP
27398f1b 12.BI "size_t malloc_usable_size(void *" ptr );
c7db92b9 13.fi
6978778c
MK
14.SH DESCRIPTION
15The
16.BR malloc_usable_size ()
17function returns the number of usable bytes in the block pointed to by
18.IR ptr ,
19a pointer to a block of memory allocated by
20.BR malloc (3)
21or a related function.
22.SH RETURN VALUE
23.BR malloc_usable_size ()
24returns the number of usable bytes in
25the block of allocated memory pointed to by
26.IR ptr .
27If
28.I ptr
29is NULL, 0 is returned.
4b5ef086 30.SH ATTRIBUTES
bb374f15
PH
31For an explanation of the terms used in this section, see
32.BR attributes (7).
c466875e
MK
33.ad l
34.nh
bb374f15
PH
35.TS
36allbox;
c466875e 37lbx lb lb
bb374f15
PH
38l l l.
39Interface Attribute Value
40T{
4b5ef086 41.BR malloc_usable_size ()
bb374f15
PH
42T} Thread safety MT-Safe
43.TE
c466875e
MK
44.hy
45.ad
46.sp 1
6978778c
MK
47.SH CONFORMING TO
48This function is a GNU extension.
49.SH NOTES
50The value returned by
51.BR malloc_usable_size ()
52may be greater than the requested size of the allocation because
53of alignment and minimum size constraints.
54Although the excess bytes can be overwritten by the application
55without ill effects,
56this is not good programming practice:
57the number of excess bytes in an allocation depends on
58the underlying implementation.
847e0d88 59.PP
6978778c
MK
60The main use of this function is for debugging and introspection.
61.SH SEE ALSO
62.BR malloc (3)