17 if (stringList != NULL)
30 if (stringList != NULL)
47 bool stringAdded =
false;
49 if (stringList != NULL &&
string != NULL)
51 const char** new_list = NULL;
52 if (stringList->
strings == NULL)
54 new_list = malloc(
sizeof(
const char*));
64 new_list = realloc(stringList->
strings, newCount *
sizeof(
const char*));
84 bool stringsAdded =
false;
86 if (stringList != NULL && strings != NULL)
88 const char** new_list = NULL;
89 if (stringList->
strings == NULL)
91 new_list = calloc(numStrings,
sizeof(
const char*));
101 new_list = realloc(stringList->
strings, newCount *
sizeof(
const char*));
104 if (new_list != NULL)
107 stringList->
strings = new_list;
109 for (
size_t index = 0; index < numStrings; index++)
111 stringList->
strings[offset + index] = strings[index];
125 if (stringList != NULL && stringList->
strings != NULL)
127 if (removeIndex >= 0 && (
size_t)removeIndex < stringList->strings_count)
129 for (
size_t stringIndex = removeIndex; stringIndex < stringList->
allocated_count - 1; stringIndex++)
131 stringList->
strings[stringIndex] = stringList->
strings[stringIndex + 1];
145 if (stringList != NULL &&
string != NULL)
147 for (
size_t index = 0; index < stringList->
strings_count; index++)
149 if (strcmp(
string, stringList->
strings[index]) == 0)
151 foundIndex = (int)index;
165 bool matched =
false;
167 if (left != NULL && right != NULL)
175 if (found_index == -1)
int ConstStringList_Find(ConstStringList *stringList, const char *string)
Search the given string list for the given string. If found, return the index of the found string.
void ConstStringList_Initialize(ConstStringList *stringList)
Initialize the given string list.
bool ConstStringList_AddStrings(ConstStringList *stringList, const char **strings, size_t numStrings)
Add an array of strings to the given string list.
bool ConstStringList_AreListsEqual(ConstStringList *left, ConstStringList *right)
Compare two strings lists to determine if they have the same contents.
bool ConstStringList_AddString(ConstStringList *stringList, const char *string)
Add a string to the given string list.
void ConstStringList_Remove(ConstStringList *stringList, int removeIndex)
Remove the specified string from the given string list.
void ConstStringList_Clear(ConstStringList *stringList)
Clear the specified string list. The strings in the list are left alone, but the list itself is delet...
Declaration of the ConstStringList structure and supporting functions to work with a list of constant...
Represents a list of pointers to zero-terminated strings that are to remain constant and never delete...
size_t strings_count
Number of strings in the strings list.
const char ** strings
Pointer to an array of zero-terminated string pointers. These strings are constant and will not be du...
size_t allocated_count
The number of strings that can be held in the strings list.