https://git.reactos.org/?p=reactos.git;a=commitdiff;h=1b18dc22d5eaee3280074…
commit 1b18dc22d5eaee3280074628e975ee6968ca3e23
Author: winesync <ros-dev(a)reactos.org>
AuthorDate: Mon Mar 14 20:05:29 2022 +0100
Commit: Mark Jansen <mark.jansen(a)reactos.org>
CommitDate: Sun Mar 20 19:28:43 2022 +0100
[WINESYNC] msi: Use CRT allocation functions.
Signed-off-by: Hans Leidekker <hans(a)codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard(a)winehq.org>
wine commit id 0d5f28457e8eced81677509f5129a20f10df526c by Hans Leidekker
<hans(a)codeweavers.com>
---
dll/win32/msi/custom.c | 5 ++---
dll/win32/msi/handle.c | 6 +++---
dll/win32/msi/install.c | 17 ++++++++---------
dll/win32/msi/msipriv.h | 16 +++++-----------
dll/win32/msi/package.c | 15 +++++++--------
dll/win32/msi/streams.c | 3 ++-
dll/win32/msi/string.c | 10 ++++------
dll/win32/msi/where.c | 3 ++-
8 files changed, 33 insertions(+), 42 deletions(-)
diff --git a/dll/win32/msi/custom.c b/dll/win32/msi/custom.c
index fb23d7b755a..3ee4f82e41f 100644
--- a/dll/win32/msi/custom.c
+++ b/dll/win32/msi/custom.c
@@ -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)
diff --git a/dll/win32/msi/handle.c b/dll/win32/msi/handle.c
index d2731935a3d..29c5784c10e 100644
--- a/dll/win32/msi/handle.c
+++ b/dll/win32/msi/handle.c
@@ -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;
diff --git a/dll/win32/msi/install.c b/dll/win32/msi/install.c
index 4ede0d17ccd..7aad6bffc07 100644
--- a/dll/win32/msi/install.c
+++ b/dll/win32/msi/install.c
@@ -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;
}
diff --git a/dll/win32/msi/msipriv.h b/dll/win32/msi/msipriv.h
index 6da8203b721..7a86b32d6ba 100644
--- a/dll/win32/msi/msipriv.h
+++ b/dll/win32/msi/msipriv.h
@@ -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 )
diff --git a/dll/win32/msi/package.c b/dll/win32/msi/package.c
index fda1622f666..14ddcb79a57 100644
--- a/dll/win32/msi/package.c
+++ b/dll/win32/msi/package.c
@@ -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;
diff --git a/dll/win32/msi/streams.c b/dll/win32/msi/streams.c
index 1ef99c2ab05..8f6986039a9 100644
--- a/dll/win32/msi/streams.c
+++ b/dll/win32/msi/streams.c
@@ -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;
}
diff --git a/dll/win32/msi/string.c b/dll/win32/msi/string.c
index 0e250ff4527..fb0134810b9 100644
--- a/dll/win32/msi/string.c
+++ b/dll/win32/msi/string.c
@@ -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;
diff --git a/dll/win32/msi/where.c b/dll/win32/msi/where.c
index 2a64de8cd9d..684d9d5fb98 100644
--- a/dll/win32/msi/where.c
+++ b/dll/win32/msi/where.c
@@ -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;