+ if (PcdGet32 (PcdMaximumLinkedListLength) > 0) {\r
+ Count = 0;\r
+ Ptr = List;\r
+\r
+ //\r
+ // Count the total number of nodes in List.\r
+ // Exit early if the number of nodes in List >= PcdMaximumLinkedListLength\r
+ //\r
+ do {\r
+ Ptr = Ptr->ForwardLink;\r
+ Count++;\r
+ } while ((Ptr != List) && (Count < PcdGet32 (PcdMaximumLinkedListLength)));\r
+\r
+ //\r
+ // return whether linked list is too long\r
+ //\r
+ return (BOOLEAN)(Count < PcdGet32 (PcdMaximumLinkedListLength));\r
+ }\r
+\r
+ return TRUE;\r
+}\r
+\r
+/**\r
+ Checks whether FirstEntry and SecondEntry are part of the same doubly-linked\r
+ list.\r
+\r
+ If FirstEntry is NULL, then ASSERT().\r
+ If FirstEntry->ForwardLink is NULL, then ASSERT().\r
+ If FirstEntry->BackLink is NULL, then ASSERT().\r
+ If SecondEntry is NULL, then ASSERT();\r
+ If PcdMaximumLinkedListLength is not zero, and List contains more than\r
+ PcdMaximumLinkedListLength nodes, then ASSERT().\r
+\r
+ @param FirstEntry A pointer to a node in a linked list.\r
+ @param SecondEntry A pointer to the node to locate.\r
+\r
+ @retval TRUE SecondEntry is in the same doubly-linked list as FirstEntry.\r
+ @retval FALSE SecondEntry isn't in the same doubly-linked list as FirstEntry,\r
+ or FirstEntry is invalid.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+IsNodeInList (\r
+ IN CONST LIST_ENTRY *FirstEntry,\r
+ IN CONST LIST_ENTRY *SecondEntry\r
+ )\r
+{\r
+ UINTN Count;\r
+ CONST LIST_ENTRY *Ptr;\r
+\r
+ //\r
+ // ASSERT List not too long\r
+ //\r
+ ASSERT (InternalBaseLibIsListValid (FirstEntry));\r
+\r
+ ASSERT (SecondEntry != NULL);\r
+\r
+ Count = 0;\r
+ Ptr = FirstEntry;\r