/* If PatchVariable is NULL, then ASSERT(). If SizeOfBuffer is NULL, then ASSERT(). If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT(). */
VOID* EFIAPI LibPatchPcdSetPtr(OUT VOID *PatchVariable, IN UINTN MaximumDatumSize, IN OUT UINTN *SizeOfBuffer, IN CONST VOID *Buffer)
/* If PatchVariable is NULL, then ASSERT(). If SizeOfBuffer is NULL, then ASSERT(). If SizeOfBuffer > 0 and Buffer is NULL, then ASSERT(). */
VOID* EFIAPI LibPatchPcdSetPtr(OUT VOID *PatchVariable, IN UINTN MaximumDatumSize, IN OUT UINTN *SizeOfBuffer, IN CONST VOID *Buffer)
{
  ASSERT (PatchVariable != NULL);
  ASSERT (SizeOfBuffer  != NULL);
  if (*SizeOfBuffer > 0) {
    ASSERT (Buffer != NULL);
  }
  if ((*SizeOfBuffer > MaximumDatumSize) ||
      (*SizeOfBuffer == MAX_ADDRESS))
  {
    *SizeOfBuffer = MaximumDatumSize;
    return NULL;
  }
  CopyMem (PatchVariable, Buffer, *SizeOfBuffer);
  return (VOID *)Buffer;
}