ogl_beamforming

Ultrasound Beamforming Implemented with OpenGL
git clone anongit@rnpnr.xyz:ogl_beamforming.git
Log | Files | Refs | Feed | Submodules | README | LICENSE

Commit: 3bfa4af7007e3b867c302c2a88fa128cf86bd626
Parent: 5c077b55280a1d96f87b5271815433b889006b0e
Author: Randy Palamar
Date:   Wed, 29 Apr 2026 14:50:09 -0600

util: make da_push clear the new item

There are no current bugs related to this but it is counter
intuitive when the default behaviour of the every other function
pushing into an arena clears memory. This is imporant when the DA
is being used as a stack and items are being pushed and popped
without ever expanding the DA.

Diffstat:
Mutil.c | 8++++----
1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/util.c b/util.c @@ -5,9 +5,9 @@ #pragma GCC diagnostic ignored "-Woverride-init" #endif -#define zero_struct(s) memory_clear(s, 0, sizeof(*s)) +#define zero_struct(s) memory_clear((s), 0, sizeof(*(s))) function void * -memory_clear(void *restrict p_, u8 c, iz size) +memory_clear(void *restrict p_, u8 c, u64 size) { u8 *p = p_; while (size > 0) p[--size] = c; @@ -230,10 +230,10 @@ enum { DA_INITIAL_CAP = 16 }; } while (0) #define da_push(a, s) \ - ((s)->count == (s)->capacity \ + ((typeof((s)->data))memory_clear((s)->count == (s)->capacity \ ? da_reserve(a, s, 1), \ (s)->data + (s)->count++ \ - : (s)->data + (s)->count++) + : (s)->data + (s)->count++, 0, sizeof(*(s)->data))) function void * da_reserve_(Arena *a, void *data, iz *capacity, iz needed, uz align, iz size)