X-Git-Url: https://harrygodden.com/git/?a=blobdiff_plain;f=vg_mem.h;h=6aa22f273abfec1878cd22914a295540149d8d83;hb=183961c84950614b04ccc39455fc101da0e2dc82;hp=be11ddd2ef4ce43741b1d23f89eb1718c9a4680f;hpb=76d234b7dc5e6500e8a54009b367e7620f11ef97;p=vg.git diff --git a/vg_mem.h b/vg_mem.h index be11ddd..6aa22f2 100644 --- a/vg_mem.h +++ b/vg_mem.h @@ -157,11 +157,7 @@ static void *_vg_linear_alloc( void *buffer, u32 size, vg_print_backtrace(); size = vg_align8( size ); } -#ifdef _WIN32 - if( ((u32)buffer) % 8 ){ -#else if( ((u64)buffer) % 8 ){ -#endif vg_fatal_error( "unaligned buffer (%p)", buffer ); } @@ -201,11 +197,7 @@ static void *_vg_linear_alloc( void *buffer, u32 size, alloc->last_alloc_size = size; alloc->cur += size; -#ifdef _WIN32 - if( ((u32)data) % 8 ){ -#else if( ((u64)data) % 8 ){ -#endif vg_fatal_error( "unaligned" ); } @@ -278,7 +270,7 @@ static void *_vg_linear_extend( void *buffer, void *data, u32 extra, const char *constr_name ) { if( !data ) - return _vg_linear_alloc( buffer, extra, constr_name ); + return _vg_linear_alloc( buffer, vg_align8(extra), constr_name ); vg_linear_allocator *alloc = vg_linear_header( buffer ); @@ -286,7 +278,7 @@ static void *_vg_linear_extend( void *buffer, void *data, u32 extra, vg_fatal_error( "This block has been fixed!" ); u32 new_size = alloc->last_alloc_size + extra; - return vg_linear_resize( buffer, data, new_size ); + return vg_linear_resize( buffer, data, vg_align8(new_size) ); } /* get the current usage of allocator */ @@ -339,7 +331,17 @@ static void vg_linear_clear( void *buffer ) alloc->cur = 0; } -/* allocate a FIXED SIZE linear allocator */ +/* allocate a FIXED SIZE linear allocator + * + * FIXME: there was a bug in vg's code that caused a race condition between + * two system allocations. make this IMPOSSIBLE by requiring a lock + * on the allocater to be passed between threads. + * + * luckily that bug only exists when using development tools, but still! + * + * this should then only be checked and turned on in debugging. + * + */ static void *_vg_create_linear_allocator( void *lin_alloc, u32 size, u16 flags, const char *constr_name) {