From e98d4b4502ba75e8e206984e5d819aee0af3d670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20Iv=C4=83ncescu?= Date: Wed, 20 Feb 2019 12:04:59 +0000 Subject: [PATCH] comctl32/listbox: Move the item data removal into a separate function. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Gabriel Ivăncescu Signed-off-by: Huw Davies Signed-off-by: Alexandre Julliard --- dlls/comctl32/listbox.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/dlls/comctl32/listbox.c b/dlls/comctl32/listbox.c index 44e3b1c7d17..e89d25761e7 100644 --- a/dlls/comctl32/listbox.c +++ b/dlls/comctl32/listbox.c @@ -200,6 +200,15 @@ static void insert_item_data(LB_DESCR *descr, UINT index, WCHAR *str, ULONG_PTR item->selected = FALSE; } +static void remove_item_data(LB_DESCR *descr, UINT index) +{ + LB_ITEMDATA *item; + + item = descr->items + index; + if (index < descr->nb_items) + memmove(item, item + 1, (descr->nb_items - index) * sizeof(LB_ITEMDATA)); +} + /*********************************************************************** * LISTBOX_GetCurrentPageSize * @@ -1699,8 +1708,6 @@ static void LISTBOX_DeleteItem( LB_DESCR *descr, INT index ) */ static LRESULT LISTBOX_RemoveItem( LB_DESCR *descr, INT index ) { - LB_ITEMDATA *item; - if ((index < 0) || (index >= descr->nb_items)) return LB_ERR; /* We need to invalidate the original rect instead of the updated one. */ @@ -1713,15 +1720,9 @@ static LRESULT LISTBOX_RemoveItem( LB_DESCR *descr, INT index ) } descr->nb_items--; LISTBOX_DeleteItem( descr, index ); + remove_item_data(descr, index); - /* Remove the item */ - - item = &descr->items[index]; - if (index < descr->nb_items) - RtlMoveMemory( item, item + 1, - (descr->nb_items - index) * sizeof(LB_ITEMDATA) ); if (descr->anchor_item == descr->nb_items) descr->anchor_item--; - resize_storage(descr, descr->nb_items); /* Repaint the items */