| _CP_str_null | Index Level | _CP_substr |
| Syntax | CPSTR* _CP_str_realloc(CPSTR* old, int expression) |
| Category | C Interface |
| Type | C Function |
| 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. |
| Options | |
| See Also | C Functions introduction _CP_str_alloc _CP_str_free |
| Example |
CPSTR * s = _CP_mkstr("hi");
s = _CP_str_realloc(s, 3); _CP_SADDR(s)[2] = '!'; |
| Warnings | The pointer allocated by _CP_str_realloc must eventually be released by calling _CP_str_free, not free(). |
| Compatibility | AP 6.1 |
| _CP_str_null | Index Level | _CP_substr |