diff --git a/dlls/msi/create.c b/dlls/msi/create.c index e442361071a..855999ec582 100644 --- a/dlls/msi/create.c +++ b/dlls/msi/create.c @@ -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; diff --git a/dlls/msi/delete.c b/dlls/msi/delete.c index 46eab5fd826..d42bf600649 100644 --- a/dlls/msi/delete.c +++ b/dlls/msi/delete.c @@ -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; diff --git a/dlls/msi/distinct.c b/dlls/msi/distinct.c index 64fa5ef9755..7ecd48d20fa 100644 --- a/dlls/msi/distinct.c +++ b/dlls/msi/distinct.c @@ -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; diff --git a/dlls/msi/events.c b/dlls/msi/events.c index 0b1d60f3dc0..08a85c66496 100644 --- a/dlls/msi/events.c +++ b/dlls/msi/events.c @@ -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", diff --git a/dlls/msi/handle.c b/dlls/msi/handle.c index d5d51fd7912..339acca728d 100644 --- a/dlls/msi/handle.c +++ b/dlls/msi/handle.c @@ -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); } diff --git a/dlls/msi/insert.c b/dlls/msi/insert.c index 7e317bb30ce..5d9fcb90ebf 100644 --- a/dlls/msi/insert.c +++ b/dlls/msi/insert.c @@ -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; diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h index f000d7cf022..5736cfa1178 100644 --- a/dlls/msi/msipriv.h +++ b/dlls/msi/msipriv.h @@ -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; } diff --git a/dlls/msi/order.c b/dlls/msi/order.c index 2a03bab63b8..b17be99143d 100644 --- a/dlls/msi/order.c +++ b/dlls/msi/order.c @@ -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; diff --git a/dlls/msi/package.c b/dlls/msi/package.c index 3c0086ce7c9..069aa5bd434 100644 --- a/dlls/msi/package.c +++ b/dlls/msi/package.c @@ -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; } diff --git a/dlls/msi/preview.c b/dlls/msi/preview.c index 5c596fbc85a..4c7c62b6022 100644 --- a/dlls/msi/preview.c +++ b/dlls/msi/preview.c @@ -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; } diff --git a/dlls/msi/record.c b/dlls/msi/record.c index 8bdc3c4cf47..05f80967cc1 100644 --- a/dlls/msi/record.c +++ b/dlls/msi/record.c @@ -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; } diff --git a/dlls/msi/registry.c b/dlls/msi/registry.c index c96a766fcfa..b8c206a0d53 100644 --- a/dlls/msi/registry.c +++ b/dlls/msi/registry.c @@ -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; } diff --git a/dlls/msi/select.c b/dlls/msi/select.c index 0ab500f2f15..ae4bc6cb7d2 100644 --- a/dlls/msi/select.c +++ b/dlls/msi/select.c @@ -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; diff --git a/dlls/msi/source.c b/dlls/msi/source.c index 63e4aeb8682..4f67e185f03 100644 --- a/dlls/msi/source.c +++ b/dlls/msi/source.c @@ -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); diff --git a/dlls/msi/sql.y b/dlls/msi/sql.y index 30a4046c742..97fe0111903 100644 --- a/dlls/msi/sql.y +++ b/dlls/msi/sql.y @@ -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]; } diff --git a/dlls/msi/string.c b/dlls/msi/string.c index 62a73310e07..f7ff8cace47 100644 --- a/dlls/msi/string.c +++ b/dlls/msi/string.c @@ -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; imaxcount; 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; } diff --git a/dlls/msi/suminfo.c b/dlls/msi/suminfo.c index 38a47134571..1dbee575b0a 100644 --- a/dlls/msi/suminfo.c +++ b/dlls/msi/suminfo.c @@ -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], §ion_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; diff --git a/dlls/msi/update.c b/dlls/msi/update.c index 0af29e07b17..0971982c9f5 100644 --- a/dlls/msi/update.c +++ b/dlls/msi/update.c @@ -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; diff --git a/dlls/msi/upgrade.c b/dlls/msi/upgrade.c index 8a091718484..3851abb2a4c 100644 --- a/dlls/msi/upgrade.c +++ b/dlls/msi/upgrade.c @@ -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) diff --git a/dlls/msi/where.c b/dlls/msi/where.c index 9bad7b54c8d..2602b1838a8 100644 --- a/dlls/msi/where.c +++ b/dlls/msi/where.c @@ -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;