Can you make this into a PCD? That would be cleaner. I would like patchable be one option.
> -----Original Message----- > From: Qiu, Shumin > Sent: Monday, December 21, 2015 7:19 AM > To: edk2-devel@lists.01.org > Cc: Qiu, Shumin <shumin....@intel.com>; Carsey, Jaben > <jaben.car...@intel.com>; Ni, Ruiyu <ruiyu...@intel.com> > Subject: [PATCH v2 2/4] ShellPkg: Refine the code logic of 'command history'. > Importance: High > > Add the macro MAX_HISTORY_COMMANDS_COUNT to indicate the max count > of history commands. > > Cc: Jaben Carsey <jaben.car...@intel.com> > Cc: Ruiyu Ni <ruiyu...@intel.com> > Contributed-under: TianoCore Contribution Agreement 1.0 > Signed-off-by: Qiu Shumin <shumin....@intel.com> > Reviewed-by: Ruiyu Ni <ruiyu...@intel.com> > --- > ShellPkg/Application/Shell/Shell.c | 24 +++++++++++++++++++++++- > ShellPkg/Application/Shell/Shell.h | 2 ++ > 2 files changed, 25 insertions(+), 1 deletion(-) > > diff --git a/ShellPkg/Application/Shell/Shell.c > b/ShellPkg/Application/Shell/Shell.c > index 3606322..be97879 100644 > --- a/ShellPkg/Application/Shell/Shell.c > +++ b/ShellPkg/Application/Shell/Shell.c > @@ -1288,13 +1288,35 @@ AddLineToCommandHistory(ble > ) > { > BUFFER_LIST *Node; > + BUFFER_LIST *Walker; > + UINT8 MaxHistoryCmdCount; > + UINT8 Count; > + > + Count = 0; > + MaxHistoryCmdCount = MAX_HISTORY_COMMANDS_COUNT; > > Node = AllocateZeroPool(sizeof(BUFFER_LIST)); > ASSERT(Node != NULL); > Node->Buffer = AllocateCopyPool(StrSize(Buffer), Buffer); > ASSERT(Node->Buffer != NULL); > > - InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, > &Node->Link); > + for ( Walker = > (BUFFER_LIST*)GetFirstNode(&ShellInfoObject.ViewingSettings.CommandHistor > y.Link) > + ; !IsNull(&ShellInfoObject.ViewingSettings.CommandHistory.Link, > &Walker- > >Link) > + ; Walker = > (BUFFER_LIST*)GetNextNode(&ShellInfoObject.ViewingSettings.CommandHisto > ry.Link, &Walker->Link) > + ){ > + Count++; > + } > + if (Count < MaxHistoryCmdCount){ > + InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, > &Node->Link); > + } else { > + Walker = > (BUFFER_LIST*)GetFirstNode(&ShellInfoObject.ViewingSettings.CommandHistor > y.Link); > + RemoveEntryList(&Walker->Link); > + if (Walker->Buffer != NULL) { > + FreePool(Walker->Buffer); > + } > + FreePool(Walker); > + InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, > &Node->Link); > + } > } > > /** > diff --git a/ShellPkg/Application/Shell/Shell.h > b/ShellPkg/Application/Shell/Shell.h > index 5726320..d5d5878 100644 > --- a/ShellPkg/Application/Shell/Shell.h > +++ b/ShellPkg/Application/Shell/Shell.h > @@ -124,6 +124,8 @@ typedef struct { > > extern SHELL_INFO ShellInfoObject; > > +#define MAX_HISTORY_COMMANDS_COUNT 32 > + > /** > Converts the command line to it's post-processed form. this replaces > variables > and alias' per UEFI Shell spec. > > -- > 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel