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
25ad6d75
Commit
25ad6d75
authored
Nov 22, 2022
by
Nikolay Sivov
Committed by
Alexandre Julliard
Nov 22, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comctl32/treeview: Use CRT allocation functions.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
parent
fca468be
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
24 deletions
+21
-24
treeview.c
dlls/comctl32/treeview.c
+21
-24
No files found.
dlls/comctl32/treeview.c
View file @
25ad6d75
...
...
@@ -60,7 +60,6 @@
#include "vssym32.h"
#include "wine/debug.h"
#include "wine/exception.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
treeview
);
...
...
@@ -549,7 +548,7 @@ TREEVIEW_TVItemFromItem(const TREEVIEW_INFO *infoPtr, UINT mask, TVITEMW *tvItem
if
(
!
infoPtr
->
bNtfUnicode
)
{
tvItem
->
cchTextMax
=
WideCharToMultiByte
(
CP_ACP
,
0
,
item
->
pszText
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
tvItem
->
pszText
=
heap_
alloc
(
tvItem
->
cchTextMax
);
tvItem
->
pszText
=
m
alloc
(
tvItem
->
cchTextMax
);
WideCharToMultiByte
(
CP_ACP
,
0
,
item
->
pszText
,
-
1
,
(
LPSTR
)
tvItem
->
pszText
,
tvItem
->
cchTextMax
,
0
,
0
);
}
else
...
...
@@ -590,8 +589,8 @@ TREEVIEW_SendTreeviewNotify(const TREEVIEW_INFO *infoPtr, UINT code, UINT action
ret
=
TREEVIEW_SendRealNotify
(
infoPtr
,
code
,
&
nmhdr
.
hdr
);
if
(
!
infoPtr
->
bNtfUnicode
)
{
heap_
free
(
nmhdr
.
itemOld
.
pszText
);
heap_
free
(
nmhdr
.
itemNew
.
pszText
);
free
(
nmhdr
.
itemOld
.
pszText
);
free
(
nmhdr
.
itemNew
.
pszText
);
}
return
ret
;
}
...
...
@@ -690,7 +689,7 @@ TREEVIEW_BeginLabelEditNotify(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *editI
ret
=
TREEVIEW_SendRealNotify
(
infoPtr
,
TVN_BEGINLABELEDITW
,
&
tvdi
.
hdr
);
if
(
!
infoPtr
->
bNtfUnicode
)
heap_
free
(
tvdi
.
item
.
pszText
);
free
(
tvdi
.
item
.
pszText
);
return
ret
;
}
...
...
@@ -736,7 +735,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
(
LPSTR
)
callback
.
item
.
pszText
,
-
1
,
NULL
,
0
);
buflen
=
max
((
len
)
*
sizeof
(
WCHAR
),
TEXT_CALLBACK_SIZE
);
newText
=
heap_
realloc
(
item
->
pszText
,
buflen
);
newText
=
realloc
(
item
->
pszText
,
buflen
);
TRACE
(
"returned str %s, len=%d, buflen=%d
\n
"
,
debugstr_a
((
LPSTR
)
callback
.
item
.
pszText
),
len
,
buflen
);
...
...
@@ -754,7 +753,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
else
{
int
len
=
max
(
lstrlenW
(
callback
.
item
.
pszText
)
+
1
,
TEXT_CALLBACK_SIZE
);
LPWSTR
newText
=
heap_
realloc
(
item
->
pszText
,
len
*
sizeof
(
WCHAR
));
LPWSTR
newText
=
realloc
(
item
->
pszText
,
len
*
sizeof
(
WCHAR
));
TRACE
(
"returned wstr %s, len=%d
\n
"
,
debugstr_w
(
callback
.
item
.
pszText
),
len
);
...
...
@@ -777,7 +776,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
(
LPSTR
)
callback
.
item
.
pszText
,
-
1
,
NULL
,
0
);
buflen
=
max
((
len
)
*
sizeof
(
WCHAR
),
TEXT_CALLBACK_SIZE
);
newText
=
heap_
alloc
(
buflen
);
newText
=
m
alloc
(
buflen
);
TRACE
(
"same buffer str %s, len=%d, buflen=%d
\n
"
,
debugstr_a
((
LPSTR
)
callback
.
item
.
pszText
),
len
,
buflen
);
...
...
@@ -790,7 +789,7 @@ TREEVIEW_UpdateDispInfo(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
(
LPSTR
)
callback
.
item
.
pszText
,
-
1
,
item
->
pszText
,
buflen
/
sizeof
(
WCHAR
));
item
->
cchTextMax
=
buflen
/
sizeof
(
WCHAR
);
heap_
free
(
oldText
);
free
(
oldText
);
}
}
}
...
...
@@ -998,7 +997,7 @@ TREEVIEW_UpdateSubTree(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *root)
static
TREEVIEW_ITEM
*
TREEVIEW_AllocateItem
(
const
TREEVIEW_INFO
*
infoPtr
)
{
TREEVIEW_ITEM
*
newItem
=
heap_alloc_zero
(
sizeof
(
*
newItem
));
TREEVIEW_ITEM
*
newItem
=
calloc
(
1
,
sizeof
(
*
newItem
));
if
(
!
newItem
)
return
NULL
;
...
...
@@ -1014,7 +1013,7 @@ TREEVIEW_AllocateItem(const TREEVIEW_INFO *infoPtr)
if
(
DPA_InsertPtr
(
infoPtr
->
items
,
INT_MAX
,
newItem
)
==
-
1
)
{
heap_
free
(
newItem
);
free
(
newItem
);
return
NULL
;
}
...
...
@@ -1039,7 +1038,7 @@ TREEVIEW_FreeItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
infoPtr
->
dropItem
=
NULL
;
if
(
infoPtr
->
insertMarkItem
==
item
)
infoPtr
->
insertMarkItem
=
NULL
;
heap_
free
(
item
);
free
(
item
);
}
...
...
@@ -1133,13 +1132,13 @@ TREEVIEW_DoSetItemT(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
tvItem
->
pszText
,
-
1
,
NULL
,
0
);
/* Allocate new block to make pointer comparison in item_changed() work. */
newText
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
));
newText
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
if
(
newText
==
NULL
)
return
FALSE
;
callbackClear
|=
TVIF_TEXT
;
heap_
free
(
item
->
pszText
);
free
(
item
->
pszText
);
item
->
pszText
=
newText
;
item
->
cchTextMax
=
len
;
if
(
isW
)
...
...
@@ -1153,7 +1152,7 @@ TREEVIEW_DoSetItemT(const TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item,
else
{
callbackSet
|=
TVIF_TEXT
;
item
->
pszText
=
heap_
realloc
(
item
->
pszText
,
TEXT_CALLBACK_SIZE
*
sizeof
(
WCHAR
));
item
->
pszText
=
realloc
(
item
->
pszText
,
TEXT_CALLBACK_SIZE
*
sizeof
(
WCHAR
));
item
->
cchTextMax
=
TEXT_CALLBACK_SIZE
;
TRACE
(
"setting callback, item %p
\n
"
,
item
);
}
...
...
@@ -1498,7 +1497,7 @@ TREEVIEW_RemoveItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item)
infoPtr
->
uNumItems
--
;
if
(
item
->
pszText
!=
LPSTR_TEXTCALLBACKW
)
heap_
free
(
item
->
pszText
);
free
(
item
->
pszText
);
TREEVIEW_FreeItem
(
infoPtr
,
item
);
}
...
...
@@ -4086,7 +4085,7 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel)
if
(
!
infoPtr
->
bNtfUnicode
)
{
DWORD
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
tvdi
.
item
.
pszText
,
-
1
,
NULL
,
0
);
newText
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
));
newText
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
MultiByteToWideChar
(
CP_ACP
,
0
,
(
LPSTR
)
tvdi
.
item
.
pszText
,
-
1
,
newText
,
len
);
iLength
=
len
-
1
;
}
...
...
@@ -4095,11 +4094,11 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel)
if
(
lstrcmpW
(
newText
,
editedItem
->
pszText
)
!=
0
)
{
WCHAR
*
ptr
=
heap_
realloc
(
editedItem
->
pszText
,
sizeof
(
WCHAR
)
*
(
iLength
+
1
));
WCHAR
*
ptr
=
realloc
(
editedItem
->
pszText
,
sizeof
(
WCHAR
)
*
(
iLength
+
1
));
if
(
ptr
==
NULL
)
{
ERR
(
"OutOfMemory, cannot allocate space for label
\n
"
);
if
(
newText
!=
tmpText
)
heap_
free
(
newText
);
if
(
newText
!=
tmpText
)
free
(
newText
);
DestroyWindow
(
infoPtr
->
hwndEdit
);
infoPtr
->
hwndEdit
=
0
;
infoPtr
->
editItem
=
NULL
;
...
...
@@ -4113,7 +4112,7 @@ TREEVIEW_EndEditLabelNow(TREEVIEW_INFO *infoPtr, BOOL bCancel)
TREEVIEW_ComputeTextWidth
(
infoPtr
,
editedItem
,
0
);
}
}
if
(
newText
!=
tmpText
)
heap_
free
(
newText
);
if
(
newText
!=
tmpText
)
free
(
newText
);
}
ShowWindow
(
infoPtr
->
hwndEdit
,
SW_HIDE
);
...
...
@@ -5135,9 +5134,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
TRACE
(
"wnd %p, style %#lx
\n
"
,
hwnd
,
GetWindowLongW
(
hwnd
,
GWL_STYLE
));
infoPtr
=
heap_alloc_zero
(
sizeof
(
TREEVIEW_INFO
));
if
(
infoPtr
==
NULL
)
if
(
!
(
infoPtr
=
calloc
(
1
,
sizeof
(
*
infoPtr
))))
{
ERR
(
"could not allocate info memory!
\n
"
);
return
0
;
...
...
@@ -5260,7 +5257,7 @@ TREEVIEW_Destroy(TREEVIEW_INFO *infoPtr)
DeleteObject
(
infoPtr
->
hUnderlineFont
);
DeleteObject
(
infoPtr
->
hBoldUnderlineFont
);
DestroyWindow
(
infoPtr
->
hwndToolTip
);
heap_
free
(
infoPtr
);
free
(
infoPtr
);
return
0
;
}
...
...
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