TutRealloc reallocate memory
ptr
pointer to the previously allocated block of memory
size
number of bytes to allocate
Pointer to the reallocated memory block if successful, NULL
if the requested memory could not be allocated.
None
TutRealloc changes the size of the previously allocated memory block to the specified size. Using this function ensures the portability to all the platforms that are currently supported by SmartSockets.
TutRealloc allows size
to be 0
. This is useful for allocating a non-null placeholder that is resized later with TutRealloc.
All SmartSockets memory management uses the functions TutCalloc, TutFree, TutMalloc, and TutRealloc. You can set debugger breakpoints in these functions to trace SmartSockets memory usage.
TutCalloc, TutFree, TutMalloc, and TutRealloc are not compatible with other memory management functions. Memory allocated by SmartSockets (including memory allocated by TutCalloc, TutMalloc, or TutRealloc) must be reallocated with TutRealloc and freed with TutFree. Attempting to mix memory management functions will result in unpredictable and potentially unstable behavior.
This example allocates a string 30 characters long and then increases the size of the string to 50 characters:
T_STR strptr;/* the string has to be 30 characters long, so one space has to be */
/* reserved for the terminating NULL */
strptr = (T_STR)TutMalloc(31); . . . strptr = TutRealloc(strptr, 51);
TIBCO SmartSockets™ Utilities Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |