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
ed510dd9
Commit
ed510dd9
authored
Nov 23, 2022
by
Alex Henrie
Committed by
Alexandre Julliard
Nov 24, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
pdh: Use standard C functions for memory allocation.
parent
8d9eb707
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
30 deletions
+21
-30
pdh_main.c
dlls/pdh/pdh_main.c
+21
-30
No files found.
dlls/pdh/pdh_main.c
View file @
ed510dd9
...
...
@@ -20,6 +20,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include <math.h>
#define NONAMELESSUNION
...
...
@@ -32,7 +33,6 @@
#include "winperf.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
pdh
);
...
...
@@ -47,15 +47,6 @@ static CRITICAL_SECTION_DEBUG pdh_handle_cs_debug =
};
static
CRITICAL_SECTION
pdh_handle_cs
=
{
&
pdh_handle_cs_debug
,
-
1
,
0
,
0
,
0
,
0
};
static
inline
WCHAR
*
pdh_strdup
(
const
WCHAR
*
src
)
{
WCHAR
*
dst
;
if
(
!
src
)
return
NULL
;
if
((
dst
=
heap_alloc
(
(
lstrlenW
(
src
)
+
1
)
*
sizeof
(
WCHAR
)
)))
lstrcpyW
(
dst
,
src
);
return
dst
;
}
static
inline
WCHAR
*
pdh_strdup_aw
(
const
char
*
src
)
{
int
len
;
...
...
@@ -63,7 +54,7 @@ static inline WCHAR *pdh_strdup_aw( const char *src )
if
(
!
src
)
return
NULL
;
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
src
,
-
1
,
NULL
,
0
);
if
((
dst
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
MultiByteToWideChar
(
CP_ACP
,
0
,
src
,
-
1
,
dst
,
len
);
if
((
dst
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
MultiByteToWideChar
(
CP_ACP
,
0
,
src
,
-
1
,
dst
,
len
);
return
dst
;
}
...
...
@@ -98,7 +89,7 @@ static struct counter *create_counter( void )
{
struct
counter
*
counter
;
if
((
counter
=
heap_alloc_zero
(
sizeof
(
struct
counter
)
)))
if
((
counter
=
calloc
(
1
,
sizeof
(
struct
counter
)
)))
{
counter
->
magic
=
PDH_MAGIC_COUNTER
;
return
counter
;
...
...
@@ -109,8 +100,8 @@ static struct counter *create_counter( void )
static
void
destroy_counter
(
struct
counter
*
counter
)
{
counter
->
magic
=
0
;
heap_
free
(
counter
->
path
);
heap_
free
(
counter
);
free
(
counter
->
path
);
free
(
counter
);
}
#define PDH_MAGIC_QUERY 0x50444830
/* 'PDH0' */
...
...
@@ -130,7 +121,7 @@ static struct query *create_query( void )
{
struct
query
*
query
;
if
((
query
=
heap_alloc_zero
(
sizeof
(
struct
query
)
)))
if
((
query
=
calloc
(
1
,
sizeof
(
struct
query
)
)))
{
query
->
magic
=
PDH_MAGIC_QUERY
;
list_init
(
&
query
->
counters
);
...
...
@@ -142,7 +133,7 @@ static struct query *create_query( void )
static
void
destroy_query
(
struct
query
*
query
)
{
query
->
magic
=
0
;
heap_
free
(
query
);
free
(
query
);
}
struct
source
...
...
@@ -222,7 +213,7 @@ PDH_STATUS WINAPI PdhAddCounterA( PDH_HQUERY query, LPCSTR path,
ret
=
PdhAddCounterW
(
query
,
pathW
,
userdata
,
counter
);
heap_
free
(
pathW
);
free
(
pathW
);
return
ret
;
}
...
...
@@ -254,7 +245,7 @@ PDH_STATUS WINAPI PdhAddCounterW( PDH_HQUERY hquery, LPCWSTR path,
{
if
((
counter
=
create_counter
()))
{
counter
->
path
=
pdh_str
dup
(
counter_sources
[
i
].
path
);
counter
->
path
=
wcs
dup
(
counter_sources
[
i
].
path
);
counter
->
collect
=
counter_sources
[
i
].
collect
;
counter
->
type
=
counter_sources
[
i
].
type
;
counter
->
defaultscale
=
counter_sources
[
i
].
scale
;
...
...
@@ -822,8 +813,8 @@ PDH_STATUS WINAPI PdhLookupPerfIndexByNameA( LPCSTR machine, LPCSTR name, LPDWOR
ret
=
PdhLookupPerfIndexByNameW
(
machineW
,
nameW
,
index
);
heap_
free
(
nameW
);
heap_
free
(
machineW
);
free
(
nameW
);
free
(
machineW
);
return
ret
;
}
...
...
@@ -878,7 +869,7 @@ PDH_STATUS WINAPI PdhLookupPerfNameByIndexA( LPCSTR machine, DWORD index, LPSTR
else
WideCharToMultiByte
(
CP_ACP
,
0
,
bufferW
,
-
1
,
buffer
,
required
,
NULL
,
NULL
);
*
size
=
required
;
}
heap_
free
(
machineW
);
free
(
machineW
);
return
ret
;
}
...
...
@@ -934,7 +925,7 @@ PDH_STATUS WINAPI PdhOpenQueryA( LPCSTR source, DWORD_PTR userdata, PDH_HQUERY *
if
(
source
&&
!
(
sourceW
=
pdh_strdup_aw
(
source
)))
return
PDH_MEMORY_ALLOCATION_FAILURE
;
ret
=
PdhOpenQueryW
(
sourceW
,
userdata
,
query
);
heap_
free
(
sourceW
);
free
(
sourceW
);
return
ret
;
}
...
...
@@ -1030,7 +1021,7 @@ PDH_STATUS WINAPI PdhValidatePathA( LPCSTR path )
ret
=
PdhValidatePathW
(
pathW
);
heap_
free
(
pathW
);
free
(
pathW
);
return
ret
;
}
...
...
@@ -1128,7 +1119,7 @@ PDH_STATUS WINAPI PdhMakeCounterPathA( PDH_COUNTER_PATH_ELEMENTS_A *e, LPSTR buf
ret
=
PdhMakeCounterPathW
(
&
eW
,
NULL
,
&
buflenW
,
flags
);
if
(
ret
==
PDH_MORE_DATA
)
{
if
((
bufferW
=
heap_
alloc
(
buflenW
*
sizeof
(
WCHAR
)
)))
if
((
bufferW
=
m
alloc
(
buflenW
*
sizeof
(
WCHAR
)
)))
{
if
(
!
(
ret
=
PdhMakeCounterPathW
(
&
eW
,
bufferW
,
&
buflenW
,
flags
)))
{
...
...
@@ -1137,18 +1128,18 @@ PDH_STATUS WINAPI PdhMakeCounterPathA( PDH_COUNTER_PATH_ELEMENTS_A *e, LPSTR buf
else
ret
=
PDH_MORE_DATA
;
*
buflen
=
len
;
}
heap_
free
(
bufferW
);
free
(
bufferW
);
}
else
ret
=
PDH_MEMORY_ALLOCATION_FAILURE
;
}
done:
heap_
free
(
eW
.
szMachineName
);
heap_
free
(
eW
.
szObjectName
);
heap_
free
(
eW
.
szInstanceName
);
heap_
free
(
eW
.
szParentInstance
);
heap_
free
(
eW
.
szCounterName
);
free
(
eW
.
szMachineName
);
free
(
eW
.
szObjectName
);
free
(
eW
.
szInstanceName
);
free
(
eW
.
szParentInstance
);
free
(
eW
.
szCounterName
);
return
ret
;
}
...
...
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