rb_strlist.h
¶
Contains the definition of the rb_strlist_t structure.
General purpose string list structure used in Rootbeer. This header defines the structure along with helper methods for managing the rb_strlist_t
type.
Functions
-
int rb_strlist_init(rb_strlist_t *list, size_t initial_capacity)¶
Initializes a string list with a specified initial capacity.
- Parameters:
list – Pointer to the rb_strlist_t structure to initialize.
initial_capacity – The initial capacity of the string list.
- Returns:
0 on success, or a non-zero error code on failure.
-
int rb_strlist_add(rb_strlist_t *list, const char *str)¶
Adds a new string to the string list. If the list is full, it will automatically expand its capacity. IMPORTANT: This uses linear O(n) scanning for deduplication.
- Parameters:
list – Pointer to the rb_strlist_t structure.
str – The string to add to the list.
- Returns:
0 on success, or a non-zero error code on failure.
-
void rb_strlist_free(rb_strlist_t *list)¶
Frees the memory allocated for the string list. IMPORTANT: This will also free all strings stored in the list.
- Parameters:
list – Pointer to the rb_strlist_t structure to free.
-
struct rb_strlist_t¶
- #include <rb_strlist.h>
A structure to hold a list of strings. This structure is used to manage a list of strings that is reused for the context storing any tracked files, such as Lua scripts, extra files, etc. The list is capable of self-expanding to accommodate more strings as needed.