From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- programs/rpcss/epmp.c | 6 +++--- programs/rpcss/irotp.c | 22 ++++++++++------------ programs/rpcss/rpcss_main.c | 11 +++++------ 3 files changed, 18 insertions(+), 21 deletions(-)
diff --git a/programs/rpcss/epmp.c b/programs/rpcss/epmp.c index 2a13aaccb8b..0d4cb9af982 100644 --- a/programs/rpcss/epmp.c +++ b/programs/rpcss/epmp.c @@ -57,7 +57,7 @@ static void delete_registered_ept_entry(struct registered_ept_entry *entry) I_RpcFree(entry->endpoint); I_RpcFree(entry->address); list_remove(&entry->entry); - HeapFree(GetProcessHeap(), 0, entry); + free(entry); }
static struct registered_ept_entry *find_ept_entry( @@ -106,7 +106,7 @@ void __cdecl ept_insert(handle_t h,
for (i = 0; i < num_ents; i++) { - struct registered_ept_entry *entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*entry)); + struct registered_ept_entry *entry = malloc(sizeof(*entry)); if (!entry) { /* FIXME: cleanup code to delete added entries */ @@ -121,7 +121,7 @@ void __cdecl ept_insert(handle_t h, { WINE_WARN("TowerExplode failed %lu\n", rpc_status); *status = rpc_status; - HeapFree(GetProcessHeap(), 0, entry); + free(entry); break; /* FIXME: more cleanup? */ }
diff --git a/programs/rpcss/irotp.c b/programs/rpcss/irotp.c index 47a88852a2d..daf48daf0a7 100644 --- a/programs/rpcss/irotp.c +++ b/programs/rpcss/irotp.c @@ -61,10 +61,10 @@ static inline void rot_entry_release(struct rot_entry *rot_entry) { if (!InterlockedDecrement(&rot_entry->refs)) { - HeapFree(GetProcessHeap(), 0, rot_entry->object); - HeapFree(GetProcessHeap(), 0, rot_entry->moniker); - HeapFree(GetProcessHeap(), 0, rot_entry->moniker_data); - HeapFree(GetProcessHeap(), 0, rot_entry); + free(rot_entry->object); + free(rot_entry->moniker); + free(rot_entry->moniker_data); + free(rot_entry); } }
@@ -88,12 +88,11 @@ HRESULT __cdecl IrotRegister( return E_INVALIDARG; }
- rot_entry = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*rot_entry)); - if (!rot_entry) + if (!(rot_entry = calloc(1, sizeof(*rot_entry)))) return E_OUTOFMEMORY;
rot_entry->refs = 1; - rot_entry->object = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(InterfaceData, abData[obj->ulCntData])); + rot_entry->object = malloc(FIELD_OFFSET(InterfaceData, abData[obj->ulCntData])); if (!rot_entry->object) { rot_entry_release(rot_entry); @@ -104,7 +103,7 @@ HRESULT __cdecl IrotRegister(
rot_entry->last_modified = *time;
- rot_entry->moniker = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(InterfaceData, abData[mk->ulCntData])); + rot_entry->moniker = malloc(FIELD_OFFSET(InterfaceData, abData[mk->ulCntData])); if (!rot_entry->moniker) { rot_entry_release(rot_entry); @@ -113,8 +112,7 @@ HRESULT __cdecl IrotRegister( rot_entry->moniker->ulCntData = mk->ulCntData; memcpy(&rot_entry->moniker->abData, mk->abData, mk->ulCntData);
- rot_entry->moniker_data = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(MonikerComparisonData, abData[data->ulCntData])); - if (!rot_entry->moniker_data) + if (!(rot_entry->moniker_data = malloc(FIELD_OFFSET(MonikerComparisonData, abData[data->ulCntData])))) { rot_entry_release(rot_entry); return E_OUTOFMEMORY; @@ -370,10 +368,10 @@ void __RPC_USER IrotContextHandle_rundown(IrotContextHandle ctxt_handle)
void * __RPC_USER MIDL_user_allocate(SIZE_T size) { - return HeapAlloc(GetProcessHeap(), 0, size); + return malloc(size); }
void __RPC_USER MIDL_user_free(void * p) { - HeapFree(GetProcessHeap(), 0, p); + free(p); } diff --git a/programs/rpcss/rpcss_main.c b/programs/rpcss/rpcss_main.c index 2fef34d1171..dfe5ced7c07 100644 --- a/programs/rpcss/rpcss_main.c +++ b/programs/rpcss/rpcss_main.c @@ -31,7 +31,6 @@ #include "irpcss.h"
#include "wine/debug.h" -#include "wine/heap.h" #include "wine/list.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole); @@ -58,14 +57,14 @@ HRESULT __cdecl irpcss_server_register(handle_t h, const GUID *clsid, unsigned i struct registered_class *entry; static LONG next_cookie;
- if (!(entry = heap_alloc_zero(sizeof(*entry)))) + if (!(entry = calloc(1, sizeof(*entry)))) return E_OUTOFMEMORY;
entry->clsid = *clsid; entry->single_use = !(flags & (REGCLS_MULTIPLEUSE | REGCLS_MULTI_SEPARATE)); - if (!(entry->object = heap_alloc(FIELD_OFFSET(MInterfacePointer, abData[object->ulCntData])))) + if (!(entry->object = malloc(FIELD_OFFSET(MInterfacePointer, abData[object->ulCntData])))) { - heap_free(entry); + free(entry); return E_OUTOFMEMORY; } entry->object->ulCntData = object->ulCntData; @@ -82,8 +81,8 @@ HRESULT __cdecl irpcss_server_register(handle_t h, const GUID *clsid, unsigned i static void scm_revoke_class(struct registered_class *_class) { list_remove(&_class->entry); - heap_free(_class->object); - heap_free(_class); + free(_class->object); + free(_class); }
HRESULT __cdecl irpcss_server_revoke(handle_t h, unsigned int cookie)
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- programs/wscript/host.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/programs/wscript/host.c b/programs/wscript/host.c index 463f5ee7aa6..44336deac13 100644 --- a/programs/wscript/host.c +++ b/programs/wscript/host.c @@ -28,7 +28,6 @@ #include "wscript.h"
#include <wine/debug.h> -#include <wine/heap.h>
WINE_DEFAULT_DEBUG_CHANNEL(wscript);
@@ -81,13 +80,13 @@ static void print_string(const WCHAR *string) }
lena = WideCharToMultiByte(GetOEMCP(), 0, string, len, NULL, 0, NULL, NULL); - buf = heap_alloc(len); + buf = malloc(len); if(!buf) return;
WideCharToMultiByte(GetOEMCP(), 0, string, len, buf, lena, NULL, NULL); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), buf, lena, &count, FALSE); - heap_free(buf); + free(buf); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE), "\r\n", 2, &count, FALSE); }
@@ -334,8 +333,8 @@ static HRESULT WINAPI Host_Echo(IHost *iface, SAFEARRAY *args) return hres;
argc = ubound-lbound+1; - strs = heap_alloc_zero(argc*sizeof(*strs)); - if(!strs) { + if (!(strs = calloc(argc, sizeof(*strs)))) + { SafeArrayUnaccessData(args); return E_OUTOFMEMORY; } @@ -353,7 +352,7 @@ static HRESULT WINAPI Host_Echo(IHost *iface, SAFEARRAY *args)
SafeArrayUnaccessData(args); if(SUCCEEDED(hres)) { - ptr = output = heap_alloc((len+1)*sizeof(WCHAR)); + ptr = output = malloc((len+1)*sizeof(WCHAR)); if(output) { for(i=0; i < argc; i++) { if(i) @@ -370,13 +369,13 @@ static HRESULT WINAPI Host_Echo(IHost *iface, SAFEARRAY *args)
for(i=0; i < argc; i++) SysFreeString(strs[i]); - heap_free(strs); + free(strs); if(FAILED(hres)) return hres;
print_string(output);
- heap_free(output); + free(output); return S_OK; }
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- programs/wordpad/print.c | 8 +++----- programs/wordpad/registry.c | 6 ++---- programs/wordpad/wordpad.c | 34 ++++++++++++++++------------------ programs/wordpad/wordpad.h | 2 ++ 4 files changed, 23 insertions(+), 27 deletions(-)
diff --git a/programs/wordpad/print.c b/programs/wordpad/print.c index acc583eefc5..d73c2d7757e 100644 --- a/programs/wordpad/print.c +++ b/programs/wordpad/print.c @@ -749,7 +749,7 @@ void close_preview(HWND hMainWnd) preview.window.right = 0; preview.window.bottom = 0; preview.page = 0; - HeapFree(GetProcessHeap(), 0, preview.pageEnds); + free(preview.pageEnds); preview.pageEnds = NULL; preview.pageCapacity = 0; if (preview.zoomlevel > 0) @@ -783,13 +783,11 @@ static void draw_preview(HWND hEditorWnd, FORMATRANGE* lpFr, RECT* paper, int pa if (!preview.pageEnds) { preview.pageCapacity = 32; - preview.pageEnds = HeapAlloc(GetProcessHeap(), 0, - sizeof(int) * preview.pageCapacity); + preview.pageEnds = malloc(sizeof(int) * preview.pageCapacity); if (!preview.pageEnds) return; } else if (page >= preview.pageCapacity) { int *new_buffer; - new_buffer = HeapReAlloc(GetProcessHeap(), 0, preview.pageEnds, - sizeof(int) * preview.pageCapacity * 2); + new_buffer = realloc(preview.pageEnds, sizeof(int) * preview.pageCapacity * 2); if (!new_buffer) return; preview.pageCapacity *= 2; preview.pageEnds = new_buffer; diff --git a/programs/wordpad/registry.c b/programs/wordpad/registry.c index 138111614bf..2de81c5d583 100644 --- a/programs/wordpad/registry.c +++ b/programs/wordpad/registry.c @@ -51,9 +51,7 @@ static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey) if(subKey) { WCHAR backslash[] = {'\',0}; - key = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - (lstrlenW(wszProgramKey)+lstrlenW(subKey)+lstrlenW(backslash)+1) - *sizeof(WCHAR)); + key = calloc(lstrlenW(wszProgramKey)+lstrlenW(subKey)+lstrlenW(backslash)+1, sizeof(WCHAR));
if(!key) return 1; @@ -73,7 +71,7 @@ static LRESULT registry_get_handle(HKEY *hKey, LPDWORD action, LPCWSTR subKey) }
if(subKey) - HeapFree(GetProcessHeap(), 0, key); + free(key);
return ret; } diff --git a/programs/wordpad/wordpad.c b/programs/wordpad/wordpad.c index 7f79eccc8bb..4a3aa2375bf 100644 --- a/programs/wordpad/wordpad.c +++ b/programs/wordpad/wordpad.c @@ -239,8 +239,7 @@ static void set_caption(LPCWSTR wszNewFileName) else wszNewFileName = file_basename((LPWSTR)wszNewFileName);
- wszCaption = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - lstrlenW(wszNewFileName)*sizeof(WCHAR)+sizeof(wszSeparator)+sizeof(wszAppTitle)); + wszCaption = calloc(1, lstrlenW(wszNewFileName)*sizeof(WCHAR)+sizeof(wszSeparator)+sizeof(wszAppTitle));
if(!wszCaption) return; @@ -253,7 +252,7 @@ static void set_caption(LPCWSTR wszNewFileName)
SetWindowTextW(hMainWnd, wszCaption);
- HeapFree(GetProcessHeap(), 0, wszCaption); + free(wszCaption); }
static BOOL validate_endptr(LPCWSTR endptr, UNIT *punit) @@ -615,8 +614,8 @@ static BOOL array_reserve(void **elements, size_t *capacity, size_t count, size_ if (new_capacity < count) new_capacity = max_capacity;
- new_elements = *elements ? HeapReAlloc(GetProcessHeap(), 0, *elements, new_capacity * size) : - HeapAlloc(GetProcessHeap(), 0, new_capacity * size); + new_elements = *elements ? realloc(*elements, new_capacity * size) : + malloc(new_capacity * size); if (!new_elements) return FALSE;
@@ -638,7 +637,7 @@ static void add_font(struct font_array *fonts, LPCWSTR fontName, DWORD fontType, fontHeight = ntmc->ntmTm.tmHeight - ntmc->ntmTm.tmInternalLeading;
idx = fonts->count; - fonts->fonts[idx].name = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(fontName) + 1)*sizeof(WCHAR) ); + fonts->fonts[idx].name = malloc((lstrlenW(fontName) + 1)*sizeof(WCHAR) ); lstrcpyW( fonts->fonts[idx].name, fontName ); fonts->fonts[idx].lParam = MAKELONG(fontType, fontHeight);
@@ -685,7 +684,7 @@ static void populate_font_list(HWND hListWnd) { if (!lstrcmpiW(font_array.fonts[i].name, font_array.fonts[j].name)) { - HeapFree(GetProcessHeap(), 0, font_array.fonts[i].name); + free(font_array.fonts[i].name); font_array.fonts[i].name = NULL; } else if (++j != i) @@ -707,9 +706,9 @@ static void populate_font_list(HWND hListWnd)
SendMessageW(hListWnd, CBEM_INSERTITEMW, 0, (LPARAM)&cbitem);
- HeapFree(GetProcessHeap(), 0, font_array.fonts[i].name); + free(font_array.fonts[i].name); } - HeapFree(GetProcessHeap(), 0, font_array.fonts); + free(font_array.fonts);
ZeroMemory(&fmt, sizeof(fmt)); fmt.cbSize = sizeof(fmt); @@ -1015,8 +1014,7 @@ static BOOL prompt_save_changes(void) else displayFileName = file_basename(wszFileName);
- text = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - (lstrlenW(displayFileName)+lstrlenW(wszSaveChanges))*sizeof(WCHAR)); + text = calloc(lstrlenW(displayFileName)+lstrlenW(wszSaveChanges), sizeof(WCHAR));
if(!text) return FALSE; @@ -1025,7 +1023,7 @@ static BOOL prompt_save_changes(void)
ret = MessageBoxW(hMainWnd, text, wszAppTitle, MB_YESNOCANCEL | MB_ICONEXCLAMATION);
- HeapFree(GetProcessHeap(), 0, text); + free(text);
switch(ret) { @@ -2401,20 +2399,20 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) case ID_EDIT_GETTEXT: { int nLen = GetWindowTextLengthW(hwndEditor); - LPWSTR data = HeapAlloc( GetProcessHeap(), 0, (nLen+1)*sizeof(WCHAR) ); + LPWSTR data = malloc((nLen+1)*sizeof(WCHAR) ); TEXTRANGEW tr;
GetWindowTextW(hwndEditor, data, nLen+1); MessageBoxW(NULL, data, wszAppTitle, MB_OK);
- HeapFree( GetProcessHeap(), 0, data); - data = HeapAlloc(GetProcessHeap(), 0, (nLen+1)*sizeof(WCHAR)); + free(data); + data = malloc((nLen+1)*sizeof(WCHAR)); tr.chrg.cpMin = 0; tr.chrg.cpMax = nLen; tr.lpstrText = data; SendMessageW(hwndEditor, EM_GETTEXTRANGE, 0, (LPARAM)&tr); MessageBoxW(NULL, data, wszAppTitle, MB_OK); - HeapFree( GetProcessHeap(), 0, data ); + free(data);
/* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */ return 0; @@ -2449,12 +2447,12 @@ static LRESULT OnCommand( HWND hWnd, WPARAM wParam, LPARAM lParam) WCHAR *data = NULL;
SendMessageW(hwndEditor, EM_EXGETSEL, 0, (LPARAM)&range); - data = HeapAlloc(GetProcessHeap(), 0, sizeof(*data) * (range.cpMax-range.cpMin+1)); + data = malloc(sizeof(*data) * (range.cpMax-range.cpMin+1)); SendMessageW(hwndEditor, EM_GETSELTEXT, 0, (LPARAM)data); sprintf(buf, "Start = %ld, End = %ld", range.cpMin, range.cpMax); MessageBoxA(hWnd, buf, "Editor", MB_OK); MessageBoxW(hWnd, data, wszAppTitle, MB_OK); - HeapFree( GetProcessHeap(), 0, data); + free(data); /* SendMessage(hwndEditor, EM_SETSEL, 0, -1); */ return 0; } diff --git a/programs/wordpad/wordpad.h b/programs/wordpad/wordpad.h index 0baf8c924dd..6dae06b38eb 100644 --- a/programs/wordpad/wordpad.h +++ b/programs/wordpad/wordpad.h @@ -17,6 +17,8 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA */
+#include <stdlib.h> + #include <windef.h> #include <winuser.h>
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- programs/winepath/winepath.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/programs/winepath/winepath.c b/programs/winepath/winepath.c index 17cfdc1d2eb..88c64b91a42 100644 --- a/programs/winepath/winepath.c +++ b/programs/winepath/winepath.c @@ -195,7 +195,7 @@ int __cdecl wmain(int argc, WCHAR *argv[]) if (outputformats & UNIXFORMAT) { WCHAR *ntpath, *tail; int ntpathlen=lstrlenW(argv[i]); - ntpath=HeapAlloc(GetProcessHeap(), 0, sizeof(*ntpath)*(ntpathlen+1)); + ntpath = malloc(sizeof(*ntpath)*(ntpathlen+1)); lstrcpyW(ntpath, argv[i]); tail=NULL; while (1) @@ -215,7 +215,7 @@ int __cdecl wmain(int argc, WCHAR *argv[]) { printf("%s%c", unix_name, separator); } - HeapFree( GetProcessHeap(), 0, unix_name ); + free( unix_name ); break; }
@@ -247,7 +247,7 @@ int __cdecl wmain(int argc, WCHAR *argv[]) tail=slash; *tail='\0'; } - HeapFree(GetProcessHeap(), 0, ntpath); + free(ntpath); } if (outputformats & WINDOWSFORMAT) { WCHAR* windows_name; @@ -255,17 +255,17 @@ int __cdecl wmain(int argc, WCHAR *argv[]) DWORD size;
size=WideCharToMultiByte(CP_UNIXCP, 0, argv[i], -1, NULL, 0, NULL, NULL); - unix_name=HeapAlloc(GetProcessHeap(), 0, size); + unix_name = malloc(size); WideCharToMultiByte(CP_UNIXCP, 0, argv[i], -1, unix_name, size, NULL, NULL);
if ((windows_name = wine_get_dos_file_name_ptr(unix_name))) { WideCharToMultiByte(CP_UNIXCP, 0, windows_name, -1, path, MAX_PATH, NULL, NULL); printf("%s%c", path, separator); - HeapFree( GetProcessHeap(), 0, windows_name ); + free( windows_name ); } else printf("%c", separator); - HeapFree( GetProcessHeap(), 0, unix_name ); + free( unix_name ); } }
From: Nikolay Sivov nsivov@codeweavers.com
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- programs/winemsibuilder/main.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/programs/winemsibuilder/main.c b/programs/winemsibuilder/main.c index 3b1221860b3..3bbd0735505 100644 --- a/programs/winemsibuilder/main.c +++ b/programs/winemsibuilder/main.c @@ -77,7 +77,7 @@ static int import_tables( const WCHAR *msifile, WCHAR **tables ) if (r != ERROR_SUCCESS) return 1;
len = GetCurrentDirectoryW( 0, NULL ); - if (!(dir = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) + if (!(dir = malloc( (len + 1) * sizeof(WCHAR) ))) { MsiCloseHandle( hdb ); return 1; @@ -102,7 +102,7 @@ static int import_tables( const WCHAR *msifile, WCHAR **tables ) WINE_ERR( "failed to commit changes (%u)\n", r ); }
- HeapFree( GetProcessHeap(), 0, dir ); + free( dir ); MsiCloseHandle( hdb ); return (r != ERROR_SUCCESS); } @@ -135,7 +135,7 @@ static WCHAR *encode_stream( const WCHAR *in ) return NULL;
count += 2; - if (!(out = HeapAlloc( GetProcessHeap(), 0, count * sizeof(WCHAR) ))) return NULL; + if (!(out = malloc( count * sizeof(WCHAR) ))) return NULL; p = out; while (count--) { @@ -162,7 +162,7 @@ static WCHAR *encode_stream( const WCHAR *in ) } *p++ = c; } - HeapFree( GetProcessHeap(), 0, out ); + free( out ); return NULL; }
@@ -236,7 +236,7 @@ static int add_stream( const WCHAR *msifile, const WCHAR *stream, const WCHAR *f ret = 0;
done: - HeapFree( GetProcessHeap(), 0, encname ); + free( encname ); if (stm) IStream_Release( stm ); IStorage_Release( stg ); return ret;