ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

VOID CMAPI HvFreeCell ( PHHIVE  RegistryHive,
HCELL_INDEX  CellIndex 
)

Definition at line 448 of file hivecell.c.

Referenced by CmiAddSubKey(), CmpDoCreateChild(), CmpFreeKeyBody(), CmpFreeKeyByCell(), CmpFreeValue(), CmpFreeValueData(), CmpRemoveSubKey(), CmpRemoveValueFromList(), CmpSetValueKeyNew(), CmpSplitLeaf(), HvReallocateCell(), and RegSetValueExW().

{
   PHCELL Free;
   PHCELL Neighbor;
   PHBIN Bin;
   ULONG CellType;
   ULONG CellBlock;

   ASSERT(RegistryHive->ReadOnly == FALSE);

   CMLTRACE(CMLIB_HCELL_DEBUG, "%s - Hive %p, CellIndex %08lx\n",
       __FUNCTION__, RegistryHive, CellIndex);

   Free = HvpGetCellHeader(RegistryHive, CellIndex);

   ASSERT(Free->Size < 0);

   Free->Size = -Free->Size;

   CellType = (CellIndex & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT;
   CellBlock = (CellIndex & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT;

   /* FIXME: Merge free blocks */
   Bin = (PHBIN)RegistryHive->Storage[CellType].BlockList[CellBlock].BinAddress;

   if ((CellIndex & ~HCELL_TYPE_MASK) + Free->Size <
       Bin->FileOffset + Bin->Size)
   {
      Neighbor = (PHCELL)((ULONG_PTR)Free + Free->Size);
      if (Neighbor->Size > 0)
      {
         HvpRemoveFree(RegistryHive, Neighbor,
                       ((HCELL_INDEX)((ULONG_PTR)Neighbor - (ULONG_PTR)Bin +
                       Bin->FileOffset)) | (CellIndex & HCELL_TYPE_MASK));
         Free->Size += Neighbor->Size;
      }
   }

   Neighbor = (PHCELL)(Bin + 1);
   while (Neighbor < Free)
   {
      if (Neighbor->Size > 0)
      {
         if ((ULONG_PTR)Neighbor + Neighbor->Size == (ULONG_PTR)Free)
         {
            HCELL_INDEX NeighborCellIndex =
               (HCELL_INDEX)((ULONG_PTR)Neighbor - (ULONG_PTR)Bin +
               Bin->FileOffset) | (CellIndex & HCELL_TYPE_MASK);

            if (HvpComputeFreeListIndex(Neighbor->Size) !=
                HvpComputeFreeListIndex(Neighbor->Size + Free->Size))
            {
               HvpRemoveFree(RegistryHive, Neighbor, NeighborCellIndex);
               Neighbor->Size += Free->Size;
               HvpAddFree(RegistryHive, Neighbor, NeighborCellIndex);
            }
            else
               Neighbor->Size += Free->Size;

            if (CellType == Stable)
               HvMarkCellDirty(RegistryHive, NeighborCellIndex, FALSE);

            return;
         }
         Neighbor = (PHCELL)((ULONG_PTR)Neighbor + Neighbor->Size);
      }
      else
      {
         Neighbor = (PHCELL)((ULONG_PTR)Neighbor - Neighbor->Size);
      }
   }

   /* Add block to the list of free blocks */
   HvpAddFree(RegistryHive, Free, CellIndex);

   if (CellType == Stable)
      HvMarkCellDirty(RegistryHive, CellIndex, FALSE);
}

Generated on Sat May 26 2012 06:02:46 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.