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
c5f4874e
Commit
c5f4874e
authored
Oct 21, 2022
by
Eric Pouech
Committed by
Alexandre Julliard
Oct 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dbghelp: Use heap functions for allocation.
Create a dedicated heap for each module (as it was done for the private home grown pools). Signed-off-by:
Eric Pouech
<
eric.pouech@gmail.com
>
parent
f0e6447b
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
87 deletions
+5
-87
dbghelp_private.h
dlls/dbghelp/dbghelp_private.h
+1
-5
storage.c
dlls/dbghelp/storage.c
+4
-82
No files found.
dlls/dbghelp/dbghelp_private.h
View file @
c5f4874e
...
...
@@ -34,13 +34,9 @@
#include "cvconst.h"
/* #define USE_STATS */
struct
pool
/* poor's man */
{
struct
list
arena_list
;
struct
list
arena_full
;
size_t
arena_size
;
HANDLE
heap
;
};
void
pool_init
(
struct
pool
*
a
,
size_t
arena_size
)
DECLSPEC_HIDDEN
;
...
...
dlls/dbghelp/storage.c
View file @
c5f4874e
...
...
@@ -25,100 +25,22 @@
#include "wine/debug.h"
#include "dbghelp_private.h"
#ifdef USE_STATS
#include <math.h>
#endif
WINE_DEFAULT_DEBUG_CHANNEL
(
dbghelp
);
struct
pool_arena
{
struct
list
entry
;
char
*
current
;
char
*
end
;
};
void
pool_init
(
struct
pool
*
a
,
size_t
arena_size
)
void
pool_init
(
struct
pool
*
pool
,
size_t
arena_size
)
{
list_init
(
&
a
->
arena_list
);
list_init
(
&
a
->
arena_full
);
a
->
arena_size
=
arena_size
;
pool
->
heap
=
HeapCreate
(
HEAP_NO_SERIALIZE
,
arena_size
,
0
);
}
void
pool_destroy
(
struct
pool
*
pool
)
{
struct
pool_arena
*
arena
;
struct
pool_arena
*
next
;
#ifdef USE_STATS
size_t
alloc
,
used
,
num
;
alloc
=
used
=
num
=
0
;
LIST_FOR_EACH_ENTRY
(
arena
,
&
pool
->
arena_list
,
struct
pool_arena
,
entry
)
{
alloc
+=
arena
->
end
-
(
char
*
)
arena
;
used
+=
arena
->
current
-
(
char
*
)
arena
;
num
++
;
}
LIST_FOR_EACH_ENTRY
(
arena
,
&
pool
->
arena_full
,
struct
pool_arena
,
entry
)
{
alloc
+=
arena
->
end
-
(
char
*
)
arena
;
used
+=
arena
->
current
-
(
char
*
)
arena
;
num
++
;
}
if
(
alloc
==
0
)
alloc
=
1
;
/* avoid division by zero */
FIXME
(
"STATS: pool %p has allocated %u kbytes, used %u kbytes in %u arenas, non-allocation ratio: %.2f%%
\n
"
,
pool
,
(
unsigned
)(
alloc
>>
10
),
(
unsigned
)(
used
>>
10
),
(
unsigned
)
num
,
100
.
0
-
(
float
)
used
/
(
float
)
alloc
*
100
.
0
);
#endif
LIST_FOR_EACH_ENTRY_SAFE
(
arena
,
next
,
&
pool
->
arena_list
,
struct
pool_arena
,
entry
)
{
list_remove
(
&
arena
->
entry
);
HeapFree
(
GetProcessHeap
(),
0
,
arena
);
}
LIST_FOR_EACH_ENTRY_SAFE
(
arena
,
next
,
&
pool
->
arena_full
,
struct
pool_arena
,
entry
)
{
list_remove
(
&
arena
->
entry
);
HeapFree
(
GetProcessHeap
(),
0
,
arena
);
}
HeapDestroy
(
pool
->
heap
);
}
void
*
pool_alloc
(
struct
pool
*
pool
,
size_t
len
)
{
struct
pool_arena
*
arena
;
void
*
ret
;
size_t
size
;
len
=
(
len
+
3
)
&
~
3
;
/* round up size on DWORD boundary */
LIST_FOR_EACH_ENTRY
(
arena
,
&
pool
->
arena_list
,
struct
pool_arena
,
entry
)
{
if
(
arena
->
end
-
arena
->
current
>=
len
)
{
ret
=
arena
->
current
;
arena
->
current
+=
len
;
if
(
arena
->
current
+
16
>=
arena
->
end
)
{
list_remove
(
&
arena
->
entry
);
list_add_tail
(
&
pool
->
arena_full
,
&
arena
->
entry
);
}
return
ret
;
}
}
size
=
max
(
pool
->
arena_size
,
len
);
arena
=
HeapAlloc
(
GetProcessHeap
(),
0
,
size
+
sizeof
(
struct
pool_arena
));
if
(
!
arena
)
return
NULL
;
ret
=
arena
+
1
;
arena
->
current
=
(
char
*
)
ret
+
len
;
arena
->
end
=
(
char
*
)
ret
+
size
;
if
(
arena
->
current
+
16
>=
arena
->
end
)
list_add_tail
(
&
pool
->
arena_full
,
&
arena
->
entry
);
else
list_add_head
(
&
pool
->
arena_list
,
&
arena
->
entry
);
return
ret
;
return
HeapAlloc
(
pool
->
heap
,
0
,
len
);
}
char
*
pool_strdup
(
struct
pool
*
pool
,
const
char
*
str
)
...
...
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