[WINESYNC] msi: Use CRT allocation functions.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>

wine commit id 0d5f28457e8eced81677509f5129a20f10df526c by Hans Leidekker <hans@codeweavers.com>
This commit is contained in:
winesync 2022-03-14 20:05:29 +01:00 committed by Mark Jansen
parent 34c24483e5
commit 1b18dc22d5
No known key found for this signature in database
GPG key ID: B39240EE84BEAE8B
8 changed files with 33 additions and 42 deletions

View file

@ -36,7 +36,6 @@
#include "msipriv.h"
#include "winemsi_s.h"
#include "wine/asm.h"
#include "wine/heap.h"
#include "wine/debug.h"
#include "wine/unicode.h"
#include "wine/exception.h"
@ -75,12 +74,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)

View file

@ -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;

View file

@ -34,7 +34,6 @@
#include "msipriv.h"
#include "winemsi_s.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;
}

View file

@ -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 )

View file

@ -50,7 +50,6 @@
#include "msidefs.h"
#include "sddl.h"
#include "wine/heap.h"
#include "wine/debug.h"
#include "wine/exception.h"
@ -2279,7 +2278,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;
}
@ -2293,13 +2292,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);
@ -2309,7 +2308,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;
@ -2321,7 +2320,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;
@ -2362,7 +2361,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);
@ -2372,7 +2371,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;

View file

@ -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;
}

View file

@ -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;

View file

@ -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;