48 if (list != NULL && s != NULL)
50 const char** new_list = NULL;
53 new_list = calloc(1,
sizeof(
char*));
57 size_t newSize = (list->
strings_count + 1) *
sizeof(
const char*);
58 new_list = realloc(list->
strings, newSize);
74 if (s != NULL && components != NULL)
77 if (splitChars == NULL || *splitChars ==
'\0')
84 size_t foundIndex = strcspn(work, splitChars);
85 if (foundIndex < strlen(work))
87 work[foundIndex] =
'\0';
89 work += foundIndex + 1;
Declaration of the split functions, for splitting a string on delimiters.
void SplitList_Clear(SplitList *list)
Clear the given SplitList object so it can be reused again. Releases the list of sub-strings (but doe...
void SplitList_Initialize(SplitList *list)
Initialize the given SplitList object.
void split(char *s, const char *splitChars, SplitList *components)
Split the given path into multiple strings based on the given delimiter. The pointers to each string ...
void SplitList_AddString(SplitList *list, const char *s)
Add a string to the given SplitList object. The string is not duplicated but instead is just copied i...
Represents a collection of sub-strings split from a single string using the split() function.
size_t strings_count
Number of sub-strings.
const char ** strings
Pointers to each sub-string.