summaryrefslogtreecommitdiff
path: root/source/kit/dynamic_array.h
diff options
context:
space:
mode:
Diffstat (limited to 'source/kit/dynamic_array.h')
-rw-r--r--source/kit/dynamic_array.h32
1 files changed, 14 insertions, 18 deletions
diff --git a/source/kit/dynamic_array.h b/source/kit/dynamic_array.h
index d2f2a6b..dbb18d9 100644
--- a/source/kit/dynamic_array.h
+++ b/source/kit/dynamic_array.h
@@ -8,27 +8,26 @@ extern "C" {
#endif
typedef struct {
- ptrdiff_t capacity;
- ptrdiff_t size;
+ i64 capacity;
+ i64 size;
void *values;
kit_allocator_t *alloc;
} kit_da_void_t;
-void kit_da_init(kit_da_void_t *array, ptrdiff_t element_size,
- ptrdiff_t size, kit_allocator_t *alloc);
+void kit_da_init(kit_da_void_t *array, i64 element_size, i64 size,
+ kit_allocator_t *alloc);
-void kit_da_resize(kit_da_void_t *array, ptrdiff_t element_size,
- ptrdiff_t size);
+void kit_da_resize(kit_da_void_t *array, i64 element_size, i64 size);
-void kit_da_resize_exact(kit_da_void_t *array, ptrdiff_t element_size,
- ptrdiff_t size);
+void kit_da_resize_exact(kit_da_void_t *array, i64 element_size,
+ i64 size);
/* Dynamic array type definition.
*/
#define KIT_DA(element_type_) \
struct { \
- ptrdiff_t capacity; \
- ptrdiff_t size; \
+ i64 capacity; \
+ i64 size; \
element_type_ *values; \
kit_allocator_t *alloc; \
}
@@ -70,7 +69,7 @@ void kit_da_resize_exact(kit_da_void_t *array, ptrdiff_t element_size,
*/
#define KIT_DA_APPEND(array_, value_) \
do { \
- ptrdiff_t kit_index_back_ = (array_).size; \
+ i64 kit_index_back_ = (array_).size; \
KIT_DA_RESIZE((array_), kit_index_back_ + 1); \
if (kit_index_back_ < (array_).size) \
(array_).values[kit_index_back_] = (value_); \
@@ -80,9 +79,9 @@ void kit_da_resize_exact(kit_da_void_t *array, ptrdiff_t element_size,
*/
#define KIT_DA_INSERT(array_, index_, value_) \
do { \
- ptrdiff_t kit_i_; \
- ptrdiff_t kit_index_back_ = (array_).size; \
- ptrdiff_t kit_indert_n_ = (index_); \
+ i64 kit_i_; \
+ i64 kit_index_back_ = (array_).size; \
+ i64 kit_indert_n_ = (index_); \
KIT_DA_RESIZE((array_), kit_index_back_ + 1); \
if (kit_index_back_ + 1 == (array_).size) { \
for (kit_i_ = kit_index_back_; kit_i_ > kit_indert_n_; \
@@ -96,19 +95,16 @@ void kit_da_resize_exact(kit_da_void_t *array, ptrdiff_t element_size,
*/
#define KIT_DA_ERASE(array_, index_) \
do { \
- ptrdiff_t i_; \
+ i64 i_; \
for (i_ = (index_) + 1; i_ < (array_).size; i_++) \
(array_).values[i_ - 1] = (array_).values[i_]; \
KIT_DA_RESIZE((array_), (array_).size - 1); \
} while (0)
-typedef KIT_DA(char) kit_string_t;
-
#ifndef KIT_DISABLE_SHORT_NAMES
# define da_void_t kit_da_void_t
# define da_init kit_da_init
# define da_resize kit_da_resize
-# define string_t kit_string_t
# define DA KIT_DA
# define DA_INIT KIT_DA_INIT