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