add PTK_LIST_GROW

This commit is contained in:
jacekpoz 2024-09-11 01:04:18 +02:00
parent 7dc9a329ad
commit 3a2a80f70a
Signed by: poz
SSH key fingerprint: SHA256:JyLeVWE4bF3tDnFeUpUaJsPsNlJyBldDGV/dIKSLyN8

View file

@ -23,11 +23,15 @@
#define PTK_LIST_REMOVE_AT(T, list, index) _remove_at_PtkList((void *)list.data, &list.size, index, sizeof(T)) #define PTK_LIST_REMOVE_AT(T, list, index) _remove_at_PtkList((void *)list.data, &list.size, index, sizeof(T))
#define PTK_LIST_SET(T, list, index, elem) do {\ #define PTK_LIST_GROW(T, list, new_size) do {\
while (list.allocated <= index) {\ while (list.allocated < new_size) {\
/* let's hope this doesn't fail !!! */\ /* let's hope this doesn't fail !!! */\
_grow_PtkList((void *)&list.data, &list.allocated, sizeof(T));\ _grow_PtkList((void *)&list.data, &list.allocated, sizeof(T));\
}\ }\
} while (0)
#define PTK_LIST_SET(T, list, index, elem) do {\
PTK_LIST_GROW(T, list, index + 1);\
list.data[index] = elem;\ list.data[index] = elem;\
} while (0) } while (0)