Align using real address for larger than 16 byte alignment
authorhgn <hgodden00@gmail.com>
Wed, 2 Jul 2025 12:22:29 +0000 (12:22 +0000)
committerhgn <hgodden00@gmail.com>
Wed, 2 Jul 2025 12:22:29 +0000 (12:22 +0000)
vg_kv.h
vg_mem.c

diff --git a/vg_kv.h b/vg_kv.h
index 41c97515652c22a8bb63fbe90f036b6e33dec7ca..2ddd5f2d46856079e94f3ac64eeb4b6bbd6dbcf4 100644 (file)
--- 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 );
index 92b9ef50c8eb9d4e8b0965cf65008758be60b0c6..9a609a612a723723960040cee00de4e3ff4cfb63 100644 (file)
--- 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;