1 .\" Copyright (c) 2012 by Michael Kerrisk <mtk.manpages@gmail.com>
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date. The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein. The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
23 .TH MALLOC_USABLE_SIZE 3 2012-03-29 "GNU" "Linux Programmer's Manual"
25 malloc_usable_size \- obtain size of block of memory allocated from heap
27 .B #include <malloc.h>
29 .BI "size_t malloc_usable_size (void *" ptr );
32 .BR malloc_usable_size ()
33 function returns the number of usable bytes in the block pointed to by
35 a pointer to a block of memory allocated by
37 or a related function.
39 .BR malloc_usable_size ()
40 returns the number of usable bytes in
41 the block of allocated memory pointed to by
45 is NULL, 0 is returned.
47 This function is a GNU extension.
50 .BR malloc_usable_size ()
51 may be greater than the requested size of the allocation because
52 of alignment and minimum size constraints.
53 Although the excess bytes can be overwritten by the application
55 this is not good programming practice:
56 the number of excess bytes in an allocation depends on
57 the underlying implementation.
59 The main use of this function is for debugging and introspection.