Commit 6341e6d9 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

atl: Use CRT allocation functions.

parent 33ff4a66
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "atlcom.h" #include "atlcom.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(atl); WINE_DEFAULT_DEBUG_CHANNEL(atl);
...@@ -294,7 +293,7 @@ HRESULT WINAPI AtlModuleAddTermFunc(_ATL_MODULE *pM, _ATL_TERMFUNC *pFunc, DWORD ...@@ -294,7 +293,7 @@ HRESULT WINAPI AtlModuleAddTermFunc(_ATL_MODULE *pM, _ATL_TERMFUNC *pFunc, DWORD
TRACE("version %04x (%p %p %Id)\n", _ATL_VER, pM, pFunc, dw); TRACE("version %04x (%p %p %Id)\n", _ATL_VER, pM, pFunc, dw);
if (_ATL_VER > _ATL_VER_30 || pM->cbSize > ATLVer1Size) { if (_ATL_VER > _ATL_VER_30 || pM->cbSize > ATLVer1Size) {
termfunc_elem = HeapAlloc(GetProcessHeap(), 0, sizeof(_ATL_TERMFUNC_ELEM)); termfunc_elem = malloc(sizeof(*termfunc_elem));
termfunc_elem->pFunc = pFunc; termfunc_elem->pFunc = pFunc;
termfunc_elem->dw = dw; termfunc_elem->dw = dw;
termfunc_elem->pNext = pM->m_pTermFuncs; termfunc_elem->pNext = pM->m_pTermFuncs;
...@@ -320,7 +319,7 @@ void WINAPI AtlCallTermFunc(_ATL_MODULE *pM) ...@@ -320,7 +319,7 @@ void WINAPI AtlCallTermFunc(_ATL_MODULE *pM)
iter->pFunc(iter->dw); iter->pFunc(iter->dw);
tmp = iter; tmp = iter;
iter = iter->pNext; iter = iter->pNext;
HeapFree(GetProcessHeap(), 0, tmp); free(tmp);
} }
pM->m_pTermFuncs = NULL; pM->m_pTermFuncs = NULL;
...@@ -342,13 +341,13 @@ HRESULT WINAPI AtlLoadTypeLib(HINSTANCE inst, LPCOLESTR lpszIndex, ...@@ -342,13 +341,13 @@ HRESULT WINAPI AtlLoadTypeLib(HINSTANCE inst, LPCOLESTR lpszIndex,
TRACE("(%p %s %p %p)\n", inst, debugstr_w(lpszIndex), pbstrPath, ppTypeLib); TRACE("(%p %s %p %p)\n", inst, debugstr_w(lpszIndex), pbstrPath, ppTypeLib);
index_len = lpszIndex ? lstrlenW(lpszIndex) : 0; index_len = lpszIndex ? lstrlenW(lpszIndex) : 0;
path = heap_alloc((MAX_PATH+index_len)*sizeof(WCHAR) + sizeof(L".tlb")); path = malloc((MAX_PATH+index_len)*sizeof(WCHAR) + sizeof(L".tlb"));
if(!path) if(!path)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
path_len = GetModuleFileNameW(inst, path, MAX_PATH); path_len = GetModuleFileNameW(inst, path, MAX_PATH);
if(!path_len) { if(!path_len) {
heap_free(path); free(path);
return HRESULT_FROM_WIN32(GetLastError()); return HRESULT_FROM_WIN32(GetLastError());
} }
...@@ -374,7 +373,7 @@ HRESULT WINAPI AtlLoadTypeLib(HINSTANCE inst, LPCOLESTR lpszIndex, ...@@ -374,7 +373,7 @@ HRESULT WINAPI AtlLoadTypeLib(HINSTANCE inst, LPCOLESTR lpszIndex,
} }
} }
heap_free(path); free(path);
if(FAILED(hres)) if(FAILED(hres))
return hres; return hres;
......
...@@ -121,7 +121,7 @@ HRESULT WINAPI AtlModuleTerm(_ATL_MODULE *pM) ...@@ -121,7 +121,7 @@ HRESULT WINAPI AtlModuleTerm(_ATL_MODULE *pM)
iter->pFunc(iter->dw); iter->pFunc(iter->dw);
tmp = iter; tmp = iter;
iter = iter->pNext; iter = iter->pNext;
HeapFree(GetProcessHeap(), 0, tmp); free(tmp);
} }
} }
......
...@@ -63,12 +63,12 @@ static LRESULT CALLBACK AtlAxWin_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, L ...@@ -63,12 +63,12 @@ static LRESULT CALLBACK AtlAxWin_wndproc( HWND hWnd, UINT wMsg, WPARAM wParam, L
if ( wMsg == WM_CREATE ) if ( wMsg == WM_CREATE )
{ {
DWORD len = GetWindowTextLengthW( hWnd ) + 1; DWORD len = GetWindowTextLengthW( hWnd ) + 1;
WCHAR *ptr = HeapAlloc( GetProcessHeap(), 0, len*sizeof(WCHAR) ); WCHAR *ptr = malloc( len*sizeof(WCHAR) );
if (!ptr) if (!ptr)
return 1; return 1;
GetWindowTextW( hWnd, ptr, len ); GetWindowTextW( hWnd, ptr, len );
AtlAxCreateControlEx( ptr, hWnd, NULL, NULL, NULL, NULL, NULL ); AtlAxCreateControlEx( ptr, hWnd, NULL, NULL, NULL, NULL, NULL );
HeapFree( GetProcessHeap(), 0, ptr ); free( ptr );
return 0; return 0;
} }
return DefWindowProcW( hWnd, wMsg, wParam, lParam ); return DefWindowProcW( hWnd, wMsg, wParam, lParam );
...@@ -225,7 +225,7 @@ static ULONG WINAPI OleClientSite_Release(IOleClientSite *iface) ...@@ -225,7 +225,7 @@ static ULONG WINAPI OleClientSite_Release(IOleClientSite *iface)
if (!ref) if (!ref)
{ {
IOCS_Detach( This ); IOCS_Detach( This );
HeapFree( GetProcessHeap(), 0, This ); free( This );
} }
return ref; return ref;
...@@ -945,7 +945,7 @@ static HRESULT IOCS_Create( HWND hWnd, IUnknown *pUnkControl, IUnknown **contain ...@@ -945,7 +945,7 @@ static HRESULT IOCS_Create( HWND hWnd, IUnknown *pUnkControl, IUnknown **contain
return S_OK; return S_OK;
*container = NULL; *container = NULL;
This = HeapAlloc(GetProcessHeap(), 0, sizeof(IOCS)); This = malloc(sizeof(*This));
if (!This) if (!This)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
...@@ -969,7 +969,7 @@ static HRESULT IOCS_Create( HWND hWnd, IUnknown *pUnkControl, IUnknown **contain ...@@ -969,7 +969,7 @@ static HRESULT IOCS_Create( HWND hWnd, IUnknown *pUnkControl, IUnknown **contain
else else
{ {
IOCS_Detach( This ); IOCS_Detach( This );
HeapFree(GetProcessHeap(), 0, This); free(This);
} }
return hr; return hr;
...@@ -1160,7 +1160,7 @@ static inline BOOL advance_array(WORD **pptr, DWORD *palloc, DWORD *pfilled, con ...@@ -1160,7 +1160,7 @@ static inline BOOL advance_array(WORD **pptr, DWORD *palloc, DWORD *pfilled, con
if ( (*pfilled + size) > *palloc ) if ( (*pfilled + size) > *palloc )
{ {
*palloc = ((*pfilled+size) + 0xFF) & ~0xFF; *palloc = ((*pfilled+size) + 0xFF) & ~0xFF;
*pptr = HeapReAlloc( GetProcessHeap(), 0, *pptr, *palloc * sizeof(WORD) ); *pptr = realloc( *pptr, *palloc * sizeof(WORD) );
if (!*pptr) if (!*pptr)
return FALSE; return FALSE;
} }
...@@ -1186,7 +1186,7 @@ static LPDLGTEMPLATEW AX_ConvertDialogTemplate(LPCDLGTEMPLATEW src_tmpl) ...@@ -1186,7 +1186,7 @@ static LPDLGTEMPLATEW AX_ConvertDialogTemplate(LPCDLGTEMPLATEW src_tmpl)
DWORD style; DWORD style;
filled = 0; allocated = 256; filled = 0; allocated = 256;
output = HeapAlloc( GetProcessHeap(), 0, allocated * sizeof(WORD) ); output = malloc( allocated * sizeof(WORD) );
if (!output) if (!output)
return NULL; return NULL;
...@@ -1307,12 +1307,12 @@ HWND WINAPI AtlAxCreateDialogA(HINSTANCE hInst, LPCSTR name, HWND owner, DLGPROC ...@@ -1307,12 +1307,12 @@ HWND WINAPI AtlAxCreateDialogA(HINSTANCE hInst, LPCSTR name, HWND owner, DLGPROC
return AtlAxCreateDialogW( hInst, (LPCWSTR) name, owner, dlgProc, param ); return AtlAxCreateDialogW( hInst, (LPCWSTR) name, owner, dlgProc, param );
length = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 ); length = MultiByteToWideChar( CP_ACP, 0, name, -1, NULL, 0 );
nameW = HeapAlloc( GetProcessHeap(), 0, length * sizeof(WCHAR) ); nameW = malloc( length * sizeof(WCHAR) );
if (nameW) if (nameW)
{ {
MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, length ); MultiByteToWideChar( CP_ACP, 0, name, -1, nameW, length );
res = AtlAxCreateDialogW( hInst, nameW, owner, dlgProc, param ); res = AtlAxCreateDialogW( hInst, nameW, owner, dlgProc, param );
HeapFree( GetProcessHeap(), 0, nameW ); free( nameW );
} }
return res; return res;
} }
...@@ -1349,7 +1349,7 @@ HWND WINAPI AtlAxCreateDialogW(HINSTANCE hInst, LPCWSTR name, HWND owner, DLGPRO ...@@ -1349,7 +1349,7 @@ HWND WINAPI AtlAxCreateDialogW(HINSTANCE hInst, LPCWSTR name, HWND owner, DLGPRO
if ( newptr ) if ( newptr )
{ {
res = CreateDialogIndirectParamW( hInst, newptr, owner, dlgProc, param ); res = CreateDialogIndirectParamW( hInst, newptr, owner, dlgProc, param );
HeapFree( GetProcessHeap(), 0, newptr ); free( newptr );
} else } else
res = NULL; res = NULL;
FreeResource ( hrsrc ); FreeResource ( hrsrc );
...@@ -1425,7 +1425,7 @@ INT_PTR WINAPI AtlAxDialogBoxW(HINSTANCE instance, const WCHAR *name, ...@@ -1425,7 +1425,7 @@ INT_PTR WINAPI AtlAxDialogBoxW(HINSTANCE instance, const WCHAR *name,
return 0; return 0;
ret = DialogBoxIndirectParamW(instance, template, owner, proc, param); ret = DialogBoxIndirectParamW(instance, template, owner, proc, param);
HeapFree(GetProcessHeap(), 0, template); free(template);
return ret; return ret;
} }
......
...@@ -74,7 +74,7 @@ static inline Registrar *impl_from_IRegistrar(IRegistrar *iface) ...@@ -74,7 +74,7 @@ static inline Registrar *impl_from_IRegistrar(IRegistrar *iface)
static void strbuf_init(strbuf *buf) static void strbuf_init(strbuf *buf)
{ {
buf->str = HeapAlloc(GetProcessHeap(), 0, 128*sizeof(WCHAR)); buf->str = malloc(128*sizeof(WCHAR));
buf->alloc = 128; buf->alloc = 128;
buf->len = 0; buf->len = 0;
} }
...@@ -85,7 +85,7 @@ static void strbuf_write(LPCOLESTR str, strbuf *buf, int len) ...@@ -85,7 +85,7 @@ static void strbuf_write(LPCOLESTR str, strbuf *buf, int len)
len = lstrlenW(str); len = lstrlenW(str);
if(buf->len+len+1 >= buf->alloc) { if(buf->len+len+1 >= buf->alloc) {
buf->alloc = (buf->len+len)<<1; buf->alloc = (buf->len+len)<<1;
buf->str = HeapReAlloc(GetProcessHeap(), 0, buf->str, buf->alloc*sizeof(WCHAR)); buf->str = realloc(buf->str, buf->alloc*sizeof(WCHAR));
} }
memcpy(buf->str+buf->len, str, len*sizeof(OLECHAR)); memcpy(buf->str+buf->len, str, len*sizeof(OLECHAR));
buf->len += len; buf->len += len;
...@@ -292,7 +292,7 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO ...@@ -292,7 +292,7 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO
if(FAILED(hres)) if(FAILED(hres))
break; break;
count = (lstrlenW(buf->str) + 1) / 2; count = (lstrlenW(buf->str) + 1) / 2;
bytes = HeapAlloc(GetProcessHeap(), 0, count); bytes = malloc(count);
if(bytes == NULL) { if(bytes == NULL) {
hres = E_OUTOFMEMORY; hres = E_OUTOFMEMORY;
break; break;
...@@ -313,7 +313,7 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO ...@@ -313,7 +313,7 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO
hres = HRESULT_FROM_WIN32(lres); hres = HRESULT_FROM_WIN32(lres);
} }
} }
HeapFree(GetProcessHeap(), 0, bytes); free(bytes);
break; break;
} }
default: default:
...@@ -360,7 +360,7 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO ...@@ -360,7 +360,7 @@ static HRESULT do_process_key(LPCOLESTR *pstr, HKEY parent_key, strbuf *buf, BOO
break; break;
} }
HeapFree(GetProcessHeap(), 0, name.str); free(name.str);
if(hkey && key_type != IS_VAL) if(hkey && key_type != IS_VAL)
RegCloseKey(hkey); RegCloseKey(hkey);
*pstr = iter; *pstr = iter;
...@@ -411,7 +411,7 @@ static HRESULT do_process_root_key(LPCOLESTR data, BOOL do_register) ...@@ -411,7 +411,7 @@ static HRESULT do_process_root_key(LPCOLESTR data, BOOL do_register)
if(FAILED(hres)) if(FAILED(hres))
break; break;
} }
HeapFree(GetProcessHeap(), 0, buf.str); free(buf.str);
return hres; return hres;
} }
...@@ -426,7 +426,7 @@ static HRESULT string_register(Registrar *This, LPCOLESTR data, BOOL do_register ...@@ -426,7 +426,7 @@ static HRESULT string_register(Registrar *This, LPCOLESTR data, BOOL do_register
hres = do_preprocess(This, data, &buf); hres = do_preprocess(This, data, &buf);
if(FAILED(hres)) { if(FAILED(hres)) {
WARN("preprocessing failed!\n"); WARN("preprocessing failed!\n");
HeapFree(GetProcessHeap(), 0, buf.str); free(buf.str);
return hres; return hres;
} }
...@@ -434,7 +434,7 @@ static HRESULT string_register(Registrar *This, LPCOLESTR data, BOOL do_register ...@@ -434,7 +434,7 @@ static HRESULT string_register(Registrar *This, LPCOLESTR data, BOOL do_register
if(FAILED(hres) && do_register) if(FAILED(hres) && do_register)
do_process_root_key(buf.str, FALSE); do_process_root_key(buf.str, FALSE);
HeapFree(GetProcessHeap(), 0, buf.str); free(buf.str);
return hres; return hres;
} }
...@@ -456,13 +456,13 @@ static HRESULT resource_register(Registrar *This, LPCOLESTR resFileName, ...@@ -456,13 +456,13 @@ static HRESULT resource_register(Registrar *This, LPCOLESTR resFileName,
reslen = SizeofResource(hins, src); reslen = SizeofResource(hins, src);
if(regstra) { if(regstra) {
len = MultiByteToWideChar(CP_ACP, 0, regstra, reslen, NULL, 0)+1; len = MultiByteToWideChar(CP_ACP, 0, regstra, reslen, NULL, 0)+1;
regstrw = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(WCHAR)); regstrw = calloc(len, sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, regstra, reslen, regstrw, len); MultiByteToWideChar(CP_ACP, 0, regstra, reslen, regstrw, len);
regstrw[len-1] = '\0'; regstrw[len-1] = '\0';
hres = string_register(This, regstrw, do_register); hres = string_register(This, regstrw, do_register);
HeapFree(GetProcessHeap(), 0, regstrw); free(regstrw);
}else { }else {
WARN("could not load resource\n"); WARN("could not load resource\n");
hres = HRESULT_FROM_WIN32(GetLastError()); hres = HRESULT_FROM_WIN32(GetLastError());
...@@ -491,21 +491,21 @@ static HRESULT file_register(Registrar *This, LPCOLESTR fileName, BOOL do_regist ...@@ -491,21 +491,21 @@ static HRESULT file_register(Registrar *This, LPCOLESTR fileName, BOOL do_regist
file = CreateFileW(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); file = CreateFileW(fileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
if(file != INVALID_HANDLE_VALUE) { if(file != INVALID_HANDLE_VALUE) {
filelen = GetFileSize(file, NULL); filelen = GetFileSize(file, NULL);
regstra = HeapAlloc(GetProcessHeap(), 0, filelen); regstra = malloc(filelen);
if(ReadFile(file, regstra, filelen, NULL, NULL)) { if(ReadFile(file, regstra, filelen, NULL, NULL)) {
len = MultiByteToWideChar(CP_ACP, 0, regstra, filelen, NULL, 0)+1; len = MultiByteToWideChar(CP_ACP, 0, regstra, filelen, NULL, 0)+1;
regstrw = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(WCHAR)); regstrw = calloc(len, sizeof(WCHAR));
MultiByteToWideChar(CP_ACP, 0, regstra, filelen, regstrw, len); MultiByteToWideChar(CP_ACP, 0, regstra, filelen, regstrw, len);
regstrw[len-1] = '\0'; regstrw[len-1] = '\0';
hres = string_register(This, regstrw, do_register); hres = string_register(This, regstrw, do_register);
HeapFree(GetProcessHeap(), 0, regstrw); free(regstrw);
}else { }else {
WARN("Failed to read file %s\n", debugstr_w(fileName)); WARN("Failed to read file %s\n", debugstr_w(fileName));
hres = HRESULT_FROM_WIN32(GetLastError()); hres = HRESULT_FROM_WIN32(GetLastError());
} }
HeapFree(GetProcessHeap(), 0, regstra); free(regstra);
CloseHandle(file); CloseHandle(file);
}else { }else {
WARN("Could not open file %s\n", debugstr_w(fileName)); WARN("Could not open file %s\n", debugstr_w(fileName));
...@@ -545,7 +545,7 @@ static ULONG WINAPI Registrar_Release(IRegistrar *iface) ...@@ -545,7 +545,7 @@ static ULONG WINAPI Registrar_Release(IRegistrar *iface)
TRACE("(%p) ->%ld\n", This, ref); TRACE("(%p) ->%ld\n", This, ref);
if(!ref) { if(!ref) {
IRegistrar_ClearReplacements(iface); IRegistrar_ClearReplacements(iface);
HeapFree(GetProcessHeap(), 0, This); free(This);
} }
return ref; return ref;
} }
...@@ -558,14 +558,14 @@ static HRESULT WINAPI Registrar_AddReplacement(IRegistrar *iface, LPCOLESTR Key, ...@@ -558,14 +558,14 @@ static HRESULT WINAPI Registrar_AddReplacement(IRegistrar *iface, LPCOLESTR Key,
TRACE("(%p)->(%s %s)\n", This, debugstr_w(Key), debugstr_w(item)); TRACE("(%p)->(%s %s)\n", This, debugstr_w(Key), debugstr_w(item));
new_rep = HeapAlloc(GetProcessHeap(), 0, sizeof(rep_list)); new_rep = malloc(sizeof(*new_rep));
new_rep->key_len = lstrlenW(Key); new_rep->key_len = lstrlenW(Key);
new_rep->key = HeapAlloc(GetProcessHeap(), 0, (new_rep->key_len + 1) * sizeof(OLECHAR)); new_rep->key = malloc((new_rep->key_len + 1) * sizeof(OLECHAR));
memcpy(new_rep->key, Key, (new_rep->key_len+1)*sizeof(OLECHAR)); memcpy(new_rep->key, Key, (new_rep->key_len+1)*sizeof(OLECHAR));
len = lstrlenW(item)+1; len = lstrlenW(item)+1;
new_rep->item = HeapAlloc(GetProcessHeap(), 0, len*sizeof(OLECHAR)); new_rep->item = malloc(len*sizeof(OLECHAR));
memcpy(new_rep->item, item, len*sizeof(OLECHAR)); memcpy(new_rep->item, item, len*sizeof(OLECHAR));
new_rep->next = This->rep; new_rep->next = This->rep;
...@@ -587,9 +587,9 @@ static HRESULT WINAPI Registrar_ClearReplacements(IRegistrar *iface) ...@@ -587,9 +587,9 @@ static HRESULT WINAPI Registrar_ClearReplacements(IRegistrar *iface)
iter = This->rep; iter = This->rep;
while(iter) { while(iter) {
iter2 = iter->next; iter2 = iter->next;
HeapFree(GetProcessHeap(), 0, iter->key); free(iter->key);
HeapFree(GetProcessHeap(), 0, iter->item); free(iter->item);
HeapFree(GetProcessHeap(), 0, iter); free(iter);
iter = iter2; iter = iter2;
} }
...@@ -680,13 +680,12 @@ HRESULT WINAPI AtlCreateRegistrar(IRegistrar **ret) ...@@ -680,13 +680,12 @@ HRESULT WINAPI AtlCreateRegistrar(IRegistrar **ret)
{ {
Registrar *registrar; Registrar *registrar;
registrar = HeapAlloc(GetProcessHeap(), 0, sizeof(*registrar)); registrar = calloc(1, sizeof(*registrar));
if(!registrar) if(!registrar)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
registrar->IRegistrar_iface.lpVtbl = &RegistrarVtbl; registrar->IRegistrar_iface.lpVtbl = &RegistrarVtbl;
registrar->ref = 1; registrar->ref = 1;
registrar->rep = NULL;
*ret = &registrar->IRegistrar_iface; *ret = &registrar->IRegistrar_iface;
return S_OK; return S_OK;
......
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