1MALLOC_USABLE_SIZE(3)      Linux Programmer's Manual     MALLOC_USABLE_SIZE(3)
2
3
4

NAME

6       malloc_usable_size - obtain size of block of memory allocated from heap
7

SYNOPSIS

9       #include <malloc.h>
10
11       size_t malloc_usable_size(void *ptr);
12

DESCRIPTION

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

RETURN VALUE

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

ATTRIBUTES

23       For an  explanation  of  the  terms  used  in  this  section,  see  at‐
24       tributes(7).
25
26       ┌────────────────────────────────────────────┬───────────────┬─────────┐
27Interface                                   Attribute     Value   
28       ├────────────────────────────────────────────┼───────────────┼─────────┤
29malloc_usable_size()                        │ Thread safety │ MT-Safe │
30       └────────────────────────────────────────────┴───────────────┴─────────┘
31

CONFORMING TO

33       This function is a GNU extension.
34

NOTES

36       The  value returned by malloc_usable_size() may be greater than the re‐
37       quested size of the allocation because of alignment  and  minimum  size
38       constraints.   Although  the excess bytes can be overwritten by the ap‐
39       plication without ill effects, this is not good  programming  practice:
40       the  number  of excess bytes in an allocation depends on the underlying
41       implementation.
42
43       The main use of this function is for debugging and introspection.
44

SEE ALSO

46       malloc(3)
47

COLOPHON

49       This page is part of release 5.12 of the Linux  man-pages  project.   A
50       description  of  the project, information about reporting bugs, and the
51       latest    version    of    this    page,    can     be     found     at
52       https://www.kernel.org/doc/man-pages/.
53
54
55
56GNU                               2021-03-22             MALLOC_USABLE_SIZE(3)
Impressum