/* Function will replace the current Argc and Argv in the ShellParameters protocol structure with Argv and Argc. The current values are de-allocated and the OldArgv must not be deallocated by the caller. */
VOID RestoreArgcArgv(IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN CHAR16 ***OldArgv, IN UINTN *OldArgc)
/* Function will replace the current Argc and Argv in the ShellParameters protocol structure with Argv and Argc. The current values are de-allocated and the OldArgv must not be deallocated by the caller. */
VOID RestoreArgcArgv(IN OUT EFI_SHELL_PARAMETERS_PROTOCOL *ShellParameters, IN CHAR16 ***OldArgv, IN UINTN *OldArgc)
{
  UINTN  LoopCounter;
  ASSERT (ShellParameters != NULL);
  ASSERT (OldArgv         != NULL);
  ASSERT (OldArgc         != NULL);
  if (ShellParameters->Argv != NULL) {
    for ( LoopCounter = 0
          ; LoopCounter < ShellParameters->Argc
          ; LoopCounter++
          )
    {
      FreePool (ShellParameters->Argv[LoopCounter]);
    }
    FreePool (ShellParameters->Argv);
  }
  ShellParameters->Argv = *OldArgv;
  *OldArgv              = NULL;
  ShellParameters->Argc = *OldArgc;
  *OldArgc              = 0;
}