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