Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/fusion/asmcache.c | 50 +++++++++++++++++++++--------------------------- dlls/fusion/asmenum.c | 17 +++++++--------- dlls/fusion/asmname.c | 34 ++++++++++++++++---------------- dlls/fusion/assembly.c | 39 +++++++++++++++---------------------- dlls/fusion/fusionpriv.h | 4 ++-- 5 files changed, 62 insertions(+), 82 deletions(-)
diff --git a/dlls/fusion/asmcache.c b/dlls/fusion/asmcache.c index 6cc6602dcc..668aa8777e 100644 --- a/dlls/fusion/asmcache.c +++ b/dlls/fusion/asmcache.c @@ -63,9 +63,7 @@ static BOOL create_full_path(LPCWSTR path) BOOL ret = TRUE; int len;
- new_path = HeapAlloc(GetProcessHeap(), 0, (strlenW(path) + 1) * sizeof(WCHAR)); - if (!new_path) - return FALSE; + if (!(new_path = heap_alloc((strlenW(path) + 1) * sizeof(WCHAR)))) return FALSE;
strcpyW(new_path, path);
@@ -103,7 +101,7 @@ static BOOL create_full_path(LPCWSTR path) new_path[len] = '\'; }
- HeapFree(GetProcessHeap(), 0, new_path); + heap_free(new_path); return ret; }
@@ -200,7 +198,7 @@ static ULONG WINAPI IAssemblyCacheImpl_Release(IAssemblyCache *iface) if (!refCount) { CloseHandle( cache->lock ); - HeapFree( GetProcessHeap(), 0, cache ); + heap_free( cache ); } return refCount; } @@ -258,7 +256,7 @@ static HRESULT WINAPI IAssemblyCacheImpl_UninstallAssembly(IAssemblyCache *iface if (hr != HRESULT_FROM_WIN32( ERROR_INSUFFICIENT_BUFFER )) goto done;
- if (!(path = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ))) + if (!(path = heap_alloc( len * sizeof(WCHAR) ))) { hr = E_OUTOFMEMORY; goto done; @@ -293,7 +291,7 @@ done: IAssemblyName_Release( asmname ); if (next) IAssemblyName_Release( next ); if (asmenum) IAssemblyEnum_Release( asmenum ); - HeapFree( GetProcessHeap(), 0, path ); + heap_free( path ); cache_unlock( cache ); return hr; } @@ -375,9 +373,7 @@ static HRESULT WINAPI IAssemblyCacheImpl_CreateAssemblyCacheItem(IAssemblyCache
*ppAsmItem = NULL;
- item = HeapAlloc(GetProcessHeap(), 0, sizeof(IAssemblyCacheItemImpl)); - if (!item) - return E_OUTOFMEMORY; + if (!(item = heap_alloc(sizeof(*item)))) return E_OUTOFMEMORY;
item->IAssemblyCacheItem_iface.lpVtbl = &AssemblyCacheItemVtbl; item->ref = 1; @@ -400,22 +396,22 @@ static HRESULT copy_file( const WCHAR *src_dir, DWORD src_len, const WCHAR *dst_ DWORD len = strlenW( filename ); HRESULT hr = S_OK;
- if (!(src_file = HeapAlloc( GetProcessHeap(), 0, (src_len + len + 1) * sizeof(WCHAR) ))) + if (!(src_file = heap_alloc( (src_len + len + 1) * sizeof(WCHAR) ))) return E_OUTOFMEMORY; memcpy( src_file, src_dir, src_len * sizeof(WCHAR) ); strcpyW( src_file + src_len, filename );
- if (!(dst_file = HeapAlloc( GetProcessHeap(), 0, (dst_len + len + 1) * sizeof(WCHAR) ))) + if (!(dst_file = heap_alloc( (dst_len + len + 1) * sizeof(WCHAR) ))) { - HeapFree( GetProcessHeap(), 0, src_file ); + heap_free( src_file ); return E_OUTOFMEMORY; } memcpy( dst_file, dst_dir, dst_len * sizeof(WCHAR) ); strcpyW( dst_file + dst_len, filename );
if (!CopyFileW( src_file, dst_file, FALSE )) hr = HRESULT_FROM_WIN32( GetLastError() ); - HeapFree( GetProcessHeap(), 0, src_file ); - HeapFree( GetProcessHeap(), 0, dst_file ); + heap_free( src_file ); + heap_free( dst_file ); return hr; }
@@ -488,7 +484,7 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface, get_assembly_directory(asmdir, MAX_PATH, clr_version, architecture);
dst_len += strlenW(asmdir) + strlenW(name) + strlenW(version) + strlenW(token); - if (!(dst_dir = HeapAlloc(GetProcessHeap(), 0, dst_len * sizeof(WCHAR)))) + if (!(dst_dir = heap_alloc(dst_len * sizeof(WCHAR)))) { hr = E_OUTOFMEMORY; goto done; @@ -528,13 +524,13 @@ static HRESULT WINAPI IAssemblyCacheImpl_InstallAssembly(IAssemblyCache *iface, }
done: - HeapFree(GetProcessHeap(), 0, name); - HeapFree(GetProcessHeap(), 0, token); - HeapFree(GetProcessHeap(), 0, version); - HeapFree(GetProcessHeap(), 0, asmpath); - HeapFree(GetProcessHeap(), 0, dst_dir); - for (i = 0; i < count; i++) HeapFree(GetProcessHeap(), 0, external_files[i]); - HeapFree(GetProcessHeap(), 0, external_files); + 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); assembly_release(assembly); cache_unlock( cache ); return hr; @@ -565,16 +561,14 @@ HRESULT WINAPI CreateAssemblyCache(IAssemblyCache **ppAsmCache, DWORD dwReserved
*ppAsmCache = NULL;
- cache = HeapAlloc(GetProcessHeap(), 0, sizeof(IAssemblyCacheImpl)); - if (!cache) - return E_OUTOFMEMORY; + if (!(cache = heap_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) { - HeapFree( GetProcessHeap(), 0, cache ); + heap_free( cache ); return HRESULT_FROM_WIN32( GetLastError() ); } *ppAsmCache = &cache->IAssemblyCache_iface; @@ -627,7 +621,7 @@ static ULONG WINAPI IAssemblyCacheItemImpl_Release(IAssemblyCacheItem *iface) TRACE("(%p)->(ref before = %u)\n", This, refCount + 1);
if (!refCount) - HeapFree(GetProcessHeap(), 0, This); + heap_free(This);
return refCount; } diff --git a/dlls/fusion/asmenum.c b/dlls/fusion/asmenum.c index 4a5dadd994..ba86818a2c 100644 --- a/dlls/fusion/asmenum.c +++ b/dlls/fusion/asmenum.c @@ -106,10 +106,10 @@ static ULONG WINAPI IAssemblyEnumImpl_Release(IAssemblyEnum *iface)
list_remove(&asmname->entry); IAssemblyName_Release(asmname->name); - HeapFree(GetProcessHeap(), 0, asmname); + heap_free(asmname); }
- HeapFree(GetProcessHeap(), 0, This); + heap_free(This); }
return refCount; @@ -355,8 +355,7 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name, } sprintfW(disp, name_fmt, parent, version, token);
- asmname = HeapAlloc(GetProcessHeap(), 0, sizeof(ASMNAME)); - if (!asmname) + if (!(asmname = heap_alloc(sizeof(*asmname)))) { hr = E_OUTOFMEMORY; break; @@ -366,7 +365,7 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name, CANOF_PARSE_DISPLAY_NAME, NULL); if (FAILED(hr)) { - HeapFree(GetProcessHeap(), 0, asmname); + heap_free(asmname); break; }
@@ -374,7 +373,7 @@ static HRESULT enum_gac_assemblies(struct list *assemblies, IAssemblyName *name, if (FAILED(hr)) { IAssemblyName_Release(asmname->name); - HeapFree(GetProcessHeap(), 0, asmname); + heap_free(asmname); break; }
@@ -477,9 +476,7 @@ HRESULT WINAPI CreateAssemblyEnum(IAssemblyEnum **pEnum, IUnknown *pUnkReserved, if (dwFlags == 0 || dwFlags == ASM_CACHE_ROOT) return E_INVALIDARG;
- asmenum = HeapAlloc(GetProcessHeap(), 0, sizeof(IAssemblyEnumImpl)); - if (!asmenum) - return E_OUTOFMEMORY; + if (!(asmenum = heap_alloc(sizeof(*asmenum)))) return E_OUTOFMEMORY;
asmenum->IAssemblyEnum_iface.lpVtbl = &AssemblyEnumVtbl; asmenum->ref = 1; @@ -490,7 +487,7 @@ HRESULT WINAPI CreateAssemblyEnum(IAssemblyEnum **pEnum, IUnknown *pUnkReserved, hr = enumerate_gac(asmenum, pName); if (FAILED(hr)) { - HeapFree(GetProcessHeap(), 0, asmenum); + heap_free(asmenum); return hr; } } diff --git a/dlls/fusion/asmname.c b/dlls/fusion/asmname.c index ea104349b3..c5d07009a3 100644 --- a/dlls/fusion/asmname.c +++ b/dlls/fusion/asmname.c @@ -115,12 +115,12 @@ static ULONG WINAPI IAssemblyNameImpl_Release(IAssemblyName *iface)
if (!refCount) { - HeapFree(GetProcessHeap(), 0, This->path); - HeapFree(GetProcessHeap(), 0, This->displayname); - HeapFree(GetProcessHeap(), 0, This->name); - HeapFree(GetProcessHeap(), 0, This->culture); - HeapFree(GetProcessHeap(), 0, This->procarch); - HeapFree(GetProcessHeap(), 0, This); + heap_free(This->path); + heap_free(This->displayname); + heap_free(This->name); + heap_free(This->culture); + heap_free(This->procarch); + heap_free(This); }
return refCount; @@ -663,7 +663,7 @@ static WCHAR *parse_value( const WCHAR *str, unsigned int len ) BOOL quoted = FALSE; unsigned int i = 0;
- if (!(ret = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return NULL; + if (!(ret = heap_alloc( (len + 1) * sizeof(WCHAR) ))) return NULL; if (*p == '"') { quoted = TRUE; @@ -672,7 +672,7 @@ static WCHAR *parse_value( const WCHAR *str, unsigned int len ) while (*p && *p != '"') ret[i++] = *p++; if ((quoted && *p != '"') || (!quoted && *p == '"')) { - HeapFree( GetProcessHeap(), 0, ret ); + heap_free( ret ); return NULL; } ret[i] = 0; @@ -769,7 +769,7 @@ static HRESULT parse_display_name(IAssemblyNameImpl *name, LPCWSTR szAssemblyNam
hr = parse_procarch( name, name->procarch ); } - HeapFree( GetProcessHeap(), 0, value ); + heap_free( value );
if (FAILED(hr)) goto done; @@ -778,13 +778,13 @@ static HRESULT parse_display_name(IAssemblyNameImpl *name, LPCWSTR szAssemblyNam }
done: - HeapFree(GetProcessHeap(), 0, save); + heap_free(save); if (FAILED(hr)) { - HeapFree(GetProcessHeap(), 0, name->displayname); - HeapFree(GetProcessHeap(), 0, name->name); - HeapFree(GetProcessHeap(), 0, name->culture); - HeapFree(GetProcessHeap(), 0, name->procarch); + heap_free(name->displayname); + heap_free(name->name); + heap_free(name->culture); + heap_free(name->procarch); } return hr; } @@ -809,9 +809,7 @@ HRESULT WINAPI CreateAssemblyNameObject(IAssemblyName **ppAssemblyNameObj, (!szAssemblyName || !*szAssemblyName)) return E_INVALIDARG;
- name = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAssemblyNameImpl)); - if (!name) - return E_OUTOFMEMORY; + if (!(name = heap_alloc_zero(sizeof(*name)))) return E_OUTOFMEMORY;
name->IAssemblyName_iface.lpVtbl = &AssemblyNameVtbl; name->ref = 1; @@ -819,7 +817,7 @@ HRESULT WINAPI CreateAssemblyNameObject(IAssemblyName **ppAssemblyNameObj, hr = parse_display_name(name, szAssemblyName); if (FAILED(hr)) { - HeapFree(GetProcessHeap(), 0, name); + heap_free(name); return hr; }
diff --git a/dlls/fusion/assembly.c b/dlls/fusion/assembly.c index c2f98ecf72..ec380ef442 100644 --- a/dlls/fusion/assembly.c +++ b/dlls/fusion/assembly.c @@ -539,9 +539,7 @@ static HRESULT parse_metadata_header(ASSEMBLY *assembly, DWORD *hdrsz)
metadatahdr = (METADATAHDR *)ptr;
- assembly->metadatahdr = HeapAlloc(GetProcessHeap(), 0, sizeof(METADATAHDR)); - if (!assembly->metadatahdr) - return E_OUTOFMEMORY; + if (!(assembly->metadatahdr = heap_alloc(sizeof(*assembly->metadatahdr)))) return E_OUTOFMEMORY;
size = FIELD_OFFSET(METADATAHDR, Version); memcpy(assembly->metadatahdr, metadatahdr, size); @@ -646,9 +644,7 @@ HRESULT assembly_create(ASSEMBLY **out, LPCWSTR file)
*out = NULL;
- assembly = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(ASSEMBLY)); - if (!assembly) - return E_OUTOFMEMORY; + if (!(assembly = heap_alloc_zero(sizeof(*assembly)))) return E_OUTOFMEMORY;
assembly->path = strdupW(file); if (!assembly->path) @@ -699,12 +695,12 @@ HRESULT assembly_release(ASSEMBLY *assembly) if (!assembly) return S_OK;
- HeapFree(GetProcessHeap(), 0, assembly->metadatahdr); - HeapFree(GetProcessHeap(), 0, assembly->path); + heap_free(assembly->metadatahdr); + heap_free(assembly->path); UnmapViewOfFile(assembly->data); CloseHandle(assembly->hmap); CloseHandle(assembly->hfile); - HeapFree(GetProcessHeap(), 0, assembly); + heap_free(assembly);
return S_OK; } @@ -717,8 +713,8 @@ static LPWSTR assembly_dup_str(const ASSEMBLY *assembly, DWORD index)
len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
- if ((cpy = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)))) - MultiByteToWideChar(CP_ACP, 0, str, -1, cpy, len); + if ((cpy = heap_alloc(len * sizeof(WCHAR)))) + MultiByteToWideChar(CP_ACP, 0, str, -1, cpy, len);
return cpy; } @@ -752,7 +748,7 @@ HRESULT assembly_get_name(ASSEMBLY *assembly, LPWSTR *name)
HRESULT assembly_get_path(const ASSEMBLY *assembly, LPWSTR *path) { - LPWSTR cpy = HeapAlloc(GetProcessHeap(), 0, (strlenW(assembly->path) + 1) * sizeof(WCHAR)); + WCHAR *cpy = heap_alloc((strlenW(assembly->path) + 1) * sizeof(WCHAR)); *path = cpy; if (cpy) strcpyW(cpy, assembly->path); @@ -779,8 +775,7 @@ HRESULT assembly_get_version(ASSEMBLY *assembly, LPWSTR *version) if (!asmtbl) return E_FAIL;
- *version = HeapAlloc(GetProcessHeap(), 0, sizeof(format) + 4 * strlen("65535") * sizeof(WCHAR)); - if (!*version) + if (!(*version = heap_alloc(sizeof(format) + 4 * strlen("65535") * sizeof(WCHAR)))) return E_OUTOFMEMORY;
sprintfW(*version, format, asmtbl->MajorVersion, asmtbl->MinorVersion, @@ -852,8 +847,7 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token) if (!CryptGetHashParam(hash, HP_HASHVAL, NULL, &size, 0)) return E_FAIL;
- hashdata = HeapAlloc(GetProcessHeap(), 0, size); - if (!hashdata) + if (!(hashdata = heap_alloc(size))) { hr = E_OUTOFMEMORY; goto done; @@ -865,8 +859,7 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token) for (i = size - 1; i >= size - 8; i--) tokbytes[size - i - 1] = hashdata[i];
- tok = HeapAlloc(GetProcessHeap(), 0, (TOKEN_LENGTH + 1) * sizeof(WCHAR)); - if (!tok) + if (!(tok = heap_alloc((TOKEN_LENGTH + 1) * sizeof(WCHAR)))) { hr = E_OUTOFMEMORY; goto done; @@ -878,7 +871,7 @@ HRESULT assembly_get_pubkey_token(ASSEMBLY *assembly, LPWSTR *token) hr = S_OK;
done: - HeapFree(GetProcessHeap(), 0, hashdata); + heap_free(hashdata); CryptDestroyHash(hash); CryptReleaseContext(crypt, 0);
@@ -913,9 +906,7 @@ HRESULT assembly_get_external_files(ASSEMBLY *assembly, LPWSTR **files, DWORD *c if (num_rows <= 0) return S_OK;
- ret = HeapAlloc(GetProcessHeap(), 0, num_rows * sizeof(WCHAR *)); - if (!ret) - return E_OUTOFMEMORY; + if (!(ret = heap_alloc(num_rows * sizeof(WCHAR *)))) return E_OUTOFMEMORY;
for (i = 0; i < num_rows; i++) { @@ -928,8 +919,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--) HeapFree(GetProcessHeap(), 0, ret[i]); - HeapFree(GetProcessHeap(), 0, ret); + for (; i >= 0; i--) heap_free(ret[i]); + heap_free(ret); return E_OUTOFMEMORY; } ptr += assembly->stringsz; /* skip Name field */ diff --git a/dlls/fusion/fusionpriv.h b/dlls/fusion/fusionpriv.h index 95b1282050..22de4ca784 100644 --- a/dlls/fusion/fusionpriv.h +++ b/dlls/fusion/fusionpriv.h @@ -27,6 +27,7 @@ #include "winbase.h" #include "winuser.h" #include "winver.h" +#include "wine/heap.h"
#include <pshpack1.h>
@@ -448,8 +449,7 @@ static inline LPWSTR strdupW(LPCWSTR src) if (!src) return NULL;
- dest = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(src) + 1) * sizeof(WCHAR)); - if (dest) + if ((dest = heap_alloc((lstrlenW(src) + 1) * sizeof(WCHAR)))) lstrcpyW(dest, src);
return dest;