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
d3fe9faf
Commit
d3fe9faf
authored
Mar 30, 2022
by
Nikolay Sivov
Committed by
Alexandre Julliard
Mar 30, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fusion: Use CRT memory allocation functions.
Signed-off-by:
Nikolay Sivov
<
nsivov@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
a4061238
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
64 additions
and
80 deletions
+64
-80
asmcache.c
dlls/fusion/asmcache.c
+22
-22
asmenum.c
dlls/fusion/asmenum.c
+7
-7
asmname.c
dlls/fusion/asmname.c
+22
-24
assembly.c
dlls/fusion/assembly.c
+13
-13
fusionpriv.h
dlls/fusion/fusionpriv.h
+0
-14
No files found.
dlls/fusion/asmcache.c
View file @
d3fe9faf
...
...
@@ -62,7 +62,7 @@ static BOOL create_full_path(LPCWSTR path)
BOOL
ret
=
TRUE
;
int
len
;
if
(
!
(
new_path
=
heap_
alloc
((
lstrlenW
(
path
)
+
1
)
*
sizeof
(
WCHAR
))))
return
FALSE
;
if
(
!
(
new_path
=
m
alloc
((
lstrlenW
(
path
)
+
1
)
*
sizeof
(
WCHAR
))))
return
FALSE
;
lstrcpyW
(
new_path
,
path
);
...
...
@@ -100,7 +100,7 @@ static BOOL create_full_path(LPCWSTR path)
new_path
[
len
]
=
'\\'
;
}
heap_
free
(
new_path
);
free
(
new_path
);
return
ret
;
}
...
...
@@ -197,7 +197,7 @@ static ULONG WINAPI IAssemblyCacheImpl_Release(IAssemblyCache *iface)
if
(
!
refCount
)
{
CloseHandle
(
cache
->
lock
);
heap_
free
(
cache
);
free
(
cache
);
}
return
refCount
;
}
...
...
@@ -255,7 +255,7 @@ static HRESULT WINAPI IAssemblyCacheImpl_UninstallAssembly(IAssemblyCache *iface
if
(
hr
!=
HRESULT_FROM_WIN32
(
ERROR_INSUFFICIENT_BUFFER
))
goto
done
;
if
(
!
(
path
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
if
(
!
(
path
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
{
hr
=
E_OUTOFMEMORY
;
goto
done
;
...
...
@@ -290,7 +290,7 @@ done:
IAssemblyName_Release
(
asmname
);
if
(
next
)
IAssemblyName_Release
(
next
);
if
(
asmenum
)
IAssemblyEnum_Release
(
asmenum
);
heap_
free
(
path
);
free
(
path
);
cache_unlock
(
cache
);
return
hr
;
}
...
...
@@ -372,7 +372,7 @@ static HRESULT WINAPI IAssemblyCacheImpl_CreateAssemblyCacheItem(IAssemblyCache
*
ppAsmItem
=
NULL
;
if
(
!
(
item
=
heap_
alloc
(
sizeof
(
*
item
))))
return
E_OUTOFMEMORY
;
if
(
!
(
item
=
m
alloc
(
sizeof
(
*
item
))))
return
E_OUTOFMEMORY
;
item
->
IAssemblyCacheItem_iface
.
lpVtbl
=
&
AssemblyCacheItemVtbl
;
item
->
ref
=
1
;
...
...
@@ -395,22 +395,22 @@ static HRESULT copy_file( const WCHAR *src_dir, DWORD src_len, const WCHAR *dst_
DWORD
len
=
lstrlenW
(
filename
);
HRESULT
hr
=
S_OK
;
if
(
!
(
src_file
=
heap_
alloc
(
(
src_len
+
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
(
!
(
src_file
=
m
alloc
(
(
src_len
+
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
E_OUTOFMEMORY
;
memcpy
(
src_file
,
src_dir
,
src_len
*
sizeof
(
WCHAR
)
);
lstrcpyW
(
src_file
+
src_len
,
filename
);
if
(
!
(
dst_file
=
heap_
alloc
(
(
dst_len
+
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
(
!
(
dst_file
=
m
alloc
(
(
dst_len
+
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
heap_
free
(
src_file
);
free
(
src_file
);
return
E_OUTOFMEMORY
;
}
memcpy
(
dst_file
,
dst_dir
,
dst_len
*
sizeof
(
WCHAR
)
);
lstrcpyW
(
dst_file
+
dst_len
,
filename
);
if
(
!
CopyFileW
(
src_file
,
dst_file
,
FALSE
))
hr
=
HRESULT_FROM_WIN32
(
GetLastError
()
);
heap_
free
(
src_file
);
heap_
free
(
dst_file
);
free
(
src_file
);
free
(
dst_file
);
return
hr
;
}
...
...
@@ -483,7 +483,7 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface,
get_assembly_directory
(
asmdir
,
MAX_PATH
,
clr_version
,
architecture
);
dst_len
+=
lstrlenW
(
asmdir
)
+
lstrlenW
(
name
)
+
lstrlenW
(
version
)
+
lstrlenW
(
token
);
if
(
!
(
dst_dir
=
heap_
alloc
(
dst_len
*
sizeof
(
WCHAR
))))
if
(
!
(
dst_dir
=
m
alloc
(
dst_len
*
sizeof
(
WCHAR
))))
{
hr
=
E_OUTOFMEMORY
;
goto
done
;
...
...
@@ -523,13 +523,13 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface,
}
done:
heap_
free
(
name
);
heap_
free
(
token
);
heap_
free
(
version
);
heap_
free
(
asmpath
);
heap_
free
(
dst_dir
);
for
(
i
=
0
;
i
<
count
;
i
++
)
heap_
free
(
external_files
[
i
]);
heap_
free
(
external_files
);
free
(
name
);
free
(
token
);
free
(
version
);
free
(
asmpath
);
free
(
dst_dir
);
for
(
i
=
0
;
i
<
count
;
i
++
)
free
(
external_files
[
i
]);
free
(
external_files
);
assembly_release
(
assembly
);
cache_unlock
(
cache
);
return
hr
;
...
...
@@ -560,14 +560,14 @@ HRESULT WINAPI CreateAssemblyCache(IAssemblyCache **ppAsmCache, DWORD dwReserved
*
ppAsmCache
=
NULL
;
if
(
!
(
cache
=
heap_
alloc
(
sizeof
(
*
cache
))))
return
E_OUTOFMEMORY
;
if
(
!
(
cache
=
m
alloc
(
sizeof
(
*
cache
))))
return
E_OUTOFMEMORY
;
cache
->
IAssemblyCache_iface
.
lpVtbl
=
&
AssemblyCacheVtbl
;
cache
->
ref
=
1
;
cache
->
lock
=
CreateMutexW
(
NULL
,
FALSE
,
cache_mutex_nameW
);
if
(
!
cache
->
lock
)
{
heap_
free
(
cache
);
free
(
cache
);
return
HRESULT_FROM_WIN32
(
GetLastError
()
);
}
*
ppAsmCache
=
&
cache
->
IAssemblyCache_iface
;
...
...
@@ -620,7 +620,7 @@ static ULONG WINAPI IAssemblyCacheItemImpl_Release(IAssemblyCacheItem *iface)
TRACE
(
"(%p)->(ref before = %lu)
\n
"
,
This
,
refCount
+
1
);
if
(
!
refCount
)
heap_
free
(
This
);
free
(
This
);
return
refCount
;
}
...
...
dlls/fusion/asmenum.c
View file @
d3fe9faf
...
...
@@ -105,10 +105,10 @@ static ULONG WINAPI IAssemblyEnumImpl_Release(IAssemblyEnum *iface)
list_remove
(
&
asmname
->
entry
);
IAssemblyName_Release
(
asmname
->
name
);
heap_
free
(
asmname
);
free
(
asmname
);
}
heap_
free
(
This
);
free
(
This
);
}
return
refCount
;
...
...
@@ -354,7 +354,7 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name,
}
swprintf
(
disp
,
ARRAY_SIZE
(
disp
),
name_fmt
,
parent
,
version
,
token
);
if
(
!
(
asmname
=
heap_
alloc
(
sizeof
(
*
asmname
))))
if
(
!
(
asmname
=
m
alloc
(
sizeof
(
*
asmname
))))
{
hr
=
E_OUTOFMEMORY
;
break
;
...
...
@@ -364,7 +364,7 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name,
CANOF_PARSE_DISPLAY_NAME
,
NULL
);
if
(
FAILED
(
hr
))
{
heap_
free
(
asmname
);
free
(
asmname
);
break
;
}
...
...
@@ -372,7 +372,7 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name,
if
(
FAILED
(
hr
))
{
IAssemblyName_Release
(
asmname
->
name
);
heap_
free
(
asmname
);
free
(
asmname
);
break
;
}
...
...
@@ -475,7 +475,7 @@ HRESULT WINAPI CreateAssemblyEnum(IAssemblyEnum **pEnum, IUnknown *pUnkReserved,
if
(
dwFlags
==
0
||
dwFlags
==
ASM_CACHE_ROOT
)
return
E_INVALIDARG
;
if
(
!
(
asmenum
=
heap_
alloc
(
sizeof
(
*
asmenum
))))
return
E_OUTOFMEMORY
;
if
(
!
(
asmenum
=
m
alloc
(
sizeof
(
*
asmenum
))))
return
E_OUTOFMEMORY
;
asmenum
->
IAssemblyEnum_iface
.
lpVtbl
=
&
AssemblyEnumVtbl
;
asmenum
->
ref
=
1
;
...
...
@@ -486,7 +486,7 @@ HRESULT WINAPI CreateAssemblyEnum(IAssemblyEnum **pEnum, IUnknown *pUnkReserved,
hr
=
enumerate_gac
(
asmenum
,
pName
);
if
(
FAILED
(
hr
))
{
heap_
free
(
asmenum
);
free
(
asmenum
);
return
hr
;
}
}
...
...
dlls/fusion/asmname.c
View file @
d3fe9faf
...
...
@@ -114,12 +114,12 @@ static ULONG WINAPI IAssemblyNameImpl_Release(IAssemblyName *iface)
if
(
!
refCount
)
{
heap_
free
(
This
->
path
);
heap_
free
(
This
->
displayname
);
heap_
free
(
This
->
name
);
heap_
free
(
This
->
culture
);
heap_
free
(
This
->
procarch
);
heap_
free
(
This
);
free
(
This
->
path
);
free
(
This
->
displayname
);
free
(
This
->
name
);
free
(
This
->
culture
);
free
(
This
->
procarch
);
free
(
This
);
}
return
refCount
;
...
...
@@ -521,7 +521,7 @@ HRESULT IAssemblyName_SetPath(IAssemblyName *iface, LPCWSTR path)
{
IAssemblyNameImpl
*
name
=
unsafe_impl_from_IAssemblyName
(
iface
);
name
->
path
=
strdupW
(
path
);
name
->
path
=
wcsdup
(
path
);
if
(
!
name
->
path
)
return
E_OUTOFMEMORY
;
...
...
@@ -576,12 +576,10 @@ static HRESULT parse_version(IAssemblyNameImpl *name, LPWSTR version)
static
HRESULT
parse_culture
(
IAssemblyNameImpl
*
name
,
LPCWSTR
culture
)
{
static
const
WCHAR
empty
[]
=
{
0
};
if
(
lstrlenW
(
culture
)
==
2
)
name
->
culture
=
strdupW
(
culture
);
name
->
culture
=
wcsdup
(
culture
);
else
name
->
culture
=
strdupW
(
empty
);
name
->
culture
=
wcsdup
(
L""
);
return
S_OK
;
}
...
...
@@ -662,7 +660,7 @@ static WCHAR *parse_value( const WCHAR *str, unsigned int len )
BOOL
quoted
=
FALSE
;
unsigned
int
i
=
0
;
if
(
!
(
ret
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
NULL
;
if
(
!
(
ret
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
NULL
;
if
(
*
p
==
'\"'
)
{
quoted
=
TRUE
;
...
...
@@ -671,7 +669,7 @@ static WCHAR *parse_value( const WCHAR *str, unsigned int len )
while
(
*
p
&&
*
p
!=
'\"'
)
ret
[
i
++
]
=
*
p
++
;
if
((
quoted
&&
*
p
!=
'\"'
)
||
(
!
quoted
&&
*
p
==
'\"'
))
{
heap_
free
(
ret
);
free
(
ret
);
return
NULL
;
}
ret
[
i
]
=
0
;
...
...
@@ -687,11 +685,11 @@ static HRESULT parse_display_name(IAssemblyNameImpl *name, LPCWSTR szAssemblyNam
if
(
!
szAssemblyName
)
return
S_OK
;
name
->
displayname
=
strdupW
(
szAssemblyName
);
name
->
displayname
=
wcsdup
(
szAssemblyName
);
if
(
!
name
->
displayname
)
return
E_OUTOFMEMORY
;
str
=
strdupW
(
szAssemblyName
);
str
=
wcsdup
(
szAssemblyName
);
save
=
str
;
if
(
!
str
)
{
...
...
@@ -709,7 +707,7 @@ static HRESULT parse_display_name(IAssemblyNameImpl *name, LPCWSTR szAssemblyNam
goto
done
;
}
name
->
name
=
strdupW
(
str
);
name
->
name
=
wcsdup
(
str
);
if
(
!
name
->
name
)
{
hr
=
E_OUTOFMEMORY
;
...
...
@@ -768,7 +766,7 @@ static HRESULT parse_display_name(IAssemblyNameImpl *name, LPCWSTR szAssemblyNam
hr
=
parse_procarch
(
name
,
name
->
procarch
);
}
heap_
free
(
value
);
free
(
value
);
if
(
FAILED
(
hr
))
goto
done
;
...
...
@@ -777,13 +775,13 @@ static HRESULT parse_display_name(IAssemblyNameImpl *name, LPCWSTR szAssemblyNam
}
done:
heap_
free
(
save
);
free
(
save
);
if
(
FAILED
(
hr
))
{
heap_
free
(
name
->
displayname
);
heap_
free
(
name
->
name
);
heap_
free
(
name
->
culture
);
heap_
free
(
name
->
procarch
);
free
(
name
->
displayname
);
free
(
name
->
name
);
free
(
name
->
culture
);
free
(
name
->
procarch
);
}
return
hr
;
}
...
...
@@ -808,7 +806,7 @@ HRESULT WINAPI CreateAssemblyNameObject(IAssemblyName **ppAssemblyNameObj,
(
!
szAssemblyName
||
!*
szAssemblyName
))
return
E_INVALIDARG
;
if
(
!
(
name
=
heap_alloc_zero
(
sizeof
(
*
name
))))
return
E_OUTOFMEMORY
;
if
(
!
(
name
=
calloc
(
1
,
sizeof
(
*
name
))))
return
E_OUTOFMEMORY
;
name
->
IAssemblyName_iface
.
lpVtbl
=
&
AssemblyNameVtbl
;
name
->
ref
=
1
;
...
...
@@ -816,7 +814,7 @@ HRESULT WINAPI CreateAssemblyNameObject(IAssemblyName **ppAssemblyNameObj,
hr
=
parse_display_name
(
name
,
szAssemblyName
);
if
(
FAILED
(
hr
))
{
heap_
free
(
name
);
free
(
name
);
return
hr
;
}
...
...
dlls/fusion/assembly.c
View file @
d3fe9faf
...
...
@@ -540,7 +540,7 @@ static HRESULT parse_metadata_header(ASSEMBLY *assembly, DWORD *hdrsz)
metadatahdr
=
(
METADATAHDR
*
)
ptr
;
if
(
!
(
assembly
->
metadatahdr
=
heap_
alloc
(
sizeof
(
*
assembly
->
metadatahdr
))))
return
E_OUTOFMEMORY
;
if
(
!
(
assembly
->
metadatahdr
=
m
alloc
(
sizeof
(
*
assembly
->
metadatahdr
))))
return
E_OUTOFMEMORY
;
size
=
FIELD_OFFSET
(
METADATAHDR
,
Version
);
memcpy
(
assembly
->
metadatahdr
,
metadatahdr
,
size
);
...
...
@@ -645,9 +645,9 @@ HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file)
*
out
=
NULL
;
if
(
!
(
assembly
=
heap_alloc_zero
(
sizeof
(
*
assembly
))))
return
E_OUTOFMEMORY
;
if
(
!
(
assembly
=
calloc
(
1
,
sizeof
(
*
assembly
))))
return
E_OUTOFMEMORY
;
assembly
->
path
=
strdupW
(
file
);
assembly
->
path
=
wcsdup
(
file
);
if
(
!
assembly
->
path
)
{
hr
=
E_OUTOFMEMORY
;
...
...
@@ -696,12 +696,12 @@ HRESULT assembly_release(ASSEMBLY *assembly)
if
(
!
assembly
)
return
S_OK
;
heap_
free
(
assembly
->
metadatahdr
);
heap_
free
(
assembly
->
path
);
free
(
assembly
->
metadatahdr
);
free
(
assembly
->
path
);
UnmapViewOfFile
(
assembly
->
data
);
CloseHandle
(
assembly
->
hmap
);
CloseHandle
(
assembly
->
hfile
);
heap_
free
(
assembly
);
free
(
assembly
);
return
S_OK
;
}
...
...
@@ -714,7 +714,7 @@ static LPWSTR assembly_dup_str(const ASSEMBLY *assembly, DWORD index)
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
NULL
,
0
);
if
((
cpy
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
))))
if
((
cpy
=
m
alloc
(
len
*
sizeof
(
WCHAR
))))
MultiByteToWideChar
(
CP_ACP
,
0
,
str
,
-
1
,
cpy
,
len
);
return
cpy
;
...
...
@@ -749,7 +749,7 @@ HRESULT assembly_get_name(ASSEMBLY *assembly, LPWSTR *name)
HRESULT
assembly_get_path
(
const
ASSEMBLY
*
assembly
,
LPWSTR
*
path
)
{
WCHAR
*
cpy
=
heap_
alloc
((
lstrlenW
(
assembly
->
path
)
+
1
)
*
sizeof
(
WCHAR
));
WCHAR
*
cpy
=
m
alloc
((
lstrlenW
(
assembly
->
path
)
+
1
)
*
sizeof
(
WCHAR
));
*
path
=
cpy
;
if
(
cpy
)
lstrcpyW
(
cpy
,
assembly
->
path
);
...
...
@@ -776,7 +776,7 @@ HRESULT assembly_get_version(ASSEMBLY *assembly, LPWSTR *version)
if
(
!
asmtbl
)
return
E_FAIL
;
if
(
!
(
*
version
=
heap_
alloc
(
24
*
sizeof
(
WCHAR
))))
if
(
!
(
*
version
=
m
alloc
(
24
*
sizeof
(
WCHAR
))))
return
E_OUTOFMEMORY
;
swprintf
(
*
version
,
24
,
format
,
asmtbl
->
MajorVersion
,
asmtbl
->
MinorVersion
,
...
...
@@ -846,7 +846,7 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token)
for
(
i
=
size
-
1
;
i
>=
size
-
8
;
i
--
)
tokbytes
[
size
-
i
-
1
]
=
hashdata
[
i
];
if
(
!
(
tok
=
heap_
alloc
((
TOKEN_LENGTH
+
1
)
*
sizeof
(
WCHAR
))))
if
(
!
(
tok
=
m
alloc
((
TOKEN_LENGTH
+
1
)
*
sizeof
(
WCHAR
))))
{
hr
=
E_OUTOFMEMORY
;
goto
done
;
...
...
@@ -890,7 +890,7 @@ HRESULT assembly_get_external_files(ASSEMBLY *assembly, LPWSTR **files, DWORD *c
if
(
num_rows
<=
0
)
return
S_OK
;
if
(
!
(
ret
=
heap_
alloc
(
num_rows
*
sizeof
(
WCHAR
*
))))
return
E_OUTOFMEMORY
;
if
(
!
(
ret
=
m
alloc
(
num_rows
*
sizeof
(
WCHAR
*
))))
return
E_OUTOFMEMORY
;
for
(
i
=
0
;
i
<
num_rows
;
i
++
)
{
...
...
@@ -903,8 +903,8 @@ HRESULT assembly_get_external_files(ASSEMBLY *assembly, LPWSTR **files, DWORD *c
ret
[
i
]
=
assembly_dup_str
(
assembly
,
idx
);
if
(
!
ret
[
i
])
{
for
(;
i
>=
0
;
i
--
)
heap_
free
(
ret
[
i
]);
heap_
free
(
ret
);
for
(;
i
>=
0
;
i
--
)
free
(
ret
[
i
]);
free
(
ret
);
return
E_OUTOFMEMORY
;
}
ptr
+=
assembly
->
stringsz
;
/* skip Name field */
...
...
dlls/fusion/fusionpriv.h
View file @
d3fe9faf
...
...
@@ -27,7 +27,6 @@
#include "winbase.h"
#include "winuser.h"
#include "winver.h"
#include "wine/heap.h"
#include <pshpack1.h>
...
...
@@ -442,19 +441,6 @@ HRESULT assembly_get_external_files(ASSEMBLY *assembly, LPWSTR **files, DWORD *c
extern
HRESULT
IAssemblyName_SetPath
(
IAssemblyName
*
iface
,
LPCWSTR
path
)
DECLSPEC_HIDDEN
;
extern
HRESULT
IAssemblyName_GetPath
(
IAssemblyName
*
iface
,
LPWSTR
buf
,
ULONG
*
len
)
DECLSPEC_HIDDEN
;
static
inline
LPWSTR
strdupW
(
LPCWSTR
src
)
{
LPWSTR
dest
;
if
(
!
src
)
return
NULL
;
if
((
dest
=
heap_alloc
((
lstrlenW
(
src
)
+
1
)
*
sizeof
(
WCHAR
))))
lstrcpyW
(
dest
,
src
);
return
dest
;
}
#define BYTES_PER_TOKEN 8
#define CHARS_PER_BYTE 2
#define TOKEN_LENGTH (BYTES_PER_TOKEN * CHARS_PER_BYTE + 1)
...
...
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