Changeset 117


Ignore:
Timestamp:
08/03/08 16:10:33 (16 years ago)
Author:
tim
Message:

reordered orphaned value extraction to be faster and more accurate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/reglookup-recover.c

    r116 r117  
    478478
    479479
     480/* NOTE: unalloc_keys should be an empty range_list. */
    480481int extractKeys(REGF_FILE* f,
    481482                range_list* unalloc_cells,
     
    638639
    639640
    640 
    641 int extractValues(REGF_FILE* f, 
    642                   range_list* unalloc_cells, 
     641/* NOTE: unalloc_values should be an empty range_list. */
     642int extractValues(REGF_FILE* f,
     643                  range_list* unalloc_cells,
    643644                  range_list* unalloc_values)
    644645{
     
    662663          return 20;
    663664        }
    664        
    665         if(!removeRange(unalloc_cells, vk->offset, vk->cell_size))
    666           return 30;
    667 
    668         if(vk->data != NULL && !vk->data_in_offset)
    669         {
    670           off = vk->data_off+REGF_BLOCKSIZE;
    671           if(!range_list_has_range(unalloc_cells, off,
    672                                    vk->data_size))
    673           { /* We've parsed a data cell which isn't in the unallocated
    674              * list, so prune it.
    675              */
    676             free(vk->data);
    677             vk->data = NULL;
    678           }
    679           else
    680           { /*A data record was recovered. Remove from unalloc_cells.*/
    681             if(!removeRange(unalloc_cells, off, vk->data_size))
    682               return 40;
    683           }
    684         }
    685 
    686         /* TODO: This ugly hack is needed because unalloc_cells is changing
    687          *       underneath us when we find things.  Need a better approach
    688          *       so we can parse things single-pass.
     665        j+=vk->cell_size-8;
     666      }
     667    }
     668  }
     669 
     670  /* Remove value ranges from the unalloc_cells before we continue. */
     671  for(i=0; i<range_list_size(unalloc_values); i++)
     672  {
     673    cur_elem = range_list_get(unalloc_values, i);
     674    if(!removeRange(unalloc_cells, cur_elem->offset, cur_elem->length))
     675      return 30;
     676  }
     677
     678  /* Now see if the data associated with each value is intact */
     679  for(i=0; i<range_list_size(unalloc_values); i++)
     680  {
     681    cur_elem = range_list_get(unalloc_values, i);
     682    vk = (REGF_VK_REC*)cur_elem->data;
     683    if(vk == NULL)
     684      return 40;
     685
     686    if(vk->data != NULL && !vk->data_in_offset)
     687    {
     688      off = vk->data_off+REGF_BLOCKSIZE;
     689      if(!range_list_has_range(unalloc_cells, off, vk->data_size))
     690      { /* We've parsed a data cell which isn't in the unallocated
     691         * list, so prune it.
    689692         */
    690         i=0;
    691         break;
     693        free(vk->data);
     694        vk->data = NULL;
     695      }
     696      else
     697      { /*A data record was recovered. Remove from unalloc_cells.*/
     698        if(!removeRange(unalloc_cells, off, vk->data_size))
     699          return 50;
    692700      }
    693701    }
Note: See TracChangeset for help on using the changeset viewer.