Namespace list functions
This commit is contained in:
@@ -17,12 +17,12 @@
|
||||
u64 count; \
|
||||
} LIST_TYPE_NAME(T)
|
||||
|
||||
#define create_list(T) \
|
||||
#define list_create(T) \
|
||||
(LIST_TYPE_NAME(T) *)_create_list(sizeof(T), BASE_LIST_CAPACITY)
|
||||
#define create_list_with_capacity(T, CAPACITY) \
|
||||
#define list_create_with_capacity(T, CAPACITY) \
|
||||
(LIST_TYPE_NAME(T) *)_create_list(sizeof(T), CAPACITY)
|
||||
|
||||
#define destroy_list(T, LP) \
|
||||
#define list_destroy(T, LP) \
|
||||
do { \
|
||||
munmap(LP->items, sizeof(T) * LP->capacity); \
|
||||
LP->items = NULL; \
|
||||
@@ -31,7 +31,7 @@
|
||||
munmap(LP, sizeof(LIST_TYPE_NAME(T))); \
|
||||
} while (0)
|
||||
|
||||
#define append(T, LP, ITEM) \
|
||||
#define list_append(T, LP, ITEM) \
|
||||
do { \
|
||||
if (LP->count + 1 >= LP->capacity) { \
|
||||
u64 new_capacity = LP->capacity * 2; \
|
||||
@@ -50,7 +50,7 @@
|
||||
LP->items[(LP->count)++] = ITEM; \
|
||||
} while (0)
|
||||
|
||||
#define get(LP, IDX) LP->items[IDX]
|
||||
#define list_get(LP, IDX) LP->items[IDX]
|
||||
|
||||
MAKE_LIST_TYPE(void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user