memory semantics
[vg.git] / vg_mem.h
index 598bc83c352f3c7e382a0835cad459b0cbb2a113..49ab3e3061a8af2eb1cb87aaae01f51cd6877728 100644 (file)
--- a/vg_mem.h
+++ b/vg_mem.h
@@ -49,37 +49,12 @@ struct vg_allocation_meta
 struct vg_linear_allocator
 {
    u32 size;
-   /*     */
-   /*     */
-   /*     */
    u32 cur;
-   /*    */
-   /*    */
-   /*    */
    u16 allocation_count;
-   /*                 */
    u16 flags;
-   /*      */
    u32 last_alloc_size;
-   /*                */
-   /*                */
-   /*                */
    void *last_alloc;
-   /*             */
-   /*             */
-   /*             */
-   /*             */
-   /*             */
-   /*             */
-   /*             */
    vg_allocation_meta *alloc_table;
-   /*                            */
-   /*                            */
-   /*                            */
-   /*                            */
-   /*                            */
-   /*                            */
-   /*                            */
 
 #ifdef _WIN32
    /* 32 bit pointers! */
@@ -216,8 +191,10 @@ VG_STATIC void vg_linear_del( void *buffer, void *data )
 {
    vg_linear_allocator *alloc = vg_linear_header( buffer );
 
-   if( alloc->last_alloc != data )
-      vg_fatal_error( "This block has been fixed!" );
+   if( alloc->last_alloc != data ){
+      vg_fatal_error( "This block has been fixed! Last alloc: %p, this: %p\n",
+                      alloc->last_alloc, data );
+   }
 
    if( vg_mem.use_libc_malloc && (alloc->flags & VG_MEMORY_SYSTEM) ){
       vg_allocation_meta *meta = &alloc->alloc_table[alloc->allocation_count-1];
@@ -339,9 +316,8 @@ VG_STATIC void *vg_create_linear_allocator( void *lin_alloc, u32 size,
       }
       
       alloc->cur += block_size;
-      alloc->last_alloc = NULL; /* cant resize this block! */
+      alloc->last_alloc = header;
       alloc->last_alloc_size = block_size;
-
       alloc->allocation_count ++;
    }
    else{