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
5fe08217
Commit
5fe08217
authored
Nov 27, 2022
by
Alex Henrie
Committed by
Alexandre Julliard
Nov 29, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
comctl32: Use standard C functions for memory allocation in edit.c.
parent
77572690
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
43 deletions
+35
-43
edit.c
dlls/comctl32/edit.c
+35
-43
No files found.
dlls/comctl32/edit.c
View file @
5fe08217
...
...
@@ -44,7 +44,6 @@
#include "uxtheme.h"
#include "vsstyle.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
edit
);
...
...
@@ -239,7 +238,7 @@ static INT EDIT_WordBreakProc(EDITSTATE *es, LPWSTR s, INT index, INT count, INT
memset
(
&
psa
,
0
,
sizeof
(
SCRIPT_ANALYSIS
));
psa
.
eScript
=
SCRIPT_UNDEFINED
;
es
->
logAttr
=
heap_
alloc
(
sizeof
(
SCRIPT_LOGATTR
)
*
get_text_length
(
es
));
es
->
logAttr
=
m
alloc
(
sizeof
(
SCRIPT_LOGATTR
)
*
get_text_length
(
es
));
ScriptBreak
(
es
->
text
,
get_text_length
(
es
),
&
psa
,
es
->
logAttr
);
}
...
...
@@ -477,7 +476,7 @@ static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta
{
/* The buffer has been expanded, create a new line and
insert it into the link list */
LINEDEF
*
new_line
=
heap_alloc_zero
(
sizeof
(
*
new_line
));
LINEDEF
*
new_line
=
calloc
(
1
,
sizeof
(
*
new_line
));
new_line
->
next
=
previous_line
->
next
;
previous_line
->
next
=
new_line
;
current_line
=
new_line
;
...
...
@@ -487,7 +486,7 @@ static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta
{
/* The previous line merged with this line so we delete this extra entry */
previous_line
->
next
=
current_line
->
next
;
heap_
free
(
current_line
);
free
(
current_line
);
current_line
=
previous_line
->
next
;
es
->
line_count
--
;
continue
;
...
...
@@ -587,7 +586,7 @@ static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta
if
(
current_line
->
ssa
)
{
count
=
ScriptString_pcOutChars
(
current_line
->
ssa
);
piDx
=
heap_
alloc
(
sizeof
(
INT
)
*
(
*
count
));
piDx
=
m
alloc
(
sizeof
(
INT
)
*
(
*
count
));
ScriptStringGetLogicalWidths
(
current_line
->
ssa
,
piDx
);
prev
=
current_line
->
net_length
-
1
;
...
...
@@ -597,7 +596,7 @@ static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta
}
while
(
prev
>
0
&&
current_line
->
width
>
fw
);
if
(
prev
<=
0
)
prev
=
1
;
heap_
free
(
piDx
);
free
(
piDx
);
}
else
prev
=
(
fw
/
es
->
char_width
);
...
...
@@ -686,7 +685,7 @@ static void EDIT_BuildLineDefs_ML(EDITSTATE *es, INT istart, INT iend, INT delta
{
pnext
=
current_line
->
next
;
EDIT_InvalidateUniscribeData_linedef
(
current_line
);
heap_
free
(
current_line
);
free
(
current_line
);
current_line
=
pnext
;
es
->
line_count
--
;
}
...
...
@@ -1174,7 +1173,7 @@ static inline void text_buffer_changed(EDITSTATE *es)
{
es
->
text_length
=
(
UINT
)
-
1
;
heap_free
(
es
->
logAttr
);
free
(
es
->
logAttr
);
es
->
logAttr
=
NULL
;
EDIT_InvalidateUniscribeData
(
es
);
}
...
...
@@ -1300,7 +1299,8 @@ static BOOL EDIT_MakeUndoFit(EDITSTATE *es, UINT size)
TRACE
(
"trying to ReAlloc to %d+1
\n
"
,
size
);
alloc_size
=
ROUND_TO_GROW
((
size
+
1
)
*
sizeof
(
WCHAR
));
if
((
new_undo_text
=
HeapReAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
es
->
undo_text
,
alloc_size
)))
{
if
((
new_undo_text
=
realloc
(
es
->
undo_text
,
alloc_size
)))
{
memset
(
new_undo_text
+
es
->
undo_buffer_size
,
0
,
alloc_size
-
es
->
undo_buffer_size
*
sizeof
(
WCHAR
));
es
->
undo_text
=
new_undo_text
;
es
->
undo_buffer_size
=
alloc_size
/
sizeof
(
WCHAR
)
-
1
;
return
TRUE
;
...
...
@@ -2473,7 +2473,7 @@ static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, const WCHAR *lpsz_r
/* there is something to be deleted */
TRACE
(
"deleting stuff.
\n
"
);
bufl
=
e
-
s
;
buf
=
heap_
alloc
((
bufl
+
1
)
*
sizeof
(
WCHAR
));
buf
=
m
alloc
((
bufl
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
buf
)
return
;
memcpy
(
buf
,
es
->
text
+
s
,
bufl
*
sizeof
(
WCHAR
));
buf
[
bufl
]
=
0
;
/* ensure 0 termination */
...
...
@@ -2586,7 +2586,7 @@ static void EDIT_EM_ReplaceSel(EDITSTATE *es, BOOL can_undo, const WCHAR *lpsz_r
EDIT_EM_EmptyUndoBuffer
(
es
);
}
heap_
free
(
buf
);
free
(
buf
);
s
+=
strl
;
...
...
@@ -2831,12 +2831,12 @@ static BOOL EDIT_EM_SetTabStops(EDITSTATE *es, INT count, const INT *tabs)
{
if
(
!
(
es
->
style
&
ES_MULTILINE
))
return
FALSE
;
heap_
free
(
es
->
tabs
);
free
(
es
->
tabs
);
es
->
tabs_count
=
count
;
if
(
!
count
)
es
->
tabs
=
NULL
;
else
{
es
->
tabs
=
heap_
alloc
(
count
*
sizeof
(
INT
));
es
->
tabs
=
m
alloc
(
count
*
sizeof
(
INT
));
memcpy
(
es
->
tabs
,
tabs
,
count
*
sizeof
(
INT
));
}
EDIT_InvalidateUniscribeData
(
es
);
...
...
@@ -2880,7 +2880,7 @@ static BOOL EDIT_EM_Undo(EDITSTATE *es)
ulength
=
lstrlenW
(
es
->
undo_text
);
utext
=
heap_
alloc
((
ulength
+
1
)
*
sizeof
(
WCHAR
));
utext
=
m
alloc
((
ulength
+
1
)
*
sizeof
(
WCHAR
));
lstrcpyW
(
utext
,
es
->
undo_text
);
...
...
@@ -2894,7 +2894,7 @@ static BOOL EDIT_EM_Undo(EDITSTATE *es)
/* send the notification after the selection start and end are set */
if
(
!
notify_parent
(
es
,
EN_CHANGE
))
return
TRUE
;
EDIT_EM_ScrollCaret
(
es
);
heap_
free
(
utext
);
free
(
utext
);
TRACE
(
"after UNDO:insertion length = %d, deletion buffer = %s
\n
"
,
es
->
undo_insert_count
,
debugstr_w
(
es
->
undo_text
));
...
...
@@ -4203,14 +4203,6 @@ static LRESULT EDIT_EM_GetThumb(EDITSTATE *es)
EDIT_WM_HScroll
(
es
,
EM_GETTHUMB
,
0
));
}
static
inline
WCHAR
*
heap_strdupW
(
const
WCHAR
*
str
)
{
int
len
=
lstrlenW
(
str
)
+
1
;
WCHAR
*
ret
=
heap_alloc
(
len
*
sizeof
(
WCHAR
));
lstrcpyW
(
ret
,
str
);
return
ret
;
}
/*********************************************************************
*
* EM_SETCUEBANNER
...
...
@@ -4221,8 +4213,8 @@ static BOOL EDIT_EM_SetCueBanner(EDITSTATE *es, BOOL draw_focused, const WCHAR *
if
(
es
->
style
&
ES_MULTILINE
||
!
cue_text
)
return
FALSE
;
heap_
free
(
es
->
cue_banner_text
);
es
->
cue_banner_text
=
heap_strdupW
(
cue_text
);
free
(
es
->
cue_banner_text
);
es
->
cue_banner_text
=
wcsdup
(
cue_text
);
es
->
cue_banner_draw_focused
=
draw_focused
;
return
TRUE
;
...
...
@@ -4272,7 +4264,7 @@ static void EDIT_GetCompositionStr(HIMC hIMC, LPARAM CompFlag, EDITSTATE *es)
return
;
}
lpCompStr
=
heap_
alloc
(
buflen
);
lpCompStr
=
m
alloc
(
buflen
);
if
(
!
lpCompStr
)
{
ERR
(
"Unable to allocate IME CompositionString
\n
"
);
...
...
@@ -4292,11 +4284,11 @@ static void EDIT_GetCompositionStr(HIMC hIMC, LPARAM CompFlag, EDITSTATE *es)
if
(
dwBufLenAttr
)
{
dwBufLenAttr
++
;
lpCompStrAttr
=
heap_
alloc
(
dwBufLenAttr
+
1
);
lpCompStrAttr
=
m
alloc
(
dwBufLenAttr
+
1
);
if
(
!
lpCompStrAttr
)
{
ERR
(
"Unable to allocate IME Attribute String
\n
"
);
heap_
free
(
lpCompStr
);
free
(
lpCompStr
);
return
;
}
ImmGetCompositionStringW
(
hIMC
,
GCS_COMPATTR
,
lpCompStrAttr
,
...
...
@@ -4323,8 +4315,8 @@ static void EDIT_GetCompositionStr(HIMC hIMC, LPARAM CompFlag, EDITSTATE *es)
es
->
selection_start
=
es
->
composition_start
;
es
->
selection_end
=
es
->
selection_start
+
es
->
composition_len
;
heap_
free
(
lpCompStrAttr
);
heap_
free
(
lpCompStr
);
free
(
lpCompStrAttr
);
free
(
lpCompStr
);
}
static
void
EDIT_GetResultStr
(
HIMC
hIMC
,
EDITSTATE
*
es
)
...
...
@@ -4338,7 +4330,7 @@ static void EDIT_GetResultStr(HIMC hIMC, EDITSTATE *es)
return
;
}
lpResultStr
=
heap_
alloc
(
buflen
);
lpResultStr
=
m
alloc
(
buflen
);
if
(
!
lpResultStr
)
{
ERR
(
"Unable to alloc buffer for IME string
\n
"
);
...
...
@@ -4357,7 +4349,7 @@ static void EDIT_GetResultStr(HIMC hIMC, EDITSTATE *es)
es
->
composition_start
=
es
->
selection_end
;
es
->
composition_len
=
0
;
heap_
free
(
lpResultStr
);
free
(
lpResultStr
);
}
static
void
EDIT_ImeComposition
(
HWND
hwnd
,
LPARAM
CompFlag
,
EDITSTATE
*
es
)
...
...
@@ -4404,7 +4396,7 @@ static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs)
TRACE
(
"Creating edit control, style = %#lx
\n
"
,
lpcs
->
style
);
if
(
!
(
es
=
heap_alloc_zero
(
sizeof
(
*
es
))))
if
(
!
(
es
=
calloc
(
1
,
sizeof
(
*
es
))))
return
FALSE
;
SetWindowLongPtrW
(
hwnd
,
0
,
(
LONG_PTR
)
es
);
...
...
@@ -4466,12 +4458,12 @@ static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs)
goto
cleanup
;
es
->
buffer_size
=
LocalSize
(
es
->
hloc32W
)
/
sizeof
(
WCHAR
)
-
1
;
if
(
!
(
es
->
undo_text
=
heap_alloc_zero
((
es
->
buffer_size
+
1
)
*
sizeof
(
WCHAR
))))
if
(
!
(
es
->
undo_text
=
calloc
(
es
->
buffer_size
+
1
,
sizeof
(
WCHAR
))))
goto
cleanup
;
es
->
undo_buffer_size
=
es
->
buffer_size
;
if
(
es
->
style
&
ES_MULTILINE
)
if
(
!
(
es
->
first_line_def
=
heap_alloc_zero
(
sizeof
(
LINEDEF
))))
if
(
!
(
es
->
first_line_def
=
calloc
(
1
,
sizeof
(
LINEDEF
))))
goto
cleanup
;
es
->
line_count
=
1
;
...
...
@@ -4496,11 +4488,11 @@ static LRESULT EDIT_WM_NCCreate(HWND hwnd, LPCREATESTRUCTW lpcs)
cleanup:
SetWindowLongPtrW
(
es
->
hwndSelf
,
0
,
0
);
EDIT_InvalidateUniscribeData
(
es
);
heap_
free
(
es
->
first_line_def
);
heap_
free
(
es
->
undo_text
);
free
(
es
->
first_line_def
);
free
(
es
->
undo_text
);
if
(
es
->
hloc32W
)
LocalFree
(
es
->
hloc32W
);
heap_
free
(
es
->
logAttr
);
heap_
free
(
es
);
free
(
es
->
logAttr
);
free
(
es
);
return
FALSE
;
}
...
...
@@ -4583,14 +4575,14 @@ static LRESULT EDIT_WM_NCDestroy(EDITSTATE *es)
while
(
pc
)
{
pp
=
pc
->
next
;
heap_
free
(
pc
);
free
(
pc
);
pc
=
pp
;
}
SetWindowLongPtrW
(
es
->
hwndSelf
,
0
,
0
);
heap_
free
(
es
->
undo_text
);
heap_
free
(
es
->
cue_banner_text
);
heap_
free
(
es
);
free
(
es
->
undo_text
);
free
(
es
->
cue_banner_text
);
free
(
es
);
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