Change boolean size to 1 byte
This commit is contained in:
@@ -28,16 +28,16 @@
|
||||
#define u32 uint32_t
|
||||
#define u64 uint64_t
|
||||
|
||||
#define b32 uint32_t
|
||||
#define b8 uint8_t
|
||||
|
||||
#ifndef WAPP_PLATFORM_CPP
|
||||
|
||||
#ifndef false
|
||||
#define false (b32)0
|
||||
#define false (b8)0
|
||||
#endif // !false
|
||||
|
||||
#ifndef true
|
||||
#define true (b32)1
|
||||
#define true (b8)1
|
||||
#endif // !true
|
||||
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
@@ -21,14 +21,14 @@ struct arena {
|
||||
u8 *buf;
|
||||
u8 *offset;
|
||||
u64 capacity;
|
||||
b32 committed;
|
||||
b8 committed;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
wapp_misc_utils_padding_size(sizeof(u8 *) * 2 + sizeof(u64) + sizeof(b32));
|
||||
wapp_misc_utils_padding_size(sizeof(u8 *) * 2 + sizeof(u64) + sizeof(b8));
|
||||
#endif // ifdef WAPP_PLATFORM_WINDOWS
|
||||
};
|
||||
|
||||
b32 wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity, MemAllocFlags flags, b32 zero_buffer) {
|
||||
b8 wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity, MemAllocFlags flags, b8 zero_buffer) {
|
||||
if (!arena || *arena || base_capacity == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ typedef struct arena Arena;
|
||||
* control over how the Arena is initialised. Wrapper macros are provided for
|
||||
* easier use.
|
||||
*/
|
||||
b32 wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity, MemAllocFlags flags, b32 zero_buffer);
|
||||
b8 wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity, MemAllocFlags flags, b8 zero_buffer);
|
||||
void *wapp_mem_arena_alloc(Arena *arena, u64 size);
|
||||
void *wapp_mem_arena_alloc_aligned(Arena *arena, u64 size, u64 alignment);
|
||||
void *wapp_mem_arena_realloc(Arena *arena, void *ptr, u64 old_size, u64 new_size);
|
||||
|
||||
@@ -12,9 +12,9 @@ wapp_intern inline void *mem_arena_realloc_aligned(void *ptr, u64 old_size, u64
|
||||
void *alloc_obj);
|
||||
|
||||
|
||||
Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity, MemAllocFlags flags, b32 zero_buffer) {
|
||||
Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity, MemAllocFlags flags, b8 zero_buffer) {
|
||||
Allocator allocator = {0};
|
||||
b32 initialised = wapp_mem_arena_init_custom((Arena **)(&allocator.obj), base_capacity, flags, zero_buffer);
|
||||
b8 initialised = wapp_mem_arena_init_custom((Arena **)(&allocator.obj), base_capacity, flags, zero_buffer);
|
||||
if (!initialised) {
|
||||
return allocator;
|
||||
}
|
||||
|
||||
@@ -32,7 +32,7 @@ BEGIN_C_LINKAGE
|
||||
* The `wapp_mem_arena_allocator_init_custom` provides the most control over how
|
||||
* the Arena is initialised. Wrapper macros are provided for easier use.
|
||||
*/
|
||||
Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity, MemAllocFlags flags, b32 zero_buffer);
|
||||
Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity, MemAllocFlags flags, b8 zero_buffer);
|
||||
void wapp_mem_arena_allocator_clear(Allocator *allocator);
|
||||
void wapp_mem_arena_allocator_destroy(Allocator *allocator);
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include "../../../common/assert/assert.h"
|
||||
#include <stddef.h>
|
||||
|
||||
wapp_intern b32 is_power_of_two(u64 num) { return (num & (num - 1)) == 0; }
|
||||
wapp_intern b8 is_power_of_two(u64 num) { return (num & (num - 1)) == 0; }
|
||||
|
||||
void *wapp_mem_util_align_forward(void *ptr, u64 alignment) {
|
||||
wapp_debug_assert(ptr != NULL, "`ptr` should not be NULL");
|
||||
|
||||
@@ -36,7 +36,7 @@ u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
const Str8Node *node = first_node;
|
||||
u64 node_index = 1;
|
||||
b32 running = node_index < parts->node_count;
|
||||
b8 running = node_index < parts->node_count;
|
||||
while (running && node->next) {
|
||||
node = node->next;
|
||||
if (node->item->size == 0) {
|
||||
@@ -46,7 +46,7 @@ u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) {
|
||||
if (dst->size > 0) {
|
||||
char dst_last = wapp_str8_get(dst, dst->size - 1);
|
||||
char node_start = wapp_str8_get(node->item, 0);
|
||||
b32 add_path_sep = dst_last != WAPP_PATH_SEP && node_start != WAPP_PATH_SEP;
|
||||
b8 add_path_sep = dst_last != WAPP_PATH_SEP && node_start != WAPP_PATH_SEP;
|
||||
|
||||
if (add_path_sep) {
|
||||
wapp_str8_concat_capped(dst, &separator);
|
||||
@@ -68,7 +68,7 @@ Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels) {
|
||||
goto RETURN_DIRUP;
|
||||
}
|
||||
|
||||
b32 absolute = wapp_str8_get(path, 0) == WAPP_PATH_SEP;
|
||||
b8 absolute = wapp_str8_get(path, 0) == WAPP_PATH_SEP;
|
||||
Str8 separator = wapp_str8_buf(4);
|
||||
wapp_str8_push_back(&separator, WAPP_PATH_SEP);
|
||||
|
||||
|
||||
@@ -29,11 +29,11 @@ typedef struct commander_result CMDResult;
|
||||
struct commander_result {
|
||||
i32 exit_code;
|
||||
CMDError error;
|
||||
b32 exited;
|
||||
b8 exited;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#include "../../../../common/misc/misc_utils.h"
|
||||
wapp_misc_utils_padding_size(sizeof(b32) + sizeof(i32) + sizeof(CMDError));
|
||||
wapp_misc_utils_padding_size(sizeof(b8) + sizeof(i32) + sizeof(CMDError));
|
||||
#endif // !WAPP_PLATFORM_WINDOWS
|
||||
};
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ void wapp_void_ptr_array_extend_capped(VoidPArray *array, const VoidPArray *othe
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_void_ptr_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -74,7 +74,7 @@ void wapp_void_ptr_array_copy_capped(const VoidPArray *src, VoidPArray *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_void_ptr_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -193,7 +193,7 @@ void wapp_str8_array_extend_capped(Str8Array *array, const Str8Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_str8_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -223,7 +223,7 @@ void wapp_str8_array_copy_capped(const Str8Array *src, Str8Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_str8_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -308,43 +308,43 @@ Str8 *_str8_array_pop(Str8Array *array) {
|
||||
return out;
|
||||
}
|
||||
|
||||
b32 *wapp_b32_array_get(const B32Array *array, u64 index) {
|
||||
b8 *wapp_b8_array_get(const B8Array *array, u64 index) {
|
||||
wapp_debug_assert(array != NULL, "`array` should not be NULL");
|
||||
wapp_runtime_assert(index < array->count, "`index` is out of bounds");
|
||||
|
||||
u8 *ptr = (u8 *)(array->items) + (array->item_size * index);
|
||||
return (b32 *)ptr;
|
||||
return (b8 *)ptr;
|
||||
}
|
||||
|
||||
void wapp_b32_array_set(B32Array *array, u64 index, b32 *item) {
|
||||
b32 *ptr = wapp_b32_array_get(array, index);
|
||||
void wapp_b8_array_set(B8Array *array, u64 index, b8 *item) {
|
||||
b8 *ptr = wapp_b8_array_get(array, index);
|
||||
|
||||
memcpy((void *)ptr, (void *)item, array->item_size);
|
||||
}
|
||||
|
||||
void wapp_b32_array_append_capped(B32Array *array, b32 *item) {
|
||||
void wapp_b8_array_append_capped(B8Array *array, b8 *item) {
|
||||
wapp_debug_assert(array != NULL, "`array` should not be NULL");
|
||||
wapp_runtime_assert(array->count < array->capacity, "`array` is full");
|
||||
|
||||
u64 index = (array->count)++;
|
||||
wapp_b32_array_set(array, index, item);
|
||||
wapp_b8_array_set(array, index, item);
|
||||
}
|
||||
|
||||
void wapp_b32_array_extend_capped(B32Array *array, const B32Array *other) {
|
||||
void wapp_b8_array_extend_capped(B8Array *array, const B8Array *other) {
|
||||
wapp_debug_assert(array != NULL && other != NULL, "`array` and `other` should not be NULL");
|
||||
|
||||
u64 remaining_capacity = array->capacity - array->count;
|
||||
wapp_runtime_assert(other->count < remaining_capacity, "`array` does not have enough capacity");
|
||||
|
||||
b32 *item;
|
||||
b8 *item;
|
||||
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_b32_array_get(other, item_index);
|
||||
item = wapp_b8_array_get(other, item_index);
|
||||
++item_index;
|
||||
running = item_index < items_to_add;
|
||||
|
||||
@@ -352,29 +352,29 @@ void wapp_b32_array_extend_capped(B32Array *array, const B32Array *other) {
|
||||
continue;
|
||||
}
|
||||
|
||||
wapp_b32_array_append_capped(array, item);
|
||||
wapp_b8_array_append_capped(array, item);
|
||||
}
|
||||
}
|
||||
|
||||
void wapp_b32_array_clear(B32Array *array) {
|
||||
void wapp_b8_array_clear(B8Array *array) {
|
||||
wapp_debug_assert(array != NULL, "`array` should not be NULL");
|
||||
array->count = 0;
|
||||
}
|
||||
|
||||
void wapp_b32_array_copy_capped(const B32Array *src, B32Array *dst) {
|
||||
void wapp_b8_array_copy_capped(const B8Array *src, B8Array *dst) {
|
||||
wapp_debug_assert(src != NULL && dst != NULL, "`src` and `dst` should not be NULL");
|
||||
|
||||
wapp_b32_array_clear(dst);
|
||||
wapp_b8_array_clear(dst);
|
||||
|
||||
b32 *item;
|
||||
b8 *item;
|
||||
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_b32_array_get(src, item_index);
|
||||
item = wapp_b8_array_get(src, item_index);
|
||||
++item_index;
|
||||
running = item_index < to_copy;
|
||||
|
||||
@@ -382,77 +382,77 @@ void wapp_b32_array_copy_capped(const B32Array *src, B32Array *dst) {
|
||||
continue;
|
||||
}
|
||||
|
||||
wapp_b32_array_append_capped(dst, item);
|
||||
wapp_b8_array_append_capped(dst, item);
|
||||
}
|
||||
}
|
||||
|
||||
B32Array *wapp_b32_array_append_alloc(const Allocator *allocator, B32Array *array, b32 *item) {
|
||||
B8Array *wapp_b8_array_append_alloc(const Allocator *allocator, B8Array *array, b8 *item) {
|
||||
wapp_debug_assert(allocator != NULL && array != NULL, "`allocator` and `array` should not be NULL");
|
||||
|
||||
B32Array *output = array;
|
||||
B8Array *output = array;
|
||||
|
||||
if (array->count >= array->capacity) {
|
||||
u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(array->capacity * 2);
|
||||
output = (B32Array *)_array_alloc_capacity(allocator, new_capacity, array->item_size);
|
||||
output = (B8Array *)_array_alloc_capacity(allocator, new_capacity, array->item_size);
|
||||
if (!output) {
|
||||
output = array;
|
||||
goto RETURN_B32_ARRAY_APPEND_ALLOC;
|
||||
goto RETURN_B8_ARRAY_APPEND_ALLOC;
|
||||
}
|
||||
wapp_b32_array_copy_capped(array, output);
|
||||
wapp_b8_array_copy_capped(array, output);
|
||||
}
|
||||
|
||||
wapp_b32_array_append_capped(output, item);
|
||||
wapp_b8_array_append_capped(output, item);
|
||||
|
||||
RETURN_B32_ARRAY_APPEND_ALLOC:
|
||||
RETURN_B8_ARRAY_APPEND_ALLOC:
|
||||
return output;
|
||||
}
|
||||
|
||||
B32Array *wapp_b32_array_extend_alloc(const Allocator *allocator, B32Array *array, const B32Array *other) {
|
||||
B8Array *wapp_b8_array_extend_alloc(const Allocator *allocator, B8Array *array, const B8Array *other) {
|
||||
wapp_debug_assert(allocator != NULL && array != NULL && other != NULL, "`allocator`, `array` and `other` should not be NULL");
|
||||
|
||||
B32Array *output = array;
|
||||
B8Array *output = array;
|
||||
|
||||
u64 remaining_capacity = array->capacity - array->count;
|
||||
if (other->count >= remaining_capacity) {
|
||||
u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(array->capacity * 2);
|
||||
output = (B32Array *)_array_alloc_capacity(allocator, new_capacity, array->item_size);
|
||||
output = (B8Array *)_array_alloc_capacity(allocator, new_capacity, array->item_size);
|
||||
if (!output) {
|
||||
output = array;
|
||||
goto RETURN_B32_ARRAY_EXTEND_ALLOC;
|
||||
goto RETURN_B8_ARRAY_EXTEND_ALLOC;
|
||||
}
|
||||
wapp_b32_array_copy_capped(array, output);
|
||||
wapp_b8_array_copy_capped(array, output);
|
||||
}
|
||||
|
||||
wapp_b32_array_extend_capped(output, other);
|
||||
wapp_b8_array_extend_capped(output, other);
|
||||
|
||||
RETURN_B32_ARRAY_EXTEND_ALLOC:
|
||||
RETURN_B8_ARRAY_EXTEND_ALLOC:
|
||||
return output;
|
||||
}
|
||||
|
||||
B32Array *wapp_b32_array_copy_alloc(const Allocator *allocator, const B32Array *src, B32Array *dst) {
|
||||
B8Array *wapp_b8_array_copy_alloc(const Allocator *allocator, const B8Array *src, B8Array *dst) {
|
||||
wapp_debug_assert(allocator != NULL && src != NULL && dst != NULL, "`allocator`, `src` and `dst` should not be NULL");
|
||||
|
||||
B32Array *output = dst;
|
||||
B8Array *output = dst;
|
||||
|
||||
if (src->count >= dst->capacity) {
|
||||
u64 new_capacity = wapp_misc_utils_u64_round_up_pow2(dst->capacity * 2);
|
||||
output = (B32Array *)_array_alloc_capacity(allocator, new_capacity, src->item_size);
|
||||
output = (B8Array *)_array_alloc_capacity(allocator, new_capacity, src->item_size);
|
||||
if (!output) {
|
||||
output = dst;
|
||||
goto RETURN_B32_ARRAY_COPY_ALLOC;
|
||||
goto RETURN_B8_ARRAY_COPY_ALLOC;
|
||||
}
|
||||
}
|
||||
|
||||
wapp_b32_array_clear(output);
|
||||
wapp_b32_array_copy_capped(src, output);
|
||||
wapp_b8_array_clear(output);
|
||||
wapp_b8_array_copy_capped(src, output);
|
||||
|
||||
RETURN_B32_ARRAY_COPY_ALLOC:
|
||||
RETURN_B8_ARRAY_COPY_ALLOC:
|
||||
return output;
|
||||
}
|
||||
|
||||
b32 *_b32_array_pop(B32Array *array) {
|
||||
b8 *_b8_array_pop(B8Array *array) {
|
||||
u64 index = array->count - 1;
|
||||
b32 *out = wapp_b32_array_get(array, index);
|
||||
b8 *out = wapp_b8_array_get(array, index);
|
||||
--(array->count);
|
||||
return out;
|
||||
}
|
||||
@@ -491,7 +491,7 @@ void wapp_char_array_extend_capped(CharArray *array, const CharArray *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_char_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -521,7 +521,7 @@ void wapp_char_array_copy_capped(const CharArray *src, CharArray *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_char_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -640,7 +640,7 @@ void wapp_c8_array_extend_capped(C8Array *array, const C8Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_c8_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -670,7 +670,7 @@ void wapp_c8_array_copy_capped(const C8Array *src, C8Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_c8_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -789,7 +789,7 @@ void wapp_c16_array_extend_capped(C16Array *array, const C16Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_c16_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -819,7 +819,7 @@ void wapp_c16_array_copy_capped(const C16Array *src, C16Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_c16_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -938,7 +938,7 @@ void wapp_c32_array_extend_capped(C32Array *array, const C32Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_c32_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -968,7 +968,7 @@ void wapp_c32_array_copy_capped(const C32Array *src, C32Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_c32_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1087,7 +1087,7 @@ void wapp_i8_array_extend_capped(I8Array *array, const I8Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i8_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -1117,7 +1117,7 @@ void wapp_i8_array_copy_capped(const I8Array *src, I8Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i8_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1236,7 +1236,7 @@ void wapp_i16_array_extend_capped(I16Array *array, const I16Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i16_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -1266,7 +1266,7 @@ void wapp_i16_array_copy_capped(const I16Array *src, I16Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i16_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1385,7 +1385,7 @@ void wapp_i32_array_extend_capped(I32Array *array, const I32Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i32_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -1415,7 +1415,7 @@ void wapp_i32_array_copy_capped(const I32Array *src, I32Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i32_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1534,7 +1534,7 @@ void wapp_i64_array_extend_capped(I64Array *array, const I64Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i64_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -1564,7 +1564,7 @@ void wapp_i64_array_copy_capped(const I64Array *src, I64Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_i64_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1683,7 +1683,7 @@ void wapp_u8_array_extend_capped(U8Array *array, const U8Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u8_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -1713,7 +1713,7 @@ void wapp_u8_array_copy_capped(const U8Array *src, U8Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u8_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1832,7 +1832,7 @@ void wapp_u16_array_extend_capped(U16Array *array, const U16Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u16_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -1862,7 +1862,7 @@ void wapp_u16_array_copy_capped(const U16Array *src, U16Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u16_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -1981,7 +1981,7 @@ void wapp_u32_array_extend_capped(U32Array *array, const U32Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u32_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2011,7 +2011,7 @@ void wapp_u32_array_copy_capped(const U32Array *src, U32Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u32_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -2130,7 +2130,7 @@ void wapp_u64_array_extend_capped(U64Array *array, const U64Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u64_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2160,7 +2160,7 @@ void wapp_u64_array_copy_capped(const U64Array *src, U64Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_u64_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -2279,7 +2279,7 @@ void wapp_f32_array_extend_capped(F32Array *array, const F32Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_f32_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2309,7 +2309,7 @@ void wapp_f32_array_copy_capped(const F32Array *src, F32Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_f32_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -2428,7 +2428,7 @@ void wapp_f64_array_extend_capped(F64Array *array, const F64Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_f64_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2458,7 +2458,7 @@ void wapp_f64_array_copy_capped(const F64Array *src, F64Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_f64_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -2577,7 +2577,7 @@ void wapp_f128_array_extend_capped(F128Array *array, const F128Array *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_f128_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2607,7 +2607,7 @@ void wapp_f128_array_copy_capped(const F128Array *src, F128Array *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_f128_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -2726,7 +2726,7 @@ void wapp_iptr_array_extend_capped(IptrArray *array, const IptrArray *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_iptr_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2756,7 +2756,7 @@ void wapp_iptr_array_copy_capped(const IptrArray *src, IptrArray *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_iptr_array_get(src, item_index);
|
||||
++item_index;
|
||||
@@ -2875,7 +2875,7 @@ void wapp_uptr_array_extend_capped(UptrArray *array, const UptrArray *other) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 items_to_add = other->count;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_uptr_array_get(other, item_index);
|
||||
++item_index;
|
||||
@@ -2905,7 +2905,7 @@ void wapp_uptr_array_copy_capped(const UptrArray *src, UptrArray *dst) {
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 to_copy = src->count < dst->capacity ? src->count : dst->capacity;
|
||||
u64 item_index = 0;
|
||||
b32 running = true;
|
||||
b8 running = true;
|
||||
while (running) {
|
||||
item = wapp_uptr_array_get(src, item_index);
|
||||
++item_index;
|
||||
|
||||
@@ -16,7 +16,7 @@ BEGIN_C_LINKAGE
|
||||
|
||||
#define wapp_void_ptr_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((VoidPArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(void *)))
|
||||
#define wapp_str8_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((Str8Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(Str8)))
|
||||
#define wapp_b32_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((B32Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(b32)))
|
||||
#define wapp_b8_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((B8Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(b8)))
|
||||
#define wapp_char_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((CharArray *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(char)))
|
||||
#define wapp_c8_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((C8Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(c8)))
|
||||
#define wapp_c16_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY) ((C16Array *)_array_alloc_capacity(ALLOCATOR_PTR, CAPACITY, sizeof(c16)))
|
||||
@@ -70,22 +70,22 @@ BEGIN_C_LINKAGE
|
||||
*_str8_array_pop(ARRAY_PTR) : \
|
||||
Str8{} \
|
||||
)
|
||||
#define wapp_b32_array(...) ([&]() { \
|
||||
wapp_persist b32 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return B32Array{ \
|
||||
#define wapp_b8_array(...) ([&]() { \
|
||||
wapp_persist b8 buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b8, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
return B8Array{ \
|
||||
buf, \
|
||||
wapp_misc_utils_va_args_count(b32, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2), \
|
||||
sizeof(b32) \
|
||||
wapp_misc_utils_va_args_count(b8, __VA_ARGS__), \
|
||||
wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b8, __VA_ARGS__) * 2), \
|
||||
sizeof(b8) \
|
||||
}; \
|
||||
}())
|
||||
#define wapp_b32_array_with_capacity(CAPACITY) ([&]() { \
|
||||
wapp_persist b32 buf[CAPACITY] = {}; \
|
||||
return B32Array{buf, 0, CAPACITY, sizeof(b32)}; \
|
||||
#define wapp_b8_array_with_capacity(CAPACITY) ([&]() { \
|
||||
wapp_persist b8 buf[CAPACITY] = {}; \
|
||||
return B8Array{buf, 0, CAPACITY, sizeof(b8)}; \
|
||||
}())
|
||||
#define wapp_b32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_b32_array_pop(ARRAY_PTR) : \
|
||||
b32{} \
|
||||
#define wapp_b8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_b8_array_pop(ARRAY_PTR) : \
|
||||
b8{} \
|
||||
)
|
||||
#define wapp_char_array(...) ([&]() { \
|
||||
wapp_persist char buf[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2)] = {__VA_ARGS__}; \
|
||||
@@ -399,16 +399,16 @@ BEGIN_C_LINKAGE
|
||||
*_str8_array_pop(ARRAY_PTR) : \
|
||||
(Str8){0} \
|
||||
)
|
||||
#define wapp_b32_array(...) ((B32Array){ \
|
||||
.items = (b32[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
|
||||
.count = wapp_misc_utils_va_args_count(b32, __VA_ARGS__), \
|
||||
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b32, __VA_ARGS__) * 2), \
|
||||
.item_size = sizeof(b32) \
|
||||
#define wapp_b8_array(...) ((B8Array){ \
|
||||
.items = (b8[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b8, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
|
||||
.count = wapp_misc_utils_va_args_count(b8, __VA_ARGS__), \
|
||||
.capacity = wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(b8, __VA_ARGS__) * 2), \
|
||||
.item_size = sizeof(b8) \
|
||||
})
|
||||
#define wapp_b32_array_with_capacity(CAPACITY) ((B32Array){.items = (b32[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(b32)})
|
||||
#define wapp_b32_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_b32_array_pop(ARRAY_PTR) : \
|
||||
(b32){0} \
|
||||
#define wapp_b8_array_with_capacity(CAPACITY) ((B8Array){.items = (b8[CAPACITY]){0}, .count = 0, .capacity = CAPACITY, .item_size = sizeof(b8)})
|
||||
#define wapp_b8_array_pop(ARRAY_PTR) (ARRAY_PTR != NULL && (ARRAY_PTR)->count > 0 ? \
|
||||
*_b8_array_pop(ARRAY_PTR) : \
|
||||
(b8){0} \
|
||||
)
|
||||
#define wapp_char_array(...) ((CharArray){ \
|
||||
.items = (char[wapp_misc_utils_u64_round_up_pow2(wapp_misc_utils_va_args_count(char, __VA_ARGS__) * 2)]){__VA_ARGS__}, \
|
||||
@@ -625,9 +625,9 @@ struct Str8Array {
|
||||
u64 item_size;
|
||||
};
|
||||
|
||||
typedef struct B32Array B32Array;
|
||||
struct B32Array {
|
||||
b32 *items;
|
||||
typedef struct B8Array B8Array;
|
||||
struct B8Array {
|
||||
b8 *items;
|
||||
u64 count;
|
||||
u64 capacity;
|
||||
u64 item_size;
|
||||
@@ -789,16 +789,16 @@ Str8Array *wapp_str8_array_append_alloc(const Allocator *allocator, Str8Array *a
|
||||
Str8Array *wapp_str8_array_extend_alloc(const Allocator *allocator, Str8Array *array, const Str8Array *other);
|
||||
Str8Array *wapp_str8_array_copy_alloc(const Allocator *allocator, const Str8Array *src, Str8Array *dst);
|
||||
Str8 *_str8_array_pop(Str8Array *array);
|
||||
b32 *wapp_b32_array_get(const B32Array *array, u64 index);
|
||||
void wapp_b32_array_set(B32Array *array, u64 index, b32 *item);
|
||||
void wapp_b32_array_append_capped(B32Array *array, b32 *item);
|
||||
void wapp_b32_array_extend_capped(B32Array *array, const B32Array *other);
|
||||
void wapp_b32_array_clear(B32Array *array);
|
||||
void wapp_b32_array_copy_capped(const B32Array *src, B32Array *dst);
|
||||
B32Array *wapp_b32_array_append_alloc(const Allocator *allocator, B32Array *array, b32 *item);
|
||||
B32Array *wapp_b32_array_extend_alloc(const Allocator *allocator, B32Array *array, const B32Array *other);
|
||||
B32Array *wapp_b32_array_copy_alloc(const Allocator *allocator, const B32Array *src, B32Array *dst);
|
||||
b32 *_b32_array_pop(B32Array *array);
|
||||
b8 *wapp_b8_array_get(const B8Array *array, u64 index);
|
||||
void wapp_b8_array_set(B8Array *array, u64 index, b8 *item);
|
||||
void wapp_b8_array_append_capped(B8Array *array, b8 *item);
|
||||
void wapp_b8_array_extend_capped(B8Array *array, const B8Array *other);
|
||||
void wapp_b8_array_clear(B8Array *array);
|
||||
void wapp_b8_array_copy_capped(const B8Array *src, B8Array *dst);
|
||||
B8Array *wapp_b8_array_append_alloc(const Allocator *allocator, B8Array *array, b8 *item);
|
||||
B8Array *wapp_b8_array_extend_alloc(const Allocator *allocator, B8Array *array, const B8Array *other);
|
||||
B8Array *wapp_b8_array_copy_alloc(const Allocator *allocator, const B8Array *src, B8Array *dst);
|
||||
b8 *_b8_array_pop(B8Array *array);
|
||||
char *wapp_char_array_get(const CharArray *array, u64 index);
|
||||
void wapp_char_array_set(CharArray *array, u64 index, char *item);
|
||||
void wapp_char_array_append_capped(CharArray *array, char *item);
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
wapp_intern VoidPList void_ptr_node_to_list(VoidPNode *node);
|
||||
wapp_intern Str8List str8_node_to_list(Str8Node *node);
|
||||
wapp_intern B32List b32_node_to_list(B32Node *node);
|
||||
wapp_intern B8List b8_node_to_list(B8Node *node);
|
||||
wapp_intern CharList char_node_to_list(CharNode *node);
|
||||
wapp_intern C8List c8_node_to_list(C8Node *node);
|
||||
wapp_intern C16List c16_node_to_list(C16Node *node);
|
||||
@@ -375,11 +375,11 @@ void wapp_str8_list_empty(Str8List *list) {
|
||||
}
|
||||
}
|
||||
|
||||
B32Node *wapp_b32_list_get(const B32List *list, u64 index) {
|
||||
B8Node *wapp_b8_list_get(const B8List *list, u64 index) {
|
||||
wapp_runtime_assert(index < list->node_count, "`index` is out of bounds");
|
||||
|
||||
B32Node *output = NULL;
|
||||
B32Node *current = list->first;
|
||||
B8Node *output = NULL;
|
||||
B8Node *current = list->first;
|
||||
for (u64 i = 1; i <= index; ++i) {
|
||||
current = current->next;
|
||||
}
|
||||
@@ -389,10 +389,10 @@ B32Node *wapp_b32_list_get(const B32List *list, u64 index) {
|
||||
return output;
|
||||
}
|
||||
|
||||
void wapp_b32_list_push_front(B32List *list, B32Node *node) {
|
||||
void wapp_b8_list_push_front(B8List *list, B8Node *node) {
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
|
||||
B32List node_list = b32_node_to_list(node);
|
||||
B8List node_list = b8_node_to_list(node);
|
||||
|
||||
if (list->node_count == 0) {
|
||||
*list = node_list;
|
||||
@@ -401,7 +401,7 @@ void wapp_b32_list_push_front(B32List *list, B32Node *node) {
|
||||
|
||||
list->node_count += node_list.node_count;
|
||||
|
||||
B32Node *first = list->first;
|
||||
B8Node *first = list->first;
|
||||
if (first) {
|
||||
first->prev = node_list.last;
|
||||
}
|
||||
@@ -410,10 +410,10 @@ void wapp_b32_list_push_front(B32List *list, B32Node *node) {
|
||||
node_list.last->next = first;
|
||||
}
|
||||
|
||||
void wapp_b32_list_push_back(B32List *list, B32Node *node) {
|
||||
void wapp_b8_list_push_back(B8List *list, B8Node *node) {
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
|
||||
B32List node_list = b32_node_to_list(node);
|
||||
B8List node_list = b8_node_to_list(node);
|
||||
|
||||
if (list->node_count == 0) {
|
||||
*list = node_list;
|
||||
@@ -422,7 +422,7 @@ void wapp_b32_list_push_back(B32List *list, B32Node *node) {
|
||||
|
||||
list->node_count += node_list.node_count;
|
||||
|
||||
B32Node *last = list->last;
|
||||
B8Node *last = list->last;
|
||||
if (last) {
|
||||
last->next = node_list.first;
|
||||
}
|
||||
@@ -431,27 +431,27 @@ void wapp_b32_list_push_back(B32List *list, B32Node *node) {
|
||||
node_list.first->prev = last;
|
||||
}
|
||||
|
||||
void wapp_b32_list_insert(B32List *list, B32Node *node, u64 index) {
|
||||
void wapp_b8_list_insert(B8List *list, B8Node *node, u64 index) {
|
||||
wapp_debug_assert(list != NULL && node != NULL && (node->item) != NULL, "`list`, `node` and `node->item` should not be NULL");
|
||||
|
||||
if (index == 0) {
|
||||
wapp_b32_list_push_front(list, node);
|
||||
wapp_b8_list_push_front(list, node);
|
||||
return;
|
||||
} else if (index == list->node_count) {
|
||||
wapp_b32_list_push_back(list, node);
|
||||
wapp_b8_list_push_back(list, node);
|
||||
return;
|
||||
}
|
||||
|
||||
B32Node *dst_node = wapp_b32_list_get(list, index);
|
||||
B8Node *dst_node = wapp_b8_list_get(list, index);
|
||||
if (!dst_node) {
|
||||
return;
|
||||
}
|
||||
|
||||
B32List node_list = b32_node_to_list(node);
|
||||
B8List node_list = b8_node_to_list(node);
|
||||
|
||||
list->node_count += node_list.node_count;
|
||||
|
||||
B32Node *prev = dst_node->prev;
|
||||
B8Node *prev = dst_node->prev;
|
||||
|
||||
dst_node->prev = node_list.last;
|
||||
prev->next = node_list.first;
|
||||
@@ -460,20 +460,20 @@ void wapp_b32_list_insert(B32List *list, B32Node *node, u64 index) {
|
||||
node_list.last->next = dst_node;
|
||||
}
|
||||
|
||||
B32Node *wapp_b32_list_pop_front(B32List *list) {
|
||||
B8Node *wapp_b8_list_pop_front(B8List *list) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
B32Node *output = NULL;
|
||||
B8Node *output = NULL;
|
||||
|
||||
if (list->node_count == 0) {
|
||||
goto RETURN_B32_LIST_POP_FRONT;
|
||||
goto RETURN_B8_LIST_POP_FRONT;
|
||||
}
|
||||
|
||||
output = list->first;
|
||||
|
||||
if (list->node_count == 1) {
|
||||
*list = (B32List){0};
|
||||
goto RETURN_B32_LIST_POP_FRONT;
|
||||
*list = (B8List){0};
|
||||
goto RETURN_B8_LIST_POP_FRONT;
|
||||
}
|
||||
|
||||
--(list->node_count);
|
||||
@@ -481,24 +481,24 @@ B32Node *wapp_b32_list_pop_front(B32List *list) {
|
||||
|
||||
output->prev = output->next = NULL;
|
||||
|
||||
RETURN_B32_LIST_POP_FRONT:
|
||||
RETURN_B8_LIST_POP_FRONT:
|
||||
return output;
|
||||
}
|
||||
|
||||
B32Node *wapp_b32_list_pop_back(B32List *list) {
|
||||
B8Node *wapp_b8_list_pop_back(B8List *list) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
B32Node *output = NULL;
|
||||
B8Node *output = NULL;
|
||||
|
||||
if (list->node_count == 0) {
|
||||
goto RETURN_B32_LIST_POP_BACK;
|
||||
goto RETURN_B8_LIST_POP_BACK;
|
||||
}
|
||||
|
||||
output = list->last;
|
||||
|
||||
if (list->node_count == 1) {
|
||||
*list = (B32List){0};
|
||||
goto RETURN_B32_LIST_POP_BACK;
|
||||
*list = (B8List){0};
|
||||
goto RETURN_B8_LIST_POP_BACK;
|
||||
}
|
||||
|
||||
--(list->node_count);
|
||||
@@ -506,26 +506,26 @@ B32Node *wapp_b32_list_pop_back(B32List *list) {
|
||||
|
||||
output->prev = output->next = NULL;
|
||||
|
||||
RETURN_B32_LIST_POP_BACK:
|
||||
RETURN_B8_LIST_POP_BACK:
|
||||
return output;
|
||||
}
|
||||
|
||||
B32Node *wapp_b32_list_remove(B32List *list, u64 index) {
|
||||
B8Node *wapp_b8_list_remove(B8List *list, u64 index) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
B32Node *output = NULL;
|
||||
B8Node *output = NULL;
|
||||
|
||||
if (index == 0) {
|
||||
output = wapp_b32_list_pop_front(list);
|
||||
goto RETURN_B32_LIST_REMOVE;
|
||||
output = wapp_b8_list_pop_front(list);
|
||||
goto RETURN_B8_LIST_REMOVE;
|
||||
} else if (index == list->node_count) {
|
||||
output = wapp_b32_list_pop_back(list);
|
||||
goto RETURN_B32_LIST_REMOVE;
|
||||
output = wapp_b8_list_pop_back(list);
|
||||
goto RETURN_B8_LIST_REMOVE;
|
||||
}
|
||||
|
||||
output = wapp_b32_list_get(list, index);
|
||||
output = wapp_b8_list_get(list, index);
|
||||
if (!output) {
|
||||
goto RETURN_B32_LIST_REMOVE;
|
||||
goto RETURN_B8_LIST_REMOVE;
|
||||
}
|
||||
|
||||
output->prev->next = output->next;
|
||||
@@ -535,16 +535,16 @@ B32Node *wapp_b32_list_remove(B32List *list, u64 index) {
|
||||
|
||||
output->prev = output->next = NULL;
|
||||
|
||||
RETURN_B32_LIST_REMOVE:
|
||||
RETURN_B8_LIST_REMOVE:
|
||||
return output;
|
||||
}
|
||||
|
||||
void wapp_b32_list_empty(B32List *list) {
|
||||
void wapp_b8_list_empty(B8List *list) {
|
||||
wapp_debug_assert(list != NULL, "`list` should not be NULL");
|
||||
|
||||
u64 count = list->node_count;
|
||||
for (u64 i = 0; i < count; ++i) {
|
||||
wapp_b32_list_pop_back(list);
|
||||
wapp_b8_list_pop_back(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3521,8 +3521,8 @@ wapp_intern Str8List str8_node_to_list(Str8Node *node) {
|
||||
return output;
|
||||
}
|
||||
|
||||
wapp_intern B32List b32_node_to_list(B32Node *node) {
|
||||
B32List output = {.first = node, .last = node, .node_count = 1};
|
||||
wapp_intern B8List b8_node_to_list(B8Node *node) {
|
||||
B8List output = {.first = node, .last = node, .node_count = 1};
|
||||
|
||||
while (output.first->prev != NULL) {
|
||||
output.first = output.first->prev;
|
||||
|
||||
@@ -15,7 +15,7 @@ BEGIN_C_LINKAGE
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
#define wapp_void_ptr_list_node(ITEM_PTR) VoidPNode{ITEM_PTR, nullptr, nullptr}
|
||||
#define wapp_str8_list_node(ITEM_PTR) Str8Node{ITEM_PTR, nullptr, nullptr}
|
||||
#define wapp_b32_list_node(ITEM_PTR) B32Node{ITEM_PTR, nullptr, nullptr}
|
||||
#define wapp_b8_list_node(ITEM_PTR) B8Node{ITEM_PTR, nullptr, nullptr}
|
||||
#define wapp_char_list_node(ITEM_PTR) CharNode{ITEM_PTR, nullptr, nullptr}
|
||||
#define wapp_c8_list_node(ITEM_PTR) C8Node{ITEM_PTR, nullptr, nullptr}
|
||||
#define wapp_c16_list_node(ITEM_PTR) C16Node{ITEM_PTR, nullptr, nullptr}
|
||||
@@ -36,7 +36,7 @@ BEGIN_C_LINKAGE
|
||||
#else
|
||||
#define wapp_void_ptr_list_node(ITEM_PTR) ((VoidPNode){.item = ITEM_PTR})
|
||||
#define wapp_str8_list_node(ITEM_PTR) ((Str8Node){.item = ITEM_PTR})
|
||||
#define wapp_b32_list_node(ITEM_PTR) ((B32Node){.item = ITEM_PTR})
|
||||
#define wapp_b8_list_node(ITEM_PTR) ((B8Node){.item = ITEM_PTR})
|
||||
#define wapp_char_list_node(ITEM_PTR) ((CharNode){.item = ITEM_PTR})
|
||||
#define wapp_c8_list_node(ITEM_PTR) ((C8Node){.item = ITEM_PTR})
|
||||
#define wapp_c16_list_node(ITEM_PTR) ((C16Node){.item = ITEM_PTR})
|
||||
@@ -100,17 +100,17 @@ struct Str8List {
|
||||
u64 node_count;
|
||||
};
|
||||
|
||||
typedef struct B32Node B32Node;
|
||||
struct B32Node {
|
||||
b32 *item;
|
||||
B32Node *prev;
|
||||
B32Node *next;
|
||||
typedef struct B8Node B8Node;
|
||||
struct B8Node {
|
||||
b8 *item;
|
||||
B8Node *prev;
|
||||
B8Node *next;
|
||||
};
|
||||
|
||||
typedef struct B32List B32List;
|
||||
struct B32List {
|
||||
B32Node *first;
|
||||
B32Node *last;
|
||||
typedef struct B8List B8List;
|
||||
struct B8List {
|
||||
B8Node *first;
|
||||
B8Node *last;
|
||||
u64 node_count;
|
||||
};
|
||||
|
||||
@@ -368,14 +368,14 @@ Str8Node *wapp_str8_list_pop_front(Str8List *list);
|
||||
Str8Node *wapp_str8_list_pop_back(Str8List *list);
|
||||
Str8Node *wapp_str8_list_remove(Str8List *list, u64 index);
|
||||
void wapp_str8_list_empty(Str8List *list);
|
||||
B32Node *wapp_b32_list_get(const B32List *list, u64 index);
|
||||
void wapp_b32_list_push_front(B32List *list, B32Node *node);
|
||||
void wapp_b32_list_push_back(B32List *list, B32Node *node);
|
||||
void wapp_b32_list_insert(B32List *list, B32Node *node, u64 index);
|
||||
B32Node *wapp_b32_list_pop_front(B32List *list);
|
||||
B32Node *wapp_b32_list_pop_back(B32List *list);
|
||||
B32Node *wapp_b32_list_remove(B32List *list, u64 index);
|
||||
void wapp_b32_list_empty(B32List *list);
|
||||
B8Node *wapp_b8_list_get(const B8List *list, u64 index);
|
||||
void wapp_b8_list_push_front(B8List *list, B8Node *node);
|
||||
void wapp_b8_list_push_back(B8List *list, B8Node *node);
|
||||
void wapp_b8_list_insert(B8List *list, B8Node *node, u64 index);
|
||||
B8Node *wapp_b8_list_pop_front(B8List *list);
|
||||
B8Node *wapp_b8_list_pop_back(B8List *list);
|
||||
B8Node *wapp_b8_list_remove(B8List *list, u64 index);
|
||||
void wapp_b8_list_empty(B8List *list);
|
||||
CharNode *wapp_char_list_get(const CharList *list, u64 index);
|
||||
void wapp_char_list_push_front(CharList *list, CharNode *node);
|
||||
void wapp_char_list_push_back(CharList *list, CharNode *node);
|
||||
|
||||
@@ -123,7 +123,7 @@ void wapp_str8_push_back(Str8 *str, c8 c) {
|
||||
wapp_str8_set(str, index, c);
|
||||
}
|
||||
|
||||
b32 wapp_str8_equal(Str8RO *s1, Str8RO *s2) {
|
||||
b8 wapp_str8_equal(Str8RO *s1, Str8RO *s2) {
|
||||
if (s1->size != s2->size) {
|
||||
return false;
|
||||
}
|
||||
@@ -131,7 +131,7 @@ b32 wapp_str8_equal(Str8RO *s1, Str8RO *s2) {
|
||||
return wapp_str8_equal_to_count(s1, s2, s1->size);
|
||||
}
|
||||
|
||||
b32 wapp_str8_equal_to_count(Str8RO* s1, Str8RO* s2, u64 count) {
|
||||
b8 wapp_str8_equal_to_count(Str8RO* s1, Str8RO* s2, u64 count) {
|
||||
if (!s1 || !s2) {
|
||||
return false;
|
||||
}
|
||||
@@ -278,7 +278,7 @@ i64 wapp_str8_find(Str8RO *str, Str8RO substr) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
u64 char_index = 0;
|
||||
b32 running = char_index < str->size;
|
||||
b8 running = char_index < str->size;
|
||||
while (running) {
|
||||
const c8 *sub = str->buf + char_index;
|
||||
if (memcmp(sub, substr.buf, substr.size) == 0) {
|
||||
@@ -300,7 +300,7 @@ i64 wapp_str8_rfind(Str8RO *str, Str8RO substr) {
|
||||
// NOTE (Abdelrahman): Uses a while loop instead of a for loop to get rid of
|
||||
// MSVC Spectre mitigation warnings
|
||||
i64 char_index = str->size - substr.size;
|
||||
b32 running = char_index >= 0;
|
||||
b8 running = char_index >= 0;
|
||||
while (running) {
|
||||
const c8 *sub = str->buf + char_index;
|
||||
if (memcmp(sub, substr.buf, substr.size) == 0) {
|
||||
@@ -427,7 +427,7 @@ Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8RO *d
|
||||
// MSVC Spectre mitigation warnings
|
||||
Str8Node *node;
|
||||
u64 node_index = 0;
|
||||
b32 running = node_index < list->node_count;
|
||||
b8 running = node_index < list->node_count;
|
||||
while (running) {
|
||||
node = wapp_str8_list_get(list, node_index);
|
||||
if (!node) {
|
||||
@@ -438,7 +438,7 @@ Str8 *wapp_str8_join(const Allocator *allocator, const Str8List *list, Str8RO *d
|
||||
|
||||
// NOTE (Abdelrahman): Comparison extracted to variable to silence
|
||||
// MSVC Spectre mitigation warnings
|
||||
b32 not_last = node_index + 1 < list->node_count;
|
||||
b8 not_last = node_index + 1 < list->node_count;
|
||||
if (not_last) {
|
||||
wapp_str8_concat_capped(output, delimiter);
|
||||
}
|
||||
@@ -460,7 +460,7 @@ u64 wapp_str8_list_total_size(const Str8List *list) {
|
||||
Str8Node* node;
|
||||
u64 node_index = 0;
|
||||
u64 output = 0;
|
||||
b32 running = node_index < list->node_count;
|
||||
b8 running = node_index < list->node_count;
|
||||
while (running) {
|
||||
node = wapp_str8_list_get(list, node_index);
|
||||
if (!node) {
|
||||
|
||||
@@ -89,8 +89,8 @@ void wapp_str8_dealloc_buf(const Allocator *allocator, Str8 **str);
|
||||
c8 wapp_str8_get(Str8RO *str, u64 index);
|
||||
void wapp_str8_set(Str8 *str, u64 index, c8 c);
|
||||
void wapp_str8_push_back(Str8 *str, c8 c);
|
||||
b32 wapp_str8_equal(Str8RO *s1, Str8RO *s2);
|
||||
b32 wapp_str8_equal_to_count(Str8RO* s1, Str8RO* s2, u64 count);
|
||||
b8 wapp_str8_equal(Str8RO *s1, Str8RO *s2);
|
||||
b8 wapp_str8_equal_to_count(Str8RO* s1, Str8RO* s2, u64 count);
|
||||
Str8 wapp_str8_slice(Str8RO *str, u64 start, u64 end);
|
||||
void wapp_str8_concat_capped(Str8 *dst, Str8RO *src);
|
||||
void wapp_str8_copy_cstr_capped(Str8 *dst, const char *src);
|
||||
|
||||
@@ -18,7 +18,7 @@ wapp_intern void seed_os_generator(void);
|
||||
wapp_intern u64 generate_random_number(void);
|
||||
|
||||
XOR256State wapp_prng_xorshift_init_state(void) {
|
||||
wapp_persist b32 seeded = false;
|
||||
wapp_persist b8 seeded = false;
|
||||
if (!seeded) {
|
||||
seeded = true;
|
||||
seed_os_generator();
|
||||
|
||||
@@ -22,10 +22,10 @@ BEGIN_C_LINKAGE
|
||||
typedef struct test_func_result TestFuncResult;
|
||||
struct test_func_result {
|
||||
Str8RO name;
|
||||
b32 passed;
|
||||
b8 passed;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
wapp_misc_utils_padding_size(sizeof(Str8RO) + sizeof(b32));
|
||||
wapp_misc_utils_padding_size(sizeof(Str8RO) + sizeof(b8));
|
||||
#endif // WAPP_PLATFORM_WINDOWS
|
||||
};
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ UUID *wapp_uuid_init_uuid4(UUID *uuid) {
|
||||
|
||||
wapp_intern UUID4 generate_uuid4(void) {
|
||||
wapp_persist XOR256State state = {0};
|
||||
wapp_persist b32 initialised = false;
|
||||
wapp_persist b8 initialised = false;
|
||||
|
||||
if (!initialised) {
|
||||
initialised = true;
|
||||
|
||||
Reference in New Issue
Block a user