Commit 89548cd0 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

taskschd: Add some useful inline helpers for memory management.

parent 463b1b64
......@@ -60,8 +60,8 @@ static ULONG WINAPI TaskFolder_Release(ITaskFolder *iface)
if (!ref)
{
TRACE("destroying %p\n", iface);
HeapFree(GetProcessHeap(), 0, folder->path);
HeapFree(GetProcessHeap(), 0, folder);
heap_free(folder->path);
heap_free(folder);
}
return ref;
......@@ -374,7 +374,7 @@ HRESULT TaskFolder_create(const WCHAR *parent, const WCHAR *path, ITaskFolder **
if (parent) len += strlenW(parent);
/* +1 if parent is not '\' terminated */
folder_path = HeapAlloc(GetProcessHeap(), 0, (len + 2) * sizeof(WCHAR));
folder_path = heap_alloc((len + 2) * sizeof(WCHAR));
if (!folder_path) return E_OUTOFMEMORY;
folder_path[0] = 0;
......@@ -399,16 +399,16 @@ HRESULT TaskFolder_create(const WCHAR *parent, const WCHAR *path, ITaskFolder **
hr = create ? reg_create_folder(folder_path, &hfolder) : reg_open_folder(folder_path, &hfolder);
if (hr)
{
HeapFree(GetProcessHeap(), 0, folder_path);
heap_free(folder_path);
return hr;
}
reg_close_folder(hfolder);
folder = HeapAlloc(GetProcessHeap(), 0, sizeof(*folder));
folder = heap_alloc(sizeof(*folder));
if (!folder)
{
HeapFree(GetProcessHeap(), 0, folder_path);
heap_free(folder_path);
return E_OUTOFMEMORY;
}
......
......@@ -56,7 +56,7 @@ static ULONG WINAPI folders_Release(ITaskFolderCollection *iface)
if (!ref)
{
TRACE("destroying %p\n", iface);
HeapFree(GetProcessHeap(), 0, folders);
heap_free(folders);
}
return ref;
......@@ -144,7 +144,7 @@ HRESULT TaskFolderCollection_create(const WCHAR *path, ITaskFolderCollection **o
{
TaskFolderCollection *folders;
folders = HeapAlloc(GetProcessHeap(), 0, sizeof(*folders));
folders = heap_alloc(sizeof(*folders));
if (!folders) return E_OUTOFMEMORY;
folders->ITaskFolderCollection_iface.lpVtbl = &TaskFolderCollection_vtbl;
......
......@@ -59,7 +59,7 @@ static ULONG WINAPI TaskService_Release(ITaskService *iface)
if (!ref)
{
TRACE("destroying %p\n", iface);
HeapFree(GetProcessHeap(), 0, task_svc);
heap_free(task_svc);
}
return ref;
......@@ -254,7 +254,7 @@ HRESULT TaskService_create(void **obj)
{
TaskService *task_svc;
task_svc = HeapAlloc(GetProcessHeap(), 0, sizeof(*task_svc));
task_svc = heap_alloc(sizeof(*task_svc));
if (!task_svc) return E_OUTOFMEMORY;
task_svc->ITaskService_iface.lpVtbl = &TaskService_vtbl;
......
......@@ -16,8 +16,37 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "wine/unicode.h"
HRESULT TaskService_create(void **obj) DECLSPEC_HIDDEN;
HRESULT TaskFolder_create(const WCHAR *parent, const WCHAR *path, ITaskFolder **obj, BOOL create) DECLSPEC_HIDDEN;
HRESULT TaskFolderCollection_create(const WCHAR *path, ITaskFolderCollection **obj) DECLSPEC_HIDDEN;
const char *debugstr_variant(const VARIANT *v) DECLSPEC_HIDDEN;
static void *heap_alloc(SIZE_T size) __WINE_ALLOC_SIZE(1);
static inline void *heap_alloc(SIZE_T size)
{
return HeapAlloc(GetProcessHeap(), 0, size);
}
static void *heap_realloc(void *ptr, SIZE_T size) __WINE_ALLOC_SIZE(2);
static inline void *heap_realloc(void *ptr, SIZE_T size)
{
return HeapReAlloc(GetProcessHeap(), 0, ptr, size);
}
static inline BOOL heap_free(void *ptr)
{
return HeapFree(GetProcessHeap(), 0, ptr);
}
static inline WCHAR *heap_strdupW(const WCHAR *src)
{
WCHAR *dst;
unsigned len;
if (!src) return NULL;
len = (strlenW(src) + 1) * sizeof(WCHAR);
if ((dst = heap_alloc(len))) memcpy(dst, src, len);
return dst;
}
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