/* Take the passed in Buffer of size ElementSize and grow the buffer by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes. Copy the current data in Buffer to the new version of Buffer and free the old version of buffer. */
EFI_STATUS ConSplitterGrowBuffer(IN UINTN ElementSize, IN OUT UINTN *Count, IN OUT VOID **Buffer)
/* Take the passed in Buffer of size ElementSize and grow the buffer by CONSOLE_SPLITTER_ALLOC_UNIT * ElementSize bytes. Copy the current data in Buffer to the new version of Buffer and free the old version of buffer. */
EFI_STATUS ConSplitterGrowBuffer(IN UINTN ElementSize, IN OUT UINTN *Count, IN OUT VOID **Buffer)
{
  VOID  *Ptr;
  Ptr = ReallocatePool (
          ElementSize * (*Count),
          ElementSize * ((*Count) + CONSOLE_SPLITTER_ALLOC_UNIT),
          *Buffer
          );
  if (Ptr == NULL) {
    return EFI_OUT_OF_RESOURCES;
  }
  *Count += CONSOLE_SPLITTER_ALLOC_UNIT;
  *Buffer = Ptr;
  return EFI_SUCCESS;
}