1MALLOC_USABLE_SIZE(3) Linux Programmer's Manual MALLOC_USABLE_SIZE(3)
2
3
4
6 malloc_usable_size - obtain size of block of memory allocated from heap
7
9 #include <malloc.h>
10
11 size_t malloc_usable_size (void *ptr);
12
14 The malloc_usable_size() function returns the number of usable bytes in
15 the block pointed to by ptr, a pointer to a block of memory allocated
16 by malloc(3) or a related function.
17
19 malloc_usable_size() returns the number of usable bytes in the block of
20 allocated memory pointed to by ptr. If ptr is NULL, 0 is returned.
21
23 For an explanation of the terms used in this section, see at‐
24 tributes(7).
25
26 ┌─────────────────────┬───────────────┬─────────┐
27 │Interface │ Attribute │ Value │
28 ├─────────────────────┼───────────────┼─────────┤
29 │malloc_usable_size() │ Thread safety │ MT-Safe │
30 └─────────────────────┴───────────────┴─────────┘
32 This function is a GNU extension.
33
35 The value returned by malloc_usable_size() may be greater than the re‐
36 quested size of the allocation because of alignment and minimum size
37 constraints. Although the excess bytes can be overwritten by the ap‐
38 plication without ill effects, this is not good programming practice:
39 the number of excess bytes in an allocation depends on the underlying
40 implementation.
41
42 The main use of this function is for debugging and introspection.
43
45 malloc(3)
46
48 This page is part of release 5.10 of the Linux man-pages project. A
49 description of the project, information about reporting bugs, and the
50 latest version of this page, can be found at
51 https://www.kernel.org/doc/man-pages/.
52
53
54
55GNU 2017-09-15 MALLOC_USABLE_SIZE(3)