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
ee1f96eb
Commit
ee1f96eb
authored
Jul 03, 2022
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jul 05, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wordpad: Use CRT allocation functions.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
parent
a0bef9f3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
27 deletions
+23
-27
print.c
programs/wordpad/print.c
+3
-5
registry.c
programs/wordpad/registry.c
+2
-4
wordpad.c
programs/wordpad/wordpad.c
+16
-18
wordpad.h
programs/wordpad/wordpad.h
+2
-0
No files found.
programs/wordpad/print.c
View file @
ee1f96eb
...
@@ -749,7 +749,7 @@ void close_preview(HWND hMainWnd)
...
@@ -749,7 +749,7 @@ void close_preview(HWND hMainWnd)
preview
.
window
.
right
=
0
;
preview
.
window
.
right
=
0
;
preview
.
window
.
bottom
=
0
;
preview
.
window
.
bottom
=
0
;
preview
.
page
=
0
;
preview
.
page
=
0
;
HeapFree
(
GetProcessHeap
(),
0
,
preview
.
pageEnds
);
free
(
preview
.
pageEnds
);
preview
.
pageEnds
=
NULL
;
preview
.
pageEnds
=
NULL
;
preview
.
pageCapacity
=
0
;
preview
.
pageCapacity
=
0
;
if
(
preview
.
zoomlevel
>
0
)
if
(
preview
.
zoomlevel
>
0
)
...
@@ -783,13 +783,11 @@ static void draw_preview(HWND hEditorWnd, FORMATRANGE* lpFr, RECT* paper, int pa
...
@@ -783,13 +783,11 @@ static void draw_preview(HWND hEditorWnd, FORMATRANGE* lpFr, RECT* paper, int pa
if
(
!
preview
.
pageEnds
)
if
(
!
preview
.
pageEnds
)
{
{
preview
.
pageCapacity
=
32
;
preview
.
pageCapacity
=
32
;
preview
.
pageEnds
=
HeapAlloc
(
GetProcessHeap
(),
0
,
preview
.
pageEnds
=
malloc
(
sizeof
(
int
)
*
preview
.
pageCapacity
);
sizeof
(
int
)
*
preview
.
pageCapacity
);
if
(
!
preview
.
pageEnds
)
return
;
if
(
!
preview
.
pageEnds
)
return
;
}
else
if
(
page
>=
preview
.
pageCapacity
)
{
}
else
if
(
page
>=
preview
.
pageCapacity
)
{
int
*
new_buffer
;
int
*
new_buffer
;
new_buffer
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
preview
.
pageEnds
,
new_buffer
=
realloc
(
preview
.
pageEnds
,
sizeof
(
int
)
*
preview
.
pageCapacity
*
2
);
sizeof
(
int
)
*
preview
.
pageCapacity
*
2
);
if
(
!
new_buffer
)
return
;
if
(
!
new_buffer
)
return
;
preview
.
pageCapacity
*=
2
;
preview
.
pageCapacity
*=
2
;
preview
.
pageEnds
=
new_buffer
;
preview
.
pageEnds
=
new_buffer
;
...
...
programs/wordpad/registry.c
View file @
ee1f96eb
...
@@ -51,9 +51,7 @@ static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
...
@@ -51,9 +51,7 @@ static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
if
(
subKey
)
if
(
subKey
)
{
{
WCHAR
backslash
[]
=
{
'\\'
,
0
};
WCHAR
backslash
[]
=
{
'\\'
,
0
};
key
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
key
=
calloc
(
lstrlenW
(
wszProgramKey
)
+
lstrlenW
(
subKey
)
+
lstrlenW
(
backslash
)
+
1
,
sizeof
(
WCHAR
));
(
lstrlenW
(
wszProgramKey
)
+
lstrlenW
(
subKey
)
+
lstrlenW
(
backslash
)
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
key
)
if
(
!
key
)
return
1
;
return
1
;
...
@@ -73,7 +71,7 @@ static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
...
@@ -73,7 +71,7 @@ static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey)
}
}
if
(
subKey
)
if
(
subKey
)
HeapFree
(
GetProcessHeap
(),
0
,
key
);
free
(
key
);
return
ret
;
return
ret
;
}
}
...
...
programs/wordpad/wordpad.c
View file @
ee1f96eb
...
@@ -239,8 +239,7 @@ static void set_caption(LPCWSTR wszNewFileName)
...
@@ -239,8 +239,7 @@ static void set_caption(LPCWSTR wszNewFileName)
else
else
wszNewFileName
=
file_basename
((
LPWSTR
)
wszNewFileName
);
wszNewFileName
=
file_basename
((
LPWSTR
)
wszNewFileName
);
wszCaption
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
wszCaption
=
calloc
(
1
,
lstrlenW
(
wszNewFileName
)
*
sizeof
(
WCHAR
)
+
sizeof
(
wszSeparator
)
+
sizeof
(
wszAppTitle
));
lstrlenW
(
wszNewFileName
)
*
sizeof
(
WCHAR
)
+
sizeof
(
wszSeparator
)
+
sizeof
(
wszAppTitle
));
if
(
!
wszCaption
)
if
(
!
wszCaption
)
return
;
return
;
...
@@ -253,7 +252,7 @@ static void set_caption(LPCWSTR wszNewFileName)
...
@@ -253,7 +252,7 @@ static void set_caption(LPCWSTR wszNewFileName)
SetWindowTextW
(
hMainWnd
,
wszCaption
);
SetWindowTextW
(
hMainWnd
,
wszCaption
);
HeapFree
(
GetProcessHeap
(),
0
,
wszCaption
);
free
(
wszCaption
);
}
}
static
BOOL
validate_endptr
(
LPCWSTR
endptr
,
UNIT
*
punit
)
static
BOOL
validate_endptr
(
LPCWSTR
endptr
,
UNIT
*
punit
)
...
@@ -615,8 +614,8 @@ static BOOL array_reserve(void **elements, size_t *capacity, size_t count, size_
...
@@ -615,8 +614,8 @@ static BOOL array_reserve(void **elements, size_t *capacity, size_t count, size_
if
(
new_capacity
<
count
)
if
(
new_capacity
<
count
)
new_capacity
=
max_capacity
;
new_capacity
=
max_capacity
;
new_elements
=
*
elements
?
HeapReAlloc
(
GetProcessHeap
(),
0
,
*
elements
,
new_capacity
*
size
)
:
new_elements
=
*
elements
?
realloc
(
*
elements
,
new_capacity
*
size
)
:
HeapAlloc
(
GetProcessHeap
(),
0
,
new_capacity
*
size
);
malloc
(
new_capacity
*
size
);
if
(
!
new_elements
)
if
(
!
new_elements
)
return
FALSE
;
return
FALSE
;
...
@@ -638,7 +637,7 @@ static void add_font(struct font_array *fonts, LPCWSTR fontName, DWORD fontType,
...
@@ -638,7 +637,7 @@ static void add_font(struct font_array *fonts, LPCWSTR fontName, DWORD fontType,
fontHeight
=
ntmc
->
ntmTm
.
tmHeight
-
ntmc
->
ntmTm
.
tmInternalLeading
;
fontHeight
=
ntmc
->
ntmTm
.
tmHeight
-
ntmc
->
ntmTm
.
tmInternalLeading
;
idx
=
fonts
->
count
;
idx
=
fonts
->
count
;
fonts
->
fonts
[
idx
].
name
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
lstrlenW
(
fontName
)
+
1
)
*
sizeof
(
WCHAR
)
);
fonts
->
fonts
[
idx
].
name
=
malloc
(
(
lstrlenW
(
fontName
)
+
1
)
*
sizeof
(
WCHAR
)
);
lstrcpyW
(
fonts
->
fonts
[
idx
].
name
,
fontName
);
lstrcpyW
(
fonts
->
fonts
[
idx
].
name
,
fontName
);
fonts
->
fonts
[
idx
].
lParam
=
MAKELONG
(
fontType
,
fontHeight
);
fonts
->
fonts
[
idx
].
lParam
=
MAKELONG
(
fontType
,
fontHeight
);
...
@@ -685,7 +684,7 @@ static void populate_font_list(HWND hListWnd)
...
@@ -685,7 +684,7 @@ static void populate_font_list(HWND hListWnd)
{
{
if
(
!
lstrcmpiW
(
font_array
.
fonts
[
i
].
name
,
font_array
.
fonts
[
j
].
name
))
if
(
!
lstrcmpiW
(
font_array
.
fonts
[
i
].
name
,
font_array
.
fonts
[
j
].
name
))
{
{
HeapFree
(
GetProcessHeap
(),
0
,
font_array
.
fonts
[
i
].
name
);
free
(
font_array
.
fonts
[
i
].
name
);
font_array
.
fonts
[
i
].
name
=
NULL
;
font_array
.
fonts
[
i
].
name
=
NULL
;
}
}
else
if
(
++
j
!=
i
)
else
if
(
++
j
!=
i
)
...
@@ -707,9 +706,9 @@ static void populate_font_list(HWND hListWnd)
...
@@ -707,9 +706,9 @@ static void populate_font_list(HWND hListWnd)
SendMessageW
(
hListWnd
,
CBEM_INSERTITEMW
,
0
,
(
LPARAM
)
&
cbitem
);
SendMessageW
(
hListWnd
,
CBEM_INSERTITEMW
,
0
,
(
LPARAM
)
&
cbitem
);
HeapFree
(
GetProcessHeap
(),
0
,
font_array
.
fonts
[
i
].
name
);
free
(
font_array
.
fonts
[
i
].
name
);
}
}
HeapFree
(
GetProcessHeap
(),
0
,
font_array
.
fonts
);
free
(
font_array
.
fonts
);
ZeroMemory
(
&
fmt
,
sizeof
(
fmt
));
ZeroMemory
(
&
fmt
,
sizeof
(
fmt
));
fmt
.
cbSize
=
sizeof
(
fmt
);
fmt
.
cbSize
=
sizeof
(
fmt
);
...
@@ -1015,8 +1014,7 @@ static BOOL prompt_save_changes(void)
...
@@ -1015,8 +1014,7 @@ static BOOL prompt_save_changes(void)
else
else
displayFileName
=
file_basename
(
wszFileName
);
displayFileName
=
file_basename
(
wszFileName
);
text
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
text
=
calloc
(
lstrlenW
(
displayFileName
)
+
lstrlenW
(
wszSaveChanges
),
sizeof
(
WCHAR
));
(
lstrlenW
(
displayFileName
)
+
lstrlenW
(
wszSaveChanges
))
*
sizeof
(
WCHAR
));
if
(
!
text
)
if
(
!
text
)
return
FALSE
;
return
FALSE
;
...
@@ -1025,7 +1023,7 @@ static BOOL prompt_save_changes(void)
...
@@ -1025,7 +1023,7 @@ static BOOL prompt_save_changes(void)
ret
=
MessageBoxW
(
hMainWnd
,
text
,
wszAppTitle
,
MB_YESNOCANCEL
|
MB_ICONEXCLAMATION
);
ret
=
MessageBoxW
(
hMainWnd
,
text
,
wszAppTitle
,
MB_YESNOCANCEL
|
MB_ICONEXCLAMATION
);
HeapFree
(
GetProcessHeap
(),
0
,
text
);
free
(
text
);
switch
(
ret
)
switch
(
ret
)
{
{
...
@@ -2401,20 +2399,20 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
...
@@ -2401,20 +2399,20 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
case
ID_EDIT_GETTEXT
:
case
ID_EDIT_GETTEXT
:
{
{
int
nLen
=
GetWindowTextLengthW
(
hwndEditor
);
int
nLen
=
GetWindowTextLengthW
(
hwndEditor
);
LPWSTR
data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
nLen
+
1
)
*
sizeof
(
WCHAR
)
);
LPWSTR
data
=
malloc
(
(
nLen
+
1
)
*
sizeof
(
WCHAR
)
);
TEXTRANGEW
tr
;
TEXTRANGEW
tr
;
GetWindowTextW
(
hwndEditor
,
data
,
nLen
+
1
);
GetWindowTextW
(
hwndEditor
,
data
,
nLen
+
1
);
MessageBoxW
(
NULL
,
data
,
wszAppTitle
,
MB_OK
);
MessageBoxW
(
NULL
,
data
,
wszAppTitle
,
MB_OK
);
HeapFree
(
GetProcessHeap
(),
0
,
data
);
free
(
data
);
data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
nLen
+
1
)
*
sizeof
(
WCHAR
));
data
=
malloc
(
(
nLen
+
1
)
*
sizeof
(
WCHAR
));
tr
.
chrg
.
cpMin
=
0
;
tr
.
chrg
.
cpMin
=
0
;
tr
.
chrg
.
cpMax
=
nLen
;
tr
.
chrg
.
cpMax
=
nLen
;
tr
.
lpstrText
=
data
;
tr
.
lpstrText
=
data
;
SendMessageW
(
hwndEditor
,
EM_GETTEXTRANGE
,
0
,
(
LPARAM
)
&
tr
);
SendMessageW
(
hwndEditor
,
EM_GETTEXTRANGE
,
0
,
(
LPARAM
)
&
tr
);
MessageBoxW
(
NULL
,
data
,
wszAppTitle
,
MB_OK
);
MessageBoxW
(
NULL
,
data
,
wszAppTitle
,
MB_OK
);
HeapFree
(
GetProcessHeap
(),
0
,
data
);
free
(
data
);
/* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */
/* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */
return
0
;
return
0
;
...
@@ -2449,12 +2447,12 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
...
@@ -2449,12 +2447,12 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam)
WCHAR
*
data
=
NULL
;
WCHAR
*
data
=
NULL
;
SendMessageW
(
hwndEditor
,
EM_EXGETSEL
,
0
,
(
LPARAM
)
&
range
);
SendMessageW
(
hwndEditor
,
EM_EXGETSEL
,
0
,
(
LPARAM
)
&
range
);
data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
data
)
*
(
range
.
cpMax
-
range
.
cpMin
+
1
));
data
=
malloc
(
sizeof
(
*
data
)
*
(
range
.
cpMax
-
range
.
cpMin
+
1
));
SendMessageW
(
hwndEditor
,
EM_GETSELTEXT
,
0
,
(
LPARAM
)
data
);
SendMessageW
(
hwndEditor
,
EM_GETSELTEXT
,
0
,
(
LPARAM
)
data
);
sprintf
(
buf
,
"Start = %ld, End = %ld"
,
range
.
cpMin
,
range
.
cpMax
);
sprintf
(
buf
,
"Start = %ld, End = %ld"
,
range
.
cpMin
,
range
.
cpMax
);
MessageBoxA
(
hWnd
,
buf
,
"Editor"
,
MB_OK
);
MessageBoxA
(
hWnd
,
buf
,
"Editor"
,
MB_OK
);
MessageBoxW
(
hWnd
,
data
,
wszAppTitle
,
MB_OK
);
MessageBoxW
(
hWnd
,
data
,
wszAppTitle
,
MB_OK
);
HeapFree
(
GetProcessHeap
(),
0
,
data
);
free
(
data
);
/* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */
/* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */
return
0
;
return
0
;
}
}
...
...
programs/wordpad/wordpad.h
View file @
ee1f96eb
...
@@ -17,6 +17,8 @@
...
@@ -17,6 +17,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
*/
#include <stdlib.h>
#include <windef.h>
#include <windef.h>
#include <winuser.h>
#include <winuser.h>
...
...
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