Commit a31b1079 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

sxs: Use CRT memory allocation functions.

parent d3fe9faf
......@@ -89,7 +89,7 @@ static ULONG WINAPI cache_Release( IAssemblyCache *iface )
{
TRACE("destroying %p\n", cache);
CloseHandle( cache->lock );
HeapFree( GetProcessHeap(), 0, cache );
free( cache );
}
return refs;
}
......@@ -115,7 +115,7 @@ static WCHAR *build_assembly_name( const WCHAR *arch, const WCHAR *name, const W
buflen += lstrlenW( name );
buflen += lstrlenW( token );
buflen += lstrlenW( version );
if (!(ret = HeapAlloc( GetProcessHeap(), 0, buflen * sizeof(WCHAR) ))) return NULL;
if (!(ret = malloc( buflen * sizeof(WCHAR) ))) return NULL;
*len = swprintf( ret, buflen, fmtW, arch, name, token, version );
return wcslwr( ret );
}
......@@ -128,15 +128,15 @@ static WCHAR *build_dll_path( const WCHAR *arch, const WCHAR *name, const WCHAR
if (!(path = build_assembly_name( arch, name, token, version, &len ))) return NULL;
len += build_sxs_path( sxsdir ) + 2;
if (!(ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
if (!(ret = malloc( len * sizeof(WCHAR) )))
{
HeapFree( GetProcessHeap(), 0, path );
free( path );
return NULL;
}
lstrcpyW( ret, sxsdir );
lstrcatW( ret, path );
lstrcatW( ret, L"\\" );
HeapFree( GetProcessHeap(), 0, path );
free( path );
return ret;
}
......@@ -151,7 +151,7 @@ static WCHAR *build_policy_name( const WCHAR *arch, const WCHAR *name, const WCH
buflen += lstrlenW( arch );
buflen += lstrlenW( name );
buflen += lstrlenW( token );
if (!(ret = HeapAlloc( GetProcessHeap(), 0, buflen * sizeof(WCHAR) ))) return NULL;
if (!(ret = malloc( buflen * sizeof(WCHAR) ))) return NULL;
*len = swprintf( ret, buflen, fmtW, arch, name, token );
return wcslwr( ret );
}
......@@ -168,13 +168,13 @@ static WCHAR *build_policy_path( const WCHAR *arch, const WCHAR *name, const WCH
len += ARRAY_SIZE(fmtW);
len += build_sxs_path( sxsdir );
len += lstrlenW( version );
if (!(ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
if (!(ret = malloc( len * sizeof(WCHAR) )))
{
HeapFree( GetProcessHeap(), 0, path );
free( path );
return NULL;
}
swprintf( ret, len, fmtW, sxsdir, path, version );
HeapFree( GetProcessHeap(), 0, path );
free( path );
return ret;
}
......@@ -259,7 +259,7 @@ static HRESULT WINAPI cache_QueryAssemblyInfo(
}
done:
HeapFree( GetProcessHeap(), 0, path );
free( path );
IAssemblyName_Release( name_obj );
cache_unlock( cache );
return hr;
......@@ -339,9 +339,9 @@ static void free_assembly( struct assembly *assembly )
struct file *file = LIST_ENTRY( item, struct file, entry );
list_remove( &file->entry );
SysFreeString( file->name );
HeapFree( GetProcessHeap(), 0, file );
free( file );
}
HeapFree( GetProcessHeap(), 0, assembly );
free( assembly );
}
static HRESULT parse_files( IXMLDOMDocument *doc, struct assembly *assembly )
......@@ -386,7 +386,7 @@ static HRESULT parse_files( IXMLDOMDocument *doc, struct assembly *assembly )
if (hr != S_OK)
goto done;
if (!(f = HeapAlloc( GetProcessHeap(), 0, sizeof(struct file) )))
if (!(f = malloc( sizeof(*f) )))
{
IXMLDOMNamedNodeMap_Release( attrs );
hr = E_OUTOFMEMORY;
......@@ -397,7 +397,7 @@ static HRESULT parse_files( IXMLDOMDocument *doc, struct assembly *assembly )
IXMLDOMNamedNodeMap_Release( attrs );
if (!f->name)
{
HeapFree( GetProcessHeap(), 0, f );
free( f );
hr = ERROR_SXS_MANIFEST_FORMAT_ERROR;
goto done;
}
......@@ -450,7 +450,7 @@ static HRESULT parse_assembly( IXMLDOMDocument *doc, struct assembly **assembly
hr = ERROR_SXS_MANIFEST_FORMAT_ERROR;
goto done;
}
if (!(a = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct assembly) )))
if (!(a = calloc(1, sizeof(*a) )))
{
hr = E_OUTOFMEMORY;
goto done;
......@@ -497,9 +497,9 @@ static WCHAR *build_policy_filename( const WCHAR *arch, const WCHAR *name, const
len += ARRAY_SIZE(policiesW) - 1;
len += lstrlenW( version );
len += ARRAY_SIZE(suffixW) - 1;
if (!(ret = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) )))
if (!(ret = malloc( (len + 1) * sizeof(WCHAR) )))
{
HeapFree( GetProcessHeap(), 0, fullname );
free( fullname );
return NULL;
}
lstrcpyW( ret, sxsdir );
......@@ -511,7 +511,7 @@ static WCHAR *build_policy_filename( const WCHAR *arch, const WCHAR *name, const
lstrcatW( ret, version );
lstrcatW( ret, suffixW );
HeapFree( GetProcessHeap(), 0, fullname );
free( fullname );
return ret;
}
......@@ -526,7 +526,7 @@ static HRESULT install_policy( const WCHAR *manifest, struct assembly *assembly
if (!dst) return E_OUTOFMEMORY;
ret = CopyFileW( manifest, dst, FALSE );
HeapFree( GetProcessHeap(), 0, dst );
free( dst );
if (!ret)
{
HRESULT hr = HRESULT_FROM_WIN32( GetLastError() );
......@@ -544,10 +544,10 @@ static WCHAR *build_source_filename( const WCHAR *manifest, struct file *file )
p = wcsrchr( manifest, '\\' );
if (!p) p = wcsrchr( manifest, '/' );
if (!p) return strdupW( manifest );
if (!p) return wcsdup( manifest );
len = p - manifest + 1;
if (!(src = HeapAlloc( GetProcessHeap(), 0, (len + lstrlenW( file->name ) + 1) * sizeof(WCHAR) )))
if (!(src = malloc( (len + lstrlenW( file->name ) + 1) * sizeof(WCHAR) )))
return NULL;
memcpy( src, manifest, len * sizeof(WCHAR) );
......@@ -567,9 +567,9 @@ static WCHAR *build_manifest_filename( const WCHAR *arch, const WCHAR *name, con
len += build_sxs_path( sxsdir );
len += ARRAY_SIZE(manifestsW) - 1;
len += ARRAY_SIZE(suffixW) - 1;
if (!(ret = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) )))
if (!(ret = malloc( (len + 1) * sizeof(WCHAR) )))
{
HeapFree( GetProcessHeap(), 0, fullname );
free( fullname );
return NULL;
}
lstrcpyW( ret, sxsdir );
......@@ -577,7 +577,7 @@ static WCHAR *build_manifest_filename( const WCHAR *arch, const WCHAR *name, con
lstrcatW( ret, fullname );
lstrcatW( ret, suffixW );
HeapFree( GetProcessHeap(), 0, fullname );
free( fullname );
return ret;
}
......@@ -615,7 +615,7 @@ static HRESULT install_assembly( const WCHAR *manifest, struct assembly *assembl
if (!dst) return E_OUTOFMEMORY;
ret = CopyFileW( manifest, dst, FALSE );
HeapFree( GetProcessHeap(), 0, dst );
free( dst );
if (!ret)
{
hr = HRESULT_FROM_WIN32( GetLastError() );
......@@ -633,9 +633,9 @@ static HRESULT install_assembly( const WCHAR *manifest, struct assembly *assembl
if (!(src = build_source_filename( manifest, file ))) goto done;
len = len_sxsdir + len_name + lstrlenW( file->name );
if (!(dst = HeapAlloc( GetProcessHeap(), 0, (len + 2) * sizeof(WCHAR) )))
if (!(dst = malloc( (len + 2) * sizeof(WCHAR) )))
{
HeapFree( GetProcessHeap(), 0, src );
free( src );
goto done;
}
lstrcpyW( dst, sxsdir );
......@@ -647,8 +647,8 @@ static HRESULT install_assembly( const WCHAR *manifest, struct assembly *assembl
for (p = dst; *p; p++) *p = towlower( *p );
ret = CopyFileW( src, dst, FALSE );
HeapFree( GetProcessHeap(), 0, src );
HeapFree( GetProcessHeap(), 0, dst );
free( src );
free( dst );
if (!ret)
{
hr = HRESULT_FROM_WIN32( GetLastError() );
......@@ -659,7 +659,7 @@ static HRESULT install_assembly( const WCHAR *manifest, struct assembly *assembl
hr = S_OK;
done:
HeapFree( GetProcessHeap(), 0, name );
free( name );
return hr;
}
......@@ -711,7 +711,7 @@ static HRESULT uninstall_assembly( struct assembly *assembly )
name = build_assembly_name( assembly->arch, assembly->name, assembly->token, assembly->version,
&len_name );
if (!name) return E_OUTOFMEMORY;
if (!(dirname = HeapAlloc( GetProcessHeap(), 0, (len_sxsdir + len_name + 1) * sizeof(WCHAR) )))
if (!(dirname = malloc( (len_sxsdir + len_name + 1) * sizeof(WCHAR) )))
goto done;
lstrcpyW( dirname, sxsdir );
lstrcpyW( dirname + len_sxsdir, name );
......@@ -719,20 +719,20 @@ static HRESULT uninstall_assembly( struct assembly *assembly )
LIST_FOR_EACH_ENTRY( file, &assembly->files, struct file, entry )
{
len = len_sxsdir + len_name + 1 + lstrlenW( file->name );
if (!(filename = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) goto done;
if (!(filename = malloc( (len + 1) * sizeof(WCHAR) ))) goto done;
lstrcpyW( filename, dirname );
lstrcatW( filename, backslashW );
lstrcatW( filename, file->name );
if (!DeleteFileW( filename )) WARN( "failed to delete file %lu\n", GetLastError() );
HeapFree( GetProcessHeap(), 0, filename );
free( filename );
}
RemoveDirectoryW( dirname );
hr = S_OK;
done:
HeapFree( GetProcessHeap(), 0, dirname );
HeapFree( GetProcessHeap(), 0, name );
free( dirname );
free( name );
return hr;
}
......@@ -800,7 +800,7 @@ static HRESULT WINAPI cache_UninstallAssembly(
done:
if (name_obj) IAssemblyName_Release( name_obj );
HeapFree( GetProcessHeap(), 0, path );
free( path );
free_assembly( assembly );
if (doc) IXMLDOMDocument_Release( doc );
if (SUCCEEDED(init)) CoUninitialize();
......@@ -834,7 +834,7 @@ HRESULT WINAPI CreateAssemblyCache( IAssemblyCache **obj, DWORD reserved )
*obj = NULL;
cache = HeapAlloc( GetProcessHeap(), 0, sizeof(struct cache) );
cache = malloc( sizeof(*cache) );
if (!cache)
return E_OUTOFMEMORY;
......@@ -843,7 +843,7 @@ HRESULT WINAPI CreateAssemblyCache( IAssemblyCache **obj, DWORD reserved )
cache->lock = CreateMutexW( NULL, FALSE, cache_mutex_nameW );
if (!cache->lock)
{
HeapFree( GetProcessHeap(), 0, cache );
free( cache );
return HRESULT_FROM_WIN32( GetLastError() );
}
*obj = &cache->IAssemblyCache_iface;
......
......@@ -88,12 +88,12 @@ static ULONG WINAPI name_Release( IAssemblyName *iface )
if (!refs)
{
TRACE("destroying %p\n", name);
HeapFree( GetProcessHeap(), 0, name->name );
HeapFree( GetProcessHeap(), 0, name->arch );
HeapFree( GetProcessHeap(), 0, name->token );
HeapFree( GetProcessHeap(), 0, name->type );
HeapFree( GetProcessHeap(), 0, name->version );
HeapFree( GetProcessHeap(), 0, name );
free( name->name );
free( name->arch );
free( name->token );
free( name->type );
free( name->version );
free( name );
}
return refs;
}
......@@ -251,9 +251,9 @@ static HRESULT WINAPI name_GetVersion(
TRACE("%p, %p, %p\n", iface, high, low);
if (!name->version) return HRESULT_FROM_WIN32( ERROR_NOT_FOUND );
if (!(version = strdupW( name->version ))) return E_OUTOFMEMORY;
if (!(version = wcsdup( name->version ))) return E_OUTOFMEMORY;
hr = parse_version( version, high, low );
HeapFree( GetProcessHeap(), 0, version );
free( version );
return hr;
}
......@@ -300,7 +300,7 @@ static WCHAR *parse_value( const WCHAR *str, unsigned int *len )
if (!*p) return NULL;
*len = p - str;
if (!(ret = HeapAlloc( GetProcessHeap(), 0, *len * sizeof(WCHAR) ))) return NULL;
if (!(ret = malloc( *len * sizeof(WCHAR) ))) return NULL;
memcpy( ret, str + 1, (*len - 1) * sizeof(WCHAR) );
ret[*len - 1] = 0;
return ret;
......@@ -314,7 +314,7 @@ static HRESULT parse_displayname( struct name *name, const WCHAR *displayname )
p = q = displayname;
while (*q && *q != ',') q++;
len = q - p;
if (!(name->name = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
if (!(name->name = malloc( (len + 1) * sizeof(WCHAR) ))) return E_OUTOFMEMORY;
memcpy( name->name, p, len * sizeof(WCHAR) );
name->name[len] = 0;
if (!*q) return S_OK;
......@@ -376,7 +376,7 @@ HRESULT WINAPI CreateAssemblyNameObject(
if (!assembly || !assembly[0] || flags != CANOF_PARSE_DISPLAY_NAME)
return E_INVALIDARG;
if (!(name = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*name) )))
if (!(name = calloc(1, sizeof(*name) )))
return E_OUTOFMEMORY;
name->IAssemblyName_iface.lpVtbl = &name_vtbl;
......@@ -385,12 +385,12 @@ HRESULT WINAPI CreateAssemblyNameObject(
hr = parse_displayname( name, assembly );
if (hr != S_OK)
{
HeapFree( GetProcessHeap(), 0, name->name );
HeapFree( GetProcessHeap(), 0, name->arch );
HeapFree( GetProcessHeap(), 0, name->token );
HeapFree( GetProcessHeap(), 0, name->type );
HeapFree( GetProcessHeap(), 0, name->version );
HeapFree( GetProcessHeap(), 0, name );
free( name->name );
free( name->arch );
free( name->token );
free( name->type );
free( name->version );
free( name );
return hr;
}
*obj = &name->IAssemblyName_iface;
......
......@@ -19,11 +19,11 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#include "windef.h"
#include "winbase.h"
#include "wine/heap.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(sxs);
......@@ -147,7 +147,7 @@ BOOL WINAPI SxsLookupClrGuid(DWORD flags, GUID *clsid, HANDLE actctx, void *buff
goto out;
}
assembly_info = heap_alloc(bytes_assembly_info);
assembly_info = malloc(bytes_assembly_info);
if (!(retval = QueryActCtxW(0, guid_info.hActCtx, &guid_info.ulAssemblyRosterIndex,
AssemblyDetailedInformationInActivationContext, assembly_info,
bytes_assembly_info, &bytes_assembly_info)))
......@@ -219,6 +219,6 @@ out:
if (flags & SXS_LOOKUP_CLR_GUID_USE_ACTCTX)
DeactivateActCtx(0, cookie);
heap_free(assembly_info);
free(assembly_info);
return retval;
}
......@@ -26,13 +26,3 @@ enum name_attr_id
};
const WCHAR *get_name_attribute( IAssemblyName *, enum name_attr_id ) DECLSPEC_HIDDEN;
static inline WCHAR *strdupW( const WCHAR *src )
{
WCHAR *dst;
if (!src) return NULL;
dst = HeapAlloc( GetProcessHeap(), 0, (lstrlenW( src ) + 1) * sizeof(WCHAR) );
if (dst) lstrcpyW( dst, src );
return dst;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment