Libretto allocates variables of type ‘struct autostr’ (with a typedef name of ‘Autostr’) and gives user code a pointer to one of these variables. Each ‘Autostr’ `contains' a null-terminated string and re-allocates that string as necessary; a pointer to the first character of this string can readily be obtained for passing to standard string functions. The memory used for the contents of a ‘Autostr’ is allocated by ‘mem_alloc’ and friends; ‘Autostr’s are therefore subject to normal allocation semantics.
Positions within a ‘Autostr’ are specified by signed zero-based integers, and are stored in variables of type ‘ssize_t’. A negative position is an out-of-band value, usually used to indicate either the last position in a string, or failure to perform the requested action.
Unless otherwise stated, if a function takes a ‘Autostr’ as both a source and a destination argument, those arguments may not refer to the same object.
All the ‘Autostr’ functions are declared in the header file libretto/autostr.h.