Ruby 3.3.2p78 (2024-05-30 revision e5a195edf62fe1bf7146a191da13fa1c4fecbd71)
pm_string_list.c
2
6void
7pm_string_list_append(pm_string_list_t *string_list, pm_string_t *string) {
8 if (string_list->length + 1 > string_list->capacity) {
9 if (string_list->capacity == 0) {
10 string_list->capacity = 1;
11 } else {
12 string_list->capacity *= 2;
13 }
14
15 string_list->strings = realloc(string_list->strings, string_list->capacity * sizeof(pm_string_t));
16 if (string_list->strings == NULL) abort();
17 }
18
19 string_list->strings[string_list->length++] = *string;
20}
21
25void
26pm_string_list_free(pm_string_list_t *string_list) {
27 free(string_list->strings);
28}
A list of strings.
A list of strings.
size_t capacity
The capacity of the string list that has been allocated.
pm_string_t * strings
A pointer to the start of the string list.
size_t length
The length of the string list.
A generic string type that can have various ownership semantics.
Definition pm_string.h:30