]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1) Add new BaseLib API GetPreviousNode()
authormdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 21 Nov 2009 21:57:11 +0000 (21:57 +0000)
committermdkinney <mdkinney@6f19259b-4bc3-4df7-8a09-765794883524>
Sat, 21 Nov 2009 21:57:11 +0000 (21:57 +0000)
2) Clarify comment for the value returned from GetNextNode() if the end of list is reached.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9464 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Include/Library/BaseLib.h
MdePkg/Library/BaseLib/LinkedList.c

index 05014a3b6d79f4cbfdbf5c9edd83a7c610a3f3fe..e63831e059c223a084c38b3c4344c83ac6f8f2fa 100644 (file)
@@ -1383,8 +1383,7 @@ GetFirstNode (
   @param  List  A pointer to the head node of a doubly linked list.\r
   @param  Node  A pointer to a node in the doubly linked list.\r
 \r
-  @return Pointer to the next node if one exists. Otherwise a null value which\r
-          is actually List is returned.\r
+  @return Pointer to the next node if one exists. Otherwise List is returned.\r
 \r
 **/\r
 LIST_ENTRY *\r
@@ -1394,7 +1393,36 @@ GetNextNode (
   IN      CONST LIST_ENTRY          *Node\r
   );\r
 \r
+  \r
+/**\r
+  Retrieves the previous node of a doubly linked list.\r
\r
+  Returns the node of a doubly linked list that precedes Node.  \r
+  List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r
+  or InitializeListHead().  If List is empty, then List is returned.\r
\r
+  If List is NULL, then ASSERT().\r
+  If Node is NULL, then ASSERT().\r
+  If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
+  InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
+  PcdMaximumLinkedListLenth nodes, then ASSERT().\r
+  If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
\r
+  @param  List  A pointer to the head node of a doubly linked list.\r
+  @param  Node  A pointer to a node in the doubly linked list.\r
\r
+  @return Pointer to the previous node if one exists. Otherwise List is returned.\r
\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GetPreviousNode (\r
+  IN      CONST LIST_ENTRY          *List,\r
+  IN      CONST LIST_ENTRY          *Node\r
+  );\r
 \r
+  \r
 /**\r
   Checks to see if a doubly linked list is empty or not.\r
 \r
index 3ff582a978c706276d3c540ea560517a8c21bb7e..0c811b0bff06b53824932a233aa3b19ae3b92cb0 100644 (file)
@@ -276,8 +276,7 @@ GetFirstNode (
   @param  List  A pointer to the head node of a doubly linked list.\r
   @param  Node  A pointer to a node in the doubly linked list.\r
 \r
-  @return Pointer to the next node if one exists. Otherwise a null value which\r
-          is actually List is returned.\r
+  @return Pointer to the next node if one exists. Otherwise List is returned.\r
 \r
 **/\r
 LIST_ENTRY *\r
@@ -295,6 +294,42 @@ GetNextNode (
   return Node->ForwardLink;\r
 }\r
 \r
+/**\r
+  Retrieves the previous node of a doubly linked list.\r
\r
+  Returns the node of a doubly linked list that precedes Node.  \r
+  List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r
+  or InitializeListHead().  If List is empty, then List is returned.\r
\r
+  If List is NULL, then ASSERT().\r
+  If Node is NULL, then ASSERT().\r
+  If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
+  InitializeListHead(), then ASSERT().\r
+  If PcdMaximumLinkedListLenth is not zero, and List contains more than\r
+  PcdMaximumLinkedListLenth nodes, then ASSERT().\r
+  If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
\r
+  @param  List  A pointer to the head node of a doubly linked list.\r
+  @param  Node  A pointer to a node in the doubly linked list.\r
\r
+  @return Pointer to the previous node if one exists. Otherwise List is returned.\r
\r
+**/\r
+LIST_ENTRY *\r
+EFIAPI\r
+GetPreviousNode (\r
+  IN      CONST LIST_ENTRY          *List,\r
+  IN      CONST LIST_ENTRY          *Node\r
+  )\r
+{\r
+  //\r
+  // ASSERT List not too long and Node is one of the nodes of List\r
+  //\r
+  ASSERT (InternalBaseLibIsNodeInList (List, Node, TRUE));\r
\r
+  return Node->BackLink;\r
+}\r
+\r
 /**\r
   Checks to see if a doubly linked list is empty or not.\r
 \r