Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
ae4199e2
Commit
ae4199e2
authored
Dec 03, 2018
by
Gabriel Ivăncescu
Committed by
Alexandre Julliard
Dec 03, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32/listbox: Store the items array size instead of using HeapSize().
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
8700ef56
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
listbox.c
dlls/user32/listbox.c
+14
-7
No files found.
dlls/user32/listbox.c
View file @
ae4199e2
...
...
@@ -67,6 +67,7 @@ typedef struct
INT
height
;
/* Window height */
LB_ITEMDATA
*
items
;
/* Array of items */
INT
nb_items
;
/* Number of items */
UINT
items_size
;
/* Total number of allocated items in the array */
INT
top_item
;
/* Top visible item */
INT
selected_item
;
/* Selected item */
INT
focus_item
;
/* Item that has the focus */
...
...
@@ -713,7 +714,7 @@ static LRESULT LISTBOX_InitStorage( LB_DESCR *descr, INT nb_items )
nb_items
+=
LB_ARRAY_GRANULARITY
-
1
;
nb_items
-=
(
nb_items
%
LB_ARRAY_GRANULARITY
);
if
(
descr
->
items
)
{
nb_items
+=
HeapSize
(
GetProcessHeap
(),
0
,
descr
->
items
)
/
sizeof
(
*
item
)
;
nb_items
+=
descr
->
items_size
;
item
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
descr
->
items
,
nb_items
*
sizeof
(
LB_ITEMDATA
));
}
...
...
@@ -727,6 +728,7 @@ static LRESULT LISTBOX_InitStorage( LB_DESCR *descr, INT nb_items )
SEND_NOTIFICATION
(
descr
,
LBN_ERRSPACE
);
return
LB_ERRSPACE
;
}
descr
->
items_size
=
nb_items
;
descr
->
items
=
item
;
return
LB_OKAY
;
}
...
...
@@ -1537,12 +1539,10 @@ static LRESULT LISTBOX_InsertItem( LB_DESCR *descr, INT index,
if
(
index
==
-
1
)
index
=
descr
->
nb_items
;
else
if
((
index
<
0
)
||
(
index
>
descr
->
nb_items
))
return
LB_ERR
;
if
(
!
descr
->
items
)
max_items
=
0
;
else
max_items
=
HeapSize
(
GetProcessHeap
(),
0
,
descr
->
items
)
/
sizeof
(
*
item
);
if
(
descr
->
nb_items
==
max_items
)
if
(
descr
->
nb_items
==
descr
->
items_size
)
{
/* We need to grow the array */
max_items
+=
LB_ARRAY_GRANULARITY
;
max_items
=
descr
->
items_size
+
LB_ARRAY_GRANULARITY
;
if
(
descr
->
items
)
item
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
descr
->
items
,
max_items
*
sizeof
(
LB_ITEMDATA
)
);
...
...
@@ -1554,6 +1554,7 @@ static LRESULT LISTBOX_InsertItem( LB_DESCR *descr, INT index,
SEND_NOTIFICATION
(
descr
,
LBN_ERRSPACE
);
return
LB_ERRSPACE
;
}
descr
->
items_size
=
max_items
;
descr
->
items
=
item
;
}
...
...
@@ -1713,13 +1714,17 @@ static LRESULT LISTBOX_RemoveItem( LB_DESCR *descr, INT index )
/* Shrink the item array if possible */
max_items
=
HeapSize
(
GetProcessHeap
(),
0
,
descr
->
items
)
/
sizeof
(
LB_ITEMDATA
)
;
max_items
=
descr
->
items_size
;
if
(
descr
->
nb_items
<
max_items
-
2
*
LB_ARRAY_GRANULARITY
)
{
max_items
-=
LB_ARRAY_GRANULARITY
;
item
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
descr
->
items
,
max_items
*
sizeof
(
LB_ITEMDATA
)
);
if
(
item
)
descr
->
items
=
item
;
if
(
item
)
{
descr
->
items_size
=
max_items
;
descr
->
items
=
item
;
}
}
/* Repaint the items */
...
...
@@ -1765,6 +1770,7 @@ static void LISTBOX_ResetContent( LB_DESCR *descr )
descr
->
selected_item
=
-
1
;
descr
->
focus_item
=
0
;
descr
->
anchor_item
=
-
1
;
descr
->
items_size
=
0
;
descr
->
items
=
NULL
;
}
...
...
@@ -2506,6 +2512,7 @@ static BOOL LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc )
descr
->
width
=
rect
.
right
-
rect
.
left
;
descr
->
height
=
rect
.
bottom
-
rect
.
top
;
descr
->
items
=
NULL
;
descr
->
items_size
=
0
;
descr
->
nb_items
=
0
;
descr
->
top_item
=
0
;
descr
->
selected_item
=
-
1
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment