1malloc_usable_size(3)      Library Functions Manual      malloc_usable_size(3)
2
3
4

NAME

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

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <malloc.h>
13
14       size_t malloc_usable_size(void *ptr);
15

DESCRIPTION

17       The malloc_usable_size() function returns the number of usable bytes in
18       the block pointed to by ptr, a pointer to a block of  memory  allocated
19       by malloc(3) or a related function.
20

RETURN VALUE

22       malloc_usable_size() returns the number of usable bytes in the block of
23       allocated memory pointed to by ptr.  If ptr is NULL, 0 is returned.
24

ATTRIBUTES

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

STANDARDS

36       GNU.
37

NOTES

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

SEE ALSO

49       malloc(3)
50
51
52
53Linux man-pages 6.04              2023-03-30             malloc_usable_size(3)
Impressum