/* Clears out all files from the Fv buffer in memory */
EFI_STATUS FvBufDuplicate(IN VOID *SourceFv, IN OUT VOID **DestinationFv)
/* Clears out all files from the Fv buffer in memory */
EFI_STATUS FvBufDuplicate(IN VOID *SourceFv, IN OUT VOID **DestinationFv)
{
  EFI_STATUS Status;
  UINTN size;
  if (DestinationFv == NULL) {
    return EFI_INVALID_PARAMETER;
  }
  Status = FvBufGetSize (SourceFv, &size);
  if (EFI_ERROR (Status)) {
    return Status;
  }
  if (*DestinationFv == NULL) {
    *DestinationFv = CommonLibBinderAllocate (size);
    if (*DestinationFv == NULL) {
      return EFI_OUT_OF_RESOURCES;
    }
  }
  CommonLibBinderCopyMem (*DestinationFv, SourceFv, size);
  return EFI_SUCCESS;
}