/* Clear the Gather list for a list of capsule images. */
VOID CleanGatherList(IN EFI_CAPSULE_BLOCK_DESCRIPTOR *BlockDescriptors, IN UINTN CapsuleNum)
/* Clear the Gather list for a list of capsule images. */
VOID CleanGatherList(IN EFI_CAPSULE_BLOCK_DESCRIPTOR *BlockDescriptors, IN UINTN CapsuleNum)
{
  EFI_CAPSULE_BLOCK_DESCRIPTOR  *TempBlockPtr;
  EFI_CAPSULE_BLOCK_DESCRIPTOR  *TempBlockPtr1;
  EFI_CAPSULE_BLOCK_DESCRIPTOR  *TempBlockPtr2;
  UINTN                         Index;
  if (BlockDescriptors != NULL) {
    TempBlockPtr1 = BlockDescriptors;
    while (1) {
      TempBlockPtr = TempBlockPtr1;
      for (Index = 0; Index < CapsuleNum; Index++) {
        if (TempBlockPtr[Index].Length == 0) {
          break;
        }
      }
      if (TempBlockPtr[Index].Union.ContinuationPointer == (UINTN)NULL) {
        break;
      }
      TempBlockPtr2 = (VOID *)((UINTN)TempBlockPtr[Index].Union.ContinuationPointer);
      FreePool (TempBlockPtr1);
      TempBlockPtr1 = TempBlockPtr2;
    }
  }
}