)\r
{\r
BUFFER_LIST *Node;\r
+ BUFFER_LIST *Walker;\r
+ UINT16 MaxHistoryCmdCount;\r
+ UINT16 Count;\r
+ \r
+ Count = 0;\r
+ MaxHistoryCmdCount = PcdGet16(PcdShellMaxHistoryCommandCount);\r
+ \r
+ if (MaxHistoryCmdCount == 0) {\r
+ return ;\r
+ }\r
+\r
\r
Node = AllocateZeroPool(sizeof(BUFFER_LIST));\r
ASSERT(Node != NULL);\r
Node->Buffer = AllocateCopyPool(StrSize(Buffer), Buffer);\r
ASSERT(Node->Buffer != NULL);\r
\r
- InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);\r
+ for ( Walker = (BUFFER_LIST*)GetFirstNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link)\r
+ ; !IsNull(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Walker->Link)\r
+ ; Walker = (BUFFER_LIST*)GetNextNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Walker->Link)\r
+ ){\r
+ Count++;\r
+ }\r
+ if (Count < MaxHistoryCmdCount){\r
+ InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);\r
+ } else {\r
+ Walker = (BUFFER_LIST*)GetFirstNode(&ShellInfoObject.ViewingSettings.CommandHistory.Link);\r
+ RemoveEntryList(&Walker->Link);\r
+ if (Walker->Buffer != NULL) {\r
+ FreePool(Walker->Buffer);\r
+ }\r
+ FreePool(Walker);\r
+ InsertTailList(&ShellInfoObject.ViewingSettings.CommandHistory.Link, &Node->Link);\r
+ }\r
}\r
\r
/**\r