summaryrefslogtreecommitdiffstats
path: root/libmsi
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2012-10-23 11:53:56 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2012-12-06 20:30:29 +0100
commit4c722e3d48b95204656f1ef698c09aaf8ec4cd27 (patch)
tree02955c2dab7937b168bb88e6cbb9c24e8dfb3e68 /libmsi
parent9ad11a6d7c458dbcd5784955ff2f8f5a4256a4fc (diff)
downloadmsitools-4c722e3d48b95204656f1ef698c09aaf8ec4cd27.tar.gz
msitools-4c722e3d48b95204656f1ef698c09aaf8ec4cd27.tar.xz
msitools-4c722e3d48b95204656f1ef698c09aaf8ec4cd27.zip
use libc memory allocation functions
Diffstat (limited to 'libmsi')
-rw-r--r--libmsi/msipriv.h16
-rw-r--r--libmsi/streams.c3
-rw-r--r--libmsi/string.c2
-rw-r--r--libmsi/where.c3
4 files changed, 14 insertions, 10 deletions
diff --git a/libmsi/msipriv.h b/libmsi/msipriv.h
index 8f98cdb..aff1951 100644
--- a/libmsi/msipriv.h
+++ b/libmsi/msipriv.h
@@ -521,30 +521,32 @@ static const WCHAR szInstallLocation[] = {'I','n','s','t','a','l','l','L','o','c
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(len, 1);
}
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 void *msi_realloc_zero( void *mem, size_t oldlen, size_t len ) __WINE_ALLOC_SIZE(3);
+static inline void *msi_realloc_zero( void *mem, size_t oldlen, size_t len )
{
- return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
+ mem = realloc( mem, len );
+ memset(mem + oldlen, 0, len - oldlen);
+ return mem;
}
static inline bool msi_free( void *mem )
{
- return HeapFree( GetProcessHeap(), 0, mem );
+ free(mem);
}
static inline char *strdupWtoA( const WCHAR *str )
diff --git a/libmsi/streams.c b/libmsi/streams.c
index dabfef5..2f0d4ec 100644
--- a/libmsi/streams.c
+++ b/libmsi/streams.c
@@ -56,8 +56,9 @@ static bool streams_set_table_size(LibmsiStreamSVIEW *sv, unsigned size)
{
if (size >= sv->max_streams)
{
+ sv->streams = msi_realloc_zero(sv->streams, sv->max_streams * sizeof(STREAM *),
+ sv->max_streams * 2 * sizeof(STREAM *));
sv->max_streams *= 2;
- sv->streams = msi_realloc_zero(sv->streams, sv->max_streams * sizeof(STREAM *));
if (!sv->streams)
return false;
}
diff --git a/libmsi/string.c b/libmsi/string.c
index 39071e4..3b8c6ec 100644
--- a/libmsi/string.c
+++ b/libmsi/string.c
@@ -138,7 +138,7 @@ static int st_find_free_entry( string_table *st )
/* dynamically resize */
sz = st->maxcount + 1 + st->maxcount/2;
- p = msi_realloc_zero( st->strings, sz * sizeof(struct msistring) );
+ p = msi_realloc_zero( st->strings, st->maxcount * sizeof(struct msistring), sz * sizeof(struct msistring) );
if( !p )
return -1;
diff --git a/libmsi/where.c b/libmsi/where.c
index 2c10d18..87f9b07 100644
--- a/libmsi/where.c
+++ b/libmsi/where.c
@@ -130,7 +130,8 @@ static unsigned add_row(LibmsiWhereView *wv, unsigned vals[])
LibmsiRowEntry **new_reorder;
unsigned newsize = wv->reorder_size * 2;
- new_reorder = msi_realloc_zero(wv->reorder, sizeof(LibmsiRowEntry *) * newsize);
+ new_reorder = msi_realloc_zero(wv->reorder, sizeof(LibmsiRowEntry *) * wv->reorder_size,
+ sizeof(LibmsiRowEntry *) * newsize);
if (!new_reorder)
return ERROR_OUTOFMEMORY;