TutCalloc allocate and clear memory
size
number of bytes to allocate
Pointer to the allocated memory block if successful; NULL
otherwise.
None
TutCalloc allocates and zeroes out a block of memory of the requested size. Using this function ensures the portability of the user-written applications to all platforms that are currently supported by SmartSockets.
TutCalloc 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.
TutFree, TutMalloc, TutRealloc
This example allocates and clears a string 30 characters long:
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)TutCalloc(31);
TIBCO SmartSockets™ Utilities Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |