cfunc.str_realloc C Function/C Functions


Command cfunc.str_realloc C Function/C Functions
Applicable release versions: AP 6.1
Category C Functions (120)
Description reallocates a CPSTR* to a new length.
"old" points to the string to reallocate. "expression" is the desired new length. If the request is for a smaller length than the current one, or if the request is for a larger length, but the system senses that the internal buffer size of the old CPSTR* is sufficient to handle the extra length, then the routine simply changes the sizea and returns a pointer equal to "old". If the requested size is too big for the internal buffer, then a new pointer is created, the old data copied to the new one, and the old string released. Any new buffer space not filled in by the old copy is undefined.
Syntax CPSTR* _CP_str_realloc(CPSTR* old, int expression)
CPSTR * s = _CP_mkstr("hi");
s = _CP_str_realloc(s, 3);
_CP_SADDR(s)[2] = '!';
Related cfunc.introduction