diff options
| author | iamcheeseman <[email protected]> | 2026-05-10 00:28:14 -0400 |
|---|---|---|
| committer | iamcheeseman <[email protected]> | 2026-05-10 00:28:14 -0400 |
| commit | 576bd27e11ec70bdbd1b9a644d2e227b57586337 (patch) | |
| tree | 2dc41e3f88bb95568f73ee372fc35512afcbcf9b /teensy/dyn_arr.h | |
| parent | 9ed5698b3c74c7ce1784d3bebe2aa73d5a0c319d (diff) | |
i ain't splitting alla this up
Diffstat (limited to 'teensy/dyn_arr.h')
| -rw-r--r-- | teensy/dyn_arr.h | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/teensy/dyn_arr.h b/teensy/dyn_arr.h deleted file mode 100644 index a764cda..0000000 --- a/teensy/dyn_arr.h +++ /dev/null @@ -1,49 +0,0 @@ -#ifndef DYN_ARR_H_ -#define DYN_ARR_H_ - -#include "common.h" -#include "mem.h" - -struct ty_list_header { - size_t cap; - size_t len; -}; - -#define TY_LIST_MIN_CAP 8 -#define TY_LIST_GROW_RATE 2 - -#define ty_list_get_header(arr) ((struct ty_list_header*)arr - 1) -#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 { \ - struct 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)) * count) + sizeof(struct ty_list_header) \ - ); \ - (arr) = (void*)(header + 1); \ - } \ - } while (0) - -#define ty_list_append(arr, elem) \ - do { \ - struct ty_list_header *header = ty_list_get_header(arr); \ - ty_list_reserve(arr, header->len + 1); \ - (arr)[header->len++] = (elem); \ - } while (0) - -#define ty_list_clear(arr) \ - (ty_list_get_header(arr)->len = 0) - -#define ty_list_free(arr) (ty_free(ty_list_get_header(arr))) - -void *ty_list_create(void); - -#endif // DYN_ARR_H_ |
