161180Sbostic.\" Copyright (c) 1991, 1993 261180Sbostic.\" The Regents of the University of California. All rights reserved. 348914Scael.\" 448914Scael.\" %sccs.include.redist.man% 548914Scael.\" 6*66953Sbostic.\" @(#)realloc.3 8.2 (Berkeley) 04/19/94 748914Scael.\" 848914Scael.Dd 948914Scael.Dt REALLOC 3 1048914Scael.Os 1148914Scael.Sh NAME 1248914Scael.Nm realloc 1348914Scael.Nd reallocation of memory function 1448914Scael.Sh SYNOPSIS 1548914Scael.Fd #include <stdlib.h> 1648914Scael.Ft void * 1748914Scael.Fn realloc "void *ptr" "size_t size" 1848914Scael.Sh DESCRIPTION 1948914ScaelThe 2048914Scael.Fn realloc 2148914Scaelfunction changes the size of the object pointed to by 2248914Scael.Fa ptr 2348914Scaelto the size specified by 2448914Scael.Fa size . 2548914ScaelThe contents of the object are unchanged up to the lesser 2648914Scaelof the new and old sizes. 2748914ScaelIf the new size is larger, the value of the newly allocated portion 2848914Scaelof the object is indeterminate. 2948914ScaelIf 3048914Scael.Fa ptr 3148914Scaelis a null pointer, the 3248914Scael.Fn realloc 3348914Scaelfunction behaves like the 3448914Scael.Xr malloc 3 3548914Scaelfunction for the specified size. 3648914ScaelOtherwise, if 3748914Scael.Fa ptr 3848914Scaeldoes not match a pointer earlier returned by the 3948914Scael.Xr calloc 3 , 4048914Scael.Xr malloc 3 , 4148914Scaelor 4248914Scael.Fn realloc 4348914Scaelfunction, or if the space has been deallocated 4448914Scaelby a call to the 4548914Scael.Xr free 4648914Scaelor 4748914Scael.Fn realloc 4848914Scaelfunction, unpredictable and usually detrimental 49*66953Sbosticbehavior will occur. 5048914ScaelIf the space cannot be allocated, the object 5148914Scaelpointed to by 5248914Scael.Fa ptr 5348914Scaelis unchanged. 5448914ScaelIf 5548914Scael.Fa size 5648914Scaelis zero and 5748914Scael.Fa ptr 5848914Scaelis not a null pointer, the object it points to is freed. 5948914Scael.Pp 6048914ScaelThe 6148914Scael.Fn realloc 6248914Scaelfunction returns either a null pointer or a pointer 6348914Scaelto the possibly moved allocated space. 6448914Scael.Sh SEE ALSO 6548914Scael.Xr alloca 3 , 6648914Scael.Xr calloc 3 , 6748914Scael.Xr free 3 , 6848914Scael.Xr malloc 3 , 6948914Scael.Sh STANDARDS 7048914ScaelThe 7148914Scael.Fn realloc 7248914Scaelfunction conforms to 7348914Scael.St -ansiC . 74