arena push zero by default

This commit is contained in:
jacob 2025-05-15 08:42:12 -05:00
parent 38f88e3cc7
commit 57174796b9
32 changed files with 192 additions and 188 deletions

View File

@ -114,7 +114,7 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(exit_callback_thread_entry_point, vcall
void app_register_exit_callback(app_exit_callback_func *func)
{
struct sys_lock lock = sys_mutex_lock_e(&G.exit_callbacks_mutex);
struct exit_callback *callback = arena_push_zero(&G.exit_callbacks_arena, struct exit_callback);
struct exit_callback *callback = arena_push(&G.exit_callbacks_arena, struct exit_callback);
callback->func = func;
callback->next = G.exit_callbacks_head;
G.exit_callbacks_head = callback;
@ -180,7 +180,7 @@ INTERNAL struct app_arg_list parse_args(struct arena *arena, struct string args_
if (key_start >= 0 && key_end > key_start && key_end <= (i64)args_str.len && value_start >= 0 && value_end > value_start && value_end <= (i64)args_str.len) {
struct string key = string_copy(arena, STRING(key_end - key_start, args_str.text + key_start));
struct string value = string_copy(arena, STRING(value_end - value_start, args_str.text + value_start));
struct app_arg *arg = arena_push_zero(arena, struct app_arg);
struct app_arg *arg = arena_push(arena, struct app_arg);
arg->key = key;
arg->value = value;
if (res.last) {

View File

@ -60,7 +60,7 @@ void arena_release(struct arena *arena)
}
/* NOTE: Application will exit if arena fails to commit memory */
void *arena_push_bytes(struct arena *arena, u64 size, u64 align)
void *arena_push_bytes_no_zero(struct arena *arena, u64 size, u64 align)
{
ASSERT(align > 0);
ASSERT(!arena->readonly);
@ -111,7 +111,7 @@ void arena_copy_replace(struct arena *dest, struct arena *src)
arena_reset(dest);
u64 data_size = src->pos;
u8 *data_src = src->base;
u8 *data_dest = arena_push_bytes(dest, data_size, 1);
u8 *data_dest = arena_push_bytes_no_zero(dest, data_size, 1);
MEMCPY(data_dest, data_src, data_size);
}

View File

@ -4,16 +4,16 @@
#include "memory.h"
#define arena_push(a, type) ((type *)arena_push_bytes((a), sizeof(type), alignof(type)))
#define arena_push_zero(a, type) ((type *)arena_push_bytes_zero((a), sizeof(type), alignof(type)))
#define arena_push_no_zero(a, type) ((type *)arena_push_bytes_no_zero((a), sizeof(type), alignof(type)))
#define arena_push_array(a, type, n) ((type *)arena_push_bytes((a), (sizeof(type) * (n)), alignof(type)))
#define arena_push_array_zero(a, type, n) ((type *)arena_push_bytes_zero((a), (sizeof(type) * (n)), alignof(type)))
#define arena_push_array_no_zero(a, type, n) ((type *)arena_push_bytes_no_zero((a), (sizeof(type) * (n)), alignof(type)))
#define arena_pop(a, type, dest) arena_pop_struct((a), sizeof(type), dest)
#define arena_pop_array(a, type, n, dest) arena_pop_struct((a), sizeof(type) * (n), dest)
/* Returns a pointer to where the next allocation would be (at alignment of type).
* Equivalent arena_push but without actually allocating anything. */
* Equivalent to arena_push but without actually allocating anything. */
#define arena_dry_push(a, type) (type *)(_arena_dry_push((a), alignof(type)))
struct temp_arena {
@ -27,15 +27,15 @@ struct temp_arena {
struct arena arena_alloc(u64 reserve);
void arena_release(struct arena *arena);
void *arena_push_bytes(struct arena *arena, u64 size, u64 align);
void *arena_push_bytes_no_zero(struct arena *arena, u64 size, u64 align);
void arena_copy_replace(struct arena *dest, struct arena *src);
void arena_decommit_unused_blocks(struct arena *arena);
void arena_set_readonly(struct arena *arena);
void arena_set_readwrite(struct arena *arena);
INLINE void *arena_push_bytes_zero(struct arena *arena, u64 size, u64 align)
INLINE void *arena_push_bytes(struct arena *arena, u64 size, u64 align)
{
void *p = arena_push_bytes(arena, size, align);
void *p = arena_push_bytes_no_zero(arena, size, align);
MEMZERO(p, size);
return p;
}
@ -71,7 +71,7 @@ INLINE void *arena_align(struct arena *arena, u64 align)
aligned_start_pos -= aligned_start_pos % align;
u64 align_bytes = aligned_start_pos - (u64)arena->pos;
if (align_bytes > 0) {
return (void *)arena_push_array(arena, u8, align_bytes);
return (void *)arena_push_array_no_zero(arena, u8, align_bytes);
} else {
return (void *)(arena->base + arena->pos);
}

View File

@ -190,7 +190,7 @@ INTERNAL struct huffman huffman_init(struct arena *arena, u32 max_code_bits, u32
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);
res.entries = arena_push_array_no_zero(arena, struct huffman_entry, res.entries_count);
u32 code_length_hist[HUFFMAN_BIT_COUNT] = ZI;
for (u32 i = 0; i < bl_counts_count; ++i) {
@ -447,7 +447,7 @@ PACK(struct frame_header {
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));
struct ase_error *e = arena_push(arena, struct ase_error);
struct ase_error *e = arena_push_no_zero(arena, struct ase_error);
*e = (struct ase_error) {
.msg = string_copy(arena, msg_src)
};
@ -588,7 +588,7 @@ struct ase_decode_image_result ase_decode_image(struct arena *arena, struct stri
res.image.width = image_width;
res.image.height = image_height;
/* TODO: Optimize this. Naive memset(0) is bloating the decode time for large images. */
res.image.pixels = arena_push_array_zero(arena, u32, image_width * image_height);
res.image.pixels = arena_push_array(arena, u32, image_width * image_height);
u32 num_layers = 0;
struct layer *layer_head = NULL;
@ -621,7 +621,7 @@ struct ase_decode_image_result ase_decode_image(struct arena *arena, struct stri
switch (chunk_type) {
case CHUNK_TYPE_LAYER: {
struct layer *layer = arena_push_zero(scratch.arena, struct layer);
struct layer *layer = arena_push(scratch.arena, struct layer);
layer->next = layer_head;
layer_head = layer;
@ -648,7 +648,7 @@ struct ase_decode_image_result ase_decode_image(struct arena *arena, struct stri
br_seek_bytes(&br, sizeof(u8) * 3);
u16 str_len = br_read_ubits(&br, 16);
layer->name = (struct string) { str_len, arena_push_array(scratch.arena, u8, str_len) };
layer->name = (struct string) { str_len, arena_push_array_no_zero(scratch.arena, u8, str_len) };
br_read_bytes(&br, layer->name);
if (layer->type == 2) {
@ -659,7 +659,7 @@ struct ase_decode_image_result ase_decode_image(struct arena *arena, struct stri
} break;
case CHUNK_TYPE_CEL: {
struct cel *cel = arena_push_zero(scratch.arena, struct cel);
struct cel *cel = arena_push(scratch.arena, struct cel);
if (cel_tail) {
cel_tail->next = cel;
} else {
@ -692,7 +692,7 @@ struct ase_decode_image_result ase_decode_image(struct arena *arena, struct stri
cel->width = br_read_ubits(&br, 16);
cel->height = br_read_ubits(&br, 16);
cel->pixels = arena_push_array(scratch.arena, u32, cel->width * cel->height);
cel->pixels = arena_push_array_no_zero(scratch.arena, u32, cel->width * cel->height);
u8 *huffman_encoded = br_read_bytes_raw(&br, chunk_end_pos - br_cur_byte(&br));
if (huffman_encoded) {
inflate((u8 *)cel->pixels, huffman_encoded);
@ -716,13 +716,13 @@ struct ase_decode_image_result ase_decode_image(struct arena *arena, struct stri
}
/* Create ordered layers array */
struct layer **layers_ordered = arena_push_array(scratch.arena, struct layer *, num_layers);
struct layer **layers_ordered = arena_push_array_no_zero(scratch.arena, struct layer *, num_layers);
for (struct layer *layer = layer_head; layer; layer = layer->next) {
layers_ordered[layer->index] = layer;
}
/* Link cels */
struct cel **cels_ordered = arena_push_array(scratch.arena, struct cel *, num_frames * num_layers);
struct cel **cels_ordered = arena_push_array_no_zero(scratch.arena, struct cel *, num_frames * num_layers);
for (struct cel *cel = cel_head; cel; cel = cel->next) {
cels_ordered[(cel->frame_index * num_layers) + cel->layer_index] = cel;
if (cel->type == CEL_TYPE_LINKED) {
@ -849,7 +849,7 @@ struct ase_decode_sheet_result ase_decode_sheet(struct arena *arena, struct stri
num_chunks = frame_header.chunks_old;
}
struct ase_frame *frame = arena_push_zero(arena, struct ase_frame);
struct ase_frame *frame = arena_push(arena, struct ase_frame);
frame->next = frame_head;
frame_head = frame;
@ -888,7 +888,7 @@ struct ase_decode_sheet_result ase_decode_sheet(struct arena *arena, struct stri
br_seek_bytes(&br, 8);
for (u16 k = 0; k < frame_span_count; ++k) {
struct ase_span *span = arena_push_zero(arena, struct ase_span);
struct ase_span *span = arena_push(arena, struct ase_span);
span->next = span_head;
span_head = span;
@ -897,7 +897,7 @@ struct ase_decode_sheet_result ase_decode_sheet(struct arena *arena, struct stri
br_seek_bytes(&br, 13);
u16 str_len = br_read_ubits(&br, 16);
span->name = (struct string) { str_len, arena_push_array(arena, u8, str_len) };
span->name = (struct string) { str_len, arena_push_array_no_zero(arena, u8, str_len) };
br_read_bytes(&br, span->name);
++num_spans;
@ -906,7 +906,7 @@ struct ase_decode_sheet_result ase_decode_sheet(struct arena *arena, struct stri
} break;
case CHUNK_TYPE_SLICE: {
struct ase_slice_key *slice_key = arena_push_zero(arena, struct ase_slice_key);
struct ase_slice_key *slice_key = arena_push(arena, struct ase_slice_key);
slice_key->next = slice_key_head;
slice_key_head = slice_key;
@ -917,11 +917,11 @@ struct ase_decode_sheet_result ase_decode_sheet(struct arena *arena, struct stri
br_seek_bytes(&br, 4);
u16 str_len = br_read_ubits(&br, 16);
slice_key->name = (struct string) { str_len, arena_push_array(arena, u8, str_len) };
slice_key->name = (struct string) { str_len, arena_push_array_no_zero(arena, u8, str_len) };
br_read_bytes(&br, slice_key->name);
for (u32 k = 0; k < num_slices; ++k) {
struct ase_slice *slice = arena_push_zero(arena, struct ase_slice);
struct ase_slice *slice = arena_push(arena, struct ase_slice);
slice->next = slice_key->slice_head;
slice_key->slice_head = slice;

View File

@ -157,7 +157,7 @@ struct string bw_get_written(struct arena *arena, struct bitbuff_writer *bw)
{
struct string res = ZI;
res.len = (bw->cur_bit + 7) >> 3;
res.text = arena_push_array(arena, u8, res.len);
res.text = arena_push_array_no_zero(arena, u8, res.len);
MEMCPY(res.text, bw->base, res.len);
return res;
}
@ -182,7 +182,7 @@ b32 bw_check_overflow_bits(struct bitbuff_writer *bw, u64 num_bits)
if (bytes_needed >= arena->pos) {
/* Grow arena */
u64 push_size = (((bytes_needed - arena->pos) / WRITE_OVERFLOW_ARENA_PUSH_SIZE) + 1) * WRITE_OVERFLOW_ARENA_PUSH_SIZE;
arena_push_array(arena, u8, push_size);
arena_push_array_no_zero(arena, u8, push_size);
}
} else {
u64 max_len = bb->fixed_buffer.len;
@ -605,7 +605,7 @@ struct string br_read_string(struct arena *arena, struct bitbuff_reader *br)
u8 *src = br_read_bytes_raw(br, len);
if (src != NULL) {
res.len = len;
res.text = arena_push_array(arena, u8, len);
res.text = arena_push_array_no_zero(arena, u8, len);
MEMCPY(res.text, src, len);
}
return res;

View File

@ -11,12 +11,12 @@ struct buddy_ctx *buddy_ctx_alloc(u64 reserve)
{
/* TODO: Determine meta reserve dynamically */
struct arena meta_arena = arena_alloc(GIGABYTE(64));
struct buddy_ctx *ctx = arena_push_zero(&meta_arena, struct buddy_ctx);
struct buddy_ctx *ctx = arena_push(&meta_arena, struct buddy_ctx);
ctx->meta_arena = meta_arena;
ctx->data_arena = arena_alloc(reserve);
/* TODO: Minimum block size */
ctx->levels = arena_push_array_zero(&ctx->meta_arena, struct buddy_level, 64);
ctx->levels = arena_push_array(&ctx->meta_arena, struct buddy_level, 64);
for (u64 i = 0; i < 64; ++i) {
struct buddy_level *level = &ctx->levels[i];
level->ctx = ctx;
@ -44,7 +44,7 @@ INTERNAL struct buddy_block *buddy_block_alloc_internal(struct buddy_ctx *ctx)
block = ctx->first_free_block;
ctx->first_free_block = block->next;
} else {
block = arena_push(&ctx->meta_arena, struct buddy_block);
block = arena_push_no_zero(&ctx->meta_arena, struct buddy_block);
}
MEMZERO_STRUCT(block);
return block;
@ -116,7 +116,7 @@ INTERNAL struct buddy_block *buddy_block_get_unused(struct buddy_ctx *ctx, struc
/* Grow arena */
i64 level_commit_diff = (level->size * 2) - arena->pos;
if (level_commit_diff > 0) {
arena_push_array(arena, u8, level_commit_diff);
arena_push_array_no_zero(arena, u8, level_commit_diff);
ASSERT(arena->pos == (level->size * 2));
}

View File

@ -337,7 +337,7 @@ INTERNAL struct epa_result epa_get_normal_from_gjk(struct collider_shape *shape0
proto = arena_dry_push(scratch.arena, struct collider_menkowski_point);
{
ASSERT(s.len == 3);
struct collider_menkowski_point *tmp = arena_push_array(scratch.arena, struct collider_menkowski_point, 3);
struct collider_menkowski_point *tmp = arena_push_array_no_zero(scratch.arena, struct collider_menkowski_point, 3);
tmp[0] = s.a;
tmp[1] = s.b;
tmp[2] = s.c;
@ -425,7 +425,7 @@ INTERNAL struct epa_result epa_get_normal_from_gjk(struct collider_shape *shape0
}
/* Insert point into prototype */
arena_push(scratch.arena, struct collider_menkowski_point);
arena_push_no_zero(scratch.arena, struct collider_menkowski_point);
++proto_count;
for (u32 i = proto_count - 1; i > closest_b_index; --i) {
u32 shift_from = (i > 0) ? i - 1 : proto_count - 1;
@ -950,7 +950,7 @@ struct v2_array menkowski(struct arena *arena, struct collider_shape *shape0, st
struct v2 dir = v2_from_angle(angle);
struct collider_menkowski_point m = get_menkowski_point(shape0, shape1, xf0, xf1, dir);
if (res.count == 0 || !v2_eq(m.p, res.points[res.count - 1])) {
*arena_push(arena, struct v2) = m.p;
*arena_push_no_zero(arena, struct v2) = m.p;
++res.count;
}
}
@ -970,7 +970,7 @@ struct v2_array cloud(struct arena *arena, struct collider_shape *shape0, struct
struct v2 p0 = xform_mul_v2(xf0, points0[i]);
for (u64 j = 0; j < count1; ++j) {
struct v2 p1 = xform_mul_v2(xf1, points1[j]);
*arena_push(arena, struct v2) = v2_sub(p0, p1);
*arena_push_no_zero(arena, struct v2) = v2_sub(p0, p1);
++res.count;
}
}

View File

@ -39,11 +39,11 @@
#define SPACE_CELL_BINS_SQRT (64)
#define SPACE_CELL_SIZE (1.0f)
#define SIM_TILES_PER_UNIT_SQRT (2)
#define SIM_TILES_PER_UNIT_SQRT (2)
#define SIM_TILES_PER_CHUNK_SQRT (16)
#define SIM_TICKS_PER_SECOND 50
#define SIM_TIMESCALE 1
//#define SIM_TIMESCALE 1
/* Like USER_INTERP_RATIO, but applies to snapshots received by the local sim from the
* master sim (how far back in time should the client render the server's state) */
#define SIM_CLIENT_INTERP_RATIO 2.0

View File

@ -124,7 +124,7 @@ void draw_circle(struct renderer_cmd_buffer *cmdbuff, struct v2 pos, f32 radius,
{
struct temp_arena scratch = scratch_begin_no_conflict();
struct v2 *points = arena_push_array(scratch.arena, struct v2, detail);
struct v2 *points = arena_push_array_no_zero(scratch.arena, struct v2, detail);
for(u32 i = 0; i < detail; ++i) {
struct v2 p = V2(
radius * math_cos(i * (PI * 2.f) / detail),
@ -193,7 +193,7 @@ void draw_circle_line(struct renderer_cmd_buffer *cmdbuff, struct v2 pos, f32 ra
{
struct temp_arena scratch = scratch_begin_no_conflict();
struct v2 *points = arena_push_array(scratch.arena, struct v2, detail);
struct v2 *points = arena_push_array_no_zero(scratch.arena, struct v2, detail);
for (u32 i = 0; i < detail; ++i) {
struct v2 p = V2(
radius * math_cos(i * (PI * 2.f) / detail),
@ -258,7 +258,7 @@ void draw_collider_line(struct renderer_cmd_buffer *cmdbuff, struct xform draw_x
{
struct temp_arena scratch = scratch_begin_no_conflict();
struct v2 *points = arena_push_array(scratch.arena, struct v2, detail);
struct v2 *points = arena_push_array_no_zero(scratch.arena, struct v2, detail);
for (u32 i = 0; i < detail; ++i) {
f32 angle = ((f32)i / (f32)detail) * (2 * PI);
struct v2 dir = V2(math_cos(angle), math_sin(angle));

View File

@ -72,7 +72,7 @@ INTERNAL struct font_task_params *font_task_params_alloc(void)
p = G.params.head_free;
G.params.head_free = p->next_free;
} else {
p = arena_push_zero(&G.params.arena, struct font_task_params);
p = arena_push(&G.params.arena, struct font_task_params);
}
sys_mutex_unlock(&lock);
}
@ -126,9 +126,9 @@ INTERNAL WORK_TASK_FUNC_DEF(font_load_asset_task, vparams)
struct font *font = NULL;
{
struct asset_cache_store store = asset_cache_store_open();
font = arena_push_zero(store.arena, struct font);
font->glyphs = arena_push_array(store.arena, struct font_glyph, result.glyphs_count);
font->lookup = arena_push_array_zero(store.arena, u16, LOOKUP_TABLE_SIZE);
font = arena_push(store.arena, struct font);
font->glyphs = arena_push_array_no_zero(store.arena, struct font_glyph, result.glyphs_count);
font->lookup = arena_push_array(store.arena, u16, LOOKUP_TABLE_SIZE);
asset_cache_store_close(&store);
}

View File

@ -178,13 +178,13 @@ struct host_startup_receipt host_startup(struct sock_startup_receipt *sock_sr)
struct host *host_alloc(u16 listen_port)
{
struct arena arena = arena_alloc(GIGABYTE(64));
struct host *host = arena_push_zero(&arena, struct host);
struct host *host = arena_push(&arena, struct host);
host->arena = arena;
host->cmd_arena = arena_alloc(GIGABYTE(64));
host->channel_arena = arena_alloc(GIGABYTE(64));
host->rcv_buffer_read = arena_push_zero(&host->arena, struct host_rcv_buffer);
host->rcv_buffer_write = arena_push_zero(&host->arena, struct host_rcv_buffer);
host->rcv_buffer_read = arena_push(&host->arena, struct host_rcv_buffer);
host->rcv_buffer_write = arena_push(&host->arena, struct host_rcv_buffer);
host->rcv_buffer_read->arena = arena_alloc(GIGABYTE(64));
host->rcv_buffer_write->arena = arena_alloc(GIGABYTE(64));
host->buddy = buddy_ctx_alloc(GIGABYTE(64));
@ -192,10 +192,10 @@ struct host *host_alloc(u16 listen_port)
host->channels = arena_dry_push(&host->channel_arena, struct host_channel);
host->num_channel_lookup_bins = NUM_CHANNEL_LOOKUP_BINS;
host->channel_lookup_bins = arena_push_array_zero(&host->arena, struct host_channel_lookup_bin, host->num_channel_lookup_bins);
host->channel_lookup_bins = arena_push_array(&host->arena, struct host_channel_lookup_bin, host->num_channel_lookup_bins);
host->num_msg_assembler_lookup_bins = NUM_MSG_ASSEMBLER_LOOKUP_BINS;
host->msg_assembler_lookup_bins = arena_push_array_zero(&host->arena, struct host_msg_assembler_lookup_bin, host->num_msg_assembler_lookup_bins);
host->msg_assembler_lookup_bins = arena_push_array(&host->arena, struct host_msg_assembler_lookup_bin, host->num_msg_assembler_lookup_bins);
host->sock = sock_alloc(listen_port, MEGABYTE(2), MEGABYTE(2));
@ -263,7 +263,7 @@ INTERNAL struct host_channel_list host_channels_from_id(struct arena *arena, str
for (u64 i = 0; i < host->num_channels_reserved; ++i) {
struct host_channel *channel = &host->channels[i];
if (channel->valid) {
struct host_channel_node *n = arena_push_zero(arena, struct host_channel_node);
struct host_channel_node *n = arena_push(arena, struct host_channel_node);
n->channel = channel;
if (res.last) {
res.last->next = n;
@ -276,7 +276,7 @@ INTERNAL struct host_channel_list host_channels_from_id(struct arena *arena, str
} else {
struct host_channel *channel = host_single_channel_from_id(host, channel_id);
if (channel->valid) {
struct host_channel_node *n = arena_push_zero(arena, struct host_channel_node);
struct host_channel_node *n = arena_push(arena, struct host_channel_node);
n->channel = channel;
res.first = n;
res.last = n;
@ -295,7 +295,7 @@ INTERNAL struct host_channel *host_channel_alloc(struct host *host, struct sock_
id = channel->id;
++id.gen;
} else {
channel = arena_push(&host->channel_arena, struct host_channel);
channel = arena_push_no_zero(&host->channel_arena, struct host_channel);
id.gen = 1;
id.idx = host->num_channels_reserved;
++host->num_channels_reserved;
@ -397,7 +397,7 @@ INTERNAL struct host_msg_assembler *host_msg_assembler_alloc(struct host_channel
ma = host->first_free_msg_assembler;
host->first_free_msg_assembler = ma->next_free;
} else {
ma = arena_push(&host->arena, struct host_msg_assembler);
ma = arena_push_no_zero(&host->arena, struct host_msg_assembler);
}
MEMZERO_STRUCT(ma);
ma->channel = channel;
@ -552,7 +552,7 @@ INTERNAL struct host_snd_packet *host_channel_snd_packet_alloc(struct host_chann
packet = host->first_free_packet;
host->first_free_packet = packet->next;
} else {
packet = arena_push(&host->arena, struct host_snd_packet);
packet = arena_push_no_zero(&host->arena, struct host_snd_packet);
}
MEMZERO_STRUCT(packet);
@ -583,7 +583,7 @@ INTERNAL struct host_snd_packet *host_channel_snd_packet_alloc(struct host_chann
INTERNAL struct host_cmd *host_cmd_alloc_and_append(struct host *host)
{
struct host_cmd *cmd = arena_push_zero(&host->cmd_arena, struct host_cmd);
struct host_cmd *cmd = arena_push(&host->cmd_arena, struct host_cmd);
if (host->last_cmd) {
host->last_cmd->next = cmd;
} else {
@ -633,7 +633,7 @@ i64 host_get_channel_last_rtt_ns(struct host *host, struct host_channel_id chann
INTERNAL struct host_event *push_event(struct arena *arena, struct host_event_list *list)
{
struct host_event *event = arena_push_zero(arena, struct host_event);
struct host_event *event = arena_push(arena, struct host_event);
if (list->last) {
list->last->next = event;
} else {
@ -655,7 +655,7 @@ struct host_event_list host_update_begin(struct arena *arena, struct host *host)
__profscope(host_update_read_packets);
struct string read_buff = ZI;
read_buff.len = PACKET_DATA_MAX_LEN;
read_buff.text = arena_push_array(scratch.arena, u8, read_buff.len);
read_buff.text = arena_push_array_no_zero(scratch.arena, u8, read_buff.len);
/* Swap read & write rcv buffers */
{
@ -792,7 +792,7 @@ struct host_event_list host_update_begin(struct arena *arena, struct host *host)
struct host_event *event = push_event(arena, &events);
struct string data = ZI;
data.len = ((chunk_count - 1) * PACKET_MSG_CHUNK_MAX_LEN) + ma->last_chunk_len;
data.text = arena_push_array(arena, u8, data.len);
data.text = arena_push_array_no_zero(arena, u8, data.len);
MEMCPY(data.text, ma->chunk_data, data.len);
event->kind = HOST_EVENT_KIND_MSG;
event->msg = data;
@ -1066,7 +1066,7 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(host_receiver_thread_entry_point, arg)
struct arena read_buff_arena = arena_alloc(read_buff_size);
struct string read_buff = ZI;
read_buff.len = read_buff_size;
read_buff.text = arena_push_array(&read_buff_arena, u8, KILOBYTE(64));
read_buff.text = arena_push_array_no_zero(&read_buff_arena, u8, KILOBYTE(64));
struct host *host = (struct host *)arg;
@ -1085,7 +1085,7 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(host_receiver_thread_entry_point, arg)
struct sys_lock lock = sys_mutex_lock_e(&host->rcv_buffer_write_mutex);
{
struct host_rcv_buffer *rcv_buffer = host->rcv_buffer_write;
struct host_rcv_packet *packet = arena_push_zero(&rcv_buffer->arena, struct host_rcv_packet);
struct host_rcv_packet *packet = arena_push(&rcv_buffer->arena, struct host_rcv_packet);
packet->address = address;
packet->data = string_copy(&rcv_buffer->arena, data);
if (rcv_buffer->last_packet) {

View File

@ -83,7 +83,7 @@ GLOBAL READONLY enum token_type g_keyword_types[] = {
INTERNAL struct token *push_token(struct arena *arena, struct token_list *list)
{
struct token *t = arena_push_zero(arena, struct token);
struct token *t = arena_push(arena, struct token);
if (!list->token_first) {
list->token_first = t;
} else {
@ -362,7 +362,7 @@ INTERNAL struct token_list lex(struct arena *arena, struct string src)
INTERNAL void append_char(struct arena *arena, struct string *str, u8 c)
{
*arena_push(arena, u8) = c;
*arena_push_no_zero(arena, u8) = c;
++str->len;
}
@ -650,7 +650,7 @@ struct parser {
INTERNAL void push_error(struct arena *arena, struct parser *p, struct token *t, struct string msg)
{
struct json_error *error = arena_push(arena, struct json_error);
struct json_error *error = arena_push_no_zero(arena, struct json_error);
*error = (struct json_error) {
.msg = msg,
.start = t->start,
@ -670,7 +670,7 @@ INTERNAL void parse(struct arena *arena, struct parser *p)
{
struct temp_arena scratch = scratch_begin(arena);
struct json *root = arena_push_zero(arena, struct json);
struct json *root = arena_push(arena, struct json);
struct token *at = p->at;
struct string src = p->src;
@ -679,7 +679,7 @@ INTERNAL void parse(struct arena *arena, struct parser *p)
}
/* Depth first stack */
*arena_push(scratch.arena, struct json *) = root;
*arena_push_no_zero(scratch.arena, struct json *) = root;
u64 stack_count = 1;
while (stack_count > 0) {
@ -799,21 +799,21 @@ INTERNAL void parse(struct arena *arena, struct parser *p)
if (is_new_parent) {
/* Push self back to stack to re-check for closing brace later */
*arena_push(scratch.arena, struct json *) = json;
*arena_push_no_zero(scratch.arena, struct json *) = json;
++stack_count;
/* Create child & push to stack */
struct json *child = arena_push_zero(arena, struct json);
struct json *child = arena_push(arena, struct json);
child->parent = json;
*arena_push(scratch.arena, struct json *) = child;
*arena_push_no_zero(scratch.arena, struct json *) = child;
++stack_count;
} else if (parent_json) {
/* Check for comma */
if (at->type == TOKEN_TYPE_COMMA) {
/* Create sibling & push to stack */
struct json *sibling = arena_push_zero(arena, struct json);
struct json *sibling = arena_push(arena, struct json);
sibling->parent = parent_json;
*arena_push(scratch.arena, struct json *) = sibling;
*arena_push_no_zero(scratch.arena, struct json *) = sibling;
++stack_count;
at = at->next;
}

View File

@ -119,7 +119,7 @@ INTERNAL struct track *track_alloc_locked(struct sys_lock *lock, struct sound *s
*track = (struct track) { .gen = track->gen + 1 };
} else {
/* Allocate new */
track = arena_push_zero(&G.track_arena, struct track);
track = arena_push(&G.track_arena, struct track);
track->gen = 1;
}
@ -273,7 +273,7 @@ struct mixed_pcm_f32 mixer_update(struct arena *arena, u64 frame_count)
struct mixed_pcm_f32 res = ZI;
res.count = frame_count * 2;
res.samples = arena_push_array_zero(arena, f32, res.count);
res.samples = arena_push_array(arena, f32, res.count);
struct v2 listener_pos = V2(0, 0);
struct v2 listener_dir = V2(0, 0);
@ -289,7 +289,7 @@ struct mixed_pcm_f32 mixer_update(struct arena *arena, u64 frame_count)
listener_dir = G.listener_dir;
/* Update & read mixes */
mixes = arena_push_array(scratch.arena, struct mix *, G.track_playing_count);
mixes = arena_push_array_no_zero(scratch.arena, struct mix *, G.track_playing_count);
for (struct track *track = G.track_first_playing; track; track = track->next) {
__profscope(prepare_track);
struct mix *mix = &track->mix;
@ -345,7 +345,7 @@ struct mixed_pcm_f32 mixer_update(struct arena *arena, u64 frame_count)
struct mixed_pcm_f32 mix_pcm = {
.count = res.count,
.samples = arena_push_array_zero(scratch.arena, f32, res.count)
.samples = arena_push_array(scratch.arena, f32, res.count)
};
/* ========================== *

View File

@ -117,7 +117,7 @@ struct mp3_decode_result mp3_decode(struct arena *arena, struct string encoded,
DWORD size_bytes;
IMFMediaBuffer_Lock(buffer, &src, NULL, &size_bytes);
{
i16 *dst = arena_push_array(arena, i16, (size_bytes + 1) >> 1);
i16 *dst = arena_push_array_no_zero(arena, i16, (size_bytes + 1) >> 1);
MEMCPY(dst, src, size_bytes);
sample_bytes_read += size_bytes;
}

View File

@ -132,7 +132,7 @@ struct phys_collision_data_array phys_create_and_update_contacts(struct arena *a
/* Push collision data */
if (ctx->pre_solve_callback || ctx->post_solve_callback) {
struct phys_collision_data *data = arena_push_zero(arena, struct phys_collision_data);
struct phys_collision_data *data = arena_push(arena, struct phys_collision_data);
++res.count;
data->constraint = &constraint_ent->contact_constraint_data;
data->e0 = e0->id;

View File

@ -757,7 +757,7 @@ INTERNAL struct dx11_texture *dx11_texture_alloc(enum renderer_texture_format fo
t = G.textures_first_free;
G.textures_first_free = t->next_free;
} else {
t = arena_push(&G.textures_arena, struct dx11_texture);
t = arena_push_no_zero(&G.textures_arena, struct dx11_texture);
}
MEMZERO_STRUCT(t);
if (!G.textures_first) {
@ -1015,8 +1015,8 @@ u32 renderer_cmd_buffer_push_vertices(struct renderer_cmd_buffer *cmdbuff, u8 **
buffer->vertex_count += vertices_count;
buffer->index_count += indices_count;
*vertices_out = arena_push_array(&buffer->vertex_arena, u8, shader->vertex_size * vertices_count);
*indices_out = arena_push_array(&buffer->index_arena, vidx, indices_count);
*vertices_out = arena_push_array_no_zero(&buffer->vertex_arena, u8, shader->vertex_size * vertices_count);
*indices_out = arena_push_array_no_zero(&buffer->index_arena, vidx, indices_count);
return first_vertex_index;
}
@ -1039,7 +1039,7 @@ void renderer_cmd_buffer_ensure_cmd(struct renderer_cmd_buffer *cmdbuff, struct
|| last_cmd->shader->kind != SHADER_TRIANGLE
|| (last_cmd->texture.handle != params->texture_params.texture.handle)
|| !sprite_tag_eq(last_cmd->sprite, params->texture_params.sprite)) {
new_cmd = arena_push(&cmdbuff->cpu_cmd_store.arena, struct renderer_cmd);
new_cmd = arena_push_no_zero(&cmdbuff->cpu_cmd_store.arena, struct renderer_cmd);
*new_cmd = (struct renderer_cmd) {
.shader = &G.shaders[SHADER_TRIANGLE],
.texture = params->texture_params.texture,
@ -1051,7 +1051,7 @@ void renderer_cmd_buffer_ensure_cmd(struct renderer_cmd_buffer *cmdbuff, struct
case SHADER_GRID:
{
if (!last_cmd || last_cmd->shader->kind != SHADER_GRID) {
new_cmd = arena_push(&cmdbuff->cpu_cmd_store.arena, struct renderer_cmd);
new_cmd = arena_push_no_zero(&cmdbuff->cpu_cmd_store.arena, struct renderer_cmd);
*new_cmd = (struct renderer_cmd) {
.shader = &G.shaders[SHADER_GRID],
};
@ -1217,7 +1217,7 @@ INTERNAL void renderer_capture_image_for_profiler(void)
struct temp_arena scratch = scratch_begin_no_conflict();
u32 *source = res.pData;
u32 *dest = arena_push_array(scratch.arena, u32, final_width * final_height);
u32 *dest = arena_push_array_no_zero(scratch.arena, u32, final_width * final_height);
u32 pitch = res.RowPitch / 4;
for (u32 y = 0; y < final_height; ++y) {
for (u32 x = 0; x < final_width; ++x) {

View File

@ -52,7 +52,7 @@ struct sys_window_settings *settings_deserialize(struct arena *arena, struct str
struct string error = ZI;
struct json_error json_error = ZI;
struct sys_window_settings *settings = arena_push_zero(arena, struct sys_window_settings);
struct sys_window_settings *settings = arena_push(arena, struct sys_window_settings);
struct json_parse_result parse_res = json_from_string(scratch.arena, src);
if (parse_res.errors.count > 0) {

View File

@ -65,21 +65,21 @@ struct sim_startup_receipt sim_startup(void)
G.nil_arena = arena_alloc(GIGABYTE(1));
/* Nil client store */
G.nil_client_store = arena_push_zero(&G.nil_arena, struct sim_client_store);
G.nil_client_store = arena_push(&G.nil_arena, struct sim_client_store);
G.nil_client_store->valid = false;
/* Nil client */
G.nil_client = arena_push_zero(&G.nil_arena, struct sim_client);
G.nil_client = arena_push(&G.nil_arena, struct sim_client);
G.nil_client->valid = false;
G.nil_client->store = sim_client_store_nil();
/* Nil snapshot */
G.nil_snapshot = arena_push_zero(&G.nil_arena, struct sim_snapshot);
G.nil_snapshot = arena_push(&G.nil_arena, struct sim_snapshot);
G.nil_snapshot->valid = false;
G.nil_snapshot->client = sim_client_nil();
/* Nil ent */
G.nil_ent = arena_push_zero(&G.nil_arena, struct sim_ent);
G.nil_ent = arena_push(&G.nil_arena, struct sim_ent);
G.nil_ent->ss = sim_snapshot_nil();
G.nil_ent->valid = false;
G.nil_ent->id = SIM_ENT_NIL_ID;
@ -107,12 +107,12 @@ struct sim_client_store *sim_client_store_alloc(void)
struct sim_client_store *store;
{
struct arena arena = arena_alloc(GIGABYTE(64));
store = arena_push_zero(&arena, struct sim_client_store);
store = arena_push(&arena, struct sim_client_store);
store->arena = arena;
}
store->valid = true;
store->num_client_lookup_bins = CLIENT_LOOKUP_BINS;
store->client_lookup_bins = arena_push_array_zero(&store->arena, struct sim_client_lookup_bin, store->num_client_lookup_bins);
store->client_lookup_bins = arena_push_array(&store->arena, struct sim_client_lookup_bin, store->num_client_lookup_bins);
store->clients_arena = arena_alloc(GIGABYTE(64));
store->clients = arena_dry_push(&store->clients_arena, struct sim_client);
return store;
@ -145,7 +145,7 @@ struct sim_client *sim_client_alloc(struct sim_client_store *store)
handle = client->handle;
++handle.gen;
} else {
client = arena_push(&store->clients_arena, struct sim_client);
client = arena_push_no_zero(&store->clients_arena, struct sim_client);
handle.gen = 1;
handle.idx = store->num_clients_reserved;
++store->num_clients_reserved;
@ -158,7 +158,7 @@ struct sim_client *sim_client_alloc(struct sim_client_store *store)
client->snapshots_arena = arena_alloc(GIGABYTE(8));
client->num_snapshot_lookup_bins = TICK_LOOKUP_BINS;
client->snapshot_lookup_bins = arena_push_array_zero(&client->snapshots_arena, struct sim_snapshot_lookup_bin, client->num_snapshot_lookup_bins);
client->snapshot_lookup_bins = arena_push_array(&client->snapshots_arena, struct sim_snapshot_lookup_bin, client->num_snapshot_lookup_bins);
return client;
}
@ -298,7 +298,7 @@ struct sim_snapshot *sim_snapshot_alloc(struct sim_client *client, struct sim_sn
}
}
arena_reset(&arena);
ss = arena_push_zero(&arena, struct sim_snapshot);
ss = arena_push(&arena, struct sim_snapshot);
ss->arena = arena;
ss->ents_arena = ents_arena;
@ -319,7 +319,7 @@ struct sim_snapshot *sim_snapshot_alloc(struct sim_client *client, struct sim_sn
/* Copy id lookup bins */
ss->num_id_bins = src->num_id_bins > 0 ? src->num_id_bins : ID_LOOKUP_BINS;
ss->id_bins = arena_push_array(&ss->arena, struct sim_ent_bin, ss->num_id_bins);
ss->id_bins = arena_push_array_no_zero(&ss->arena, struct sim_ent_bin, ss->num_id_bins);
if (src->num_id_bins > 0) {
for (u64 i = 0; i < src->num_id_bins; ++i) {
ss->id_bins[i] = src->id_bins[i];
@ -332,20 +332,20 @@ struct sim_snapshot *sim_snapshot_alloc(struct sim_client *client, struct sim_sn
ss->first_free_ent = src->first_free_ent;
ss->num_ents_allocated = src->num_ents_allocated;
ss->num_ents_reserved = src->num_ents_reserved;
ss->ents = arena_push_array(&ss->ents_arena, struct sim_ent, ss->num_ents_reserved);
ss->ents = arena_push_array_no_zero(&ss->ents_arena, struct sim_ent, ss->num_ents_reserved);
if (ss->num_ents_reserved == 0) {
/* Copying from nil snapshot, need to create blank & root entity */
/* Push blank ent at index 0 (because index 0 is never valid anyway since it maps to sim_ent_nil()) */
{
arena_push_zero(&ss->ents_arena, struct sim_ent);
arena_push(&ss->ents_arena, struct sim_ent);
++ss->num_ents_allocated;
++ss->num_ents_reserved;
}
/* Push root ent with constant id */
{
struct sim_ent *root = arena_push(&ss->ents_arena, struct sim_ent);
struct sim_ent *root = arena_push_no_zero(&ss->ents_arena, struct sim_ent);
*root = *sim_ent_nil();
root->ss = ss;
root->valid = true;
@ -775,7 +775,7 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss)
ss->num_ents_reserved = br_read_uv(br);
i64 reserve_diff = (i64)ss->num_ents_reserved - (i64)old_num_ents_reserved;
if (reserve_diff > 0) {
arena_push_array(&ss->ents_arena, struct sim_ent, reserve_diff);
arena_push_array_no_zero(&ss->ents_arena, struct sim_ent, reserve_diff);
for (u64 i = old_num_ents_reserved; i < ss->num_ents_reserved; ++i) {
struct sim_ent *e = &ss->ents[i];
*e = *sim_ent_nil();
@ -896,7 +896,7 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss)
ss->num_ents_reserved = br_read_uv(br);
i64 reserve_diff = (i64)ss->num_ents_reserved - (i64)old_num_ents_reserved;
if (reserve_diff > 0) {
arena_push_array(&ss->ents_arena, struct sim_ent, reserve_diff);
arena_push_array_no_zero(&ss->ents_arena, struct sim_ent, reserve_diff);
for (u64 i = old_num_ents_reserved; i < ss->num_ents_reserved; ++i) {
struct sim_ent *e = &ss->ents[i];
*e = *sim_ent_nil();
@ -934,7 +934,7 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss)
u64 num_ent_bits = br_read_uv(br);
struct bitbuff_reader ent_br = br_from_seek_bits(br, num_ent_bits);
if (br_num_bits_left(&ent_br) > 0) {
struct sim_ent_decode_node *n = arena_push_zero(scratch.arena, struct sim_ent_decode_node);
struct sim_ent_decode_node *n = arena_push(scratch.arena, struct sim_ent_decode_node);
n->is_new = allocation_changed && !released;
n->index = index;
n->alloc_parent_ndex = alloc_parent_index;
@ -993,7 +993,7 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss)
ss->num_ents_reserved = br_read_uv(br);
i64 reserve_diff = (i64)ss->num_ents_reserved - (i64)old_num_ents_reserved;
if (reserve_diff > 0) {
arena_push_array(&ss->ents_arena, struct sim_ent, reserve_diff);
arena_push_array_no_zero(&ss->ents_arena, struct sim_ent, reserve_diff);
for (u64 i = old_num_ents_reserved; i < ss->num_ents_reserved; ++i) {
struct sim_ent *e = &ss->ents[i];
*e = *sim_ent_nil();
@ -1006,7 +1006,7 @@ void sim_snapshot_decode(struct bitbuff_reader *br, struct sim_snapshot *ss)
b32 allocation_changed = br_read_bit(br);
if (allocation_changed) {
if (br_read_bit(br)) {
struct sim_ent_decode_node *n = arena_push_zero(scratch.arena, struct sim_ent_decode_node)
struct sim_ent_decode_node *n = arena_push(scratch.arena, struct sim_ent_decode_node)
} else {
sim_ent_enable_prop(e, SEPROP_RELEASE);
}

View File

@ -39,7 +39,7 @@ struct sim_ent *sim_ent_alloc_raw(struct sim_snapshot *ss, struct sim_ent *paren
ss->first_free_ent = ent->next_free;
} else {
/* Make new */
ent = arena_push(&ss->ents_arena, struct sim_ent);
ent = arena_push_no_zero(&ss->ents_arena, struct sim_ent);
++ss->num_ents_reserved;
}
*ent = *sim_ent_nil();
@ -141,7 +141,7 @@ void sim_ent_release_all_with_prop(struct sim_snapshot *ss, enum sim_ent_prop pr
for (u64 ent_index = 0; ent_index < ss->num_ents_reserved; ++ent_index) {
struct sim_ent *ent = &ss->ents[ent_index];
if (ent->valid && sim_ent_has_prop(ent, prop)) {
*arena_push(scratch.arena, struct sim_ent *) = ent;
*arena_push_no_zero(scratch.arena, struct sim_ent *) = ent;
++ents_to_release_count;
}
}

View File

@ -289,10 +289,6 @@ INTERNAL PHYS_COLLISION_CALLBACK_FUNC_DEF(on_collision, collision_data_array, st
} else {
struct v2 point = data->point;
/* Update bullet */
bullet->bullet_has_hit = true;
sim_ent_enable_prop(bullet, SEPROP_RELEASE);
/* Update tracer */
struct sim_ent *tracer = sim_ent_from_id(world, bullet->bullet_tracer);
if (sim_ent_should_simulate(tracer)) {
@ -306,6 +302,10 @@ INTERNAL PHYS_COLLISION_CALLBACK_FUNC_DEF(on_collision, collision_data_array, st
struct v2 knockback = v2_mul(v2_norm(vrel), bullet->bullet_knockback);
sim_ent_apply_linear_impulse(target, knockback, point);
/* Explode */
//if (sim_ent_has_prop(bullet, SEPROP_EXPLODE_ON_IMPACT)) {
//}
/* Create test blood */
/* TODO: Remove this */
{
@ -330,6 +330,10 @@ INTERNAL PHYS_COLLISION_CALLBACK_FUNC_DEF(on_collision, collision_data_array, st
decal->linear_damping = 5.0f;
decal->angular_damping = 5.0f;
}
/* Update bullet */
bullet->bullet_has_hit = true;
//sim_ent_enable_prop(bullet, SEPROP_RELEASE);
}
}
}
@ -579,7 +583,7 @@ void sim_step(struct sim_step_ctx *ctx)
struct string old_data = sim_ent_get_tile_chunk_data(chunk_ent);
struct string new_data = ZI;
new_data.len = SIM_TILES_PER_CHUNK_SQRT * SIM_TILES_PER_CHUNK_SQRT;
new_data.text = arena_push_array(scratch.arena, u8, new_data.len);
new_data.text = arena_push_array_no_zero(scratch.arena, u8, new_data.len);
if (old_data.len == new_data.len) {
MEMCPY(new_data.text, old_data.text, new_data.len);
} else {
@ -1356,7 +1360,7 @@ void sim_step(struct sim_step_ctx *ctx)
{
struct temp_arena temp = arena_temp_begin(scratch.arena);
struct sim_ent **stack = arena_push(temp.arena, struct sim_ent *);
struct sim_ent **stack = arena_push_no_zero(temp.arena, struct sim_ent *);
u64 stack_count = 1;
*stack = root;
@ -1369,7 +1373,7 @@ void sim_step(struct sim_step_ctx *ctx)
for (struct sim_ent *child = sim_ent_from_id(world, parent->first); child->valid; child = sim_ent_from_id(world, child->next)) {
if (sim_ent_should_simulate(child)) {
child->final_layer = parent_layer + child->layer;
*arena_push(temp.arena, struct sim_ent *) = child;
*arena_push_no_zero(temp.arena, struct sim_ent *) = child;
++stack_count;
}
}

View File

@ -303,7 +303,7 @@ INTERNAL struct win32_sock *win32_sock_alloc(void)
ws = G.first_free_win32_sock;
G.first_free_win32_sock = ws->next_free;
} else {
ws = arena_push(&G.win32_socks_arena, struct win32_sock);
ws = arena_push_no_zero(&G.win32_socks_arena, struct win32_sock);
}
sys_mutex_unlock(&lock);
}

View File

@ -62,7 +62,7 @@ INTERNAL struct sound_task_params *sound_task_params_alloc(void)
p = G.params.head_free;
G.params.head_free = p->next_free;
} else {
p = arena_push_zero(&G.params.arena, struct sound_task_params);
p = arena_push(&G.params.arena, struct sound_task_params);
}
sys_mutex_unlock(&lock);
}
@ -119,8 +119,8 @@ INTERNAL WORK_TASK_FUNC_DEF(sound_load_asset_task, vparams)
i16 *samples = NULL;
{
struct asset_cache_store store = asset_cache_store_open();
sound = arena_push(store.arena, struct sound);
samples = arena_push_array(store.arena, i16, decoded.pcm.count);
sound = arena_push_no_zero(store.arena, struct sound);
samples = arena_push_array_no_zero(store.arena, i16, decoded.pcm.count);
asset_cache_store_close(&store);
}
@ -151,7 +151,7 @@ INTERNAL WORK_TASK_FUNC_DEF(sound_load_asset_task, vparams)
struct sound *sound = NULL;
{
struct asset_cache_store store = asset_cache_store_open();
sound = arena_push(store.arena, struct sound);
sound = arena_push_no_zero(store.arena, struct sound);
asset_cache_store_close(&store);
}
*sound = (struct sound) { 0 };

View File

@ -25,7 +25,7 @@ struct space *space_alloc(f32 cell_size, u32 num_bins_sqrt)
struct space *space;
{
struct arena arena = arena_alloc(GIGABYTE(64));
space = arena_push_zero(&arena, struct space);
space = arena_push(&arena, struct space);
space->entry_arena = arena;
}
@ -36,7 +36,7 @@ struct space *space_alloc(f32 cell_size, u32 num_bins_sqrt)
space->cell_size = cell_size;
space->num_bins = num_bins_sqrt * num_bins_sqrt;
space->num_bins_sqrt = num_bins_sqrt;
space->bins = arena_push_array_zero(&space->cell_arena, struct space_cell_bin, space->num_bins);
space->bins = arena_push_array(&space->cell_arena, struct space_cell_bin, space->num_bins);
return space;
}
@ -51,7 +51,7 @@ void space_reset(struct space *space)
{
arena_pop_to(&space->entry_arena, (u64)space->entries - (u64)space->entry_arena.base);
arena_reset(&space->cell_arena);
space->bins = arena_push_array_zero(&space->cell_arena, struct space_cell_bin, space->num_bins);
space->bins = arena_push_array(&space->cell_arena, struct space_cell_bin, space->num_bins);
space->num_entries_reserved = 0;
space->first_free_cell = NULL;
space->first_free_cell_node = NULL;
@ -140,7 +140,7 @@ INTERNAL void space_cell_node_alloc(struct v2i32 cell_pos, struct space_entry *e
cell = space->first_free_cell;
space->first_free_cell = cell->next_free;
} else {
cell = arena_push(&space->cell_arena, struct space_cell);
cell = arena_push_no_zero(&space->cell_arena, struct space_cell);
}
MEMZERO_STRUCT(cell);
if (bin->last_cell) {
@ -162,7 +162,7 @@ INTERNAL void space_cell_node_alloc(struct v2i32 cell_pos, struct space_entry *e
node = space->first_free_cell_node;
space->first_free_cell_node = node->next_free;
} else {
node = arena_push(&space->cell_arena, struct space_cell_node);
node = arena_push_no_zero(&space->cell_arena, struct space_cell_node);
}
MEMZERO_STRUCT(node);
}
@ -281,7 +281,7 @@ struct space_entry *space_entry_alloc(struct space *space, struct sim_ent_id ent
space->first_free_entry = entry->next_free;
handle = entry->handle;
} else {
entry = arena_push(&space->entry_arena, struct space_entry);
entry = arena_push_no_zero(&space->entry_arena, struct space_entry);
handle.idx = space->num_entries_reserved;
handle.gen = 1;
++space->num_entries_reserved;

View File

@ -166,7 +166,7 @@ GLOBAL struct {
INTERNAL struct image_rgba generate_purple_black_image(struct arena *arena, u32 width, u32 height)
{
u32 *pixels = arena_push_array(arena, u32, width * height);
u32 *pixels = arena_push_array_no_zero(arena, u32, width * height);
/* Create texture containing alternating blocks of purple and black */
u32 color_size = 4;
@ -219,10 +219,10 @@ struct sprite_startup_receipt sprite_startup(struct renderer_startup_receipt *re
G.perm_arena = arena_alloc(MEGABYTE(1));
{
/* Init loading texture */
G.loading_texture = arena_push_zero(&G.perm_arena, struct sprite_texture);
G.loading_texture = arena_push(&G.perm_arena, struct sprite_texture);
/* Init nil texture */
G.nil_texture = arena_push_zero(&G.perm_arena, struct sprite_texture);
G.nil_texture = arena_push(&G.perm_arena, struct sprite_texture);
G.nil_texture->loaded = true;
{
struct temp_arena scratch = scratch_begin_no_conflict();
@ -232,12 +232,12 @@ struct sprite_startup_receipt sprite_startup(struct renderer_startup_receipt *re
}
/* Init loading sheet */
G.loading_sheet = arena_push_zero(&G.perm_arena, struct sprite_sheet);
G.loading_sheet = arena_push(&G.perm_arena, struct sprite_sheet);
G.loading_sheet->image_size = V2(IMAGE_PIXELS_PER_UNIT, IMAGE_PIXELS_PER_UNIT);
G.loading_sheet->frame_size = V2(IMAGE_PIXELS_PER_UNIT, IMAGE_PIXELS_PER_UNIT);
/* Init nil sheet */
G.nil_sheet = arena_push_zero(&G.perm_arena, struct sprite_sheet);
G.nil_sheet = arena_push(&G.perm_arena, struct sprite_sheet);
G.nil_sheet->image_size = V2(IMAGE_PIXELS_PER_UNIT, IMAGE_PIXELS_PER_UNIT);
G.nil_sheet->frame_size = V2(IMAGE_PIXELS_PER_UNIT, IMAGE_PIXELS_PER_UNIT);
G.nil_sheet->loaded = true;
@ -246,7 +246,7 @@ struct sprite_startup_receipt sprite_startup(struct renderer_startup_receipt *re
G.cache.entry_pool_mutex = sys_mutex_alloc();
G.cache.arena = arena_alloc(GIGABYTE(64));
G.cache.bins = arena_push_array_zero(&G.cache.arena, struct cache_bin, CACHE_BINS_COUNT);
G.cache.bins = arena_push_array(&G.cache.arena, struct cache_bin, CACHE_BINS_COUNT);
for (u64 i = 0; i < CACHE_BINS_COUNT; ++i) {
G.cache.bins[i].mutex = sys_mutex_alloc();
}
@ -321,7 +321,7 @@ INTERNAL void push_load_task(struct cache_ref ref, struct sprite_tag tag)
cmd = G.first_free_load_cmd;
G.first_free_load_cmd = cmd->next_free;
} else {
cmd = arena_push(&G.load_cmds_arena, struct load_cmd);
cmd = arena_push_no_zero(&G.load_cmds_arena, struct load_cmd);
}
sys_mutex_unlock(&lock);
}
@ -369,7 +369,7 @@ INTERNAL void cache_entry_load_texture(struct cache_ref ref, struct sprite_tag t
resource_close(&texture_rs);
/* Initialize */
e->texture = arena_push(&e->arena, struct sprite_texture);
e->texture = arena_push_no_zero(&e->arena, struct sprite_texture);
e->texture->width = decoded.image.width;
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);
@ -426,7 +426,7 @@ INTERNAL struct sprite_sheet init_sheet_from_ase_result(struct arena *arena, str
__profscope(init_frames);
sheet.image_size = ase.image_size;
sheet.frame_size = ase.frame_size;
sheet.frames = arena_push_array_zero(arena, struct sprite_sheet_frame, ase.num_frames);
sheet.frames = arena_push_array(arena, struct sprite_sheet_frame, ase.num_frames);
sheet.frames_count = ase.num_frames;
for (struct ase_frame *ase_frame = ase.frame_head; ase_frame; ase_frame = ase_frame->next) {
u32 index = ase_frame->index;
@ -446,7 +446,7 @@ INTERNAL struct sprite_sheet init_sheet_from_ase_result(struct arena *arena, str
sheet.spans_count = ase.num_spans;
if (ase.num_spans > 0) {
__profscope(init_spans);
sheet.spans = arena_push_array_zero(arena, struct sprite_sheet_span, sheet.spans_count);
sheet.spans = arena_push_array(arena, struct sprite_sheet_span, sheet.spans_count);
sheet.spans_dict = fixed_dict_init(arena, (u64)(ase.num_spans * SHEET_SPAN_LOOKUP_TABLE_BIN_RATIO));
u64 index = 0;
for (struct ase_span *ase_span = ase.span_head; ase_span; ase_span = ase_span->next) {
@ -492,7 +492,7 @@ INTERNAL struct sprite_sheet init_sheet_from_ase_result(struct arena *arena, str
struct temp_slice_group_node *temp_slice_group_node = fixed_dict_get(&temp_slice_dict, name);
if (!temp_slice_group_node) {
temp_slice_group_node = arena_push_zero(scratch.arena, struct temp_slice_group_node);
temp_slice_group_node = arena_push(scratch.arena, struct temp_slice_group_node);
temp_slice_group_node->name = name;
fixed_dict_set(scratch.arena, &temp_slice_dict, name, temp_slice_group_node);
@ -501,7 +501,7 @@ INTERNAL struct sprite_sheet init_sheet_from_ase_result(struct arena *arena, str
temp_slice_group_head = temp_slice_group_node;
}
struct temp_ase_slice_key_node *node = arena_push_zero(scratch.arena, struct temp_ase_slice_key_node);
struct temp_ase_slice_key_node *node = arena_push(scratch.arena, struct temp_ase_slice_key_node);
node->key = ase_slice_key;
node->next = temp_slice_group_node->temp_ase_slice_key_head;
node->earliest_frame = U32_MAX; /* To be overwritten later after iterating */
@ -514,7 +514,7 @@ INTERNAL struct sprite_sheet init_sheet_from_ase_result(struct arena *arena, str
/* Allocate slice groups & fill originals in 2d array */
sheet.slice_groups_count = num_temp_slice_group_nodes;
sheet.slice_groups = arena_push_array_zero(arena, struct sprite_sheet_slice_group, sheet.slice_groups_count);
sheet.slice_groups = arena_push_array(arena, struct sprite_sheet_slice_group, sheet.slice_groups_count);
sheet.slice_groups_dict = fixed_dict_init(arena, (u64)(num_temp_slice_group_nodes * SHEET_SLICE_LOOKUP_TABLE_BIN_RATIO));
u64 index = 0;
@ -523,7 +523,7 @@ INTERNAL struct sprite_sheet init_sheet_from_ase_result(struct arena *arena, str
slice_group->name = string_copy(arena, temp_slice_group_node->name);
slice_group->per_frame_count = temp_slice_group_node->per_frame_count;
slice_group->frame_slices = arena_push_array_zero(arena, struct sprite_sheet_slice, ase.num_frames * slice_group->per_frame_count);
slice_group->frame_slices = arena_push_array(arena, struct sprite_sheet_slice, ase.num_frames * slice_group->per_frame_count);
u64 index_in_frame = 0;
for (struct temp_ase_slice_key_node *node = temp_slice_group_node->temp_ase_slice_key_head; node; node = node->next) {
@ -680,7 +680,7 @@ INTERNAL void cache_entry_load_sheet(struct cache_ref ref, struct sprite_tag tag
resource_close(&sheet_rs);
/* Initialize */
e->sheet = arena_push(&e->arena, struct sprite_sheet);
e->sheet = arena_push_no_zero(&e->arena, struct sprite_sheet);
*e->sheet = init_sheet_from_ase_result(&e->arena, decoded);
e->sheet->loaded = true;
e->sheet->valid = true;
@ -803,9 +803,9 @@ struct sprite_scope *sprite_scope_begin(void)
bins = res->ref_node_bins;
pool = res->ref_node_pool;
} else {
res = arena_push(&G.scopes_arena, struct sprite_scope);
bins = arena_push_array(&G.scopes_arena, struct sprite_scope_cache_ref *, CACHE_BINS_COUNT);
pool = arena_push_array(&G.scopes_arena, struct sprite_scope_cache_ref, MAX_SCOPE_REFERENCES);
res = arena_push_no_zero(&G.scopes_arena, struct sprite_scope);
bins = arena_push_array_no_zero(&G.scopes_arena, struct sprite_scope_cache_ref *, CACHE_BINS_COUNT);
pool = arena_push_array_no_zero(&G.scopes_arena, struct sprite_scope_cache_ref, MAX_SCOPE_REFERENCES);
}
}
atomic_i32_eval_exchange(&G.scopes_lock, 0);
@ -926,7 +926,7 @@ INTERNAL struct sprite_scope_cache_ref *cache_entry_from_tag(struct sprite_scope
entry = G.cache.entry_pool_first_free;
G.cache.entry_pool_first_free = entry->next_free;
} else {
entry = arena_push(&G.cache.arena, struct cache_entry);
entry = arena_push_no_zero(&G.cache.arena, struct cache_entry);
}
sys_mutex_unlock(&pool_lock);
}
@ -1241,7 +1241,7 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(sprite_evictor_thread_entry_point, arg)
#endif
b32 is_old = cache_over_budget_threshold && ((cur_cycle - refcount.last_ref_cycle) > EVICTOR_GRACE_PERIOD_CYCLES);
if (is_old || is_out_of_date) {
struct evict_node *en = arena_push_zero(scratch.arena, struct evict_node);
struct evict_node *en = arena_push(scratch.arena, struct evict_node);
en->cache_entry = n;
en->cache_bin = bin;
en->last_ref_cycle = refcount.last_ref_cycle;

View File

@ -28,7 +28,7 @@
struct string string_from_char(struct arena *arena, char c)
{
u8 *dst = arena_push(arena, u8);
u8 *dst = arena_push_no_zero(arena, u8);
*dst = c;
return (struct string) {
.len = 1,
@ -58,7 +58,7 @@ struct string string_from_uint(struct arena *arena, u64 n, u64 base, u64 zfill)
}
/* Reverse text into final string */
u8 *final_text = arena_push_array(arena, u8, len);
u8 *final_text = arena_push_array_no_zero(arena, u8, len);
for (u64 i = 0; i < len; ++i) {
final_text[i] = backwards_text[len - i - 1];
}
@ -137,7 +137,7 @@ struct string string_from_float(struct arena *arena, f64 f, u32 precision)
} while (part_whole > 0);
/* Reverse text into final string */
arena_push_array(arena, u8, backwards_text_len);
arena_push_array_no_zero(arena, u8, backwards_text_len);
for (u64 i = backwards_text_len; i-- > 0;) {
final_text[final_len++] = backwards_text[i];
}
@ -191,7 +191,7 @@ struct string string_copy(struct arena *arena, struct string src)
{
struct string str = {
.len = src.len,
.text = arena_push_array(arena, u8, src.len)
.text = arena_push_array_no_zero(arena, u8, src.len)
};
MEMCPY(str.text, src.text, src.len);
return str;
@ -209,7 +209,7 @@ struct string string_copy_to_string(struct string dst, struct string src)
struct string string_repeat(struct arena *arena, struct string src, u64 count)
{
u64 final_len = src.len * count;
u8 *final_text = arena_push_array(arena, u8, final_len);
u8 *final_text = arena_push_array_no_zero(arena, u8, final_len);
for (u64 i = 0; i < count; ++i) {
MEMCPY(final_text + (src.len * i), src.text, src.len);
}
@ -223,7 +223,7 @@ struct string string_cat(struct arena *arena, struct string str1, struct string
{
struct string new_str = ZI;
new_str.len = str1.len + str2.len;
new_str.text = arena_push_array(arena, u8, new_str.len);
new_str.text = arena_push_array_no_zero(arena, u8, new_str.len);
MEMCPY(new_str.text, str1.text, str1.len);
MEMCPY(new_str.text + str1.len, str2.text, str2.len);
return new_str;
@ -259,7 +259,7 @@ struct string_array string_split(struct arena *arena, struct string str, struct
if (is_delimiter || is_end) {
/* Delimiter found */
struct string *piece_pushed = arena_push(arena, struct string);
struct string *piece_pushed = arena_push_no_zero(arena, struct string);
*piece_pushed = piece;
++pieces.count;
piece.text = piece.text + piece.len + delim.len;
@ -304,7 +304,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 = ZI;
res.text = arena_push_array(arena, u8, str.len);
res.text = arena_push_array_no_zero(arena, u8, str.len);
res.len = str.len;
for (u64 i = 0; i < str.len; ++i) {
@ -592,7 +592,7 @@ struct string string_from_string16(struct arena *arena, struct string16 str16)
struct uni_decode_utf16_result decoded = uni_decode_utf16(str16_remaining);
struct uni_encode_utf8_result encoded = uni_encode_utf8(decoded.codepoint);
u8 *dst = arena_push_array(arena, u8, encoded.count8);
u8 *dst = arena_push_array_no_zero(arena, u8, encoded.count8);
MEMCPY(dst, encoded.chars8, encoded.count8);
pos16 += decoded.advance16;
@ -616,7 +616,7 @@ struct string string_from_string32(struct arena *arena, struct string32 str32)
struct uni_decode_utf32_result decoded = uni_decode_utf32(str32_remaining);
struct uni_encode_utf8_result encoded = uni_encode_utf8(decoded.codepoint);
u8 *dst = arena_push_array(arena, u8, encoded.count8);
u8 *dst = arena_push_array_no_zero(arena, u8, encoded.count8);
MEMCPY(dst, &encoded.chars8, encoded.count8);
pos32 += 1;
@ -640,7 +640,7 @@ struct string16 string16_from_string(struct arena *arena, struct string str8)
struct uni_decode_utf8_result decoded = uni_decode_utf8(str8_remaining);
struct uni_encode_utf16_result encoded = uni_encode_utf16(decoded.codepoint);
u16 *dst = arena_push_array(arena, u16, encoded.count16);
u16 *dst = arena_push_array_no_zero(arena, u16, encoded.count16);
MEMCPY(dst, encoded.chars16, (encoded.count16 << 1));
pos8 += decoded.advance8;
@ -664,7 +664,7 @@ struct string32 string32_from_string(struct arena *arena, struct string str8)
struct uni_decode_utf8_result decoded = uni_decode_utf8(str8_remaining);
struct uni_encode_utf32_result encoded = uni_encode_utf32(decoded.codepoint);
u32 *dst = arena_push(arena, u32);
u32 *dst = arena_push_no_zero(arena, u32);
*dst = encoded.chars32;
pos8 += decoded.advance8;
@ -706,7 +706,7 @@ u64 cstr_len(char *cstr, u64 limit)
char *cstr_from_string(struct arena *arena, struct string src)
{
u8 *text = arena_push_array(arena, u8, src.len + 1);
u8 *text = arena_push_array_no_zero(arena, u8, src.len + 1);
MEMCPY(text, src.text, src.len);
text[src.len] = 0;
return (char *)text;
@ -773,13 +773,13 @@ u64 wstr_len(wchar_t *wstr, u64 limit)
wchar_t *wstr_from_string(struct arena *arena, struct string src)
{
struct string16 str16 = string16_from_string(arena, src);
*arena_push(arena, u16) = 0;
*arena_push_no_zero(arena, u16) = 0;
return (wchar_t *)str16.text;
}
wchar_t *wstr_from_string16(struct arena *arena, struct string16 src)
{
u16 *text = arena_push_array(arena, u16, src.len + 1);
u16 *text = arena_push_array_no_zero(arena, u16, src.len + 1);
text[src.len] = 0;
return (wchar_t *)text;
}

View File

@ -275,7 +275,7 @@ INTERNAL struct string string_from_win32_path(struct arena *arena, wchar_t *src)
struct string16 decode_str = { .len = *(src + 1) ? 2 : 1, .text = src };
struct uni_decode_utf16_result decoded = uni_decode_utf16(decode_str);
struct uni_encode_utf8_result encoded = uni_encode_utf8(decoded.codepoint);
u8 *dest = arena_push_array(arena, u8, encoded.count8);
u8 *dest = arena_push_array_no_zero(arena, u8, encoded.count8);
for (u32 i = 0; i < encoded.count8; ++i) {
u8 byte = encoded.chars8[i];
if (byte == '\\') {
@ -470,7 +470,7 @@ struct string sys_file_read_all(struct arena *arena, struct sys_file file)
/* ReadFile returns non-zero on success */
/* TODO: error checking */
arena_align(arena, 16);
s.text = arena_push_array(arena, u8, size);
s.text = arena_push_array_no_zero(arena, u8, size);
(UNUSED)ReadFile(
(HANDLE)file.handle,
s.text,
@ -626,7 +626,7 @@ struct win32_file_filter {
struct sys_file_filter sys_file_filter_begin(struct arena *arena, struct string pattern)
{
struct sys_file_filter filter = ZI;
struct win32_file_filter *filter_internal = arena_push_zero(arena, struct win32_file_filter);
struct win32_file_filter *filter_internal = arena_push(arena, struct win32_file_filter);
filter_internal->filter_wstr = wstr_from_string(arena, pattern);
filter.handle = (u64)filter_internal;
return filter;
@ -694,7 +694,7 @@ struct sys_watch sys_watch_alloc(struct string dir_path)
w32_watch = G.watches_first_free;
G.watches_first_free = w32_watch->next_free;
} else {
w32_watch = arena_push(&G.watches_arena, struct win32_watch);
w32_watch = arena_push_no_zero(&G.watches_arena, struct win32_watch);
}
}
sys_mutex_unlock(&lock);
@ -791,7 +791,7 @@ struct sys_watch_info_list sys_watch_wait(struct arena *arena, struct sys_watch
while (!done) {
FILE_NOTIFY_INFORMATION *res = (FILE_NOTIFY_INFORMATION *)(w32_watch->results_buff + offset);
struct sys_watch_info *info = arena_push_zero(arena, struct sys_watch_info);
struct sys_watch_info *info = arena_push(arena, struct sys_watch_info);
if (list.last) {
list.last->next = info;
info->prev = list.last;
@ -871,7 +871,7 @@ struct sys_watch_info_list sys_watch_info_copy(struct arena *arena, struct sys_w
{
struct sys_watch_info_list dst_list = ZI;
for (struct sys_watch_info *src = src_list.first; src; src = src->next) {
struct sys_watch_info *dst = arena_push_zero(arena, struct sys_watch_info);
struct sys_watch_info *dst = arena_push(arena, struct sys_watch_info);
dst->kind = src->kind;
dst->name = string_copy(arena, src->name);
if (dst_list.last) {
@ -1032,7 +1032,7 @@ INTERNAL struct win32_window *win32_window_alloc(void)
window = G.first_free_window;
G.first_free_window = window->next_free;
} else {
window = arena_push(&G.windows_arena, struct win32_window);
window = arena_push_no_zero(&G.windows_arena, struct win32_window);
}
sys_mutex_unlock(&lock);
}
@ -1387,7 +1387,7 @@ INTERNAL LRESULT CALLBACK win32_window_proc(HWND hwnd, UINT msg, WPARAM wparam,
/* Read raw input buffer */
UINT buff_size;
GetRawInputData((HRAWINPUT)lparam, RID_INPUT, NULL, &buff_size, sizeof(RAWINPUTHEADER));
u8 *buff = arena_push_array_zero(scratch.arena, u8, buff_size);
u8 *buff = arena_push_array(scratch.arena, u8, buff_size);
if (GetRawInputData((HRAWINPUT)lparam, RID_INPUT, buff, &buff_size, sizeof(RAWINPUTHEADER)) != buff_size) {
logf_error("GetRawInputData did not return correct size");
break;
@ -1672,7 +1672,7 @@ INTERNAL struct win32_condition_variable *win32_condition_variable_alloc(void)
cv = G.first_free_condition_variable;
G.first_free_condition_variable = cv->next_free;
} else {
cv = arena_push_zero(&G.condition_variables_arena, struct win32_condition_variable);
cv = arena_push(&G.condition_variables_arena, struct win32_condition_variable);
}
sys_mutex_unlock(&lock);
}
@ -1861,7 +1861,7 @@ INTERNAL struct win32_thread *win32_thread_alloc(void)
t = G.threads_first_free;
G.threads_first_free = t->next;
} else {
t = arena_push(&G.threads_arena, struct win32_thread);
t = arena_push_no_zero(&G.threads_arena, struct win32_thread);
}
MEMZERO_STRUCT(t);
if (!G.threads_first) {

View File

@ -119,7 +119,7 @@ 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 tar_entry *entry = arena_push(arena, struct tar_entry);
struct tar_entry *entry = arena_push_no_zero(arena, struct tar_entry);
*entry = (struct tar_entry) {
.is_dir = is_dir,
.file_name = file_name,

View File

@ -33,8 +33,8 @@ struct thread_local_store thread_local_store_alloc(void)
__prof;
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);
t.lookup = arena_push_array(&t.arena, void *, MAX_THREAD_LOCAL_VARS);
t.allocation_order = arena_push_array(&t.arena, u64, MAX_THREAD_LOCAL_VARS);
return t;
}
@ -94,7 +94,7 @@ void *_thread_local_var_eval(struct thread_local_var_meta *meta)
__profscope(_thread_local_var_eval__ALLOC);
/* Allocate */
arena_align(&t->arena, meta->align);
data = arena_push_array(&t->arena, u8, meta->size);
data = arena_push_array_no_zero(&t->arena, u8, meta->size);
if (meta->alloc) {
meta->alloc(data);
} else {

View File

@ -159,7 +159,7 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct string encoded,
}
/* Allocate font memory */
struct font_glyph *glyphs = (struct font_glyph *)arena_push_array_zero(arena, struct font_glyph, glyph_count);
struct font_glyph *glyphs = (struct font_glyph *)arena_push_array(arena, struct font_glyph, glyph_count);
/* Allocate (starting) atlas memory
* NOTE: This is unecessary since atlas memory will grow anyway. Could
@ -167,7 +167,7 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct string encoded,
*/
u64 atlas_w = 1024;
u64 atlas_h = 1;
u32 *atlas_memory = arena_push_array_zero(arena, u32, atlas_w * atlas_h);
u32 *atlas_memory = arena_push_array(arena, u32, atlas_w * atlas_h);
/* Fill CPU side atlas & metric data */
u32 out_offset_x = 0;
@ -236,7 +236,7 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct string encoded,
u64 diff = (out_offset_y + tex_h) - atlas_h;
/* NOTE: This allocation must be contiguous with the initial atlas
* allocation (IE: No non-atlas arena PUSHes) */
arena_push_array_zero(arena, u32, diff * atlas_w);
arena_push_array(arena, u32, diff * atlas_w);
atlas_h += diff;
}
@ -283,7 +283,7 @@ struct ttf_decode_result ttf_decode(struct arena *arena, struct string encoded,
/* Construct indices array */
u16 *cache_indices = NULL;
if (cache_codes_count > 0) {
cache_indices = arena_push_array_zero(arena, u16, cache_codes_count);
cache_indices = arena_push_array(arena, u16, cache_codes_count);
font_face->GetGlyphIndices(cache_codes, cache_codes_count, cache_indices);
}

View File

@ -279,7 +279,7 @@ INTERNAL struct sys_event_array pop_sys_events(struct arena *arena)
{
struct sys_event *src_events = (struct sys_event *)G.sys_events_arena.base;
array.count = G.sys_events_arena.pos / sizeof(*src_events);
array.events = arena_push_array(arena, struct sys_event, array.count);
array.events = arena_push_array_no_zero(arena, struct sys_event, array.count);
MEMCPY(array.events, src_events, array.count * sizeof(*src_events));
arena_reset(&G.sys_events_arena);
}
@ -291,7 +291,7 @@ INTERNAL SYS_WINDOW_EVENT_CALLBACK_FUNC_DEF(window_event_callback, event)
{
struct sys_lock lock = sys_mutex_lock_e(&G.sys_events_mutex);
{
*arena_push(&G.sys_events_arena, struct sys_event) = event;
*arena_push_no_zero(&G.sys_events_arena, struct sys_event) = event;
}
sys_mutex_unlock(&lock);
}
@ -1003,7 +1003,7 @@ INTERNAL void user_update(void)
for (u64 ent_index = 0; ent_index < G.ss_blended->num_ents_reserved; ++ent_index) {
struct sim_ent *ent = &G.ss_blended->ents[ent_index];
if (sim_ent_is_valid_and_active(ent)) {
*arena_push(scratch.arena, struct sim_ent *) = ent;
*arena_push_no_zero(scratch.arena, struct sim_ent *) = ent;
++sorted_count;
}
}
@ -2162,7 +2162,7 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_local_sim_thread_entry_point, arg)
//b32 should_decode = tick == client->highest_received_tick + 1 || client->highest_received_tick == 0;
b32 should_decode = tick > client->highest_received_tick;
if (should_decode) {
struct sim_ss_decode_node *node = arena_push_zero(scratch.arena, struct sim_ss_decode_node);
struct sim_ss_decode_node *node = arena_push(scratch.arena, struct sim_ss_decode_node);
node->client = client;
node->tick = tick;
node->base_tick = base_tick;
@ -2181,7 +2181,7 @@ INTERNAL SYS_THREAD_ENTRY_POINT_FUNC_DEF(user_local_sim_thread_entry_point, arg)
/* Decode incoming master client snapshots for decoding (only the newest one) */
b32 should_decode = client == master_client && tick > client->highest_received_tick;
if (should_decode) {
struct sim_ss_decode_node *node = queue.first ? queue.first : arena_push_zero(scratch.arena, struct sim_ss_decode_node);
struct sim_ss_decode_node *node = queue.first ? queue.first : arena_push(scratch.arena, struct sim_ss_decode_node);
node->client = client;
node->tick = tick;
node->base_tick = base_tick;

View File

@ -87,8 +87,8 @@ INLINE void merge_sort(void *items, u64 item_count, u64 item_size, sort_compare_
u64 left_size = left_count * item_size;
u64 right_size = right_count * item_size;
u8 *left = arena_push_array(scratch.arena, u8, left_size);
u8 *right = arena_push_array(scratch.arena, u8, right_size);
u8 *left = arena_push_array_no_zero(scratch.arena, u8, left_size);
u8 *right = arena_push_array_no_zero(scratch.arena, u8, right_size);
MEMCPY(left, items, left_size);
MEMCPY(right, (u8 *)items + left_size, right_size);
@ -127,7 +127,7 @@ INLINE struct fixed_dict fixed_dict_init(struct arena *arena, u64 bins_count)
struct fixed_dict dict = ZI;
bins_count = max_u64(bins_count, 1); /* Ensure at least 1 bin */
dict.bins_count = bins_count;
dict.bins = arena_push_array_zero(arena, struct fixed_dict_bin, bins_count);
dict.bins = arena_push_array(arena, struct fixed_dict_bin, bins_count);
return dict;
}
@ -152,7 +152,7 @@ INLINE void fixed_dict_set(struct arena *arena, struct fixed_dict *dict, struct
}
/* No match found, create new entry */
entry = arena_push(arena, struct fixed_dict_entry);
entry = arena_push_no_zero(arena, struct fixed_dict_entry);
entry->key = key;
entry->value = value;
entry->hash = hash;

View File

@ -125,7 +125,7 @@ struct work_startup_receipt work_startup(u32 num_worker_threads)
LIT("[P6] Worker %F"),
FMT_UINT(i));
struct worker *worker = arena_push_zero(&G.arena, struct worker);
struct worker *worker = arena_push(&G.arena, struct worker);
worker->thread = sys_thread_alloc(&worker_thread_entry_point, NULL, thread_name);
if (prev) {
prev->next = worker;
@ -181,7 +181,7 @@ INTERNAL struct work *work_alloc_locked(struct sys_lock *lock)
};
} else {
/* Make new */
work = arena_push(&G.arena, struct work);
work = arena_push_no_zero(&G.arena, struct work);
*work = (struct work) {
.condition_variable_finished = sys_condition_variable_alloc(),
.gen = 1
@ -226,7 +226,7 @@ INTERNAL struct work_task *task_alloc_locked(struct sys_lock *lock)
*task = (struct work_task) { 0 };
} else {
/* Make new */
task = arena_push_zero(&G.arena, struct work_task);
task = arena_push(&G.arena, struct work_task);
}
return task;