yabadabadoo
[vg.git] / src / vg / vg_mem.h
index 1ef1e77260eecd2e49ebbb4f069b6167a241352a..a3c7cd6e8d92b343b2627e0d1a29efb343e1d296 100644 (file)
@@ -5,6 +5,7 @@
 #include "vg_platform.h"
 
 #include <stdlib.h>
+#include <malloc.h>
 
 typedef struct vg_linear_allocator vg_linear_allocator;
 
@@ -15,7 +16,6 @@ struct
 }
 static vg_mem;
 
-#pragma pack(push,1)
 struct vg_linear_allocator
 {
    u32 size, cur;
@@ -24,11 +24,9 @@ struct vg_linear_allocator
    void *last_alloc;
    u32 last_alloc_size;
 };
-#pragma pack(pop)
 
 /* 
  * TODO: Fallback on libc
- * TODO: 8 byte alignment
  */
 
 VG_STATIC void vg_error(const char *fmt, ...);
@@ -37,6 +35,10 @@ VG_STATIC void vg_error(const char *fmt, ...);
 __attribute__((warn_unused_result))
 VG_STATIC void *vg_linear_alloc( void *allocator, u32 size )
 {
+   size += 7;
+   size >>= 3;
+   size <<= 3;
+
    if( allocator == NULL )
       vg_fatal_exit_loop( "Null allocator" );