From 91a539d9046efb068ce4464a0abd017d89998c54 Mon Sep 17 00:00:00 2001 From: hgn Date: Wed, 2 Jul 2025 12:22:29 +0000 Subject: [PATCH] Align using real address for larger than 16 byte alignment --- vg_kv.h | 2 +- vg_mem.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/vg_kv.h b/vg_kv.h index 41c9751..2ddd5f2 100644 --- a/vg_kv.h +++ b/vg_kv.h @@ -44,7 +44,7 @@ u32 vg_kv_find( vg_kvs *kvs, u32 root_offset, const char *key ); * if both key and value are set, it appends a KV pair * returns the new KV offset */ -u32 vg_kv_append( vg_kvs *kvs, u32 parent_offset, const char *key, const char *value ) +u32 vg_kv_append( vg_kvs *kvs, u32 parent_offset, const char *key, const char *value ); /* Writing KV files. w should be initialized with depth 0, and fp to a valid C stream pointer */ void vg_kv_write_block( vg_kv_write *w, const char *name, u32 name_length ); diff --git a/vg_mem.c b/vg_mem.c index 92b9ef5..9a609a6 100644 --- a/vg_mem.c +++ b/vg_mem.c @@ -120,7 +120,7 @@ void *vg_stack_allocate( vg_stack_allocator *stack, u32 size, u32 alignment, con u32 new_usage = stack->used + block_size + alignment; vg_stack_growmaybe( stack, new_usage ); - while( stack->used & (alignment-1) ) + while( ((u64)stack->data + stack->used) & (alignment-1) ) stack->used ++; void *block = (void *)stack->data + stack->used; -- 2.25.1