diff options
| author | iamcheeseman <[email protected]> | 2026-05-13 21:24:21 -0400 |
|---|---|---|
| committer | iamcheeseman <[email protected]> | 2026-05-13 21:24:21 -0400 |
| commit | 8d2793e9ef7cf7f742ec23e77c44ac21a624d01f (patch) | |
| tree | c8263278076d7c7fd575cfcf0dc35703e8dc426e /teensy/teensy_list.h | |
| parent | 13e6f3d8403f0fdbed4ead1d8eda4d9ed68ac080 (diff) | |
start ui
Diffstat (limited to 'teensy/teensy_list.h')
| -rw-r--r-- | teensy/teensy_list.h | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/teensy/teensy_list.h b/teensy/teensy_list.h index 6265e6a..12da8e0 100644 --- a/teensy/teensy_list.h +++ b/teensy/teensy_list.h @@ -16,26 +16,24 @@ typedef struct { #define ty_list_cap(arr) (ty_list_get_header(arr)->cap) #define ty_list_len(arr) (ty_list_get_header(arr)->len) -#define ty_list_reserve(arr, amt) \ - do { \ - ty_List_Header *header = ty_list_get_header(arr); \ - if (amt > header->cap) { \ - header->cap = header->cap < TY_LIST_MIN_CAP \ - ? TY_LIST_MIN_CAP \ - : header->cap * TY_LIST_GROW_RATE; \ - header = ty_realloc( \ - header, \ - (sizeof(*(arr)) * amt) + sizeof(ty_List_Header) \ - ); \ - (arr) = (void*)(header + 1); \ - } \ +#define ty_list_reserve(arr, amt) \ + do { \ + ty_List_Header *header = ty_list_get_header(arr); \ + if ((amt) > header->cap) { \ + header->cap = (amt) < TY_LIST_MIN_CAP ? TY_LIST_MIN_CAP : (amt); \ + header = ty_realloc( \ + header, \ + (sizeof(*(arr)) * (amt)) + sizeof(ty_List_Header) \ + ); \ + (arr) = (void*)(header + 1); \ + } \ } while (0) -#define ty_list_append(arr, elem) \ - do { \ +#define ty_list_append(arr, elem) \ + do { \ ty_List_Header *header = ty_list_get_header(arr); \ - ty_list_reserve(arr, header->len + 1); \ - (arr)[header->len++] = (elem); \ + ty_list_reserve(arr, header->len + 1); \ + (arr)[header->len++] = (elem); \ } while (0) #define ty_list_clear(arr) \ |
