Commit 0d5f2845 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: Use CRT allocation functions.

parent 105d1677
......@@ -36,7 +36,6 @@
#include "msipriv.h"
#include "winemsi.h"
#include "wine/asm.h"
#include "wine/heap.h"
#include "wine/debug.h"
#include "wine/exception.h"
......@@ -68,12 +67,12 @@ static struct list msi_pending_custom_actions = LIST_INIT( msi_pending_custom_ac
void __RPC_FAR * __RPC_USER MIDL_user_allocate(SIZE_T len)
{
return heap_alloc(len);
return malloc(len);
}
void __RPC_USER MIDL_user_free(void __RPC_FAR * ptr)
{
heap_free(ptr);
free(ptr);
}
LONG WINAPI rpc_filter(EXCEPTION_POINTERS *eptr)
......
......@@ -92,13 +92,13 @@ static MSIHANDLE alloc_handle_table_entry(void)
if (msihandletable_size == 0)
{
newsize = 256;
p = msi_alloc_zero(newsize*sizeof(msi_handle_info));
p = msi_alloc_zero(newsize * sizeof(*p));
}
else
{
newsize = msihandletable_size * 2;
p = msi_realloc_zero(msihandletable,
newsize*sizeof(msi_handle_info));
p = msi_realloc(msihandletable, newsize * sizeof(*p));
if (p) memset(p + msihandletable_size, 0, (newsize - msihandletable_size) * sizeof(*p));
}
if (!p)
return 0;
......
......@@ -34,7 +34,6 @@
#include "msipriv.h"
#include "winemsi.h"
#include "wine/heap.h"
#include "wine/debug.h"
#include "wine/exception.h"
......@@ -273,7 +272,7 @@ UINT WINAPI MsiGetTargetPathA(MSIHANDLE hinst, const char *folder, char *buf, DW
if (!(remote = msi_get_remote(hinst)))
{
heap_free(folderW);
free(folderW);
return ERROR_INVALID_HANDLE;
}
......@@ -291,7 +290,7 @@ UINT WINAPI MsiGetTargetPathA(MSIHANDLE hinst, const char *folder, char *buf, DW
r = msi_strncpyWtoA(path, -1, buf, sz, TRUE);
midl_user_free(path);
heap_free(folderW);
free(folderW);
return r;
}
......@@ -301,7 +300,7 @@ UINT WINAPI MsiGetTargetPathA(MSIHANDLE hinst, const char *folder, char *buf, DW
else
r = ERROR_DIRECTORY;
heap_free(folderW);
free(folderW);
msiobj_release(&package->hdr);
return r;
}
......@@ -429,7 +428,7 @@ UINT WINAPI MsiGetSourcePathA(MSIHANDLE hinst, const char *folder, char *buf, DW
if (!(remote = msi_get_remote(hinst)))
{
heap_free(folderW);
free(folderW);
return ERROR_INVALID_HANDLE;
}
......@@ -447,7 +446,7 @@ UINT WINAPI MsiGetSourcePathA(MSIHANDLE hinst, const char *folder, char *buf, DW
r = msi_strncpyWtoA(path, -1, buf, sz, TRUE);
midl_user_free(path);
heap_free(folderW);
free(folderW);
return r;
}
......@@ -457,8 +456,8 @@ UINT WINAPI MsiGetSourcePathA(MSIHANDLE hinst, const char *folder, char *buf, DW
else
r = ERROR_DIRECTORY;
heap_free(path);
heap_free(folderW);
free(path);
free(folderW);
msiobj_release(&package->hdr);
return r;
}
......@@ -509,7 +508,7 @@ UINT WINAPI MsiGetSourcePathW(MSIHANDLE hinst, const WCHAR *folder, WCHAR *buf,
else
r = ERROR_DIRECTORY;
heap_free(path);
free(path);
msiobj_release(&package->hdr);
return r;
}
......
......@@ -1141,30 +1141,24 @@ extern void msi_ui_progress(MSIPACKAGE *, int, int, int, int) DECLSPEC_HIDDEN;
static void *msi_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
static inline void *msi_alloc( size_t len )
{
return HeapAlloc( GetProcessHeap(), 0, len );
return malloc( len );
}
static void *msi_alloc_zero( size_t len ) __WINE_ALLOC_SIZE(1);
static inline void *msi_alloc_zero( size_t len )
{
return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
return calloc( 1, len );
}
static void *msi_realloc( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
static inline void *msi_realloc( void *mem, size_t len )
{
return HeapReAlloc( GetProcessHeap(), 0, mem, len );
return realloc( mem, len );
}
static void *msi_realloc_zero( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
static inline void *msi_realloc_zero( void *mem, size_t len )
static inline void msi_free( void *mem )
{
return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
}
static inline BOOL msi_free( void *mem )
{
return HeapFree( GetProcessHeap(), 0, mem );
free( mem );
}
static inline char *strdupWtoA( LPCWSTR str )
......
......@@ -43,7 +43,6 @@
#include "msidefs.h"
#include "sddl.h"
#include "wine/heap.h"
#include "wine/debug.h"
#include "wine/exception.h"
......@@ -2272,7 +2271,7 @@ UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD
if (!(remote = msi_get_remote(hinst)))
{
heap_free(nameW);
free(nameW);
return ERROR_INVALID_HANDLE;
}
......@@ -2286,13 +2285,13 @@ UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD
}
__ENDTRY
heap_free(nameW);
free(nameW);
if (!r)
{
/* String might contain embedded nulls.
* Native returns the correct size but truncates the string. */
tmp = heap_alloc_zero((len + 1) * sizeof(WCHAR));
tmp = calloc(1, (len + 1) * sizeof(WCHAR));
if (!tmp)
{
midl_user_free(value);
......@@ -2302,7 +2301,7 @@ UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD
r = msi_strncpyWtoA(tmp, len, buf, sz, TRUE);
heap_free(tmp);
free(tmp);
}
midl_user_free(value);
return r;
......@@ -2314,7 +2313,7 @@ UINT WINAPI MsiGetPropertyA(MSIHANDLE hinst, const char *name, char *buf, DWORD
r = msi_strncpyWtoA(value, len, buf, sz, FALSE);
heap_free(nameW);
free(nameW);
if (row) msiobj_release(&row->hdr);
msiobj_release(&package->hdr);
return r;
......@@ -2355,7 +2354,7 @@ UINT WINAPI MsiGetPropertyW(MSIHANDLE hinst, const WCHAR *name, WCHAR *buf, DWOR
{
/* String might contain embedded nulls.
* Native returns the correct size but truncates the string. */
tmp = heap_alloc_zero((len + 1) * sizeof(WCHAR));
tmp = calloc(1, (len + 1) * sizeof(WCHAR));
if (!tmp)
{
midl_user_free(value);
......@@ -2365,7 +2364,7 @@ UINT WINAPI MsiGetPropertyW(MSIHANDLE hinst, const WCHAR *name, WCHAR *buf, DWOR
r = msi_strncpyW(tmp, len, buf, sz);
heap_free(tmp);
free(tmp);
}
midl_user_free(value);
return r;
......
......@@ -57,7 +57,8 @@ static BOOL streams_resize_table( MSIDATABASE *db, UINT size )
{
MSISTREAM *tmp;
UINT new_size = db->num_streams_allocated * 2;
if (!(tmp = msi_realloc_zero( db->streams, new_size * sizeof(MSISTREAM) ))) return FALSE;
if (!(tmp = msi_realloc( db->streams, new_size * sizeof(*tmp) ))) return FALSE;
memset( tmp + db->num_streams_allocated, 0, (new_size - db->num_streams_allocated) * sizeof(*tmp) );
db->streams = tmp;
db->num_streams_allocated = new_size;
}
......
......@@ -139,13 +139,11 @@ static int st_find_free_entry( string_table *st )
return i;
/* dynamically resize */
sz = st->maxcount + 1 + st->maxcount/2;
p = msi_realloc_zero( st->strings, sz * sizeof(struct msistring) );
if( !p )
return -1;
sz = st->maxcount + 1 + st->maxcount / 2;
if (!(p = msi_realloc( st->strings, sz * sizeof(*p) ))) return -1;
memset( p + st->maxcount, 0, (sz - st->maxcount) * sizeof(*p) );
s = msi_realloc( st->sorted, sz*sizeof(UINT) );
if( !s )
if (!(s = msi_realloc( st->sorted, sz * sizeof(*s) )))
{
msi_free( p );
return -1;
......
......@@ -131,9 +131,10 @@ static UINT add_row(MSIWHEREVIEW *wv, UINT vals[])
MSIROWENTRY **new_reorder;
UINT newsize = wv->reorder_size * 2;
new_reorder = msi_realloc_zero(wv->reorder, sizeof(MSIROWENTRY *) * newsize);
new_reorder = msi_realloc(wv->reorder, newsize * sizeof(*new_reorder));
if (!new_reorder)
return ERROR_OUTOFMEMORY;
memset(new_reorder + wv->reorder_size, 0, (newsize - wv->reorder_size) * sizeof(*new_reorder));
wv->reorder = new_reorder;
wv->reorder_size = newsize;
......
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