/* Deleted an image properties record. The function will also call RemoveEntryList() on each code segment and the input ImageRecord before freeing each pool. */
VOID EFIAPI DeleteImagePropertiesRecord(IN IMAGE_PROPERTIES_RECORD *ImageRecord)
/* Deleted an image properties record. The function will also call RemoveEntryList() on each code segment and the input ImageRecord before freeing each pool. */
VOID EFIAPI DeleteImagePropertiesRecord(IN IMAGE_PROPERTIES_RECORD *ImageRecord)
{
  LIST_ENTRY                            *CodeSegmentListHead;
  IMAGE_PROPERTIES_RECORD_CODE_SECTION  *ImageRecordCodeSection;
  if (ImageRecord == NULL) {
    return;
  }
  CodeSegmentListHead = &ImageRecord->CodeSegmentList;
  while (!IsListEmpty (CodeSegmentListHead)) {
    ImageRecordCodeSection = CR (
                               CodeSegmentListHead->ForwardLink,
                               IMAGE_PROPERTIES_RECORD_CODE_SECTION,
                               Link,
                               IMAGE_PROPERTIES_RECORD_CODE_SECTION_SIGNATURE
                               );
    RemoveEntryList (&ImageRecordCodeSection->Link);
    FreePool (ImageRecordCodeSection);
  }
  if (!IsListEmpty (&ImageRecord->Link)) {
    RemoveEntryList (&ImageRecord->Link);
  }
  FreePool (ImageRecord);
}