Skip to content

Commit 14fafa2

Browse files
committed
Implement RtlInsertHeadList() and RtlInsertTailList()
1 parent ba8b968 commit 14fafa2

File tree

2 files changed

+58
-0
lines changed

2 files changed

+58
-0
lines changed

sdk/xtklib/includes/librtl.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ XTINLINE
2222
VOID
2323
RtlInitializeListHead32(IN PLIST_ENTRY32 ListHead);
2424

25+
XTINLINE
26+
VOID
27+
RtlInsertHeadList(IN OUT PLIST_ENTRY ListHead,
28+
IN OUT PLIST_ENTRY Entry);
29+
30+
XTINLINE
31+
VOID
32+
RtlInsertTailList(IN OUT PLIST_ENTRY ListHead,
33+
IN OUT PLIST_ENTRY Entry);
34+
2535
XTINLINE
2636
BOOLEAN
2737
RtlListEmpty(PLIST_ENTRY ListHead);

sdk/xtklib/rtl/plist.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,54 @@ RtlInitializeListHead32(IN PLIST_ENTRY32 ListHead)
4545
ListHead->Flink = PtrToUlong(ListHead);
4646
}
4747

48+
/**
49+
* This routine inserts an entry at the head of a double linked list.
50+
*
51+
* @param ListHead
52+
* Pointer to the head of the list.
53+
*
54+
* @param Entry
55+
* Pointer to the entry that will be inserted in the list.
56+
*
57+
* @return This routine does not return any value.
58+
*
59+
* @since XT 1.0
60+
*/
61+
XTINLINE
62+
VOID
63+
RtlInsertHeadList(IN OUT PLIST_ENTRY ListHead,
64+
IN OUT PLIST_ENTRY Entry)
65+
{
66+
Entry->Flink = ListHead->Flink;
67+
Entry->Blink = ListHead;
68+
ListHead->Flink->Blink = Entry;
69+
ListHead->Flink = Entry;
70+
}
71+
72+
/**
73+
* This routine inserts an entry at the tail of a double linked list.
74+
*
75+
* @param ListHead
76+
* Pointer to the head of the list.
77+
*
78+
* @param Entry
79+
* Pointer to the entry that will be inserted in the list.
80+
*
81+
* @return This routine does not return any value.
82+
*
83+
* @since XT 1.0
84+
*/
85+
XTINLINE
86+
VOID
87+
RtlInsertTailList(IN OUT PLIST_ENTRY ListHead,
88+
IN OUT PLIST_ENTRY Entry)
89+
{
90+
Entry->Flink = ListHead;
91+
Entry->Blink = ListHead->Blink;
92+
ListHead->Blink->Flink = Entry;
93+
ListHead->Blink = Entry;
94+
}
95+
4896
/**
4997
* Indicates whether a double linked list structure is empty.
5098
*

0 commit comments

Comments
 (0)