_CP_str_realloc reallocates a CPSTR* to a new length.
CPSTR* _CP_str_realloc(CPSTR* old, int expression)
old | Points to the string to reallocate. |
expression | New length desired. |
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 changes the size 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.
CPSTR * s = _CP_mkstr("hi"); s = _CP_str_realloc(s, 3); _CP_SADDR(s)[2] = ’!’;