*RootCell = &IndexKey->List[SubKeyIndex];
return LeafCell;
}
+
+ /* It didn't fit, so proceed to splitting */
}
else
{
/* Check if it's above */
if (Result >= 0)
{
- /* Get the first cell in the index */
- LeafCell = IndexKey->List[0];
+ /* Get the cell in the index */
+ LeafCell = IndexKey->List[SubKeyIndex];
LeafKey = (PCM_KEY_INDEX)HvGetCell(Hive, LeafCell);
/* Return an error in case of problems */
if (!LeafKey) return HCELL_NIL;
- /* Check if it fits into this leaf and break */
+ /* Check if it fits into this leaf */
if (LeafKey->Count < CmpMaxIndexPerHblock)
{
/* Fill in the result and return the cell */
- *RootCell = &IndexKey->List[SubKeyIndex + 1];
+ *RootCell = &IndexKey->List[SubKeyIndex];
return LeafCell;
}
- /* No, it doesn't fit, check the other leaf */
+ /* No, it doesn't fit, check the next adjacent leaf */
if (SubKeyIndex < (IndexKey->Count - 1))
{
/* Yes, there is space */
return LeafCell;
}
}
+
+ /* It didn't fit, so proceed to splitting */
}
else
{
/* Check if it fits and break */
if (LeafKey->Count < CmpMaxIndexPerHblock)
{
- /* Decrement the subkey index */
- SubKeyIndex--;
-
/* Fill in the result and return the cell */
- *RootCell = &IndexKey->List[SubKeyIndex];
+ *RootCell = &IndexKey->List[SubKeyIndex - 1];
return LeafCell;
}
}