/* Free a configuration descriptor with its interface descriptors. It may be initialized partially. */
VOID UsbFreeConfigDesc(IN USB_CONFIG_DESC *Config)
/* Free a configuration descriptor with its interface descriptors. It may be initialized partially. */
VOID UsbFreeConfigDesc(IN USB_CONFIG_DESC *Config)
{
  USB_INTERFACE_DESC  *Interface;
  UINTN               Index;
  UINTN               SetIndex;
  if (Config->Interfaces != NULL) {
    for (Index = 0; Index < Config->Desc.NumInterfaces; Index++) {
      Interface = Config->Interfaces[Index];
      if (Interface == NULL) {
        continue;
      }
      for (SetIndex = 0; SetIndex < Interface->NumOfSetting; SetIndex++) {
        if (Interface->Settings[SetIndex] != NULL) {
          UsbFreeInterfaceDesc (Interface->Settings[SetIndex]);
        }
      }
      FreePool (Interface);
    }
    FreePool (Config->Interfaces);
  }
  FreePool (Config);
}