1 .\" $Id: mandoc_malloc.3,v 1.1 2014/08/05 05:48:56 schwarze Exp $
3 .\" Copyright (c) 2014 Ingo Schwarze <schwarze@openbsd.org>
5 .\" Permission to use, copy, modify, and distribute this software for any
6 .\" purpose with or without fee is hereby granted, provided that the above
7 .\" copyright notice and this permission notice appear in all copies.
9 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 .Dd $Mdocdate: August 5 2014 $
23 .Nm mandoc_reallocarray ,
28 .Nd memory allocation function wrappers used in the mandoc library
44 .Fo mandoc_reallocarray
66 .Fa "const char *format"
70 These functions call the
72 functions of the same names, passing through their return values when
74 In case of failure, they do not return, but instead call
78 They can be used both internally by any code in the
80 and externally by programs using that library, for example
88 allocates one new object, leaving the memory uninitialized.
92 .Fn mandoc_reallocarray
93 change the size of an existing object or array, possibly moving it.
94 When shrinking the size, existing data is truncated; when growing,
95 the additional memory is not initialized.
98 allocates a new array, initializing it to zero.
102 is the size of each object.
105 is the new number of objects in the array.
108 is a pointer to the existing object or array to be resized; if it is
110 a new object or array is allocated.
116 copy a string into newly allocated memory.
119 the string pointed to by
121 needs to be NUL-terminated.
129 writes output formatted according to
131 into newly allocated memory and returns a pointer to the result in
133 For all three string functions, the result is always NUL-terminated.
135 When the objects and strings are no longer needed,
136 the pointers returned by these functions can be passed to
141 always returns the number of characters written, excluding the
145 The other functions always return a valid pointer; they never return
148 These functions are implemented in
172 is a widespread extension that first appeared in the GNU C library.
176 is an extension that first appeared in
178 If it is not provided by the operating system, the mandoc build system
179 uses a bundled portable implementation.
187 have been available since mandoc 1.9.12,
193 .Fn mandoc_reallocarray
194 since 1.12.4 and 1.13.0.
196 .An Kristaps Dzonsons Aq Mt kristaps@bsd.lv
197 .An Ingo Schwarze Aq Mt schwarze@openbsd.org