Commit | Line | Data |
---|---|---|
0e8ae7ba CL |
1 | .\" Copyright (c) 1991 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" %sccs.include.redist.man% | |
5 | .\" | |
6 | .\" @(#)realloc.3 5.1 (Berkeley) %G% | |
7 | .\" | |
8 | .Dd | |
9 | .Dt REALLOC 3 | |
10 | .Os | |
11 | .Sh NAME | |
12 | .Nm realloc | |
13 | .Nd reallocation of memory function | |
14 | .Sh SYNOPSIS | |
15 | .Fd #include <stdlib.h> | |
16 | .Ft void * | |
17 | .Fn realloc "void *ptr" "size_t size" | |
18 | .Sh DESCRIPTION | |
19 | The | |
20 | .Fn realloc | |
21 | function changes the size of the object pointed to by | |
22 | .Fa ptr | |
23 | to the size specified by | |
24 | .Fa size . | |
25 | The contents of the object are unchanged up to the lesser | |
26 | of the new and old sizes. | |
27 | If the new size is larger, the value of the newly allocated portion | |
28 | of the object is indeterminate. | |
29 | If | |
30 | .Fa ptr | |
31 | is a null pointer, the | |
32 | .Fn realloc | |
33 | function behaves like the | |
34 | .Xr malloc 3 | |
35 | function for the specified size. | |
36 | Otherwise, if | |
37 | .Fa ptr | |
38 | does not match a pointer earlier returned by the | |
39 | .Xr calloc 3 , | |
40 | .Xr malloc 3 , | |
41 | or | |
42 | .Fn realloc | |
43 | function, or if the space has been deallocated | |
44 | by a call to the | |
45 | .Xr free | |
46 | or | |
47 | .Fn realloc | |
48 | function, unpredictable and usually detrimental | |
49 | behaviour will occur. | |
50 | If the space cannot be allocated, the object | |
51 | pointed to by | |
52 | .Fa ptr | |
53 | is unchanged. | |
54 | If | |
55 | .Fa size | |
56 | is zero and | |
57 | .Fa ptr | |
58 | is not a null pointer, the object it points to is freed. | |
59 | .Pp | |
60 | The | |
61 | .Fn realloc | |
62 | function returns either a null pointer or a pointer | |
63 | to the possibly moved allocated space. | |
64 | .Sh SEE ALSO | |
65 | .Xr alloca 3 , | |
66 | .Xr calloc 3 , | |
67 | .Xr free 3 , | |
68 | .Xr malloc 3 , | |
69 | .Sh STANDARDS | |
70 | The | |
71 | .Fn realloc | |
72 | function conforms to | |
73 | .St -ansiC . |