/* This function deletes Image package from a package list node. This is a internal function. */
EFI_STATUS RemoveImagePackages(IN HII_DATABASE_PRIVATE_DATA *Private, IN EFI_HII_HANDLE Handle, IN OUT HII_DATABASE_PACKAGE_LIST_INSTANCE *PackageList)
/* This function deletes Image package from a package list node. This is a internal function. */
EFI_STATUS RemoveImagePackages(IN HII_DATABASE_PRIVATE_DATA *Private, IN EFI_HII_HANDLE Handle, IN OUT HII_DATABASE_PACKAGE_LIST_INSTANCE *PackageList)
{
  HII_IMAGE_PACKAGE_INSTANCE  *Package;
  EFI_STATUS                  Status;
  Package = PackageList->ImagePkg;
  if (Package == NULL) {
    return EFI_SUCCESS;
  }
  Status = InvokeRegisteredFunction (
             Private,
             EFI_HII_DATABASE_NOTIFY_REMOVE_PACK,
             (VOID *)Package,
             EFI_HII_PACKAGE_IMAGES,
             Handle
             );
  if (EFI_ERROR (Status)) {
    return Status;
  }
  PackageList->PackageListHdr.PackageLength -= Package->ImagePkgHdr.Header.Length;
  FreePool (Package->ImageBlock);
  if (Package->PaletteBlock != NULL) {
    FreePool (Package->PaletteBlock);
  }
  FreePool (Package);
  PackageList->ImagePkg = NULL;
  return EFI_SUCCESS;
}