OSDN Git Service

(split) LDP: Update original to LDP v3.39.
[linuxjm/LDP_man-pages.git] / original / man3 / malloc_usable_size.3
1 .\" Copyright (c) 2012 by Michael Kerrisk <mtk.manpages@gmail.com>
2 .\"
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.
6 .\"
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.
11 .\"
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
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .TH MALLOC_USABLE_SIZE 3  2012-03-29 "GNU" "Linux Programmer's Manual"
24 .SH NAME
25 malloc_usable_size \- obtain size of block of memory allocated from heap
26 .SH SYNOPSIS
27 .B #include <malloc.h>
28
29 .BI "size_t malloc_usable_size (void *" ptr );
30 .SH DESCRIPTION
31 The
32 .BR malloc_usable_size ()
33 function returns the number of usable bytes in the block pointed to by
34 .IR ptr ,
35 a pointer to a block of memory allocated by
36 .BR malloc (3)
37 or a related function.
38 .SH RETURN VALUE
39 .BR malloc_usable_size ()
40 returns the number of usable bytes in
41 the block of allocated memory pointed to by
42 .IR ptr .
43 If
44 .I ptr
45 is NULL, 0 is returned.
46 .SH CONFORMING TO
47 This function is a GNU extension.
48 .SH NOTES
49 The value returned by
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
54 without ill effects,
55 this is not good programming practice:
56 the number of excess bytes in an allocation depends on
57 the underlying implementation.
58
59 The main use of this function is for debugging and introspection.
60 .SH SEE ALSO
61 .BR malloc (3)