Complete the space allocation code for HBIN blocks ...
authorRichard Sharpe <sharpe@samba.org>
Tue, 22 Apr 2003 06:35:44 +0000 (06:35 +0000)
committerRichard Sharpe <sharpe@samba.org>
Tue, 22 Apr 2003 06:35:44 +0000 (06:35 +0000)
(This used to be commit ae5f8e4b5f7b8880293cc94c9bbe0df81a56959e)

source3/utils/editreg.c

index 02293951760f062e8f609b78d4ae50288b00d622..bdfb3dc83266455fcc07c93d3571cd0579929b6f 100644 (file)
@@ -2522,15 +2522,39 @@ void *nt_alloc_regf_space(REGF *regf, int size, int *off)
 
       /*
        * Fix up the free space ptr
+       * If it is NULL, we fix it up next time
        */
-    }
 
+      if (!blk->free_space) 
+       regf->free_space = blk->next;
+
+      *off = tmp;
+      return ret;
+    }
   }
 
   /*
    * If we got here, we need to add another block, which might be 
    * larger than one block -- deal with that later
    */
+  if (nt_create_hbin_blk(regf, REGF_HDR_BLKSIZ)) {
+    blk = regf->free_space;
+    tmp = blk->file_offset + blk->fsp_off;
+    ret = blk->data + blk->fsp_off;
+    blk->free_space -= size;
+    blk->fsp_off += size;
+
+    /*
+     * Fix up the free space ptr
+     * If it is NULL, we fix it up next time
+     */
+    
+    if (!blk->free_space) 
+      regf->free_space = blk->next;
+
+    *off = tmp;
+    return ret;
+  }
 
   return NULL;
 }