=?UTF-8?Q?Gabriel=20Iv=C4=83ncescu=20?=: comctl32/listbox: Move the item data insertion into a separate function.

Alexandre Julliard julliard at winehq.org
Wed Feb 20 16:37:00 CST 2019


Module: wine
Branch: master
Commit: bd2cc1342b50adb826e254223bf11c9316d0fb32
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=bd2cc1342b50adb826e254223bf11c9316d0fb32

Author: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Date:   Wed Feb 20 12:04:58 2019 +0000

comctl32/listbox: Move the item data insertion into a separate function.

Signed-off-by: Gabriel Ivăncescu <gabrielopcode at gmail.com>
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/comctl32/listbox.c | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/dlls/comctl32/listbox.c b/dlls/comctl32/listbox.c
index ba8b7ee..44e3b1c 100644
--- a/dlls/comctl32/listbox.c
+++ b/dlls/comctl32/listbox.c
@@ -186,6 +186,20 @@ static void set_item_selected_state(LB_DESCR *descr, UINT index, BOOL state)
         descr->items[index].selected = state;
 }
 
+static void insert_item_data(LB_DESCR *descr, UINT index, WCHAR *str, ULONG_PTR data)
+{
+    LB_ITEMDATA *item;
+
+    item = descr->items + index;
+    if (index < descr->nb_items)
+        memmove(item + 1, item, (descr->nb_items - index) * sizeof(LB_ITEMDATA));
+
+    item->str      = str;
+    item->data     = HAS_STRINGS(descr) ? 0 : data;
+    item->height   = 0;
+    item->selected = FALSE;
+}
+
 /***********************************************************************
  *           LISTBOX_GetCurrentPageSize
  *
@@ -1563,23 +1577,13 @@ static void LISTBOX_MoveCaret( LB_DESCR *descr, INT index, BOOL fully_visible )
 static LRESULT LISTBOX_InsertItem( LB_DESCR *descr, INT index,
                                    LPWSTR str, ULONG_PTR data )
 {
-    LB_ITEMDATA *item;
     INT oldfocus = descr->focus_item;
 
     if (index == -1) index = descr->nb_items;
     else if ((index < 0) || (index > descr->nb_items)) return LB_ERR;
     if (!resize_storage(descr, descr->nb_items + 1)) return LB_ERR;
 
-    /* Insert the item structure */
-
-    item = &descr->items[index];
-    if (index < descr->nb_items)
-        RtlMoveMemory( item + 1, item,
-                       (descr->nb_items - index) * sizeof(LB_ITEMDATA) );
-    item->str      = str;
-    item->data     = HAS_STRINGS(descr) ? 0 : data;
-    item->height   = 0;
-    item->selected = FALSE;
+    insert_item_data(descr, index, str, data);
     descr->nb_items++;
 
     /* Get item height */




More information about the wine-cvs mailing list