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
ed9d78d2
Commit
ed9d78d2
authored
Feb 13, 2013
by
Jacek Caban
Committed by
Alexandre Julliard
Feb 13, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
oleaut32: Don't free a string in SysFreeString if it's already in cache.
parent
22c39932
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
6 deletions
+19
-6
oleaut.c
dlls/oleaut32/oleaut.c
+19
-6
No files found.
dlls/oleaut32/oleaut.c
View file @
ed9d78d2
...
...
@@ -90,14 +90,15 @@ typedef struct {
}
u
;
}
bstr_t
;
#define BUCKET_SIZE 16
#define BUCKET_BUFFER_SIZE 6
typedef
struct
{
unsigned
short
head
;
unsigned
short
cnt
;
bstr_t
*
buf
[
6
];
bstr_t
*
buf
[
BUCKET_BUFFER_SIZE
];
}
bstr_cache_entry_t
;
#define BUCKET_SIZE 16
#define ARENA_INUSE_FILLER 0x55
#define ARENA_TAIL_FILLER 0xab
#define ARENA_FREE_FILLER 0xfeeefeee
...
...
@@ -138,7 +139,7 @@ static bstr_t *alloc_bstr(size_t size)
if
(
cache_entry
)
{
ret
=
cache_entry
->
buf
[
cache_entry
->
head
++
];
cache_entry
->
head
%=
sizeof
(
cache_entry
->
buf
)
/
sizeof
(
*
cache_entry
->
buf
)
;
cache_entry
->
head
%=
BUCKET_BUFFER_SIZE
;
cache_entry
->
cnt
--
;
}
...
...
@@ -257,14 +258,26 @@ void WINAPI SysFreeString(BSTR str)
bstr
=
bstr_from_str
(
str
);
cache_entry
=
get_cache_entry
(
bstr
->
size
+
sizeof
(
WCHAR
));
if
(
cache_entry
)
{
unsigned
i
;
EnterCriticalSection
(
&
cs_bstr_cache
);
/* According to tests, freeing a string that's already in cache doesn't corrupt anything.
* For that to work we need to search the cache. */
for
(
i
=
0
;
i
<
cache_entry
->
cnt
;
i
++
)
{
if
(
cache_entry
->
buf
[(
cache_entry
->
head
+
cache_entry
->
cnt
)
%
BUCKET_BUFFER_SIZE
]
==
bstr
)
{
WARN_
(
heap
)(
"String already is in cache!
\n
"
);
LeaveCriticalSection
(
&
cs_bstr_cache
);
return
;
}
}
if
(
cache_entry
->
cnt
<
sizeof
(
cache_entry
->
buf
)
/
sizeof
(
*
cache_entry
->
buf
))
{
cache_entry
->
buf
[(
cache_entry
->
head
+
cache_entry
->
cnt
)
%
((
sizeof
(
cache_entry
->
buf
)
/
sizeof
(
*
cache_entry
->
buf
)))
]
=
bstr
;
cache_entry
->
buf
[(
cache_entry
->
head
+
cache_entry
->
cnt
)
%
BUCKET_BUFFER_SIZE
]
=
bstr
;
cache_entry
->
cnt
++
;
if
(
WARN_ON
(
heap
))
{
unsigned
i
,
n
=
bstr_alloc_size
(
bstr
->
size
)
/
sizeof
(
DWORD
)
-
1
;
unsigned
n
=
bstr_alloc_size
(
bstr
->
size
)
/
sizeof
(
DWORD
)
-
1
;
bstr
->
size
=
ARENA_FREE_FILLER
;
for
(
i
=
0
;
i
<
n
;
i
++
)
bstr
->
u
.
dwptr
[
i
]
=
ARENA_FREE_FILLER
;
...
...
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