Simplify implementation of arrays

This commit is contained in:
Dustin J. Mitchell 2022-02-07 00:15:09 +00:00
parent e11506ee6a
commit a270b6c254
5 changed files with 130 additions and 54 deletions

View file

@ -141,8 +141,9 @@ typedef struct TCStrings {
*/
size_t _capacity;
/**
* strings representing each string. these remain owned by the TCStrings instance and will be freed
* by tc_strings_free.
* TCStrings representing each string. these remain owned by the TCStrings instance and will
* be freed by tc_strings_free. This pointer is never NULL for a valid TCStrings, and the
* *TCStrings at indexes 0..len-1 are not NULL.
*/
struct TCString *const *items;
} TCStrings;
@ -272,6 +273,8 @@ void tc_string_free(struct TCString *tcstring);
/**
* Free a TCStrings instance. The instance, and all TCStrings it contains, must not be used after
* this call.
*
* When this call returns, the `items` pointer will be NULL, signalling an invalid TCStrings.
*/
void tc_strings_free(struct TCStrings *tcstrings);