xref: /freebsd-14.2/lib/libc/stdlib/reallocf.3 (revision b2c76c41)
1*a4bd5210SJason Evans.\" Copyright (c) 1980, 1991, 1993
2*a4bd5210SJason Evans.\"	The Regents of the University of California.  All rights reserved.
3*a4bd5210SJason Evans.\"
4*a4bd5210SJason Evans.\" This code is derived from software contributed to Berkeley by
5*a4bd5210SJason Evans.\" the American National Standards Committee X3, on Information
6*a4bd5210SJason Evans.\" Processing Systems.
7*a4bd5210SJason Evans.\"
8*a4bd5210SJason Evans.\" Redistribution and use in source and binary forms, with or without
9*a4bd5210SJason Evans.\" modification, are permitted provided that the following conditions
10*a4bd5210SJason Evans.\" are met:
11*a4bd5210SJason Evans.\" 1. Redistributions of source code must retain the above copyright
12*a4bd5210SJason Evans.\"    notice, this list of conditions and the following disclaimer.
13*a4bd5210SJason Evans.\" 2. Redistributions in binary form must reproduce the above copyright
14*a4bd5210SJason Evans.\"    notice, this list of conditions and the following disclaimer in the
15*a4bd5210SJason Evans.\"    documentation and/or other materials provided with the distribution.
16*a4bd5210SJason Evans.\" 3. Neither the name of the University nor the names of its contributors
17*a4bd5210SJason Evans.\"    may be used to endorse or promote products derived from this software
18*a4bd5210SJason Evans.\"    without specific prior written permission.
19*a4bd5210SJason Evans.\"
20*a4bd5210SJason Evans.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21*a4bd5210SJason Evans.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22*a4bd5210SJason Evans.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23*a4bd5210SJason Evans.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24*a4bd5210SJason Evans.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25*a4bd5210SJason Evans.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26*a4bd5210SJason Evans.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27*a4bd5210SJason Evans.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28*a4bd5210SJason Evans.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29*a4bd5210SJason Evans.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30*a4bd5210SJason Evans.\" SUCH DAMAGE.
31*a4bd5210SJason Evans.\"
32*a4bd5210SJason Evans.\"     @(#)malloc.3	8.1 (Berkeley) 6/4/93
33*a4bd5210SJason Evans.\"
34*a4bd5210SJason Evans.Dd January 31, 2010
35*a4bd5210SJason Evans.Dt MALLOC 3
36*a4bd5210SJason Evans.Os
37*a4bd5210SJason Evans.Sh NAME
38*a4bd5210SJason Evans.Nm reallocf
39*a4bd5210SJason Evans.Nd memory reallocation function
40*a4bd5210SJason Evans.Sh LIBRARY
41*a4bd5210SJason Evans.Lb libc
42*a4bd5210SJason Evans.Sh SYNOPSIS
43*a4bd5210SJason Evans.In stdlib.h
44*a4bd5210SJason Evans.Ft void *
45*a4bd5210SJason Evans.Fn reallocf "void *ptr" "size_t size"
46*a4bd5210SJason Evans.Sh DESCRIPTION
47*a4bd5210SJason EvansThe
48*a4bd5210SJason Evans.Fn reallocf
49*a4bd5210SJason Evansfunction is identical to the
50*a4bd5210SJason Evans.Fn realloc
51*a4bd5210SJason Evansfunction, except that it
52*a4bd5210SJason Evanswill free the passed pointer when the requested memory cannot be allocated.
53*a4bd5210SJason EvansThis is a
54*a4bd5210SJason Evans.Fx
55*a4bd5210SJason Evansspecific API designed to ease the problems with traditional coding styles
56*a4bd5210SJason Evansfor
57*a4bd5210SJason Evans.Fn realloc
58*a4bd5210SJason Evanscausing memory leaks in libraries.
59*a4bd5210SJason Evans.Sh RETURN VALUES
60*a4bd5210SJason EvansThe
61*a4bd5210SJason Evans.Fn reallocf
62*a4bd5210SJason Evansfunction returns a pointer, possibly identical to
63*a4bd5210SJason Evans.Fa ptr ,
64*a4bd5210SJason Evansto the allocated memory
65*a4bd5210SJason Evansif successful; otherwise a
66*a4bd5210SJason Evans.Dv NULL
67*a4bd5210SJason Evanspointer is returned, and
68*a4bd5210SJason Evans.Va errno
69*a4bd5210SJason Evansis set to
70*a4bd5210SJason Evans.Er ENOMEM
71*a4bd5210SJason Evansif the error was the result of an allocation failure.
72*a4bd5210SJason EvansThe
73*a4bd5210SJason Evans.Fn reallocf
74*a4bd5210SJason Evansfunction deletes the original buffer when an error occurs.
75*a4bd5210SJason Evans.Sh SEE ALSO
76*a4bd5210SJason Evans.Xr realloc 3
77*a4bd5210SJason Evans.Sh HISTORY
78*a4bd5210SJason EvansThe
79*a4bd5210SJason Evans.Fn reallocf
80*a4bd5210SJason Evansfunction first appeared in
81*a4bd5210SJason Evans.Fx 3.0 .
82