]>
Commit | Line | Data |
---|---|---|
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 |
7 | malloc_usable_size \- obtain size of block of memory allocated from heap | |
ce9ba99d AC |
8 | .SH LIBRARY |
9 | Standard C library | |
8fc3b2cf | 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 |
18 | The | |
19 | .BR malloc_usable_size () | |
20 | function returns the number of usable bytes in the block pointed to by | |
21 | .IR ptr , | |
22 | a pointer to a block of memory allocated by | |
23 | .BR malloc (3) | |
24 | or a related function. | |
25 | .SH RETURN VALUE | |
26 | .BR malloc_usable_size () | |
27 | returns the number of usable bytes in | |
28 | the block of allocated memory pointed to by | |
29 | .IR ptr . | |
30 | If | |
31 | .I ptr | |
32 | is NULL, 0 is returned. | |
4b5ef086 | 33 | .SH ATTRIBUTES |
bb374f15 PH |
34 | For 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 |
39 | allbox; | |
c466875e | 40 | lbx lb lb |
bb374f15 PH |
41 | l l l. |
42 | Interface Attribute Value | |
43 | T{ | |
4b5ef086 | 44 | .BR malloc_usable_size () |
bb374f15 PH |
45 | T} Thread safety MT-Safe |
46 | .TE | |
c466875e MK |
47 | .hy |
48 | .ad | |
49 | .sp 1 | |
6978778c MK |
50 | .SH CONFORMING TO |
51 | This function is a GNU extension. | |
52 | .SH NOTES | |
53 | The value returned by | |
54 | .BR malloc_usable_size () | |
55 | may be greater than the requested size of the allocation because | |
56 | of alignment and minimum size constraints. | |
57 | Although the excess bytes can be overwritten by the application | |
58 | without ill effects, | |
59 | this is not good programming practice: | |
60 | the number of excess bytes in an allocation depends on | |
61 | the underlying implementation. | |
847e0d88 | 62 | .PP |
6978778c MK |
63 | The main use of this function is for debugging and introspection. |
64 | .SH SEE ALSO | |
65 | .BR malloc (3) |