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