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

@@ -339,34 +339,6 @@ InternalSwitchStack (
);
/**
Worker function that locates the Node in the List.
By searching the List, finds the location of the Node in List. At the same time,
verifies the validity of this list.
If List is NULL, then ASSERT().
If List->ForwardLink is NULL, then ASSERT().
If List->backLink is NULL, then ASSERT().
If Node is NULL, then ASSERT();
If PcdMaximumLinkedListLength is not zero, and prior to insertion the number
of nodes in ListHead, including the ListHead node, is greater than or
equal to PcdMaximumLinkedListLength, then ASSERT().
@param List A pointer to a node in a linked list.
@param Node A pointer to one nod.
@retval TRUE Node is in List.
@retval FALSE Node isn't in List, or List is invalid.
**/
BOOLEAN
EFIAPI
IsNodeInList (
IN CONST LIST_ENTRY *List,
IN CONST LIST_ENTRY *Node
);
/**
Worker function that returns a bit field from Operand.