Commit 8dc28d53 authored by Mike McCormack's avatar Mike McCormack Committed by Alexandre Julliard

Added memory allocation inline functions (part 1).

parent 8defc289
......@@ -199,7 +199,7 @@ static UINT CREATE_delete( struct tagMSIVIEW *view )
TRACE("%p\n", cv );
msiobj_release( &cv->db->hdr );
HeapFree( GetProcessHeap(), 0, cv );
msi_free( cv );
return ERROR_SUCCESS;
}
......@@ -226,7 +226,7 @@ UINT CREATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
TRACE("%p\n", cv );
cv = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof *cv );
cv = msi_alloc_zero( sizeof *cv );
if( !cv )
return ERROR_FUNCTION_FAILED;
......
......@@ -177,7 +177,7 @@ static UINT DELETE_delete( struct tagMSIVIEW *view )
if( dv->table )
dv->table->ops->delete( dv->table );
HeapFree( GetProcessHeap(), 0, dv );
msi_free( dv );
return ERROR_SUCCESS;
}
......@@ -203,7 +203,7 @@ UINT DELETE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table )
TRACE("%p\n", dv );
dv = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof *dv );
dv = msi_alloc_zero( sizeof *dv );
if( !dv )
return ERROR_FUNCTION_FAILED;
......
......@@ -67,7 +67,7 @@ static DISTINCTSET ** distinct_insert( DISTINCTSET **x, UINT val, UINT row )
}
/* nothing found, so add one */
*x = HeapAlloc( GetProcessHeap(), 0, sizeof (DISTINCTSET) );
*x = msi_alloc( sizeof (DISTINCTSET) );
if( *x )
{
(*x)->val = val;
......@@ -85,7 +85,7 @@ static void distinct_free( DISTINCTSET *x )
{
DISTINCTSET *next = x->nextrow;
distinct_free( x->nextcol );
HeapFree( GetProcessHeap(), 0, x );
msi_free( x );
x = next;
}
}
......@@ -126,7 +126,7 @@ static UINT DISTINCT_execute( struct tagMSIVIEW *view, MSIRECORD *record )
if( r != ERROR_SUCCESS )
return r;
dv->translation = HeapAlloc( GetProcessHeap(), 0, r_count*sizeof(UINT) );
dv->translation = msi_alloc( r_count*sizeof(UINT) );
if( !dv->translation )
return ERROR_FUNCTION_FAILED;
......@@ -178,7 +178,7 @@ static UINT DISTINCT_close( struct tagMSIVIEW *view )
if( !dv->table )
return ERROR_FUNCTION_FAILED;
HeapFree( GetProcessHeap(), 0, dv->translation );
msi_free( dv->translation );
dv->translation = NULL;
dv->row_count = 0;
......@@ -239,9 +239,9 @@ static UINT DISTINCT_delete( struct tagMSIVIEW *view )
if( dv->table )
dv->table->ops->delete( dv->table );
HeapFree( GetProcessHeap(), 0, dv->translation );
msi_free( dv->translation );
msiobj_release( &dv->db->hdr );
HeapFree( GetProcessHeap(), 0, dv );
msi_free( dv );
return ERROR_SUCCESS;
}
......@@ -275,7 +275,7 @@ UINT DISTINCT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table )
return r;
}
dv = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof *dv );
dv = msi_alloc_zero( sizeof *dv );
if( !dv )
return ERROR_FUNCTION_FAILED;
......
......@@ -239,7 +239,7 @@ static UINT ControlEvent_SetTargetPath(MSIPACKAGE* package, LPCWSTR argument,
UINT r;
/* failure to set the path halts the executing of control events */
r = MSI_SetTargetPathW(package, argument, path);
HeapFree(GetProcessHeap(),0,path);
msi_free(path);
return r;
}
......@@ -248,10 +248,10 @@ static UINT ControlEvent_SetTargetPath(MSIPACKAGE* package, LPCWSTR argument,
*/
static void free_subscriber( struct subscriber *sub )
{
HeapFree(GetProcessHeap(),0,sub->event);
HeapFree(GetProcessHeap(),0,sub->control);
HeapFree(GetProcessHeap(),0,sub->attribute);
HeapFree(GetProcessHeap(),0,sub);
msi_free(sub->event);
msi_free(sub->control);
msi_free(sub->attribute);
msi_free(sub);
}
VOID ControlEvent_SubscribeToEvent( MSIPACKAGE *package, LPCWSTR event,
......@@ -259,7 +259,7 @@ VOID ControlEvent_SubscribeToEvent( MSIPACKAGE *package, LPCWSTR event,
{
struct subscriber *sub;
sub = HeapAlloc(GetProcessHeap(),0,sizeof (*sub));
sub = msi_alloc(sizeof (*sub));
if( !sub )
return;
sub->event = strdupW(event);
......@@ -352,7 +352,7 @@ UINT ACTION_DialogBox( MSIPACKAGE* package, LPCWSTR szDialogName )
package->next_dialog = NULL;
r = event_do_dialog( package, name, TRUE );
HeapFree( GetProcessHeap(), 0, name );
msi_free( name );
}
if( r == ERROR_IO_PENDING )
......@@ -389,11 +389,11 @@ UINT ControlEvent_HandleControlEvent(MSIPACKAGE *package, LPCWSTR event,
LPWSTR wevent = strdupAtoW(Events[i].event);
if (lstrcmpW(wevent,event)==0)
{
HeapFree(GetProcessHeap(),0,wevent);
msi_free(wevent);
rc = Events[i].handler(package,argument,dialog);
return rc;
}
HeapFree(GetProcessHeap(),0,wevent);
msi_free(wevent);
i++;
}
FIXME("unhandled control event %s arg(%s)\n",
......
......@@ -132,7 +132,7 @@ void *alloc_msiobject(UINT type, UINT size, msihandledestructor destroy )
{
MSIOBJECTHDR *info;
info = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, size );
info = msi_alloc_zero( size );
if( info )
{
info->magic = MSIHANDLE_MAGIC;
......@@ -190,7 +190,7 @@ int msiobj_release( MSIOBJECTHDR *info )
{
if( info->destructor )
info->destructor( info );
HeapFree( GetProcessHeap(), 0, info );
msi_free( info );
TRACE("object %p destroyed\n", info);
}
......
......@@ -209,7 +209,7 @@ static UINT INSERT_delete( struct tagMSIVIEW *view )
if( sv )
sv->ops->delete( sv );
msiobj_release( &iv->db->hdr );
HeapFree( GetProcessHeap(), 0, iv );
msi_free( iv );
return ERROR_SUCCESS;
}
......@@ -250,7 +250,7 @@ UINT INSERT_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
return r;
}
iv = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof *iv );
iv = msi_alloc_zero( sizeof *iv );
if( !iv )
return ERROR_FUNCTION_FAILED;
......
......@@ -422,28 +422,55 @@ extern DWORD gUIFilter;
extern LPVOID gUIContext;
extern WCHAR gszLogFile[MAX_PATH];
/* memory allocation macro functions */
static inline void *msi_alloc( size_t len )
{
return HeapAlloc( GetProcessHeap(), 0, len );
}
static inline void *msi_alloc_zero( size_t len )
{
return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
}
static inline void *msi_realloc( void *mem, size_t len )
{
return HeapReAlloc( GetProcessHeap(), 0, mem, len );
}
static inline void *msi_realloc_zero( void *mem, size_t len )
{
return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );
}
static inline BOOL msi_free( void *mem )
{
return HeapFree( GetProcessHeap(), 0, mem );
}
inline static char *strdupWtoA( LPCWSTR str )
{
LPSTR ret = NULL;
if (str)
{
DWORD len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL
);
if ((ret = HeapAlloc( GetProcessHeap(), 0, len )))
WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
}
DWORD len;
if (!str) return ret;
len = WideCharToMultiByte( CP_ACP, 0, str, -1, NULL, 0, NULL, NULL);
ret = msi_alloc( len );
if (ret)
WideCharToMultiByte( CP_ACP, 0, str, -1, ret, len, NULL, NULL );
return ret;
}
inline static LPWSTR strdupAtoW( LPCSTR str )
{
LPWSTR ret = NULL;
if (str)
{
DWORD len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
if ((ret = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )))
MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
}
DWORD len;
if (!str) return ret;
len = MultiByteToWideChar( CP_ACP, 0, str, -1, NULL, 0 );
ret = msi_alloc( len * sizeof(WCHAR) );
if (ret)
MultiByteToWideChar( CP_ACP, 0, str, -1, ret, len );
return ret;
}
......@@ -451,8 +478,9 @@ inline static LPWSTR strdupW( LPCWSTR src )
{
LPWSTR dest;
if (!src) return NULL;
dest = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(src)+1)*sizeof(WCHAR));
lstrcpyW(dest, src);
dest = msi_alloc( (lstrlenW(src)+1)*sizeof(WCHAR) );
if (dest)
lstrcpyW(dest, src);
return dest;
}
......
......@@ -160,7 +160,7 @@ static UINT ORDER_execute( struct tagMSIVIEW *view, MSIRECORD *record )
if( r != ERROR_SUCCESS )
return r;
ov->reorder = HeapAlloc( GetProcessHeap(), 0, num_rows*sizeof(UINT) );
ov->reorder = msi_alloc( num_rows*sizeof(UINT) );
if( !ov->reorder )
return ERROR_FUNCTION_FAILED;
......@@ -187,7 +187,7 @@ static UINT ORDER_close( struct tagMSIVIEW *view )
if( !ov->table )
return ERROR_FUNCTION_FAILED;
HeapFree( GetProcessHeap(), 0, ov->reorder );
msi_free( ov->reorder );
ov->reorder = NULL;
return ov->table->ops->close( ov->table );
......@@ -240,11 +240,11 @@ static UINT ORDER_delete( struct tagMSIVIEW *view )
if( ov->table )
ov->table->ops->delete( ov->table );
HeapFree( GetProcessHeap(), 0, ov->reorder );
msi_free( ov->reorder );
ov->reorder = NULL;
msiobj_release( &ov->db->hdr );
HeapFree( GetProcessHeap(), 0, ov );
msi_free( ov );
return ERROR_SUCCESS;
}
......@@ -317,8 +317,7 @@ UINT ORDER_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table,
return r;
}
ov = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof *ov + sizeof (UINT) * count );
ov = msi_alloc_zero( sizeof *ov + sizeof (UINT) * count );
if( !ov )
return ERROR_FUNCTION_FAILED;
......
......@@ -454,7 +454,7 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
size = 0;
MSI_GetPropertyW(package,szProductCode,NULL,&size);
size ++;
package->ProductCode = HeapAlloc(GetProcessHeap(),0,size * sizeof(WCHAR));
package->ProductCode = msi_alloc(size * sizeof(WCHAR));
MSI_GetPropertyW(package,szProductCode,package->ProductCode, &size);
*pPackage = package;
......@@ -522,7 +522,7 @@ UINT WINAPI MsiOpenPackageExA(LPCSTR szPackage, DWORD dwOptions, MSIHANDLE *phPa
ret = MsiOpenPackageExW( szwPack, dwOptions, phPackage );
HeapFree( GetProcessHeap(), 0, szwPack );
msi_free( szwPack );
return ret;
}
......@@ -583,7 +583,7 @@ INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
if ((eMessageType & 0xff000000) == INSTALLMESSAGE_PROGRESS)
log_type |= 0x800;
message = HeapAlloc(GetProcessHeap(),0,1*sizeof (WCHAR));
message = msi_alloc(1*sizeof (WCHAR));
message[0]=0;
msg_field = MSI_RecordGetFieldCount(record);
for (i = 1; i <= msg_field; i++)
......@@ -596,8 +596,8 @@ INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
MSI_RecordGetStringW(record,i,NULL,&sz);
sz+=4;
total_size+=sz*sizeof(WCHAR);
tmp = HeapAlloc(GetProcessHeap(),0,sz*sizeof(WCHAR));
message = HeapReAlloc(GetProcessHeap(),0,message,total_size*sizeof (WCHAR));
tmp = msi_alloc(sz*sizeof(WCHAR));
message = msi_realloc(message,total_size*sizeof (WCHAR));
MSI_RecordGetStringW(record,i,tmp,&sz);
......@@ -610,7 +610,7 @@ INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
if (msg_field > 1)
strcatW(message,space);
HeapFree(GetProcessHeap(),0,tmp);
msi_free(tmp);
}
TRACE("(%p %lx %lx %s)\n",gUIHandlerA, gUIFilter, log_type,
......@@ -619,7 +619,7 @@ INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
/* convert it to ASCII */
len = WideCharToMultiByte( CP_ACP, 0, message, -1,
NULL, 0, NULL, NULL );
msg = HeapAlloc( GetProcessHeap(), 0, len );
msg = msi_alloc( len );
WideCharToMultiByte( CP_ACP, 0, message, -1,
msg, len, NULL, NULL );
......@@ -643,9 +643,9 @@ INT MSI_ProcessMessage( MSIPACKAGE *package, INSTALLMESSAGE eMessageType,
CloseHandle(log_file);
}
}
HeapFree( GetProcessHeap(), 0, msg );
msi_free( msg );
HeapFree(GetProcessHeap(),0,message);
msi_free( message);
return ERROR_SUCCESS;
}
......@@ -697,8 +697,8 @@ UINT WINAPI MsiSetPropertyA( MSIHANDLE hInstall, LPCSTR szName, LPCSTR szValue)
hr = MsiSetPropertyW( hInstall, szwName, szwValue);
end:
HeapFree( GetProcessHeap(), 0, szwName );
HeapFree( GetProcessHeap(), 0, szwValue );
msi_free( szwName );
msi_free( szwValue );
return hr;
}
......@@ -792,11 +792,11 @@ static UINT MSI_GetPropertyRow(MSIPACKAGE *package, LPCWSTR szName, MSIRECORD **
return ERROR_INVALID_PARAMETER;
sz = sizeof select + strlenW(szName)*sizeof(WCHAR);
query = HeapAlloc(GetProcessHeap(), 0, sz);
query = msi_alloc( sz);
sprintfW(query,select,szName);
rc = MSI_DatabaseOpenViewW(package->db, query, &view);
HeapFree(GetProcessHeap(), 0, query);
msi_free(query);
if (rc == ERROR_SUCCESS)
{
rc = MSI_ViewExecute(view, 0);
......@@ -877,7 +877,7 @@ UINT MSI_GetPropertyA(MSIPACKAGE *package, LPCSTR szName,
*pchValueBuf = 0;
TRACE("property not found\n");
}
HeapFree( GetProcessHeap(), 0, szwName );
msi_free( szwName );
return rc;
}
......
......@@ -145,7 +145,7 @@ UINT WINAPI MsiPreviewDialogA( MSIHANDLE hPreview, LPCSTR szDialogName )
return ERROR_OUTOFMEMORY;
}
r = MsiPreviewDialogW( hPreview, strW );
HeapFree( GetProcessHeap(), 0, strW );
msi_free( strW );
return r;
}
......
......@@ -55,7 +55,7 @@ static void MSI_FreeField( MSIFIELD *field )
case MSIFIELD_INT:
break;
case MSIFIELD_WSTR:
HeapFree( GetProcessHeap(), 0, field->u.szwVal);
msi_free( field->u.szwVal);
break;
case MSIFIELD_STREAM:
IStream_Release( field->u.stream );
......@@ -654,7 +654,7 @@ UINT WINAPI MsiRecordSetStreamA(MSIHANDLE hRecord, unsigned int iField, LPCSTR s
return ERROR_OUTOFMEMORY;
}
ret = MsiRecordSetStreamW(hRecord, iField, wstr);
HeapFree(GetProcessHeap(),0,wstr);
msi_free(wstr);
return ret;
}
......
......@@ -581,7 +581,7 @@ UINT WINAPI MsiDecomposeDescriptorA( LPCSTR szDescriptor, LPSTR szProduct,
WideCharToMultiByte( CP_ACP, 0, component, MAX_FEATURE_CHARS+1,
szComponent, MAX_FEATURE_CHARS+1, NULL, NULL );
HeapFree( GetProcessHeap(), 0, str );
msi_free( str );
return r;
}
......@@ -650,7 +650,7 @@ UINT WINAPI MsiEnumFeaturesA(LPCSTR szProduct, DWORD index,
szParent, GUID_SIZE, NULL, NULL);
}
HeapFree( GetProcessHeap(), 0, szwProduct);
msi_free( szwProduct);
return r;
}
......@@ -730,7 +730,7 @@ UINT WINAPI MsiEnumClientsA(LPCSTR szComponent, DWORD index, LPSTR szProduct)
szProduct, GUID_SIZE, NULL, NULL);
}
HeapFree( GetProcessHeap(), 0, szwComponent);
msi_free( szwComponent);
return r;
}
......@@ -780,8 +780,7 @@ UINT WINAPI MsiEnumComponentQualifiersA( LPSTR szComponent, DWORD iIndex,
szwComponent = strdupAtoW(szComponent);
if (lpQualifierBuf)
lpwQualifierBuf = HeapAlloc(GetProcessHeap(),0, (*pcchQualifierBuf) *
sizeof(WCHAR));
lpwQualifierBuf = msi_alloc( (*pcchQualifierBuf) * sizeof(WCHAR));
else
lpwQualifierBuf = NULL;
......@@ -791,8 +790,7 @@ UINT WINAPI MsiEnumComponentQualifiersA( LPSTR szComponent, DWORD iIndex,
pcchwQualifierBuf = 0;
if (lpApplicationDataBuf)
lpwApplicationDataBuf = HeapAlloc(GetProcessHeap(),0 ,
(*pcchApplicationDataBuf) * sizeof(WCHAR));
lpwApplicationDataBuf = msi_alloc( (*pcchApplicationDataBuf) * sizeof(WCHAR));
else
lpwApplicationDataBuf = NULL;
......@@ -831,9 +829,9 @@ UINT WINAPI MsiEnumComponentQualifiersA( LPSTR szComponent, DWORD iIndex,
*pcchApplicationDataBuf = length - 1;
}
HeapFree(GetProcessHeap(),0,lpwApplicationDataBuf);
HeapFree(GetProcessHeap(),0,lpwQualifierBuf);
HeapFree(GetProcessHeap(),0,szwComponent);
msi_free(lpwApplicationDataBuf);
msi_free(lpwQualifierBuf);
msi_free(szwComponent);
return rc;
}
......@@ -868,16 +866,16 @@ UINT WINAPI MsiEnumComponentQualifiersW( LPWSTR szComponent, DWORD iIndex,
return ERROR_UNKNOWN_COMPONENT;
full_buffer_size = (52 * sizeof(WCHAR)) + actual_pcchApplicationDataBuf;
full_buffer = HeapAlloc(GetProcessHeap(),0,full_buffer_size);
full_buffer = msi_alloc(full_buffer_size);
rc = RegEnumValueW(key, iIndex, lpQualifierBuf, pcchQualifierBuf, NULL,
NULL, (LPBYTE)full_buffer, &full_buffer_size);
if (rc == ERROR_MORE_DATA)
{
HeapFree(GetProcessHeap(),0,full_buffer);
msi_free(full_buffer);
full_buffer_size+=sizeof(WCHAR);
full_buffer = HeapAlloc(GetProcessHeap(),0,full_buffer_size);
full_buffer = msi_alloc(full_buffer_size);
rc = RegEnumValueW(key, iIndex, lpQualifierBuf, pcchQualifierBuf, NULL,
NULL, (LPBYTE)full_buffer, &full_buffer_size);
}
......@@ -907,7 +905,7 @@ UINT WINAPI MsiEnumComponentQualifiersW( LPWSTR szComponent, DWORD iIndex,
debugstr_w(lpApplicationDataBuf));
}
HeapFree(GetProcessHeap(),0,full_buffer);
msi_free(full_buffer);
return rc;
}
......@@ -971,6 +969,6 @@ UINT WINAPI MsiEnumRelatedProductsA(LPCSTR szUpgradeCode, DWORD dwReserved,
WideCharToMultiByte( CP_ACP, 0, productW, GUID_SIZE,
lpProductBuf, GUID_SIZE, NULL, NULL );
}
HeapFree(GetProcessHeap(), 0, szwUpgradeCode);
msi_free( szwUpgradeCode);
return r;
}
......@@ -190,7 +190,7 @@ static UINT SELECT_delete( struct tagMSIVIEW *view )
if( sv->table )
sv->table->ops->delete( sv->table );
HeapFree( GetProcessHeap(), 0, sv );
msi_free( sv );
return ERROR_SUCCESS;
}
......@@ -259,8 +259,7 @@ UINT SELECT_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table,
return r;
}
sv = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof *sv + count*sizeof (UINT) );
sv = msi_alloc_zero( sizeof *sv + count*sizeof (UINT) );
if( !sv )
return ERROR_FUNCTION_FAILED;
......
......@@ -129,7 +129,7 @@ static UINT find_given_source(HKEY key, LPCWSTR szSource, media_info *ss)
rc = RegEnumValueW(key, index, szIndex, &size, NULL, NULL, NULL, &val_size);
if (rc != ERROR_NO_MORE_ITEMS)
{
val = HeapAlloc(GetProcessHeap(),0,val_size);
val = msi_alloc(val_size);
RegEnumValueW(key, index, szIndex, &size, NULL, NULL, (LPBYTE)val,
&val_size);
if (lstrcmpiW(szSource,val)==0)
......@@ -141,7 +141,7 @@ static UINT find_given_source(HKEY key, LPCWSTR szSource, media_info *ss)
else
strcpyW(ss->szIndex,szIndex);
HeapFree(GetProcessHeap(),0,val);
msi_free(val);
index ++;
}
}
......@@ -221,7 +221,7 @@ UINT WINAPI MsiSourceListGetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
else
{
LPWSTR ptr;
buffer = HeapAlloc(GetProcessHeap(),0,size);
buffer = msi_alloc(size);
rc = RegQueryValueExW(sourcekey, INSTALLPROPERTY_LASTUSEDSOURCEW,
0, 0, (LPBYTE)buffer,&size);
ptr = strchrW(buffer,';');
......@@ -240,7 +240,7 @@ UINT WINAPI MsiSourceListGetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
else
rc = ERROR_SUCCESS;
}
HeapFree(GetProcessHeap(),0,buffer);
msi_free(buffer);
}
}
else if (strcmpW(INSTALLPROPERTY_LASTUSEDTYPEW, szProperty)==0)
......@@ -254,7 +254,7 @@ UINT WINAPI MsiSourceListGetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
rc = ERROR_UNKNOWN_PROPERTY;
else
{
buffer = HeapAlloc(GetProcessHeap(),0,size);
buffer = msi_alloc(size);
rc = RegQueryValueExW(sourcekey, INSTALLPROPERTY_LASTUSEDSOURCEW,
0, 0, (LPBYTE)buffer,&size);
if (*pcchValue < 1)
......@@ -267,7 +267,7 @@ UINT WINAPI MsiSourceListGetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
szValue[0] = buffer[0];
rc = ERROR_SUCCESS;
}
HeapFree(GetProcessHeap(),0,buffer);
msi_free(buffer);
}
}
else if (strcmpW(INSTALLPROPERTY_PACKAGENAMEW, szProperty)==0)
......@@ -369,13 +369,13 @@ UINT WINAPI MsiSourceListSetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
ERR("Unknown source type! 0x%lx\n",dwOptions);
size = (lstrlenW(szValue)+5)*sizeof(WCHAR);
buffer = HeapAlloc(GetProcessHeap(),0,size);
buffer = msi_alloc(size);
sprintfW(buffer, LastUsedSource_Fmt, typechar, 1, szValue);
rc = RegSetValueExW(sourcekey, INSTALLPROPERTY_LASTUSEDSOURCEW, 0,
REG_EXPAND_SZ, (LPBYTE)buffer, size);
if (rc != ERROR_SUCCESS)
rc = ERROR_UNKNOWN_PROPERTY;
HeapFree( GetProcessHeap(), 0, buffer );
msi_free( buffer );
}
else if (strcmpW(INSTALLPROPERTY_PACKAGENAMEW, szProperty)==0)
{
......@@ -547,11 +547,11 @@ UINT WINAPI MsiSourceListAddMediaDiskW(LPCWSTR szProduct, LPCWSTR szUserSid,
size *=sizeof(WCHAR);
buffer = HeapAlloc(GetProcessHeap(),0,size);
buffer = msi_alloc(size);
sprintfW(buffer,disk_fmt,pt1,pt2);
RegSetValueExW(mediakey, szIndex, 0, REG_SZ, (LPBYTE)buffer, size);
HeapFree( GetProcessHeap(), 0, buffer );
msi_free( buffer );
RegCloseKey(sourcekey);
RegCloseKey(mediakey);
......
......@@ -608,7 +608,7 @@ static void *parser_alloc( void *info, unsigned int sz )
SQL_input* sql = (SQL_input*) info;
struct list *mem;
mem = HeapAlloc( GetProcessHeap(), 0, sizeof (struct list) + sz );
mem = msi_alloc( sizeof (struct list) + sz );
list_add_tail( sql->mem, mem );
return &mem[1];
}
......
......@@ -72,14 +72,13 @@ string_table *msi_init_stringtable( int entries, UINT codepage )
{
string_table *st;
st = HeapAlloc( GetProcessHeap(), 0, sizeof (string_table) );
st = msi_alloc( sizeof (string_table) );
if( !st )
return NULL;
st->strings = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
sizeof (msistring) * entries );
st->strings = msi_alloc_zero( sizeof (msistring) * entries );
if( !st )
{
HeapFree( GetProcessHeap(), 0, st );
msi_free( st );
return NULL;
}
if( entries < 1 )
......@@ -98,10 +97,10 @@ VOID msi_destroy_stringtable( string_table *st )
for( i=0; i<st->maxcount; i++ )
{
if( st->strings[i].refcount )
HeapFree( GetProcessHeap(), 0, st->strings[i].str );
msi_free( st->strings[i].str );
}
HeapFree( GetProcessHeap(), 0, st->strings );
HeapFree( GetProcessHeap(), 0, st );
msi_free( st->strings );
msi_free( st );
}
static int st_find_free_entry( string_table *st )
......@@ -123,8 +122,7 @@ static int st_find_free_entry( string_table *st )
/* dynamically resize */
sz = st->maxcount + 1 + st->maxcount/2;
p = HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
st->strings, sz*sizeof(msistring) );
p = msi_realloc_zero( st->strings, sz*sizeof(msistring) );
if( !p )
return -1;
st->strings = p;
......@@ -177,7 +175,7 @@ int msi_addstring( string_table *st, UINT n, const CHAR *data, int len, UINT ref
if( len < 0 )
len = strlen(data);
sz = MultiByteToWideChar( st->codepage, 0, data, len, NULL, 0 );
st->strings[n].str = HeapAlloc( GetProcessHeap(), 0, (sz+1)*sizeof(WCHAR) );
st->strings[n].str = msi_alloc( (sz+1)*sizeof(WCHAR) );
if( !st->strings[n].str )
return -1;
MultiByteToWideChar( st->codepage, 0, data, len, st->strings[n].str, sz );
......@@ -226,7 +224,7 @@ int msi_addstringW( string_table *st, UINT n, const WCHAR *data, int len, UINT r
len = strlenW(data);
TRACE("%s, n = %d len = %d\n", debugstr_w(data), n, len );
st->strings[n].str = HeapAlloc( GetProcessHeap(), 0, (len+1)*sizeof(WCHAR) );
st->strings[n].str = msi_alloc( (len+1)*sizeof(WCHAR) );
if( !st->strings[n].str )
return -1;
TRACE("%d\n",__LINE__);
......@@ -387,13 +385,13 @@ UINT msi_string2idA( string_table *st, LPCSTR buffer, UINT *id )
sz = MultiByteToWideChar( st->codepage, 0, buffer, -1, NULL, 0 );
if( sz <= 0 )
return r;
str = HeapAlloc( GetProcessHeap(), 0, sz*sizeof(WCHAR) );
str = msi_alloc( sz*sizeof(WCHAR) );
if( !str )
return ERROR_NOT_ENOUGH_MEMORY;
MultiByteToWideChar( st->codepage, 0, buffer, -1, str, sz );
r = msi_string2idW( st, str, id );
HeapFree( GetProcessHeap(), 0, str );
msi_free( str );
return r;
}
......
......@@ -95,7 +95,7 @@ static const WCHAR szSumInfo[] = { 5 ,'S','u','m','m','a','r','y',
static void free_prop( PROPVARIANT *prop )
{
if (prop->vt == VT_LPSTR )
HeapFree( GetProcessHeap(), 0, prop->u.pszVal );
msi_free( prop->u.pszVal );
prop->vt = VT_EMPTY;
}
......@@ -207,7 +207,7 @@ static void read_properties_from_data( PROPVARIANT *prop, LPBYTE data, DWORD sz
if( type == VT_LPSTR )
{
LPSTR str = HeapAlloc( GetProcessHeap(), 0, propdata->u.str.len );
LPSTR str = msi_alloc( propdata->u.str.len );
memcpy( str, propdata->u.str.str, propdata->u.str.len );
str[ propdata->u.str.len - 1 ] = 0;
property->u.pszVal = str;
......@@ -273,7 +273,7 @@ static UINT load_summary_info( MSISUMMARYINFO *si, IStream *stm )
return ret;
}
data = HeapAlloc( GetProcessHeap(), 0, section_hdr.cbSection);
data = msi_alloc( section_hdr.cbSection);
if( !data )
return ret;
......@@ -287,7 +287,7 @@ static UINT load_summary_info( MSISUMMARYINFO *si, IStream *stm )
else
ERR("failed to read properties %ld %ld\n", count, sz);
HeapFree( GetProcessHeap(), 0, data );
msi_free( data );
return ret;
}
......@@ -394,7 +394,7 @@ static UINT save_summary_info( MSISUMMARYINFO * si, IStream *stm )
section_hdr.cbSection += sz;
}
data = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, section_hdr.cbSection );
data = msi_alloc_zero( section_hdr.cbSection );
sz = 0;
memcpy( &data[sz], &section_hdr, sizeof section_hdr );
......@@ -408,7 +408,7 @@ static UINT save_summary_info( MSISUMMARYINFO * si, IStream *stm )
sz += write_property_to_data( &si->property[i], &data[sz] );
r = IStream_Write( stm, data, sz, &count );
HeapFree( GetProcessHeap(), 0, data );
msi_free( data );
if( FAILED(r) || count != sz )
return ret;
......@@ -501,7 +501,7 @@ UINT WINAPI MsiGetSummaryInformationA(MSIHANDLE hDatabase,
ret = MsiGetSummaryInformationW(hDatabase, szwDatabase, uiUpdateCount, pHandle);
HeapFree( GetProcessHeap(), 0, szwDatabase );
msi_free( szwDatabase );
return ret;
}
......@@ -676,14 +676,14 @@ static UINT set_prop( MSIHANDLE handle, UINT uiProperty, UINT uiDataType,
{
len = WideCharToMultiByte( CP_ACP, 0, str->str.w, -1,
NULL, 0, NULL, NULL );
prop->u.pszVal = HeapAlloc( GetProcessHeap(), 0, len );
prop->u.pszVal = msi_alloc( len );
WideCharToMultiByte( CP_ACP, 0, str->str.w, -1,
prop->u.pszVal, len, NULL, NULL );
}
else
{
len = lstrlenA( str->str.a ) + 1;
prop->u.pszVal = HeapAlloc( GetProcessHeap(), 0, len );
prop->u.pszVal = msi_alloc( len );
lstrcpyA( prop->u.pszVal, str->str.a );
}
break;
......
......@@ -172,7 +172,7 @@ static UINT UPDATE_delete( struct tagMSIVIEW *view )
if( wv )
wv->ops->delete( wv );
msiobj_release( &uv->db->hdr );
HeapFree( GetProcessHeap(), 0, uv );
msi_free( uv );
return ERROR_SUCCESS;
}
......@@ -223,7 +223,7 @@ UINT UPDATE_CreateView( MSIDATABASE *db, MSIVIEW **view, LPWSTR table,
return r;
}
uv = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof *uv );
uv = msi_alloc_zero( sizeof *uv );
if( !uv )
return ERROR_FUNCTION_FAILED;
......
......@@ -82,7 +82,7 @@ static void append_productcode(MSIPACKAGE* package, LPCWSTR action_property,
/*null*/
len++;
newprop = HeapAlloc(GetProcessHeap(),0,len*sizeof(WCHAR));
newprop = msi_alloc( len*sizeof(WCHAR) );
if (prop)
{
......@@ -96,8 +96,8 @@ static void append_productcode(MSIPACKAGE* package, LPCWSTR action_property,
MSI_SetPropertyW(package, action_property, newprop);
TRACE("Found Related Product... %s now %s\n",debugstr_w(action_property),
debugstr_w(newprop));
HeapFree(GetProcessHeap(),0,prop);
HeapFree(GetProcessHeap(),0,newprop);
msi_free( prop );
msi_free( newprop );
}
static UINT ITERATE_FindRelatedProducts(MSIRECORD *rec, LPVOID param)
......
......@@ -242,7 +242,7 @@ static UINT WHERE_execute( struct tagMSIVIEW *view, MSIRECORD *record )
if( r != ERROR_SUCCESS )
return r;
wv->reorder = HeapAlloc( GetProcessHeap(), 0, count*sizeof(UINT) );
wv->reorder = msi_alloc( count*sizeof(UINT) );
if( !wv->reorder )
return ERROR_FUNCTION_FAILED;
......@@ -269,7 +269,7 @@ static UINT WHERE_close( struct tagMSIVIEW *view )
if( !wv->table )
return ERROR_FUNCTION_FAILED;
HeapFree( GetProcessHeap(), 0, wv->reorder );
msi_free( wv->reorder );
wv->reorder = NULL;
return wv->table->ops->close( wv->table );
......@@ -329,12 +329,12 @@ static UINT WHERE_delete( struct tagMSIVIEW *view )
if( wv->table )
wv->table->ops->delete( wv->table );
HeapFree( GetProcessHeap(), 0, wv->reorder );
msi_free( wv->reorder );
wv->reorder = NULL;
wv->row_count = 0;
msiobj_release( &wv->db->hdr );
HeapFree( GetProcessHeap(), 0, wv );
msi_free( wv );
return ERROR_SUCCESS;
}
......@@ -462,7 +462,7 @@ UINT WHERE_CreateView( MSIDATABASE *db, MSIVIEW **view, MSIVIEW *table,
return ERROR_FUNCTION_FAILED;
}
wv = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof *wv );
wv = msi_alloc_zero( sizeof *wv );
if( !wv )
return ERROR_FUNCTION_FAILED;
......
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