svn commit: samba r6722 - in trunk/source/registry: .

jerry at samba.org jerry at samba.org
Wed May 11 02:47:57 GMT 2005


Author: jerry
Date: 2005-05-11 02:47:57 +0000 (Wed, 11 May 2005)
New Revision: 6722

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=6722

Log:
fix a few more bugs in the registry write support
Modified:
   trunk/source/registry/regfio.c


Changeset:
Modified: trunk/source/registry/regfio.c
===================================================================
--- trunk/source/registry/regfio.c	2005-05-11 01:18:42 UTC (rev 6721)
+++ trunk/source/registry/regfio.c	2005-05-11 02:47:57 UTC (rev 6722)
@@ -1365,8 +1365,9 @@
 
 static REGF_HBIN* find_free_space( REGF_FILE *file, uint32 size )
 {
-	REGF_HBIN *hbin = NULL;
+	REGF_HBIN *hbin, *p_hbin;
 	uint32 block_off;
+	BOOL cached;
 
 	/* check open block list */
 
@@ -1395,9 +1396,28 @@
 
 		hbin = read_hbin_block( file, block_off );
 
-		if ( hbin ) 
+		if ( hbin ) {
+
+			/* make sure that we don't already have this block in memory */
+
+			cached = False;
+			for ( p_hbin=file->block_list; p_hbin!=NULL; p_hbin=p_hbin->next ) {
+				if ( p_hbin->file_off == hbin->file_off ) {
+					cached = True;	
+					break;
+				}
+			}
+
 			block_off = hbin->file_off + hbin->block_size;
 
+			if ( cached ) {
+				prs_mem_free( &hbin->ps );
+				hbin = NULL;
+				continue;
+			}
+		}
+
+
 	} while ( hbin && (hbin->free_size < size) );
 	
 	/* no free space; allocate a new one */
@@ -1428,7 +1448,16 @@
 
 	if ( !prs_uint32("allocated_size", &hbin->ps, 0, &size) )
 		return False;
+#if 0
+	if ( !prs_uint8s(True, "allocated_header", &hbin->ps, 0, header, REC_HDR_SIZE) )
+		return False;
 
+	/* reset pointer to beginning of clean record */
+
+	if ( !prs_set_offset( &hbin->ps, hbin->free_off ) )
+		return NULL;
+#endif
+
 	update_free_space( hbin, size );
 	
 	return hbin;
@@ -1553,7 +1582,7 @@
 
 	/* store the parent offset (or -1 if a the root key */
 
-	nk->parent_off = parent ? (parent->hbin_off + parent->hbin->file_off - REGF_BLOCKSIZE + HBIN_HDR_SIZE ) : REGF_OFFSET_NONE;
+	nk->parent_off = parent ? (parent->hbin_off + parent->hbin->file_off - REGF_BLOCKSIZE - HBIN_HDR_SIZE ) : REGF_OFFSET_NONE;
 
 	/* no classname currently */
 



More information about the samba-cvs mailing list