_CP_str_realloc

_CP_str_realloc reallocates a CPSTR* to a new length.

Syntax

CPSTR* _CP_str_realloc(CPSTR* old, int expression)

Parameter(s)

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.

NOTE

The pointer allocated by _CP_str_realloc must eventually be released by calling _CP_str_free, not free().

Example(s)

CPSTR * s = _CP_mkstr("hi");

s = _CP_str_realloc(s, 3);

_CP_SADDR(s)[2] = ’!’;

See Also

C Functions Overview, _CP_str_alloc, _CP_str_free