/* Empty a collection of PCI_CAP structures, optionally releasing the referenced PCI_CAP structures themselves. Release the collection at last. */
STATIC VOID EmptyAndUninitPciCapCollection(IN OUT ORDERED_COLLECTION *PciCapCollection, IN BOOLEAN FreePciCap)
/* Empty a collection of PCI_CAP structures, optionally releasing the referenced PCI_CAP structures themselves. Release the collection at last. */
STATIC VOID EmptyAndUninitPciCapCollection(IN OUT ORDERED_COLLECTION *PciCapCollection, IN BOOLEAN FreePciCap)
{
  ORDERED_COLLECTION_ENTRY  *PciCapEntry;
  ORDERED_COLLECTION_ENTRY  *NextEntry;
  for (PciCapEntry = OrderedCollectionMin (PciCapCollection);
       PciCapEntry != NULL;
       PciCapEntry = NextEntry)
  {
    PCI_CAP  *PciCap;
    NextEntry = OrderedCollectionNext (PciCapEntry);
    OrderedCollectionDelete (PciCapCollection, PciCapEntry, (VOID **)&PciCap);
    if (FreePciCap) {
      FreePool (PciCap);
    }
  }
  OrderedCollectionUninit (PciCapCollection);
}