cosmopolitan/third_party/chibicc/strarray.c
Justine Tunney 7061c79c22 Make fixes, improvements, and chibicc python bindings
- python now mixes audio 10x faster
- python octal notation is restored
- chibicc now builds code 3x faster
- chibicc now has help documentation
- chibicc can now generate basic python bindings
- linenoise now supports some paredit-like features

See #141
2021-10-08 08:41:57 -07:00

17 lines
458 B
C

#include "third_party/chibicc/chibicc.h"
void strarray_push(StringArray *arr, char *s) {
size_t i;
if (!arr->data) {
arr->data = calloc(8, sizeof(char *));
arr->capacity = 8;
}
if (arr->len + 1 == arr->capacity) {
arr->capacity += arr->capacity >> 1;
arr->data = realloc(arr->data, arr->capacity * sizeof(*arr->data));
for (i = arr->len; i < arr->capacity; i++) {
arr->data[i] = 0;
}
}
arr->data[arr->len++] = s;
}