MdePkg/BaseLib: Add IsNodeInList() function.

This patch adds IsNodeInList() to BaseLib, which verifies the given
Node is part of the doubly-linked List provided.

V2:
  - Rename "List" to "FirstEntry" and "Node" to "SecondEntry" to clarify that
    "FirstEntry" does not need to be the doubly-linked list's head node.

V3:
  - Remove ASSERTs from IsNodeInList() which are present in
    InternalBaseLibIsListValid().

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Marvin.Haeuser@outlook.com
2017-08-04 03:52:08 +08:00
committed by Liming Gao
parent 8a765da2a3
commit d0aef615ac
3 changed files with 92 additions and 29 deletions

View File

@@ -2868,6 +2868,33 @@ PathCleanUpDirectories(
#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}
/**
Checks whether FirstEntry and SecondEntry are part of the same doubly-linked
list.
If FirstEntry is NULL, then ASSERT().
If FirstEntry->ForwardLink is NULL, then ASSERT().
If FirstEntry->BackLink is NULL, then ASSERT().
If SecondEntry is NULL, then ASSERT();
If PcdMaximumLinkedListLength is not zero, and List contains more than
PcdMaximumLinkedListLength nodes, then ASSERT().
@param FirstEntry A pointer to a node in a linked list.
@param SecondEntry A pointer to the node to locate.
@retval TRUE SecondEntry is in the same doubly-linked list as FirstEntry.
@retval FALSE SecondEntry isn't in the same doubly-linked list as FirstEntry,
or FirstEntry is invalid.
**/
BOOLEAN
EFIAPI
IsNodeInList (
IN CONST LIST_ENTRY *FirstEntry,
IN CONST LIST_ENTRY *SecondEntry
);
/**
Initializes the head node of a doubly linked list, and returns the pointer to
the head node of the doubly linked list.