4 #include <winpr/windows.h>
5 #include <winpr/interlocked.h>
9 WINPR_LIST_ENTRY ItemEntry;
11 } LIST_ITEM, *PLIST_ITEM;
13 int TestInterlockedDList(
int argc,
char* argv[])
16 PLIST_ITEM pListItem = NULL;
17 WINPR_PLIST_ENTRY pListHead = NULL;
18 WINPR_PLIST_ENTRY pListEntry = NULL;
21 pListHead = (WINPR_PLIST_ENTRY)winpr_aligned_malloc(
sizeof(WINPR_LIST_ENTRY),
22 MEMORY_ALLOCATION_ALIGNMENT);
26 printf(
"Memory allocation failed.\n");
30 InitializeListHead(pListHead);
32 if (!IsListEmpty(pListHead))
34 printf(
"Expected empty list\n");
40 printf(
"InsertHeadList / RemoveHeadList\n");
42 for (Count = 1; Count <= 10; Count += 1)
45 (PLIST_ITEM)winpr_aligned_malloc(
sizeof(LIST_ITEM), MEMORY_ALLOCATION_ALIGNMENT);
46 pListItem->Signature = Count;
47 InsertHeadList(pListHead, &(pListItem->ItemEntry));
50 for (Count = 10; Count >= 1; Count -= 1)
52 pListEntry = RemoveHeadList(pListHead);
53 pListItem = (PLIST_ITEM)pListEntry;
54 winpr_aligned_free(pListItem);
59 printf(
"InsertTailList / RemoveTailList\n");
61 for (Count = 1; Count <= 10; Count += 1)
64 (PLIST_ITEM)winpr_aligned_malloc(
sizeof(LIST_ITEM), MEMORY_ALLOCATION_ALIGNMENT);
65 pListItem->Signature = Count;
66 InsertTailList(pListHead, &(pListItem->ItemEntry));
69 for (Count = 10; Count >= 1; Count -= 1)
71 pListEntry = RemoveTailList(pListHead);
72 pListItem = (PLIST_ITEM)pListEntry;
73 winpr_aligned_free(pListItem);
76 winpr_aligned_free(pListHead);