Index: trunk/lib/regfio.c
===================================================================
--- trunk/lib/regfio.c	(revision 32)
+++ trunk/lib/regfio.c	(revision 33)
@@ -254,5 +254,6 @@
 /*******************************************************************
  *******************************************************************/
-static bool prs_nk_rec( const char *desc, prs_struct *ps, int depth, REGF_NK_REC *nk )
+static bool prs_nk_rec( const char *desc, prs_struct *ps, 
+			int depth, REGF_NK_REC *nk )
 {
   uint16 class_length, name_length;
@@ -266,6 +267,5 @@
   depth++;
 	
-  /* back up and get the data_size */
-	
+  /* back up and get the data_size */	
   if ( !prs_set_offset( ps, ps->data_offset-sizeof(uint32)) )
     return false;
@@ -274,5 +274,5 @@
     return false;
 	
-  if ( !prs_uint8s( true, "header", ps, depth, nk->header, sizeof( nk->header )) )
+  if (!prs_uint8s(true, "header", ps, depth, nk->header, sizeof(nk->header)))
     return false;
 		
@@ -307,8 +307,9 @@
     return false;
 
-  if ( !prs_uint32( "max_bytes_subkeyname", ps, depth, &nk->max_bytes_subkeyname))
-    return false;
-  if ( !prs_uint32( "max_bytes_subkeyclassname", ps, depth, &nk->max_bytes_subkeyclassname))
-    return false;
+  if (!prs_uint32("max_bytes_subkeyname", ps, depth, &nk->max_bytes_subkeyname))
+    return false;
+  if ( !prs_uint32( "max_bytes_subkeyclassname", ps, 
+		    depth, &nk->max_bytes_subkeyclassname))
+  { return false; }
   if ( !prs_uint32( "max_bytes_valuename", ps, depth, &nk->max_bytes_valuename))
     return false;
@@ -325,13 +326,13 @@
     return false;	
 		
-  if ( class_length ) {
+  if ( class_length ) 
+  {
     ;;
   }
 	
-  if ( name_length ) {
-    if ( ps->io ) {
-      if ( !(nk->keyname = (char*)zcalloc(sizeof(char), name_length+1 )) )
+  if ( name_length ) 
+  {
+    if(ps->io && !(nk->keyname = (char*)zcalloc(sizeof(char), name_length+1)))
 	return false;
-    }
 
     if ( !prs_uint8s( true, "name", ps, depth, nk->keyname, name_length) )
@@ -344,13 +345,15 @@
   end_off = ps->data_offset;
 
-  /* data_size must be divisible by 8 and large enough to hold the original record */
+  /* data_size must be divisible by 8 and large enough to hold 
+     the original record */
 
   data_size = ((start_off - end_off) & 0xfffffff8 );
-  if ( data_size > nk->rec_size )
-    /*DEBUG(10,("Encountered reused record (0x%x < 0x%x)\n", data_size, nk->rec_size));*/
-
-    if ( !ps->io )
-      nk->hbin->dirty = true;
-
+  /*if ( data_size > nk->rec_size )
+      DEBUG(10,("Encountered reused record (0x%x < 0x%x)\n", data_size, nk->rec_size));*/
+
+  if ( !ps->io )
+    nk->hbin->dirty = true;
+  
+  nk->subkey_index = 0;
   return true;
 }
@@ -627,9 +630,9 @@
 
   data_size = ((start_off - end_off) & 0xfffffff8 );
-  if ( data_size > lf->rec_size )
+  /*  if ( data_size > lf->rec_size )*/
     /*DEBUG(10,("Encountered reused record (0x%x < 0x%x)\n", data_size, lf->rec_size));*/
 
-    if ( !hbin->ps.io )
-      hbin->dirty = true;
+  if ( !hbin->ps.io )
+    hbin->dirty = true;
 
   return true;
@@ -681,9 +684,9 @@
 
   data_size = ((start_off - end_off) & 0xfffffff8 );
-  if ( data_size > sk->rec_size )
+  /*  if ( data_size > sk->rec_size )*/
     /*DEBUG(10,("Encountered reused record (0x%x < 0x%x)\n", data_size, sk->rec_size));*/
 
-    if ( !hbin->ps.io )
-      hbin->dirty = true;
+  if ( !hbin->ps.io )
+    hbin->dirty = true;
 
   return true;
@@ -937,10 +940,8 @@
 
   /* get the initial nk record */
-	
-  if ( !prs_nk_rec( "nk_rec", &hbin->ps, depth, nk ))
+  if (!prs_nk_rec("nk_rec", &hbin->ps, depth, nk))
     return false;
 
   /* fill in values */
-	
   if ( nk->num_values && (nk->values_off!=REGF_OFFSET_NONE) ) 
   {
@@ -1224,4 +1225,8 @@
 
 
+/* XXX: An interator struct should be used instead, and this function
+ *   should operate on it, so the state of iteration isn't stored in the
+ * REGF_NK_REC struct itself.
+ */
 /*******************************************************************
  This acts as an interator over the subkeys defined for a given 
Index: trunk/lib/void_stack.c
===================================================================
--- trunk/lib/void_stack.c	(revision 32)
+++ trunk/lib/void_stack.c	(revision 33)
@@ -56,4 +56,10 @@
     free(stack->elements[i]);
   free(stack);
+}
+
+
+unsigned short void_stack_size(void_stack* stack)
+{
+  return stack->top;
 }
 
@@ -121,5 +127,5 @@
 
 
-void* void_stack_iterator_next(void_stack_iterator* iter)
+const void* void_stack_iterator_next(void_stack_iterator* iter)
 {
   if(iter->cur < iter->stack->top)
