Switch to using b32
This commit is contained in:
@@ -6,7 +6,6 @@
|
||||
#include "../../../common/assert/assert.h"
|
||||
#include "../../../common/misc/misc_utils.h"
|
||||
#include "../../os/mem/mem_os.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -22,14 +21,14 @@ struct arena {
|
||||
u8 *buf;
|
||||
u8 *offset;
|
||||
u64 capacity;
|
||||
bool committed;
|
||||
b32 committed;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
wapp_misc_utils_padding_size(sizeof(u8 *) * 2 + sizeof(u64) + sizeof(bool));
|
||||
wapp_misc_utils_padding_size(sizeof(u8 *) * 2 + sizeof(u64) + sizeof(b32));
|
||||
#endif // ifdef WAPP_PLATFORM_WINDOWS
|
||||
};
|
||||
|
||||
bool wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity, MemAllocFlags flags, bool zero_buffer) {
|
||||
b32 wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity, MemAllocFlags flags, b32 zero_buffer) {
|
||||
if (!arena || *arena || base_capacity == 0) {
|
||||
return false;
|
||||
}
|
||||
|
@@ -6,7 +6,6 @@
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
#include "../../os/mem/mem_os.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
@@ -28,7 +27,7 @@ typedef struct arena Arena;
|
||||
* control over how the Arena is initialised. Wrapper macros are provided for
|
||||
* easier use.
|
||||
*/
|
||||
bool wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity, MemAllocFlags flags, bool zero_buffer);
|
||||
b32 wapp_mem_arena_init_custom(Arena **arena, u64 base_capacity, MemAllocFlags flags, b32 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 @@ internal inline void *mem_arena_realloc_aligned(void *ptr, u64 old_size, u64 new
|
||||
void *alloc_obj);
|
||||
|
||||
|
||||
Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity, MemAllocFlags flags, bool zero_buffer) {
|
||||
Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity, MemAllocFlags flags, b32 zero_buffer) {
|
||||
Allocator allocator = {0};
|
||||
bool initialised = wapp_mem_arena_init_custom((Arena **)(&allocator.obj), base_capacity, flags, zero_buffer);
|
||||
b32 initialised = wapp_mem_arena_init_custom((Arena **)(&allocator.obj), base_capacity, flags, zero_buffer);
|
||||
if (!initialised) {
|
||||
return allocator;
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include "../../../common/platform/platform.h"
|
||||
#include "../../../primitives/mem_allocator/mem_allocator.h"
|
||||
#include "../../os/mem/mem_os.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
@@ -33,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, bool zero_buffer);
|
||||
Allocator wapp_mem_arena_allocator_init_custom(u64 base_capacity, MemAllocFlags flags, b32 zero_buffer);
|
||||
void wapp_mem_arena_allocator_clear(Allocator *allocator);
|
||||
void wapp_mem_arena_allocator_destroy(Allocator *allocator);
|
||||
|
||||
|
@@ -3,10 +3,9 @@
|
||||
#include "mem_utils.h"
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../../common/assert/assert.h"
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
|
||||
internal bool is_power_of_two(u64 num) { return (num & (num - 1)) == 0; }
|
||||
internal b32 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");
|
||||
|
@@ -8,7 +8,6 @@
|
||||
#include "../../../primitives/mem_allocator/mem_allocator.h"
|
||||
#include "../../../primitives/strings/str8/str8.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -22,7 +21,7 @@ u32 wapp_cpath_join_path(Str8 *dst, const Str8List *parts) {
|
||||
}
|
||||
|
||||
Str8 separator = wapp_str8_buf(4);
|
||||
wapp_str8_push_back(&separator, PATH_SEP);
|
||||
wapp_str8_push_back(&separator, WAPP_PATH_SEP);
|
||||
|
||||
u64 required_capacity = parts->node_count * separator.size + wapp_str8_list_total_size(parts);
|
||||
if (dst->capacity < required_capacity) {
|
||||
@@ -37,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;
|
||||
bool running = node_index < parts->node_count;
|
||||
b32 running = node_index < parts->node_count;
|
||||
while (running && node->next) {
|
||||
node = node->next;
|
||||
if (node->item->size == 0) {
|
||||
@@ -45,9 +44,9 @@ 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);
|
||||
bool add_path_sep = dst_last != PATH_SEP && node_start != PATH_SEP;
|
||||
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;
|
||||
|
||||
if (add_path_sep) {
|
||||
wapp_str8_concat_capped(dst, &separator);
|
||||
@@ -69,9 +68,9 @@ Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels) {
|
||||
goto RETURN_DIRUP;
|
||||
}
|
||||
|
||||
bool absolute = wapp_str8_get(path, 0) == PATH_SEP;
|
||||
b32 absolute = wapp_str8_get(path, 0) == WAPP_PATH_SEP;
|
||||
Str8 separator = wapp_str8_buf(4);
|
||||
wapp_str8_push_back(&separator, PATH_SEP);
|
||||
wapp_str8_push_back(&separator, WAPP_PATH_SEP);
|
||||
|
||||
if (path->size == 0) {
|
||||
output = wapp_str8_alloc_buf(allocator, 16);
|
||||
@@ -79,7 +78,7 @@ Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels) {
|
||||
goto RETURN_DIRUP;
|
||||
}
|
||||
|
||||
wapp_str8_push_back(output, absolute ? PATH_SEP : '.');
|
||||
wapp_str8_push_back(output, absolute ? WAPP_PATH_SEP : '.');
|
||||
goto RETURN_DIRUP;
|
||||
}
|
||||
|
||||
@@ -104,7 +103,7 @@ Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels) {
|
||||
goto LIST_CLEANUP_DIRUP;
|
||||
}
|
||||
|
||||
wapp_str8_push_back(output, absolute ? PATH_SEP : '.');
|
||||
wapp_str8_push_back(output, absolute ? WAPP_PATH_SEP : '.');
|
||||
} else {
|
||||
for (u64 i = 0; i < levels; ++i) {
|
||||
wapp_str8_list_pop_back(parts);
|
||||
@@ -118,7 +117,7 @@ Str8 *dirup(const Allocator *allocator, Str8RO *path, u64 levels) {
|
||||
output = wapp_str8_alloc_buf(allocator, alloc_size);
|
||||
if (output) {
|
||||
if (absolute) {
|
||||
wapp_str8_push_back(output, PATH_SEP);
|
||||
wapp_str8_push_back(output, WAPP_PATH_SEP);
|
||||
}
|
||||
|
||||
Str8 *joined = wapp_str8_join(&tmp_arena, parts, &separator);
|
||||
|
@@ -13,9 +13,13 @@ BEGIN_C_LINKAGE
|
||||
#endif // !WAPP_PLATFORM_CPP
|
||||
|
||||
#ifdef WAPP_PLATFORM_POSIX
|
||||
#define PATH_SEP '/'
|
||||
#include <limits.h>
|
||||
#define WAPP_PATH_SEP '/'
|
||||
#define WAPP_PATH_MAX PATH_MAX
|
||||
#elif defined(WAPP_PLATFORM_WINDOWS)
|
||||
#define PATH_SEP '\\'
|
||||
#include <windows.h>
|
||||
#define WAPP_PATH_SEP '\\'
|
||||
#define WAPP_PATH_MAX MAX_PATH
|
||||
#else
|
||||
#error "Unrecognised platform"
|
||||
#endif
|
||||
|
@@ -5,7 +5,6 @@
|
||||
#include "../../../common/aliases/aliases.h"
|
||||
#include "../../../common/platform/platform.h"
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
|
||||
#if defined(WAPP_PLATFORM_WINDOWS)
|
||||
|
@@ -10,7 +10,6 @@
|
||||
#include "../../../../primitives/mem_allocator/mem_allocator.h"
|
||||
#include "../../../../primitives/strings/str8/str8.h"
|
||||
#include <stdarg.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include "../../../../common/aliases/aliases.h"
|
||||
#include "../../../../common/platform/platform.h"
|
||||
#include "../../../../primitives/strings/str8/str8.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
@@ -5,7 +5,6 @@
|
||||
|
||||
#include "../../../../common/aliases/aliases.h"
|
||||
#include "../../../../common/platform/platform.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
@@ -30,11 +29,11 @@ typedef struct commander_result CMDResult;
|
||||
struct commander_result {
|
||||
i32 exit_code;
|
||||
CMDError error;
|
||||
bool exited;
|
||||
b32 exited;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
#include "../../../../common/misc/misc_utils.h"
|
||||
wapp_misc_utils_padding_size(sizeof(bool) + sizeof(i32) + sizeof(CMDError));
|
||||
wapp_misc_utils_padding_size(sizeof(b32) + sizeof(i32) + sizeof(CMDError));
|
||||
#endif // !WAPP_PLATFORM_WINDOWS
|
||||
};
|
||||
|
||||
|
@@ -9,7 +9,6 @@
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#define STR8_BUF_ALLOC_SIZE(CAPACITY) (sizeof(Str8) + sizeof(c8) * CAPACITY)
|
||||
|
||||
@@ -279,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;
|
||||
bool running = char_index < str->size;
|
||||
b32 running = char_index < str->size;
|
||||
while (running) {
|
||||
const c8 *sub = str->buf + char_index;
|
||||
if (memcmp(sub, substr.buf, substr.size) == 0) {
|
||||
@@ -301,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;
|
||||
bool running = char_index >= 0;
|
||||
b32 running = char_index >= 0;
|
||||
while (running) {
|
||||
const c8 *sub = str->buf + char_index;
|
||||
if (memcmp(sub, substr.buf, substr.size) == 0) {
|
||||
@@ -428,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;
|
||||
bool running = node_index < list->node_count;
|
||||
b32 running = node_index < list->node_count;
|
||||
while (running) {
|
||||
node = wapp_str8_list_get(list, node_index);
|
||||
if (!node) {
|
||||
@@ -439,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
|
||||
bool not_last = node_index + 1 < list->node_count;
|
||||
b32 not_last = node_index + 1 < list->node_count;
|
||||
if (not_last) {
|
||||
wapp_str8_concat_capped(output, delimiter);
|
||||
}
|
||||
@@ -461,7 +460,7 @@ u64 wapp_str8_list_total_size(const Str8List *list) {
|
||||
Str8Node* node;
|
||||
u64 node_index = 0;
|
||||
u64 output = 0;
|
||||
bool running = node_index < list->node_count;
|
||||
b32 running = node_index < list->node_count;
|
||||
while (running) {
|
||||
node = wapp_str8_list_get(list, node_index);
|
||||
if (!node) {
|
||||
|
@@ -10,7 +10,6 @@
|
||||
#include "../../../primitives/dbl_list/dbl_list.h"
|
||||
#include "../../mem_allocator/mem_allocator.h"
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
|
@@ -4,7 +4,6 @@
|
||||
#include "../../common/aliases/aliases.h"
|
||||
#include "../../common/assert/assert.h"
|
||||
#include "../../common/platform/platform.h"
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
|
||||
@@ -19,7 +18,7 @@ internal void seed_os_generator(void);
|
||||
internal u64 generate_random_number(void);
|
||||
|
||||
XOR256State wapp_prng_xorshift_init_state(void) {
|
||||
persistent bool seeded = false;
|
||||
persistent b32 seeded = false;
|
||||
if (!seeded) {
|
||||
seeded = true;
|
||||
seed_os_generator();
|
||||
|
@@ -6,7 +6,6 @@
|
||||
#include "../../common/misc/misc_utils.h"
|
||||
#include "../../common/platform/platform.h"
|
||||
#include "../../primitives/strings/str8/str8.h"
|
||||
#include <stdbool.h>
|
||||
|
||||
#ifdef WAPP_PLATFORM_CPP
|
||||
BEGIN_C_LINKAGE
|
||||
@@ -23,10 +22,10 @@ BEGIN_C_LINKAGE
|
||||
typedef struct test_func_result TestFuncResult;
|
||||
struct test_func_result {
|
||||
Str8RO name;
|
||||
bool passed;
|
||||
b32 passed;
|
||||
|
||||
#ifdef WAPP_PLATFORM_WINDOWS
|
||||
wapp_misc_utils_padding_size(sizeof(Str8RO) + sizeof(bool));
|
||||
wapp_misc_utils_padding_size(sizeof(Str8RO) + sizeof(b32));
|
||||
#endif // WAPP_PLATFORM_WINDOWS
|
||||
};
|
||||
|
||||
|
@@ -5,7 +5,6 @@
|
||||
#include "../common/assert/assert.h"
|
||||
#include "../primitives/strings/str8/str8.h"
|
||||
#include "../prng/xorshift/xorshift.h"
|
||||
#include <stdbool.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#define UUID_STR_FORMAT ("%.8" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.4" PRIx64 "-%.12" PRIx64)
|
||||
@@ -30,7 +29,7 @@ UUID *wapp_uuid_init_uuid4(UUID *uuid) {
|
||||
|
||||
internal UUID4 generate_uuid4(void) {
|
||||
persistent XOR256State state = {0};
|
||||
persistent bool initialised = false;
|
||||
persistent b32 initialised = false;
|
||||
|
||||
if (!initialised) {
|
||||
initialised = true;
|
||||
|
Reference in New Issue
Block a user