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
b5c031b1
Commit
b5c031b1
authored
Nov 02, 2006
by
Mike McCormack
Committed by
Alexandre Julliard
Nov 02, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
riched20: Initialize and free the RTF lookup table in DllMain to avoid memory leaks.
parent
14ec1d0c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
24 deletions
+33
-24
editor.c
dlls/riched20/editor.c
+2
-0
reader.c
dlls/riched20/reader.c
+28
-24
rtf.h
dlls/riched20/rtf.h
+3
-0
No files found.
dlls/riched20/editor.c
View file @
b5c031b1
...
...
@@ -1245,6 +1245,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
DisableThreadLibraryCalls
(
hinstDLL
);
me_heap
=
HeapCreate
(
0
,
0x10000
,
0
);
ME_RegisterEditorClass
(
hinstDLL
);
LookupInit
();
break
;
case
DLL_PROCESS_DETACH
:
...
...
@@ -1256,6 +1257,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
UnregisterClassW
(
wszClassNameListBox
,
0
);
if
(
ME_ComboBoxRegistered
)
UnregisterClassW
(
wszClassNameComboBox
,
0
);
LookupCleanup
();
HeapDestroy
(
me_heap
);
me_heap
=
NULL
;
break
;
...
...
dlls/riched20/reader.c
View file @
b5c031b1
...
...
@@ -64,7 +64,6 @@ static void ReadStyleSheet (RTF_Info *);
static
void
ReadInfoGroup
(
RTF_Info
*
);
static
void
ReadPictGroup
(
RTF_Info
*
);
static
void
ReadObjGroup
(
RTF_Info
*
);
static
void
LookupInit
(
void
);
static
void
Lookup
(
RTF_Info
*
,
char
*
);
static
int
Hash
(
const
char
*
);
...
...
@@ -214,9 +213,6 @@ void RTFInit(RTF_Info *info)
RTFFree
(
info
->
outputName
);
info
->
inputName
=
info
->
outputName
=
NULL
;
/* initialize lookup table */
LookupInit
();
for
(
i
=
0
;
i
<
rtfMaxClass
;
i
++
)
RTFSetClassCallback
(
info
,
i
,
NULL
);
for
(
i
=
0
;
i
<
rtfMaxDestination
;
i
++
)
...
...
@@ -1816,7 +1812,7 @@ static RTFKey rtfKey[] =
{
rtfDocAttr
,
rtfRTLDoc
,
"rtldoc"
,
0
},
{
rtfDocAttr
,
rtfLTRDoc
,
"ltrdoc"
,
0
},
{
rtfDocAttr
,
rtfAnsiCodePage
,
"ansicpg"
,
0
},
{
rtfDocAttr
,
rtfUTF8RTF
,
"urtf"
,
0
},
...
...
@@ -2325,26 +2321,34 @@ static RTFHashTableEntry rtfHashTable[RTF_KEY_COUNT * 2];
* Initialize lookup table hash values. Only need to do this once.
*/
static
void
LookupInit
(
void
)
void
LookupInit
(
void
)
{
static
int
inited
=
0
;
RTFKey
*
rp
;
if
(
inited
==
0
)
memset
(
rtfHashTable
,
0
,
RTF_KEY_COUNT
*
2
*
sizeof
(
*
rtfHashTable
));
for
(
rp
=
rtfKey
;
rp
->
rtfKStr
!=
NULL
;
rp
++
)
{
memset
(
rtfHashTable
,
0
,
RTF_KEY_COUNT
*
2
*
sizeof
(
*
rtfHashTable
));
for
(
rp
=
rtfKey
;
rp
->
rtfKStr
!=
NULL
;
rp
++
)
{
int
index
;
rp
->
rtfKHash
=
Hash
(
rp
->
rtfKStr
);
index
=
rp
->
rtfKHash
%
(
RTF_KEY_COUNT
*
2
);
if
(
!
rtfHashTable
[
index
].
count
)
rtfHashTable
[
index
].
value
=
RTFAlloc
(
sizeof
(
RTFKey
*
));
else
rtfHashTable
[
index
].
value
=
RTFReAlloc
(
rtfHashTable
[
index
].
value
,
sizeof
(
RTFKey
*
)
*
(
rtfHashTable
[
index
].
count
+
1
));
rtfHashTable
[
index
].
value
[
rtfHashTable
[
index
].
count
++
]
=
rp
;
}
++
inited
;
int
index
;
rp
->
rtfKHash
=
Hash
(
rp
->
rtfKStr
);
index
=
rp
->
rtfKHash
%
(
RTF_KEY_COUNT
*
2
);
if
(
!
rtfHashTable
[
index
].
count
)
rtfHashTable
[
index
].
value
=
RTFAlloc
(
sizeof
(
RTFKey
*
));
else
rtfHashTable
[
index
].
value
=
RTFReAlloc
(
rtfHashTable
[
index
].
value
,
sizeof
(
RTFKey
*
)
*
(
rtfHashTable
[
index
].
count
+
1
));
rtfHashTable
[
index
].
value
[
rtfHashTable
[
index
].
count
++
]
=
rp
;
}
}
void
LookupCleanup
(
void
)
{
int
i
;
for
(
i
=
0
;
i
<
RTF_KEY_COUNT
*
2
;
i
++
)
{
RTFFree
(
rtfHashTable
[
i
].
value
);
rtfHashTable
[
i
].
value
=
NULL
;
rtfHashTable
[
i
].
count
=
0
;
}
}
...
...
@@ -2524,7 +2528,7 @@ static void
CharAttr
(
RTF_Info
*
info
)
{
RTFFont
*
font
;
switch
(
info
->
rtfMinor
)
{
case
rtfFontNum
:
...
...
@@ -2627,9 +2631,9 @@ static void SpecialChar (RTF_Info *info)
case
rtfUnicode
:
{
int
i
;
RTFPutUnicodeChar
(
info
,
info
->
rtfParam
);
/* After \u we must skip number of character tokens set by \ucN */
for
(
i
=
0
;
i
<
info
->
unicodeLength
;
i
++
)
{
...
...
dlls/riched20/rtf.h
View file @
b5c031b1
...
...
@@ -1147,4 +1147,7 @@ int BeginFile (RTF_Info *);
int
RTFCharSetToCodePage
(
RTF_Info
*
info
,
int
charset
);
void
LookupInit
(
void
);
void
LookupCleanup
(
void
);
#endif
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