tprealloc - routine to change the size of a typed buffer
#include <atmi.h> char * tprealloc(char *ptr, long size)
tprealloc() changes the size of the buffer pointed to by ptr to size bytes and returns a pointer to the new (possibly moved) buffer. Similar to tpalloc(3c), the size of the buffer will be at least as large as the larger of size and dfltsize, where dfltsize is the default buffer size specified in tmtype_sw. If the larger of the two is less than or equal to zero, then the buffer is unchanged and NULL is returned. A buffer's type remains the same after it is re-allocated. After this function returns successfully, the returned pointer should be used to reference the buffer; ptr should no longer be used. The buffer's contents will not change up to the lesser of the new and old sizes.
Some buffer types require initialization before they can be used. tprealloc() re-initializes a buffer (in a communication manager-specific manner) after it is re-allocated and before it is returned. Thus, the buffer returned to the caller is ready for use.
Upon successful completion, tprealloc() returns a pointer to a buffer of the appropriate type aligned on a long word; otherwise it returns NULL and sets tperrno to indicate the error condition.
If the re-initialization function fails, tprealloc() fails returning NULL and the contents of the buffer pointed to by ptr may not be valid. Under the following conditions, tprealloc() fails and sets tperrno to:
If buffer re-initialization fails, tprealloc() fails returning NULL and the contents of the buffer pointed to by ptr may not be valid. This function should not be used in concert with malloc(3C), realloc(3C) or free(3C) in the C library (for example, a buffer allocated with tprealloc() should not be freed with free()).