mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-26 22:38:30 +00:00
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
This commit is contained in:
parent
28997f3acb
commit
7061c79c22
121 changed files with 5272 additions and 1928 deletions
11
third_party/chibicc/strarray.c
vendored
11
third_party/chibicc/strarray.c
vendored
|
@ -1,14 +1,17 @@
|
|||
#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->capacity == arr->len) {
|
||||
arr->data = realloc(arr->data, sizeof(char *) * arr->capacity * 2);
|
||||
arr->capacity *= 2;
|
||||
for (int i = arr->len; i < arr->capacity; i++) arr->data[i] = NULL;
|
||||
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;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue