1REALLOC(3P)                POSIX Programmer's Manual               REALLOC(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10

NAME

12       realloc - memory reallocator
13

SYNOPSIS

15       #include <stdlib.h>
16
17       void *realloc(void *ptr, size_t size);
18
19

DESCRIPTION

21       The realloc() function shall change  the  size  of  the  memory  object
22       pointed  to  by  ptr to the size specified by size. The contents of the
23       object shall remain unchanged up to the  lesser  of  the  new  and  old
24       sizes.  If  the new size of the memory object would require movement of
25       the object, the space for the previous instantiation of the  object  is
26       freed.  If  the new size is larger, the contents of the newly allocated
27       portion of the object are unspecified. If size is 0 and ptr  is  not  a
28       null  pointer,  the  object pointed to is freed. If the space cannot be
29       allocated, the object shall remain unchanged.
30
31       If ptr is a null pointer, realloc() shall be equivalent to malloc() for
32       the specified size.
33
34       If ptr does not match a pointer returned earlier by calloc(), malloc(),
35       or realloc() or if the space has previously been deallocated by a  call
36       to free() or realloc(), the behavior is undefined.
37
38       The  order  and  contiguity of storage allocated by successive calls to
39       realloc() is unspecified. The pointer returned if the  allocation  suc‐
40       ceeds shall be suitably aligned so that it may be assigned to a pointer
41       to any type of object and then used to access such  an  object  in  the
42       space  allocated  (until the space is explicitly freed or reallocated).
43       Each such allocation shall yield a pointer to an object  disjoint  from
44       any other object. The pointer returned shall point to the start (lowest
45       byte address) of the allocated space. If the space cannot be allocated,
46       a null pointer shall be returned.
47

RETURN VALUE

49       Upon  successful completion with a size not equal to 0, realloc() shall
50       return a pointer to the (possibly moved) allocated space. If size is 0,
51       either  a  null  pointer  or  a unique pointer that can be successfully
52       passed to free() shall be returned.  If there is not  enough  available
53       memory,  realloc()  shall  return  a  null  pointer   and  set errno to
54       [ENOMEM].
55

ERRORS

57       The realloc() function shall fail if:
58
59       ENOMEM Insufficient memory is available.
60
61
62       The following sections are informative.
63

EXAMPLES

65       None.
66

APPLICATION USAGE

68       None.
69

RATIONALE

71       None.
72

FUTURE DIRECTIONS

74       None.
75

SEE ALSO

77       calloc(),  free(),   malloc(),   the   Base   Definitions   volume   of
78       IEEE Std 1003.1-2001, <stdlib.h>
79
81       Portions  of  this text are reprinted and reproduced in electronic form
82       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
83       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
84       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
85       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
86       event of any discrepancy between this version and the original IEEE and
87       The  Open Group Standard, the original IEEE and The Open Group Standard
88       is the referee document. The original Standard can be  obtained  online
89       at http://www.opengroup.org/unix/online.html .
90
91
92
93IEEE/The Open Group                  2003                          REALLOC(3P)
Impressum