Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
6d58a948
Commit
6d58a948
authored
Nov 13, 2022
by
Alex Henrie
Committed by
Alexandre Julliard
Nov 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
user32: Use standard C functions for memory allocation in combo.c.
The big win here is getting rid of the reimplementation of strdup.
parent
a17f55f2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
28 deletions
+16
-28
combo.c
dlls/user32/combo.c
+16
-28
No files found.
dlls/user32/combo.c
View file @
6d58a948
...
...
@@ -23,6 +23,7 @@
#define OEMRESOURCE
#include <stdlib.h>
#include "user_private.h"
#include "controls.h"
#include "wine/debug.h"
...
...
@@ -112,7 +113,7 @@ static LRESULT COMBO_NCCreate(HWND hwnd, LONG style)
{
LPHEADCOMBO
lphc
;
if
(
COMBO_Init
()
&&
(
lphc
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
HEADCOMBO
)
))
)
if
(
COMBO_Init
()
&&
(
lphc
=
calloc
(
1
,
sizeof
(
HEADCOMBO
)
))
)
{
lphc
->
self
=
hwnd
;
SetWindowLongPtrW
(
hwnd
,
0
,
(
LONG_PTR
)
lphc
);
...
...
@@ -154,7 +155,7 @@ static LRESULT COMBO_NCDestroy( LPHEADCOMBO lphc )
NtUserDestroyWindow
(
lphc
->
hWndLBox
);
SetWindowLongPtrW
(
lphc
->
self
,
0
,
0
);
HeapFree
(
GetProcessHeap
(),
0
,
lphc
);
free
(
lphc
);
}
return
0
;
}
...
...
@@ -641,7 +642,7 @@ static void CBPaintText(
size
=
SendMessageW
(
lphc
->
hWndLBox
,
LB_GETTEXTLEN
,
id
,
0
);
if
(
size
==
LB_ERR
)
FIXME
(
"LB_ERR probably not handled yet
\n
"
);
if
(
(
pText
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
size
+
1
)
*
sizeof
(
WCHAR
)))
)
if
(
(
pText
=
malloc
(
(
size
+
1
)
*
sizeof
(
WCHAR
)))
)
{
/* size from LB_GETTEXTLEN may be too large, from LB_GETTEXT is accurate */
size
=
SendMessageW
(
lphc
->
hWndLBox
,
LB_GETTEXT
,
id
,
(
LPARAM
)
pText
);
...
...
@@ -736,7 +737,7 @@ static void CBPaintText(
if
(
!
hdc_paint
)
NtUserReleaseDC
(
lphc
->
self
,
hdc
);
}
HeapFree
(
GetProcessHeap
(),
0
,
pText
);
free
(
pText
);
}
/***********************************************************************
...
...
@@ -830,7 +831,7 @@ static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect )
length
=
SendMessageW
(
lphc
->
hWndEdit
,
WM_GETTEXTLENGTH
,
0
,
0
);
if
(
length
>
0
)
pText
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
length
+
1
)
*
sizeof
(
WCHAR
));
pText
=
malloc
(
(
length
+
1
)
*
sizeof
(
WCHAR
));
TRACE
(
"
\t
edit text length %i
\n
"
,
length
);
...
...
@@ -838,7 +839,7 @@ static INT CBUpdateLBox( LPHEADCOMBO lphc, BOOL bSelect )
{
GetWindowTextW
(
lphc
->
hWndEdit
,
pText
,
length
+
1
);
idx
=
SendMessageW
(
lphc
->
hWndLBox
,
LB_FINDSTRING
,
-
1
,
(
LPARAM
)
pText
);
HeapFree
(
GetProcessHeap
(),
0
,
pText
);
free
(
pText
);
}
SendMessageW
(
lphc
->
hWndLBox
,
LB_SETCURSEL
,
bSelect
?
idx
:
-
1
,
0
);
...
...
@@ -867,7 +868,7 @@ static void CBUpdateEdit( LPHEADCOMBO lphc , INT index )
length
=
SendMessageW
(
lphc
->
hWndLBox
,
LB_GETTEXTLEN
,
index
,
0
);
if
(
length
!=
LB_ERR
)
{
if
(
(
pText
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
length
+
1
)
*
sizeof
(
WCHAR
)))
)
if
(
(
pText
=
malloc
(
(
length
+
1
)
*
sizeof
(
WCHAR
)))
)
{
SendMessageW
(
lphc
->
hWndLBox
,
LB_GETTEXT
,
index
,
(
LPARAM
)
pText
);
}
...
...
@@ -884,7 +885,7 @@ static void CBUpdateEdit( LPHEADCOMBO lphc , INT index )
if
(
lphc
->
wState
&
CBF_FOCUSED
)
SendMessageW
(
lphc
->
hWndEdit
,
EM_SETSEL
,
0
,
-
1
);
HeapFree
(
GetProcessHeap
(),
0
,
pText
);
free
(
pText
);
}
/***********************************************************************
...
...
@@ -1295,7 +1296,7 @@ static LRESULT COMBO_GetTextW( LPHEADCOMBO lphc, INT count, LPWSTR buf )
/* 'length' is without the terminating character */
if
(
length
>=
count
)
{
LPWSTR
lpBuffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
length
+
1
)
*
sizeof
(
WCHAR
));
WCHAR
*
lpBuffer
=
malloc
(
(
length
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
lpBuffer
)
goto
error
;
length
=
SendMessageW
(
lphc
->
hWndLBox
,
LB_GETTEXT
,
idx
,
(
LPARAM
)
lpBuffer
);
...
...
@@ -1305,7 +1306,7 @@ static LRESULT COMBO_GetTextW( LPHEADCOMBO lphc, INT count, LPWSTR buf )
lstrcpynW
(
buf
,
lpBuffer
,
count
);
length
=
count
;
}
HeapFree
(
GetProcessHeap
(),
0
,
lpBuffer
);
free
(
lpBuffer
);
}
else
length
=
SendMessageW
(
lphc
->
hWndLBox
,
LB_GETTEXT
,
idx
,
(
LPARAM
)
buf
);
...
...
@@ -1345,7 +1346,7 @@ static LRESULT COMBO_GetTextA( LPHEADCOMBO lphc, INT count, LPSTR buf )
/* 'length' is without the terminating character */
if
(
length
>=
count
)
{
LPSTR
lpBuffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
length
+
1
)
);
char
*
lpBuffer
=
malloc
(
length
+
1
);
if
(
!
lpBuffer
)
goto
error
;
length
=
SendMessageA
(
lphc
->
hWndLBox
,
LB_GETTEXT
,
idx
,
(
LPARAM
)
lpBuffer
);
...
...
@@ -1355,7 +1356,7 @@ static LRESULT COMBO_GetTextA( LPHEADCOMBO lphc, INT count, LPSTR buf )
lstrcpynA
(
buf
,
lpBuffer
,
count
);
length
=
count
;
}
HeapFree
(
GetProcessHeap
(),
0
,
lpBuffer
);
free
(
lpBuffer
);
}
else
length
=
SendMessageA
(
lphc
->
hWndLBox
,
LB_GETTEXT
,
idx
,
(
LPARAM
)
buf
);
...
...
@@ -1678,19 +1679,6 @@ static LRESULT COMBO_GetComboBoxInfo(const HEADCOMBO *lphc, COMBOBOXINFO *pcbi)
return
TRUE
;
}
static
char
*
strdupA
(
LPCSTR
str
)
{
char
*
ret
;
DWORD
len
;
if
(
!
str
)
return
NULL
;
len
=
strlen
(
str
);
ret
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
+
1
);
memcpy
(
ret
,
str
,
len
+
1
);
return
ret
;
}
/***********************************************************************
* ComboWndProc_common
*/
...
...
@@ -1927,18 +1915,18 @@ LRESULT ComboWndProc_common( HWND hwnd, UINT message, WPARAM wParam, LPARAM lPar
LRESULT
ret
;
if
(
lphc
->
dwStyle
&
CBS_LOWERCASE
)
{
string
=
strdup
A
((
LPSTR
)
lParam
);
string
=
strdup
((
char
*
)
lParam
);
CharLowerA
(
string
);
}
else
if
(
lphc
->
dwStyle
&
CBS_UPPERCASE
)
{
string
=
strdup
A
((
LPSTR
)
lParam
);
string
=
strdup
((
char
*
)
lParam
);
CharUpperA
(
string
);
}
ret
=
SendMessageA
(
lphc
->
hWndLBox
,
LB_ADDSTRING
,
0
,
string
?
(
LPARAM
)
string
:
lParam
);
HeapFree
(
GetProcessHeap
(),
0
,
string
);
free
(
string
);
return
ret
;
}
case
CB_INSERTSTRING
:
...
...
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