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
33ae61d7
Commit
33ae61d7
authored
Dec 06, 2022
by
Alex Henrie
Committed by
Alexandre Julliard
Dec 07, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winhlp32: Use standard C functions for memory allocation.
parent
803c616f
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
30 deletions
+19
-30
hlpfile.c
programs/winhlp32/hlpfile.c
+0
-0
macro.c
programs/winhlp32/macro.c
+12
-23
macro.lex.l
programs/winhlp32/macro.lex.l
+2
-2
winhelp.c
programs/winhlp32/winhelp.c
+5
-5
No files found.
programs/winhlp32/hlpfile.c
View file @
33ae61d7
This diff is collapsed.
Click to expand it.
programs/winhlp32/macro.c
View file @
33ae61d7
...
...
@@ -22,6 +22,7 @@
#define WIN32_LEAN_AND_MEAN
#include <stdio.h>
#include <stdlib.h>
#include "windows.h"
#include "commdlg.h"
...
...
@@ -48,14 +49,6 @@ static unsigned MACRO_NumLoaded /* = 0 */;
/******* helper functions *******/
static
char
*
StrDup
(
const
char
*
str
)
{
char
*
dst
;
dst
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
str
)
+
1
);
strcpy
(
dst
,
str
);
return
dst
;
}
static
WINHELP_BUTTON
**
MACRO_LookupButton
(
WINHELP_WINDOW
*
win
,
LPCSTR
name
)
{
WINHELP_BUTTON
**
b
;
...
...
@@ -81,7 +74,7 @@ void CALLBACK MACRO_CreateButton(LPCSTR id, LPCSTR name, LPCSTR macro)
size
=
sizeof
(
WINHELP_BUTTON
)
+
strlen
(
id
)
+
strlen
(
name
)
+
strlen
(
macro
)
+
3
;
button
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
button
=
malloc
(
size
);
if
(
!
button
)
return
;
button
->
next
=
0
;
...
...
@@ -239,7 +232,7 @@ static void CALLBACK MACRO_ChangeButtonBinding(LPCSTR id, LPCSTR macro)
size
=
sizeof
(
WINHELP_BUTTON
)
+
strlen
(
id
)
+
strlen
((
*
b
)
->
lpszName
)
+
strlen
(
macro
)
+
3
;
button
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
button
=
malloc
(
size
);
if
(
!
button
)
return
;
button
->
next
=
(
*
b
)
->
next
;
...
...
@@ -612,17 +605,16 @@ static void CALLBACK MACRO_JumpID(LPCSTR lpszPathWindow, LPCSTR topic_id)
LPSTR
tmp
;
size_t
sz
;
tmp
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
lpszPathWindow
)
+
1
);
tmp
=
strdup
(
lpszPathWindow
);
if
(
tmp
)
{
strcpy
(
tmp
,
lpszPathWindow
);
tmp
[
ptr
-
lpszPathWindow
]
=
'\0'
;
ptr
+=
tmp
-
lpszPathWindow
;
/* ptr now points to '>' in tmp buffer */
/* in some cases, we have a trailing space that we need to get rid of */
/* FIXME: check if it has to be done in lexer rather than here */
for
(
sz
=
strlen
(
ptr
+
1
);
sz
>=
1
&&
ptr
[
sz
]
==
' '
;
sz
--
)
ptr
[
sz
]
=
'\0'
;
MACRO_JumpHash
(
tmp
,
ptr
+
1
,
HLPFILE_Hash
(
topic_id
));
HeapFree
(
GetProcessHeap
(),
0
,
tmp
);
free
(
tmp
);
}
}
else
...
...
@@ -779,10 +771,10 @@ static void CALLBACK MACRO_RegisterRoutine(LPCSTR dll_name, LPCSTR proc, LPCSTR
/* FIXME: internationalisation for error messages */
WINE_FIXME
(
"Cannot find dll %s
\n
"
,
debugstr_a
(
dll_name
));
}
else
if
((
dll
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
*
dll
))))
else
if
((
dll
=
malloc
(
sizeof
(
*
dll
))))
{
dll
->
hLib
=
hLib
;
dll
->
name
=
StrD
up
(
dll_name
);
/* FIXME: never freed */
dll
->
name
=
strd
up
(
dll_name
);
/* FIXME: never freed */
dll
->
next
=
Globals
.
dlls
;
Globals
.
dlls
=
dll
;
dll
->
handler
=
(
WINHELP_LDLLHandler
)
GetProcAddress
(
dll
->
hLib
,
"LDLLHandler"
);
...
...
@@ -800,12 +792,11 @@ static void CALLBACK MACRO_RegisterRoutine(LPCSTR dll_name, LPCSTR proc, LPCSTR
}
size
=
++
MACRO_NumLoaded
*
sizeof
(
struct
MacroDesc
);
if
(
!
MACRO_Loaded
)
MACRO_Loaded
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
);
else
MACRO_Loaded
=
HeapReAlloc
(
GetProcessHeap
(),
0
,
MACRO_Loaded
,
size
);
MACRO_Loaded
[
MACRO_NumLoaded
-
1
].
name
=
StrDup
(
proc
);
/* FIXME: never freed */
MACRO_Loaded
=
realloc
(
MACRO_Loaded
,
size
);
MACRO_Loaded
[
MACRO_NumLoaded
-
1
].
name
=
strdup
(
proc
);
/* FIXME: never freed */
MACRO_Loaded
[
MACRO_NumLoaded
-
1
].
alias
=
NULL
;
MACRO_Loaded
[
MACRO_NumLoaded
-
1
].
isBool
=
FALSE
;
MACRO_Loaded
[
MACRO_NumLoaded
-
1
].
arguments
=
StrD
up
(
args
);
/* FIXME: never freed */
MACRO_Loaded
[
MACRO_NumLoaded
-
1
].
arguments
=
strd
up
(
args
);
/* FIXME: never freed */
MACRO_Loaded
[
MACRO_NumLoaded
-
1
].
fn
=
fn
;
WINE_TRACE
(
"Added %s(%s) at %p
\n
"
,
debugstr_a
(
proc
),
debugstr_a
(
args
),
fn
);
}
...
...
@@ -841,10 +832,8 @@ static void CALLBACK MACRO_SetHelpOnFile(LPCSTR str)
WINE_TRACE
(
"(%s)
\n
"
,
debugstr_a
(
str
));
HeapFree
(
GetProcessHeap
(),
0
,
page
->
file
->
help_on_file
);
page
->
file
->
help_on_file
=
HeapAlloc
(
GetProcessHeap
(),
0
,
strlen
(
str
)
+
1
);
if
(
page
->
file
->
help_on_file
)
strcpy
(
page
->
file
->
help_on_file
,
str
);
free
(
page
->
file
->
help_on_file
);
page
->
file
->
help_on_file
=
strdup
(
str
);
}
static
void
CALLBACK
MACRO_SetPopupColor
(
LONG
r
,
LONG
g
,
LONG
b
)
...
...
programs/winhlp32/macro.lex.l
View file @
33ae61d7
...
...
@@ -75,7 +75,7 @@ struct lexret yylval;
if (lex_data->quote_stk_idx == 0)
{
assert(lex_data->cache_used < ARRAY_SIZE(lex_data->cache_string));
lex_data->strptr = lex_data->cache_string[lex_data->cache_used] =
HeapAlloc(GetProcessHeap(), 0,
strlen(lex_data->macroptr) + 1);
lex_data->strptr = lex_data->cache_string[lex_data->cache_used] =
malloc(
strlen(lex_data->macroptr) + 1);
yylval.string = lex_data->strptr;
lex_data->cache_used++;
BEGIN(quote);
...
...
@@ -355,7 +355,7 @@ BOOL MACRO_ExecuteMacro(WINHELP_WINDOW* window, LPCSTR macro)
done:
for (t = 0; t < lex_data->cache_used; t++)
HeapFree(GetProcessHeap(), 0,
lex_data->cache_string[t]);
free(
lex_data->cache_string[t]);
lex_data = prev_lex_data;
WINHELP_ReleaseWindow(window);
...
...
programs/winhlp32/winhelp.c
View file @
33ae61d7
...
...
@@ -129,7 +129,7 @@ static void WINHELP_SetupText(HWND hTextWnd, WINHELP_WINDOW* win, ULONG relative
cp
=
rd
.
char_pos_rel
;
}
/* FIXME: else leaking potentially the rd.first_link chain */
HeapFree
(
GetProcessHeap
(),
0
,
rd
.
data
);
free
(
rd
.
data
);
SendMessageW
(
hTextWnd
,
EM_POSFROMCHAR
,
(
WPARAM
)
&
ptl
,
cp
?
cp
-
1
:
0
);
pt
.
x
=
0
;
pt
.
y
=
ptl
.
y
;
SendMessageW
(
hTextWnd
,
EM_SETSCROLLPOS
,
0
,
(
LPARAM
)
&
pt
);
...
...
@@ -468,7 +468,7 @@ static void WINHELP_DeleteButtons(WINHELP_WINDOW* win)
{
DestroyWindow
(
b
->
hWnd
);
bp
=
b
->
next
;
HeapFree
(
GetProcessHeap
(),
0
,
b
);
free
(
b
);
}
win
->
first_button
=
NULL
;
}
...
...
@@ -501,7 +501,7 @@ static void WINHELP_DeletePageLinks(HLPFILE_PAGE* page)
for
(
curr
=
page
->
first_link
;
curr
;
curr
=
next
)
{
next
=
curr
->
next
;
HeapFree
(
GetProcessHeap
(),
0
,
curr
);
free
(
curr
);
}
}
...
...
@@ -575,7 +575,7 @@ static void WINHELP_DeleteWindow(WINHELP_WINDOW* win)
WINHELP_DeleteBackSet
(
win
);
if
(
win
->
page
)
HLPFILE_FreeHlpFile
(
win
->
page
->
file
);
HeapFree
(
GetProcessHeap
(),
0
,
win
);
free
(
win
);
if
(
bExit
)
MACRO_Exit
();
if
(
!
Globals
.
win_list
)
...
...
@@ -762,7 +762,7 @@ BOOL WINHELP_CreateHelpWindow(WINHELP_WNDPAGE* wpage, int nCmdShow, BOOL remembe
if
(
!
win
)
{
/* Initialize WINHELP_WINDOW struct */
win
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
WINHELP_WINDOW
));
win
=
calloc
(
1
,
sizeof
(
WINHELP_WINDOW
));
if
(
!
win
)
return
FALSE
;
win
->
next
=
Globals
.
win_list
;
Globals
.
win_list
=
win
;
...
...
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