convert some arena no_zero pushes to zeroed style

This commit is contained in:
jacob 2025-05-15 09:09:00 -05:00
parent 57174796b9
commit 2c0b2fcc36
8 changed files with 28 additions and 34 deletions

View File

@ -447,10 +447,8 @@ PACK(struct frame_header {
INTERNAL void push_error_copy_msg(struct arena *arena, struct ase_error_list *list, struct string msg_src) INTERNAL void push_error_copy_msg(struct arena *arena, struct ase_error_list *list, struct string msg_src)
{ {
logf_error("Error while decoding .ase: \"%F\"", FMT_STR(msg_src)); logf_error("Error while decoding .ase: \"%F\"", FMT_STR(msg_src));
struct ase_error *e = arena_push_no_zero(arena, struct ase_error); struct ase_error *e = arena_push(arena, struct ase_error);
*e = (struct ase_error) { e->msg = string_copy(arena, msg_src);
.msg = string_copy(arena, msg_src)
};
if (!list->first) { if (!list->first) {
list->first = e; list->first = e;
} else { } else {

View File

@ -424,14 +424,18 @@ INTERNAL struct epa_result epa_get_normal_from_gjk(struct collider_shape *shape0
} }
} }
/* Insert point into prototype */ /* Expand prototype */
arena_push_no_zero(scratch.arena, struct collider_menkowski_point); arena_push_no_zero(scratch.arena, struct collider_menkowski_point);
++proto_count; ++proto_count;
/* Shift points in prototype to make room */
for (u32 i = proto_count - 1; i > closest_b_index; --i) { for (u32 i = proto_count - 1; i > closest_b_index; --i) {
u32 shift_from = (i > 0) ? i - 1 : proto_count - 1; u32 shift_from = (i > 0) ? i - 1 : proto_count - 1;
u32 shift_to = i; u32 shift_to = i;
proto[shift_to] = proto[shift_from]; proto[shift_to] = proto[shift_from];
} }
/* Insert new point into prototype */
proto[closest_b_index] = m; proto[closest_b_index] = m;
} }
} else { } else {

View File

@ -650,12 +650,11 @@ struct parser {
INTERNAL void push_error(struct arena *arena, struct parser *p, struct token *t, struct string msg) INTERNAL void push_error(struct arena *arena, struct parser *p, struct token *t, struct string msg)
{ {
struct json_error *error = arena_push_no_zero(arena, struct json_error); struct json_error *error = arena_push(arena, struct json_error);
*error = (struct json_error) { error->msg = msg;
.msg = msg, error->start = t->start;
.start = t->start, error->end = t->end;
.end = t->end
};
struct json_error_list *list = &p->errors; struct json_error_list *list = &p->errors;
if (!list->first) { if (!list->first) {
list->first = error; list->first = error;

View File

@ -1039,22 +1039,18 @@ void renderer_cmd_buffer_ensure_cmd(struct renderer_cmd_buffer *cmdbuff, struct
|| last_cmd->shader->kind != SHADER_TRIANGLE || last_cmd->shader->kind != SHADER_TRIANGLE
|| (last_cmd->texture.handle != params->texture_params.texture.handle) || (last_cmd->texture.handle != params->texture_params.texture.handle)
|| !sprite_tag_eq(last_cmd->sprite, params->texture_params.sprite)) { || !sprite_tag_eq(last_cmd->sprite, params->texture_params.sprite)) {
new_cmd = arena_push_no_zero(&cmdbuff->cpu_cmd_store.arena, struct renderer_cmd); new_cmd = arena_push(&cmdbuff->cpu_cmd_store.arena, struct renderer_cmd);
*new_cmd = (struct renderer_cmd) { new_cmd->shader = &G.shaders[SHADER_TRIANGLE];
.shader = &G.shaders[SHADER_TRIANGLE], new_cmd->texture = params->texture_params.texture;
.texture = params->texture_params.texture, new_cmd->sprite = params->texture_params.sprite;
.sprite = params->texture_params.sprite
};
} }
} break; } break;
case SHADER_GRID: case SHADER_GRID:
{ {
if (!last_cmd || last_cmd->shader->kind != SHADER_GRID) { if (!last_cmd || last_cmd->shader->kind != SHADER_GRID) {
new_cmd = arena_push_no_zero(&cmdbuff->cpu_cmd_store.arena, struct renderer_cmd); new_cmd = arena_push(&cmdbuff->cpu_cmd_store.arena, struct renderer_cmd);
*new_cmd = (struct renderer_cmd) { new_cmd->shader = &G.shaders[SHADER_GRID];
.shader = &G.shaders[SHADER_GRID],
};
} }
} break; } break;
} }

View File

@ -125,11 +125,10 @@ INTERNAL WORK_TASK_FUNC_DEF(sound_load_asset_task, vparams)
} }
/* Initialize */ /* Initialize */
*sound = (struct sound) { MEMZERO_STRUCT(sound);
.flags = flags, sound->flags = flags;
.pcm.count = decoded.pcm.count, sound->pcm.count = decoded.pcm.count;
.pcm.samples = samples sound->pcm.samples = samples;
};
MEMCPY(sound->pcm.samples, decoded.pcm.samples, decoded.pcm.count * sizeof(*decoded.pcm.samples)); MEMCPY(sound->pcm.samples, decoded.pcm.samples, decoded.pcm.count * sizeof(*decoded.pcm.samples));
f64 elapsed = SECONDS_FROM_NS(sys_time_ns() - start_ns); f64 elapsed = SECONDS_FROM_NS(sys_time_ns() - start_ns);

View File

@ -369,7 +369,7 @@ INTERNAL void cache_entry_load_texture(struct cache_ref ref, struct sprite_tag t
resource_close(&texture_rs); resource_close(&texture_rs);
/* Initialize */ /* Initialize */
e->texture = arena_push_no_zero(&e->arena, struct sprite_texture); e->texture = arena_push(&e->arena, struct sprite_texture);
e->texture->width = decoded.image.width; e->texture->width = decoded.image.width;
e->texture->height = decoded.image.height; e->texture->height = decoded.image.height;
e->texture->texture = renderer_texture_alloc(RENDERER_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, V2I32(decoded.image.width, decoded.image.height), decoded.image.pixels); e->texture->texture = renderer_texture_alloc(RENDERER_TEXTURE_FORMAT_R8G8B8A8_UNORM, 0, V2I32(decoded.image.width, decoded.image.height), decoded.image.pixels);

View File

@ -119,12 +119,10 @@ struct tar_archive tar_parse(struct arena *arena, struct string data, struct str
} }
struct string file_name = string_cat(arena, prefix, file_name_cstr); struct string file_name = string_cat(arena, prefix, file_name_cstr);
struct tar_entry *entry = arena_push_no_zero(arena, struct tar_entry); struct tar_entry *entry = arena_push(arena, struct tar_entry);
*entry = (struct tar_entry) { entry->is_dir = is_dir;
.is_dir = is_dir, entry->file_name = file_name;
.file_name = file_name, entry->data = file_data;
.data = file_data
};
entry->next = archive.head; entry->next = archive.head;
archive.head = entry; archive.head = entry;

View File

@ -152,7 +152,7 @@ INLINE void fixed_dict_set(struct arena *arena, struct fixed_dict *dict, struct
} }
/* No match found, create new entry */ /* No match found, create new entry */
entry = arena_push_no_zero(arena, struct fixed_dict_entry); entry = arena_push(arena, struct fixed_dict_entry);
entry->key = key; entry->key = key;
entry->value = value; entry->value = value;
entry->hash = hash; entry->hash = hash;