perlin
[vg.git] / vg_mem.h
index 5edbd9c68ebc60560860f98a53a62687bfb6dc4b..9a9b31bed02baa84f2e36bcff4bb7546af5fd002 100644 (file)
--- a/vg_mem.h
+++ b/vg_mem.h
@@ -8,7 +8,7 @@
 #include <stdlib.h>
 #include <malloc.h>
 
-#define VG_MAX_ALLOCATIONS 64
+#define VG_MAX_ALLOCATIONS 128
 #define VG_FUZZ_ALLOCATIONS
 
 typedef struct vg_linear_allocator vg_linear_allocator;
@@ -96,6 +96,12 @@ VG_STATIC u32 vg_align8( u32 s )
    return m << 3;
 }
 
+VG_STATIC u32 vg_align4( u32 s )
+{
+   u32 m = (s + 3) >> 2;
+   return m << 2;
+}
+
 /* Returns allocator structure from data pointer */
 static vg_linear_allocator *vg_linear_header( void *data )
 {
@@ -210,6 +216,9 @@ VG_STATIC void vg_linear_del( void *buffer, void *data )
 __attribute__((warn_unused_result))
 VG_STATIC void *vg_linear_extend( void *buffer, void *data, u32 extra )
 {
+   if( !data )
+      return vg_linear_alloc( buffer, extra );
+
    vg_linear_allocator *alloc = vg_linear_header( buffer );
 
    if( alloc->last_alloc != data )