[SETUPLIB][USETUP] Remove the deprecated GenericListHasSingleEntry() function and...
[reactos.git] / base / setup / lib / utils / genlist.c
index 1795895..79a4895 100644 (file)
@@ -21,17 +21,13 @@ CreateGenericList(VOID)
 {
     PGENERIC_LIST List;
 
-    List = (PGENERIC_LIST)RtlAllocateHeap(ProcessHeap,
-                                          0,
-                                          sizeof(GENERIC_LIST));
+    List = RtlAllocateHeap(ProcessHeap, 0, sizeof(GENERIC_LIST));
     if (List == NULL)
         return NULL;
 
     InitializeListHead(&List->ListHead);
     List->NumOfEntries = 0;
-
     List->CurrentEntry = NULL;
-    List->BackupEntry = NULL;
 
     return List;
 }
@@ -39,7 +35,7 @@ CreateGenericList(VOID)
 VOID
 DestroyGenericList(
     IN OUT PGENERIC_LIST List,
-    IN BOOLEAN FreeUserData)
+    IN BOOLEAN FreeData)
 {
     PGENERIC_LIST_ENTRY ListEntry;
     PLIST_ENTRY Entry;
@@ -51,8 +47,8 @@ DestroyGenericList(
         ListEntry = CONTAINING_RECORD(Entry, GENERIC_LIST_ENTRY, Entry);
 
         /* Release user data */
-        if (FreeUserData && ListEntry->UserData != NULL)
-            RtlFreeHeap(ProcessHeap, 0, ListEntry->UserData);
+        if (FreeData && ListEntry->Data != NULL)
+            RtlFreeHeap(ProcessHeap, 0, ListEntry->Data);
 
         /* Release list entry */
         RtlFreeHeap(ProcessHeap, 0, ListEntry);
@@ -65,29 +61,24 @@ DestroyGenericList(
 BOOLEAN
 AppendGenericListEntry(
     IN OUT PGENERIC_LIST List,
-    IN PCHAR Text,
-    IN PVOID UserData,
+    IN PVOID Data,
     IN BOOLEAN Current)
 {
     PGENERIC_LIST_ENTRY Entry;
 
-    Entry = (PGENERIC_LIST_ENTRY)RtlAllocateHeap(ProcessHeap,
-                                                 0,
-                                                 sizeof(GENERIC_LIST_ENTRY) + strlen(Text));
+    Entry = RtlAllocateHeap(ProcessHeap, 0, sizeof(GENERIC_LIST_ENTRY));
     if (Entry == NULL)
         return FALSE;
 
-    strcpy (Entry->Text, Text);
     Entry->List = List;
-    Entry->UserData = UserData;
+    Entry->Data = Data;
+    Entry->UiData = 0;
 
     InsertTailList(&List->ListHead, &Entry->Entry);
-    List->NumOfEntries++;
+    ++List->NumOfEntries;
 
     if (Current || List->CurrentEntry == NULL)
-    {
         List->CurrentEntry = Entry;
-    }
 
     return TRUE;
 }
@@ -97,7 +88,7 @@ SetCurrentListEntry(
     IN PGENERIC_LIST List,
     IN PGENERIC_LIST_ENTRY Entry)
 {
-    if (Entry->List != List)
+    if (!Entry || (Entry->List != List))
         return;
     List->CurrentEntry = Entry;
 }
@@ -113,11 +104,10 @@ PGENERIC_LIST_ENTRY
 GetFirstListEntry(
     IN PGENERIC_LIST List)
 {
-    PLIST_ENTRY Entry = List->ListHead.Flink;
-
-    if (Entry == &List->ListHead)
+    if (IsListEmpty(&List->ListHead))
         return NULL;
-    return CONTAINING_RECORD(Entry, GENERIC_LIST_ENTRY, Entry);
+
+    return CONTAINING_RECORD(List->ListHead.Flink, GENERIC_LIST_ENTRY, Entry);
 }
 
 PGENERIC_LIST_ENTRY
@@ -128,21 +118,22 @@ GetNextListEntry(
 
     if (Next == &Entry->List->ListHead)
         return NULL;
+
     return CONTAINING_RECORD(Next, GENERIC_LIST_ENTRY, Entry);
 }
 
 PVOID
-GetListEntryUserData(
+GetListEntryData(
     IN PGENERIC_LIST_ENTRY Entry)
 {
-    return Entry->UserData;
+    return Entry->Data;
 }
 
-LPCSTR
-GetListEntryText(
+ULONG_PTR
+GetListEntryUiData(
     IN PGENERIC_LIST_ENTRY Entry)
 {
-    return Entry->Text;
+    return Entry->UiData;
 }
 
 ULONG
@@ -152,30 +143,4 @@ GetNumberOfListEntries(
     return List->NumOfEntries;
 }
 
-VOID
-SaveGenericListState(
-    IN PGENERIC_LIST List)
-{
-    List->BackupEntry = List->CurrentEntry;
-}
-
-VOID
-RestoreGenericListState(
-    IN PGENERIC_LIST List)
-{
-    List->CurrentEntry = List->BackupEntry;
-}
-
-BOOLEAN
-GenericListHasSingleEntry(
-    IN PGENERIC_LIST List)
-{
-    if (!IsListEmpty(&List->ListHead) && List->ListHead.Flink == List->ListHead.Blink)
-        return TRUE;
-
-    /* if both list head pointers (which normally point to the first and last list member, respectively)
-       point to the same entry then it means that there's just a single thing in there, otherwise... false! */
-    return FALSE;
-}
-
 /* EOF */