replace { 0 } initializers with new ZI macro. enable 'Wmissing-field-initializers'

This commit is contained in:
jacob 2024-09-19 12:15:29 -05:00
parent eed68f04cd
commit 5593db5202
31 changed files with 124 additions and 117 deletions

View File

@ -363,7 +363,7 @@ void OnBuild(StringList cli_args)
"-Wno-declaration-after-statement -Wno-extra-semi -Wno-extra-semi-stmt "
"-Wno-bad-function-cast -Wno-class-varargs -Wno-unreachable-code-break "
"-Wno-cast-align -Wno-float-equal -Wno-zero-as-null-pointer-constant "
"-Wno-cast-qual -Wno-missing-noreturn -Wno-missing-field-initializers "
"-Wno-cast-qual -Wno-missing-noreturn "
"-Wno-missing-braces -Wno-initializer-overrides "
"-Wno-c99-extensions -Wno-c++98-compat-pedantic -Wno-c++98-compat "
"-Wno-switch-enum -Wno-switch-default "

View File

@ -36,7 +36,7 @@ GLOBAL struct {
struct sys_mutex exit_callbacks_mutex;
struct arena exit_callbacks_arena;
struct exit_callback *exit_callbacks_head;
} G = { 0 }, DEBUG_ALIAS(G, G_app);
} G = ZI, DEBUG_ALIAS(G, G_app);
/* ========================== *
* Write directory
@ -165,7 +165,7 @@ void app_entry_point(void)
{
struct temp_arena temp = arena_temp_begin(scratch.arena);
struct sys_window_settings window_settings = { 0 };
struct sys_window_settings window_settings = ZI;
struct string settings_path = app_write_path_cat(temp.arena, STR(SETTINGS_FILENAME));
logf_info("Looking for settings file \"%F\"", FMT_STR(settings_path));
if (sys_is_file(settings_path)) {
@ -174,7 +174,7 @@ void app_entry_point(void)
struct buffer file_data = sys_file_read_all(temp.arena, settings_file);
sys_file_close(settings_file);
logf_info("Deserializing settings file data: %F", FMT_STR(STRING_FROM_BUFFER(file_data)));
struct string error = { 0 };
struct string error = ZI;
struct sys_window_settings *res = settings_deserialize(temp.arena, file_data, &error);
if (error.len > 0) {
logf_info("Failed to load settings file with error - %F", FMT_STR(error));

View File

@ -11,7 +11,7 @@
struct arena arena_alloc(u64 reserve)
{
__prof;
struct arena arena = { 0 };
struct arena arena = ZI;
/* Round up to nearest block size */
u64 block_remainder = reserve % ARENA_BLOCK_SIZE;

View File

@ -86,7 +86,7 @@ INLINE void *_arena_align(struct arena *arena, u64 align)
INLINE struct temp_arena arena_temp_begin(struct arena *arena)
{
struct temp_arena t = { 0 };
struct temp_arena t = ZI;
t.arena = arena;
t.start_pos = arena->pos;
return t;

View File

@ -187,19 +187,19 @@ INTERNAL struct huffman huffman_init(struct arena *arena, u32 max_code_bits, u32
{
__prof;
struct huffman res = { 0 };
struct huffman res = ZI;
res.max_code_bits = max_code_bits;
res.entries_count = (1 << max_code_bits);
res.entries = arena_push_array(arena, struct huffman_entry, res.entries_count);
u32 code_length_hist[HUFFMAN_BIT_COUNT] = { 0 };
u32 code_length_hist[HUFFMAN_BIT_COUNT] = ZI;
for (u32 i = 0; i < bl_counts_count; ++i) {
u32 count = bl_counts[i];
ASSERT(count <= ARRAY_COUNT(code_length_hist));
++code_length_hist[count];
}
u32 next_code[HUFFMAN_BIT_COUNT] = { 0 };
u32 next_code[HUFFMAN_BIT_COUNT] = ZI;
next_code[0] = 0;
code_length_hist[0] = 0;
for (u32 i = 1; i < ARRAY_COUNT(next_code); ++i) {
@ -276,7 +276,7 @@ INTERNAL void inflate(u8 *dest, u8 *encoded)
case BLOCK_TYPE_COMPRESSED_FIXED:
case BLOCK_TYPE_COMPRESSED_DYNAMIC: {
struct temp_arena temp = arena_temp_begin(scratch.arena);
u32 lit_len_dist_table[512] = { 0 };
u32 lit_len_dist_table[512] = ZI;
u32 hlit;
u32 hdist;
@ -289,7 +289,7 @@ INTERNAL void inflate(u8 *dest, u8 *encoded)
u32 hclen = consume_bits(&bb, 4) + 4;
/* Init dict huffman (hclen) */
u32 hclen_bl_counts[19] = { 0 };
u32 hclen_bl_counts[19] = ZI;
for (u32 i = 0; i < hclen; ++i) {
u32 code = g_hclen_order[i];
hclen_bl_counts[code] = consume_bits(&bb, 3);
@ -556,7 +556,7 @@ struct ase_decode_image_result ase_decode_image(struct arena *arena, struct buff
__prof;
struct temp_arena scratch = scratch_begin(arena);
struct ase_decode_image_result res = { 0 };
struct ase_decode_image_result res = ZI;
struct byte_reader br = br_create_from_buffer(encoded);
struct ase_header ase_header;
@ -815,7 +815,7 @@ struct ase_decode_sheet_result ase_decode_sheet(struct arena *arena, struct buff
{
__prof;
struct ase_decode_sheet_result res = { 0 };
struct ase_decode_sheet_result res = ZI;
struct byte_reader br = br_create_from_buffer(encoded);
struct ase_header ase_header;

View File

@ -29,7 +29,7 @@ GLOBAL struct {
u64 dbg_table_count;
struct sys_mutex dbg_table_mutex;
#endif
} G = { 0 }, DEBUG_ALIAS(G, G_asset_cache);
} G = ZI, DEBUG_ALIAS(G, G_asset_cache);
/* ========================== *
* Startup
@ -139,7 +139,7 @@ struct asset *asset_cache_touch(struct string key, u64 hash, b32 *is_first_touch
if (G.num_assets >= MAX_ASSETS) {
sys_panic(STR("Max assets reached"));
}
struct string key_stored = { 0 };
struct string key_stored = ZI;
{
/* Copy key to store */
struct asset_cache_store store = asset_cache_store_open();

View File

@ -171,6 +171,13 @@ void __asan_unpoison_memory_region(void const volatile *add, size_t);
# define CPPFRIENDLY_INITLIST_TYPE(type) (type)
#endif
/* Zero initialization macro */
#if LANGUAGE_C
# define ZI { 0 }
#else
# define ZI { }
#endif
#if 1
# define INLINE static inline
#else

View File

@ -7,7 +7,7 @@
GLOBAL struct {
struct renderer_handle solid_white;
} G = { 0 }, DEBUG_ALIAS(G, G_draw);
} G = ZI, DEBUG_ALIAS(G, G_draw);
/* ========================== *
* Startup

View File

@ -91,7 +91,7 @@ void entity_store_reset(struct entity_store *store)
INTERNAL struct entity *entity_alloc_internal(struct entity_store *store)
{
struct entity *entity = NULL;
struct entity_handle handle = { 0 };
struct entity_handle handle = ZI;
if (store->first_free.gen) {
/* Reuse from free list */;
entity = entity_from_handle(store, store->first_free);

View File

@ -35,7 +35,7 @@ struct font_task_params_store {
GLOBAL struct {
struct font_task_params_store params;
} G = { 0 }, DEBUG_ALIAS(G, L_font);
} G = ZI, DEBUG_ALIAS(G, L_font);
/* ========================== *
* Startup
@ -193,7 +193,7 @@ struct asset *font_load_asset(struct string path, f32 point_size, b32 help)
/* Push task */
asset_cache_mark_loading(asset);
struct work_handle wh = { 0 };
struct work_handle wh = ZI;
if (help) {
wh = work_push_task_and_help(&font_load_asset_task, params, WORK_PRIORITY_NORMAL);
} else {

View File

@ -29,7 +29,7 @@ GLOBAL struct {
struct atomic_u64 prev_tick_id;
struct world prev_tick;
struct world tick;
} G = { 0 }, DEBUG_ALIAS(G, G_game);
} G = ZI, DEBUG_ALIAS(G, G_game);
/* ========================== *
* Startup
@ -85,7 +85,7 @@ INTERNAL void push_cmds(struct game_cmd_array cmd_array)
INTERNAL struct game_cmd_array pop_cmds(struct arena *arena)
{
struct game_cmd_array array = { 0 };
struct game_cmd_array array = ZI;
if (G.game_cmds_arena.pos > 0) {
struct sys_lock lock = sys_mutex_lock_e(&G.game_cmds_mutex);
struct buffer game_cmds_buff = arena_to_buffer(&G.game_cmds_arena);
@ -292,8 +292,8 @@ INTERNAL void create_contact_manifolds(void)
/* TODO: Remove this */
static struct arena dict_arena = { 0 };
static struct fixed_dict dict = { 0 };
static struct arena dict_arena = ZI;
static struct fixed_dict dict = ZI;
if (dict.buckets_count == 0) {
dict_arena = arena_alloc(GIGABYTE(64));
dict = fixed_dict_init(&dict_arena, 4096);

View File

@ -32,7 +32,7 @@ INTERNAL struct v2 menkowski_point(struct v2_array poly0, struct v2_array shape1
b32 gjk_boolean(struct v2_array shape0, struct v2_array shape1)
{
struct { struct v2 a, b, c; } s = { 0 };
struct { struct v2 a, b, c; } s = ZI;
/* First point is support point in shape's general directions to eachother */
s.a = menkowski_point(shape0, shape1, v2_sub(shape1.points[0], shape0.points[0]));
@ -160,23 +160,23 @@ struct v2_array cloud(struct arena *arena, struct v2_array poly0, struct v2_arra
struct gjk_contact_points_result gjk_contact_points(struct v2_array shape0, struct v2_array shape1)
{
struct temp_arena scratch = scratch_begin_no_conflict(); /* TODO: Only begin scratch for EPA */
struct gjk_contact_points_result res = { 0 };
struct gjk_contact_points_result res = ZI;
/* TODO: Verify epsilon */
/* FIXME: Infinite loop when epsilon too low and shapes is too far from 0 (precision issue) */
const f32 epsilon = 0.0000100f;
struct gjk_simplex s = { 0 };
struct gjk_simplex s = ZI;
b32 colliding = false;
struct gjk_menkowski_point *proto = NULL;
u32 proto_count = 0;
struct gjk_contact_pair pair0 = { 0 };
struct gjk_contact_pair pair1 = { 0 };
struct gjk_contact_pair pair0 = ZI;
struct gjk_contact_pair pair1 = ZI;
u32 num_pairs = 0;
/* Used by GJK & EPA */
struct v2 dir = { 0 };
struct gjk_menkowski_point m = { 0 };
struct v2 dir = ZI;
struct gjk_menkowski_point m = ZI;
#if GJK_DEBUG
u32 dbg_step = 0;
@ -430,18 +430,18 @@ abort:
struct gjk_contact_points_result gjk_contact_points(struct v2_array shape0, struct v2_array shape1)
{
struct temp_arena scratch = scratch_begin_no_conflict();
struct gjk_contact_points_result res = { 0 };
struct gjk_contact_points_result res = ZI;
/* TODO: Verify epsilon */
/* FIXME: Infinite loop when epsilon too low and shapes is too far from 0 (precision issue) */
const f32 epsilon = 0.0000100;
struct gjk_simplex s = { 0 };
struct gjk_simplex s = ZI;
b32 colliding = false;
struct gjk_menkowski_point *proto = NULL;
u32 proto_count = 0;
struct gjk_contact_pair pair0 = { 0 };
struct gjk_contact_pair pair1 = { 0 };
struct gjk_contact_pair pair0 = ZI;
struct gjk_contact_pair pair1 = ZI;
u32 num_pairs = 0;
#if GJK_DEBUG
@ -453,8 +453,8 @@ struct gjk_contact_points_result gjk_contact_points(struct v2_array shape0, stru
* Construct encapsulating simplex OR closest feature if not colliding
* ========================== */
struct v2 dir = { 0 };
struct gjk_menkowski_point m = { 0 };
struct v2 dir = ZI;
struct gjk_menkowski_point m = ZI;
/* Determine encapsulating simplex if colliding, or closest edge / point to origin on simplex */
{
/* First point is support point in shape's general directions to eachother */
@ -730,14 +730,14 @@ abort:
struct gjk_extended_result gjk_extended(struct v2_array shape0, struct v2_array shape1)
{
struct temp_arena scratch = scratch_begin_no_conflict();
struct gjk_extended_result res = { 0 };
struct gjk_extended_result res = ZI;
/* TODO: Verify epsilon */
const f32 epsilon = 0.0000100;
struct gjk_simplex s = { 0 };
struct gjk_simplex s = ZI;
b32 colliding = false;
struct v2 shape0_p = { 0 };
struct v2 shape1_p = { 0 };
struct v2 shape0_p = ZI;
struct v2 shape1_p = ZI;
struct gjk_menkowski_point *proto = NULL;
u32 proto_count = 0;
@ -750,8 +750,8 @@ struct gjk_extended_result gjk_extended(struct v2_array shape0, struct v2_array
* Construct encapsulating simplex OR closest feature if not colliding
* ========================== */
struct v2 dir = { 0 };
struct gjk_menkowski_point m = { 0 };
struct v2 dir = ZI;
struct gjk_menkowski_point m = ZI;
/* Determine encapsulating simplex if colliding, or closest edge / point to origin on simplex */
{
/* First point is support point in shape's general directions to eachother */
@ -1057,7 +1057,7 @@ INTERNAL struct poly_support_swept_result poly_support_swept(struct v2_array a,
}
}
struct poly_support_swept_result res = { 0 };
struct poly_support_swept_result res = ZI;
res.p = furthest;
res.original = furthest_original;
return res;
@ -1077,7 +1077,7 @@ INTERNAL struct gjk_menkowski_point menkowski_point_extended_swept(struct v2_arr
struct gjk_extended_result gjk_extended(struct v2_array shape0, struct v2_array shape1, struct v2 linear_velocity)
{
struct temp_arena scratch = scratch_begin_no_conflict();
struct gjk_extended_result res = { 0 };
struct gjk_extended_result res = ZI;
/* FIXME: Divs by 0 */
@ -1090,8 +1090,8 @@ struct gjk_extended_result gjk_extended(struct v2_array shape0, struct v2_array
.c = V2(F32_NAN, F32_NAN)
};
b32 colliding = false;
struct v2 shape0_p = { 0 };
struct v2 shape1_p = { 0 };
struct v2 shape0_p = ZI;
struct v2 shape1_p = ZI;
b32 velocity_intersects = false;
f32 velocity_intersection = 0;
@ -1108,8 +1108,8 @@ struct gjk_extended_result gjk_extended(struct v2_array shape0, struct v2_array
* Construct encapsulating simplex OR closest feature if not colliding
* ========================== */
struct v2 dir = { 0 };
struct gjk_menkowski_point m = { 0 };
struct v2 dir = ZI;
struct gjk_menkowski_point m = ZI;
/* Determine encapsulating simplex if colliding, or closest edge / point to origin on simplex */
{
/* First point is support point in shape's general directions to eachother */

View File

@ -95,7 +95,7 @@ INTERNAL struct token *push_token(struct arena *arena, struct token_list *list)
INTERNAL struct token_list lex(struct arena *arena, struct string src)
{
struct token_list res = { 0 };
struct token_list res = ZI;
struct token *bof = push_token(arena, &res);
bof->type = TOKEN_TYPE_BOF;
@ -705,7 +705,7 @@ INTERNAL void parse(struct arena *arena, struct parser *p)
/* Parse key */
if (at->type == TOKEN_TYPE_STRING) {
struct string t_text = (struct string) { .len = at->end - at->start, .text = &src.text[at->start] };
struct string error = { 0 };
struct string error = ZI;
struct string key = interpret_string(arena, t_text, &error);
if (error.len > 0) {
push_error(arena, p, at, error);
@ -748,7 +748,7 @@ INTERNAL void parse(struct arena *arena, struct parser *p)
case TOKEN_TYPE_STRING: {
struct string t_text = (struct string) { .len = at->end - at->start, .text = &src.text[at->start] };
struct string error = { 0 };
struct string error = ZI;
struct string value = interpret_string(arena, t_text, &error);
if (error.len > 0) {
push_error(arena, p, at, error);

View File

@ -20,7 +20,7 @@ GLOBAL struct {
log_event_callback_func *callbacks_head;
struct sys_file file;
b32 file_valid;
} G = { 0 }, DEBUG_ALIAS(G, G_log);
} G = ZI, DEBUG_ALIAS(G, G_log);
GLOBAL READONLY struct log_level_settings g_log_level_settings[LOG_LEVEL_COUNT] = {
[LOG_LEVEL_CRITICAL] = {

View File

@ -64,7 +64,7 @@ GLOBAL struct {
struct track *track_last_playing;
u64 track_playing_count;
struct track *track_first_free;
} G = { 0 }, DEBUG_ALIAS(G, G_mixer);
} G = ZI, DEBUG_ALIAS(G, G_mixer);
/* ========================== *
* Startup
@ -202,7 +202,7 @@ struct mixer_track_handle mixer_play_ex(struct sound *sound, struct mixer_desc d
/* NOTE: This is quite inefficient. */
struct mixer_desc mixer_track_get(struct mixer_track_handle handle)
{
struct mixer_desc res = { 0 };
struct mixer_desc res = ZI;
struct track *track = track_from_handle(handle);
if (track) {
@ -271,7 +271,7 @@ struct mixed_pcm_f32 mixer_update(struct arena *arena, u64 frame_count)
struct temp_arena scratch = scratch_begin(arena);
struct mixed_pcm_f32 res = { 0 };
struct mixed_pcm_f32 res = ZI;
res.count = frame_count * 2;
res.samples = arena_push_array_zero(arena, f32, res.count);

View File

@ -26,7 +26,7 @@
struct mp3_decode_result mp3_decode(struct arena *arena, struct buffer encoded, u32 flags)
{
struct mp3_decode_result res = { 0 };
struct mp3_decode_result res = ZI;
u64 sample_rate = PLAYBACK_SAMPLE_RATE;
u64 bytes_per_sample = 2;

View File

@ -45,7 +45,7 @@ GLOBAL struct {
WAVEFORMATEX *buffer_format;
u32 buffer_frames;
HANDLE mmtc_handle;
} G = { 0 }, DEBUG_ALIAS(G, G_playback_wasapi);
} G = ZI, DEBUG_ALIAS(G, G_playback_wasapi);
/* ========================== *
* Startup
@ -177,7 +177,7 @@ INTERNAL void wasapi_initialize(void)
INTERNAL struct wasapi_buffer wasapi_update_begin(void)
{
__prof;
struct wasapi_buffer wspbuf = { 0 };
struct wasapi_buffer wspbuf = ZI;
/* Wait */
{

View File

@ -147,7 +147,7 @@ GLOBAL struct {
struct dx11_shader_desc shader_info[NUM_SHADERS];
} G = { 0 }, DEBUG_ALIAS(G, G_renderer_d3d11);
} G = ZI, DEBUG_ALIAS(G, G_renderer_d3d11);
/* ========================== *
* Util
@ -542,7 +542,7 @@ struct renderer_startup_receipt renderer_startup(struct sys_window *window)
{
__profscope(create_depth_stencil_state);
/* TODO: Actually go over these (copied from elsewhere) */
D3D11_DEPTH_STENCIL_DESC desc = { 0 };
D3D11_DEPTH_STENCIL_DESC desc = ZI;
desc.DepthEnable = false;
desc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
desc.DepthFunc = D3D11_COMPARISON_ALWAYS;
@ -874,7 +874,7 @@ void renderer_canvas_present(struct renderer_canvas **canvases, u32 canvases_cou
ID3D11DeviceContext_VSSetConstantBuffers(G.devcon, 0, 1, &G.vs_constant_buffer);
struct dx11_shader *last_shader = NULL;
struct renderer_handle last_texture_handle = { 0 };
struct renderer_handle last_texture_handle = ZI;
for (struct renderer_cmd *cmd = canvas->gpu_cmd_store.cmd_first; cmd; cmd = cmd->next) {
struct dx11_shader *shader = cmd->shader;
struct dx11_buffer *buffer = &canvas->buffers[shader->kind];
@ -1021,7 +1021,7 @@ INTERNAL void renderer_capture_image_for_profiler(f32 width, f32 height)
* At the time of writing this code, 5 textures seems to be the sweet spot
* for performance.
*/
static struct prof_cap staging_caps[5] = { 0 };
static struct prof_cap staging_caps[5] = ZI;
static u32 cap_index = 0;
static b32 ready_to_read = false;

View File

@ -12,7 +12,7 @@
GLOBAL struct {
struct arena arena;
struct tar_archive archive;
} G = { 0 }, DEBUG_ALIAS(G, G_resource);
} G = ZI, DEBUG_ALIAS(G, G_resource);
#endif
struct resource_startup_receipt resource_startup(void)

View File

@ -49,8 +49,8 @@ struct sys_window_settings *settings_deserialize(struct arena *arena, struct buf
__prof;
struct temp_arena scratch = scratch_begin(arena);
struct string error = { 0 };
struct json_error json_error = { 0 };
struct string error = ZI;
struct json_error json_error = ZI;
struct sys_window_settings *settings = arena_push_zero(arena, struct sys_window_settings);
struct json_parse_result parse_res = json_from_string(scratch.arena, STRING_FROM_BUFFER(src));

View File

@ -29,7 +29,7 @@ struct sound_task_params_store {
GLOBAL struct {
struct sound_task_params_store params;
} G = { 0 }, DEBUG_ALIAS(G, G_sound);
} G = ZI, DEBUG_ALIAS(G, G_sound);
/* ========================== *
* Startup
@ -194,7 +194,7 @@ struct asset *sound_load_asset(struct string path, u32 flags, b32 help)
/* Push task */
asset_cache_mark_loading(asset);
struct work_handle wh = { 0 };
struct work_handle wh = ZI;
if (help) {
wh = work_push_task_and_help(&sound_load_asset_task, params, WORK_PRIORITY_NORMAL);
} else {

View File

@ -141,7 +141,7 @@ GLOBAL struct {
struct sys_condition_variable evictor_cv;
struct sys_thread evictor_thread;
} G = { 0 }, DEBUG_ALIAS(G, G_sprite);
} G = ZI, DEBUG_ALIAS(G, G_sprite);
/* ========================== *
* Thread local state
@ -285,7 +285,7 @@ INTERNAL APP_EXIT_CALLBACK_FUNC_DEF(sprite_shutdown)
struct sprite_tag sprite_tag_from_path(struct string path)
{
struct sprite_tag res = { 0 };
struct sprite_tag res = ZI;
res.hash = HASH_FNV128_BASIS;
res.hash = hash_fnv128(res.hash, BUFFER_FROM_STRING(path));
res.path = path;
@ -352,7 +352,7 @@ INTERNAL void cache_node_load_texture(struct cache_node *n, struct sprite_tag ta
u64 memory_size = 0;
{
/* Decode */
struct ase_decode_image_result decoded = { 0 };
struct ase_decode_image_result decoded = ZI;
if (resource_exists(path)) {
struct resource texture_rs = resource_open(path);
decoded = ase_decode_image(scratch.arena, texture_rs.bytes);
@ -396,7 +396,7 @@ INTERNAL void cache_node_load_texture(struct cache_node *n, struct sprite_tag ta
INTERNAL struct sprite_sheet init_sheet_from_ase_result(struct arena *arena, struct ase_decode_sheet_result ase)
{
__prof;
struct sprite_sheet sheet = { 0 };
struct sprite_sheet sheet = ZI;
ASSERT(ase.num_frames >= 1);
@ -655,7 +655,7 @@ INTERNAL void cache_node_load_sheet(struct cache_node *n, struct sprite_tag tag)
n->arena = arena_alloc(SHEET_ARENA_RESERVE);
{
/* Decode */
struct ase_decode_sheet_result decoded = { 0 };
struct ase_decode_sheet_result decoded = ZI;
if (resource_exists(path)) {
struct resource sheet_rs = resource_open(path);
decoded = ase_decode_sheet(scratch.arena, sheet_rs.bytes);
@ -942,7 +942,7 @@ struct sprite_sheet_frame sprite_sheet_get_frame(struct sprite_sheet *sheet, u32
if (index < sheet->frames_count ) {
return sheet->frames[index];
}
struct sprite_sheet_frame res = { 0 };
struct sprite_sheet_frame res = ZI;
res.index = 0;
res.duration = 0.1;
res.clip = CLIP_ALL;
@ -952,7 +952,7 @@ struct sprite_sheet_frame sprite_sheet_get_frame(struct sprite_sheet *sheet, u32
struct sprite_sheet_span sprite_sheet_get_span(struct sprite_sheet *sheet, struct string name)
{
__prof;
struct sprite_sheet_span res = { 0 };
struct sprite_sheet_span res = ZI;
if (sheet->spans_count > 0) {
struct sprite_sheet_span *entry = fixed_dict_get(&sheet->spans_dict, name);
if (entry) {
@ -972,7 +972,7 @@ struct sprite_sheet_slice sprite_sheet_get_slice(struct sprite_sheet *sheet, str
}
/* Return 'pivot' by default */
struct sprite_sheet_slice res = { 0 };
struct sprite_sheet_slice res = ZI;
if (string_eq(name, STR("pivot"))) {
/* 'pivot' slice does not exist, return center */
res.center = V2(0, 0);
@ -988,7 +988,7 @@ struct sprite_sheet_slice sprite_sheet_get_slice(struct sprite_sheet *sheet, str
struct sprite_sheet_slice_array sprite_sheet_get_slices(struct sprite_sheet *sheet, struct string name, u32 frame_index)
{
struct sprite_sheet_slice_array res = { 0 };
struct sprite_sheet_slice_array res = ZI;
if (sheet->slice_groups_count > 0) {
struct sprite_sheet_slice_group *group = fixed_dict_get(&sheet->slice_groups_dict, name);
if (group) {

View File

@ -199,7 +199,7 @@ struct string string_repeat(struct arena *arena, struct string src, u64 count)
struct string string_cat(struct arena *arena, struct string str1, struct string str2)
{
struct string new_str = { 0 };
struct string new_str = ZI;
new_str.len = str1.len + str2.len;
new_str.text = arena_push_array(arena, u8, new_str.len);
MEMCPY(new_str.text, str1.text, str1.len);
@ -281,7 +281,7 @@ struct string string_indent(struct arena *arena, struct string str, u32 indent)
struct string string_lower(struct arena *arena, struct string str)
{
struct string res = { 0 };
struct string res = ZI;
res.text = arena_push_array(arena, u8, str.len);
res.len = str.len;
@ -416,7 +416,7 @@ struct string string_formatv(struct arena *arena, struct string fmt, va_list arg
}
if (!no_more_args && !escape && *c == '%' && *next == 'F') {
struct string parsed_str = { 0 };
struct string parsed_str = ZI;
/* Detect arg type and parse to string */
struct fmt_arg arg = va_arg(args, struct fmt_arg);
switch (arg.type) {

View File

@ -130,7 +130,7 @@ GLOBAL struct {
struct sys_mutex windows_mutex;
struct arena windows_arena;
struct win32_window *first_free_window;
} G = { 0 }, DEBUG_ALIAS(G, G_sys_win32);
} G = ZI, DEBUG_ALIAS(G, G_sys_win32);
/* ========================== *
* Events
@ -304,7 +304,7 @@ struct string sys_get_write_path(struct arena *arena)
NULL,
&p
);
struct string path = { 0 };
struct string path = ZI;
if (res == S_OK) {
path = string_from_win32_path(arena, p);
}
@ -337,7 +337,7 @@ void sys_mkdir(struct string path)
struct temp_arena scratch = scratch_begin_no_conflict();
wchar_t *path_wstr = wstr_from_string(scratch.arena, path);
int err_code = SHCreateDirectory(NULL, path_wstr);
struct string err = { 0 };
struct string err = ZI;
switch (err_code) {
case ERROR_BAD_PATHNAME: {
err = STR("Bad path name");
@ -629,7 +629,7 @@ struct win32_file_filter {
struct sys_file_filter sys_file_filter_begin(struct arena *arena, struct string pattern)
{
struct sys_file_filter filter = { 0 };
struct sys_file_filter filter = ZI;
struct win32_file_filter *filter_internal = arena_push_zero(arena, struct win32_file_filter);
filter_internal->filter_wstr = wstr_from_string(arena, pattern);
filter.handle = (u64)filter_internal;
@ -640,7 +640,7 @@ b32 sys_file_filter_next(struct arena *arena, struct sys_file_filter *filter)
{
struct win32_file_filter *filter_internal = (struct win32_file_filter *)filter->handle;
WIN32_FIND_DATAW find_file_data = { 0 };
WIN32_FIND_DATAW find_file_data = ZI;
b32 found = false;
if (filter_internal->find_handle) {
@ -933,7 +933,7 @@ INTERNAL void win32_update_window_from_settings(struct win32_window *window, str
}
}
RECT rect = { 0 };
RECT rect = ZI;
b32 old_fullscreen = old_settings.flags & SYS_WINDOW_SETTINGS_FLAG_FULLSCREEN;
b32 fullscreen = settings->flags & SYS_WINDOW_SETTINGS_FLAG_FULLSCREEN;
@ -1373,7 +1373,7 @@ struct sys_lock sys_mutex_lock_e(struct sys_mutex *mutex)
mutex->owner_tid = (u64)GetCurrentThreadId();
atomic_i64_inc_eval(&mutex->count);
#endif
struct sys_lock lock = { 0 };
struct sys_lock lock = ZI;
lock.exclusive = true;
lock.mutex = mutex;
return lock;
@ -1386,7 +1386,7 @@ struct sys_lock sys_mutex_lock_s(struct sys_mutex *mutex)
#if RTC
atomic_i64_inc_eval(&mutex->count);
#endif
struct sys_lock lock = { 0 };
struct sys_lock lock = ZI;
lock.mutex = mutex;
return lock;
}
@ -1563,7 +1563,7 @@ INTERNAL struct win32_tls *win32_thread_get_tls(void)
INTERNAL struct win32_tls win32_tls_alloc(void)
{
struct win32_tls tls = { 0 };
struct win32_tls tls = ZI;
tls.sleep_timer = CreateWaitableTimerExW(NULL, NULL, CREATE_WAITABLE_TIMER_HIGH_RESOLUTION, TIMER_ALL_ACCESS);
tls.store = thread_local_store_alloc();
return tls;
@ -1706,7 +1706,7 @@ struct sys_thread sys_thread_alloc(sys_thread_entry_point_func *entry_point, voi
ASSERT(entry_point != NULL);
logf_info("Creating thread \"%F\"", FMT_STR(thread_name));
struct sys_thread res = { 0 };
struct sys_thread res = ZI;
struct sys_lock lock = sys_mutex_lock_e(&G.threads_mutex);
{
/* Allocate thread object */
@ -1838,7 +1838,7 @@ void sys_set_clipboard_text(struct string str)
struct string sys_get_clipboard_text(struct arena *arena)
{
struct string res = { 0 };
struct string res = ZI;
if (IsClipboardFormatAvailable(CF_UNICODETEXT) && OpenClipboard(0)) {
HANDLE handle = GetClipboardData(CF_UNICODETEXT);
if (handle) {
@ -2103,7 +2103,7 @@ int CALLBACK wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev_instance,
wc->hInstance = instance;
/* Use first icon resource as window icon (same as explorer) */
wchar_t path[4096] = { 0 };
wchar_t path[4096] = ZI;
GetModuleFileNameW(instance, path, ARRAY_COUNT(path));
ExtractIconExW(path, 0, &wc->hIcon, &wc->hIconSm, 1);

View File

@ -69,13 +69,13 @@ struct tar_archive tar_parse(struct arena *arena, struct buffer data, struct str
{
__prof;
struct tar_archive archive = { 0 };
struct tar_archive archive = ZI;
struct byte_reader br = br_create_from_buffer(data);
u64 num_files = 0;
while (br_bytes_left(&br) > 1024) {
struct tar_header header = { 0 };
struct tar_header header = ZI;
br_read_to_struct(&br, &header);
if (!string_eq(STRING_FROM_ARRAY(header.ustar_indicator), STR("ustar\0"))) {

View File

@ -13,7 +13,7 @@ GLOBAL struct {
struct atomic_i32 metas_lock_flag;
u64 metas_count;
struct thread_local_var_meta metas[MAX_THREAD_LOCAL_VARS];
} G = { 0 }, DEBUG_ALIAS(G, G_thread_local);
} G = ZI, DEBUG_ALIAS(G, G_thread_local);
INTERNAL void metas_lock(void)
{
@ -31,7 +31,7 @@ INTERNAL void metas_unlock(void)
struct thread_local_store thread_local_store_alloc(void)
{
__prof;
struct thread_local_store t = { 0 };
struct thread_local_store t = ZI;
t.arena = arena_alloc(THREAD_LOCAL_STORE_RESERVE);
t.lookup = arena_push_array_zero(&t.arena, void *, MAX_THREAD_LOCAL_VARS);
t.allocation_order = arena_push_array_zero(&t.arena, u64, MAX_THREAD_LOCAL_VARS);

View File

@ -32,7 +32,7 @@ extern "C"
GLOBAL struct {
/* FIXME: Do we need to wrap this in a mutex? */
IDWriteFactory5 *factory;
} G = { 0 }, DEBUG_ALIAS(G, L_ttf_dwrite);
} G = ZI, DEBUG_ALIAS(G, L_ttf_dwrite);
/* ========================== *
* Decode font
@ -122,7 +122,7 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct buffer encoded,
error = factory->GetGdiInterop(&dwrite_gdi_interop);
/* Get Metrics */
DWRITE_FONT_METRICS metrics = { 0 };
DWRITE_FONT_METRICS metrics = ZI;
font_face->GetMetrics(&metrics);
f32 pixel_per_em = point_size * (DPI / 72.0f);
@ -175,13 +175,13 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct buffer encoded,
u32 row_height = 0;
for (u16 i = 0; i < glyph_count; ++i) {
/* Render glyph to target */
DWRITE_GLYPH_RUN glyph_run = { 0 };
DWRITE_GLYPH_RUN glyph_run = ZI;
glyph_run.fontFace = font_face;
glyph_run.fontEmSize = pixel_per_em;
glyph_run.glyphCount = 1;
glyph_run.glyphIndices = &i;
RECT bounding_box = { 0 };
RECT bounding_box = ZI;
error = render_target->DrawGlyphRun(
raster_target_x,
raster_target_y,
@ -201,7 +201,7 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct buffer encoded,
}
/* Compute glyph metrics */
DWRITE_GLYPH_METRICS glyph_metrics = { 0 };
DWRITE_GLYPH_METRICS glyph_metrics = ZI;
error = font_face->GetDesignGlyphMetrics(&i, 1, &glyph_metrics, false);
@ -221,7 +221,7 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct buffer encoded,
/* Get the bitmap */
HBITMAP bitmap = (HBITMAP)GetCurrentObject(dc, OBJ_BITMAP);
DIBSECTION dib = { 0 };
DIBSECTION dib = ZI;
GetObject(bitmap, sizeof(dib), &dib);
/* Start new row if necessary */
@ -241,7 +241,7 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct buffer encoded,
}
/* Set bounding box metrics (now that we know atlas x & y) */
glyph->atlas_rect = { 0 };
glyph->atlas_rect = ZI;
glyph->atlas_rect.x = (f32)out_offset_x;
glyph->atlas_rect.y = (f32)out_offset_y;
glyph->atlas_rect.width = (f32)tex_w;
@ -298,7 +298,7 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct buffer encoded,
factory->Release();
/* Return */
struct ttf_decode_result result = { 0 };
struct ttf_decode_result result = ZI;
result.glyphs = glyphs;
result.glyphs_count = glyph_count;
result.cache_indices = cache_indices;

View File

@ -76,7 +76,7 @@ struct uni_decode_utf8_result uni_decode_utf8(struct string str)
struct uni_encode_utf8_result uni_encode_utf8(u32 codepoint)
{
struct uni_encode_utf8_result res = { 0 };
struct uni_encode_utf8_result res = ZI;
if (codepoint <= 0x7F) {
res.count8 = 1;
@ -136,7 +136,7 @@ struct uni_decode_utf16_result uni_decode_utf16(struct string16 str)
struct uni_encode_utf16_result uni_encode_utf16(u32 codepoint)
{
struct uni_encode_utf16_result res = { 0 };
struct uni_encode_utf16_result res = ZI;
if (codepoint <= 0xFFFF) {
res.count16 = 1;
@ -189,7 +189,7 @@ struct uni_decode_utf32_result uni_decode_utf32(struct string32 str)
struct uni_encode_utf32_result uni_encode_utf32(u32 codepoint)
{
struct uni_encode_utf32_result res = { 0 };
struct uni_encode_utf32_result res = ZI;
if (codepoint <= 0x10FFFF) {
res.chars32 = codepoint;

View File

@ -69,7 +69,7 @@ GLOBAL struct {
struct v2 viewport_center;
struct v2 viewport_cursor;
struct v2 world_cursor;
} G = { 0 }, DEBUG_ALIAS(G, G_user);
} G = ZI, DEBUG_ALIAS(G, G_user);
/* ========================== *
* Bind state
@ -165,7 +165,7 @@ INTERNAL APP_EXIT_CALLBACK_FUNC_DEF(user_shutdown)
INTERNAL struct sys_event_array pop_sys_events(struct arena *arena)
{
struct sys_event_array array = { 0 };
struct sys_event_array array = ZI;
struct sys_lock lock = sys_mutex_lock_e(&G.sys_events_mutex);
{
struct buffer events_buff = arena_to_buffer(&G.sys_events_arena);
@ -435,7 +435,7 @@ INTERNAL void user_update(void)
struct entity_store *store = G.world.entity_store;
struct sprite_scope *sprite_frame_scope = sprite_scope_begin();
struct game_cmd_list cmd_list = { 0 };
struct game_cmd_list cmd_list = ZI;
/* ========================== *
* Produce interpolated tick
@ -1223,7 +1223,7 @@ INTERNAL void user_update(void)
move_speed *= walk_ratio;
}
struct v2 input_move_dir = { 0 };
struct v2 input_move_dir = ZI;
{
for (enum user_bind_kind bind = 0; bind < (i32)ARRAY_COUNT(G.bind_states); ++bind) {
struct bind_state state = G.bind_states[bind];

View File

@ -66,7 +66,7 @@ struct fixed_dict {
INLINE struct fixed_dict fixed_dict_init(struct arena *arena, u64 buckets_count)
{
__prof;
struct fixed_dict dict = { 0 };
struct fixed_dict dict = ZI;
buckets_count = max_u64(buckets_count, 1); /* Ensure at least 1 bucket */
dict.buckets_count = buckets_count;
dict.buckets = arena_push_array_zero(arena, struct fixed_dict_bucket, buckets_count);
@ -133,7 +133,7 @@ struct sync_flag {
INLINE struct sync_flag sync_flag_alloc(void)
{
struct sync_flag sf = { 0 };
struct sync_flag sf = ZI;
sf.mutex = sys_mutex_alloc();
sf.cv = sys_condition_variable_alloc();
return sf;

View File

@ -82,7 +82,7 @@ GLOBAL struct {
/* Pointers to the last piece of work of each priority in the scheduled
* work list (used for O(1) insertion) */
struct work *scheduled_work_priority_tails[NUM_WORK_PRIORITIES];
} G = { 0 }, DEBUG_ALIAS(G, G_work);
} G = ZI, DEBUG_ALIAS(G, G_work);
/* ========================== *
* Thread local state
@ -502,7 +502,7 @@ struct work_handle work_push_task_and_help(work_task_func *func, void *data, enu
struct work_slate work_slate_begin(void)
{
__prof;
struct work_slate ws = { 0 };
struct work_slate ws = ZI;
return ws;
}