mirror of
https://github.com/reactos/wine.git
synced 2025-02-27 08:15:36 +00:00
taskschd: Add some useful inline helpers for memory management.
This commit is contained in:
parent
463b1b6450
commit
89548cd0ad
@ -60,8 +60,8 @@ static ULONG WINAPI TaskFolder_Release(ITaskFolder *iface)
|
|||||||
if (!ref)
|
if (!ref)
|
||||||
{
|
{
|
||||||
TRACE("destroying %p\n", iface);
|
TRACE("destroying %p\n", iface);
|
||||||
HeapFree(GetProcessHeap(), 0, folder->path);
|
heap_free(folder->path);
|
||||||
HeapFree(GetProcessHeap(), 0, folder);
|
heap_free(folder);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
@ -374,7 +374,7 @@ HRESULT TaskFolder_create(const WCHAR *parent, const WCHAR *path, ITaskFolder **
|
|||||||
if (parent) len += strlenW(parent);
|
if (parent) len += strlenW(parent);
|
||||||
|
|
||||||
/* +1 if parent is not '\' terminated */
|
/* +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;
|
if (!folder_path) return E_OUTOFMEMORY;
|
||||||
|
|
||||||
folder_path[0] = 0;
|
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);
|
hr = create ? reg_create_folder(folder_path, &hfolder) : reg_open_folder(folder_path, &hfolder);
|
||||||
if (hr)
|
if (hr)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, folder_path);
|
heap_free(folder_path);
|
||||||
return hr;
|
return hr;
|
||||||
}
|
}
|
||||||
|
|
||||||
reg_close_folder(hfolder);
|
reg_close_folder(hfolder);
|
||||||
|
|
||||||
folder = HeapAlloc(GetProcessHeap(), 0, sizeof(*folder));
|
folder = heap_alloc(sizeof(*folder));
|
||||||
if (!folder)
|
if (!folder)
|
||||||
{
|
{
|
||||||
HeapFree(GetProcessHeap(), 0, folder_path);
|
heap_free(folder_path);
|
||||||
return E_OUTOFMEMORY;
|
return E_OUTOFMEMORY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ static ULONG WINAPI folders_Release(ITaskFolderCollection *iface)
|
|||||||
if (!ref)
|
if (!ref)
|
||||||
{
|
{
|
||||||
TRACE("destroying %p\n", iface);
|
TRACE("destroying %p\n", iface);
|
||||||
HeapFree(GetProcessHeap(), 0, folders);
|
heap_free(folders);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
@ -144,7 +144,7 @@ HRESULT TaskFolderCollection_create(const WCHAR *path, ITaskFolderCollection **o
|
|||||||
{
|
{
|
||||||
TaskFolderCollection *folders;
|
TaskFolderCollection *folders;
|
||||||
|
|
||||||
folders = HeapAlloc(GetProcessHeap(), 0, sizeof(*folders));
|
folders = heap_alloc(sizeof(*folders));
|
||||||
if (!folders) return E_OUTOFMEMORY;
|
if (!folders) return E_OUTOFMEMORY;
|
||||||
|
|
||||||
folders->ITaskFolderCollection_iface.lpVtbl = &TaskFolderCollection_vtbl;
|
folders->ITaskFolderCollection_iface.lpVtbl = &TaskFolderCollection_vtbl;
|
||||||
|
@ -59,7 +59,7 @@ static ULONG WINAPI TaskService_Release(ITaskService *iface)
|
|||||||
if (!ref)
|
if (!ref)
|
||||||
{
|
{
|
||||||
TRACE("destroying %p\n", iface);
|
TRACE("destroying %p\n", iface);
|
||||||
HeapFree(GetProcessHeap(), 0, task_svc);
|
heap_free(task_svc);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ref;
|
return ref;
|
||||||
@ -254,7 +254,7 @@ HRESULT TaskService_create(void **obj)
|
|||||||
{
|
{
|
||||||
TaskService *task_svc;
|
TaskService *task_svc;
|
||||||
|
|
||||||
task_svc = HeapAlloc(GetProcessHeap(), 0, sizeof(*task_svc));
|
task_svc = heap_alloc(sizeof(*task_svc));
|
||||||
if (!task_svc) return E_OUTOFMEMORY;
|
if (!task_svc) return E_OUTOFMEMORY;
|
||||||
|
|
||||||
task_svc->ITaskService_iface.lpVtbl = &TaskService_vtbl;
|
task_svc->ITaskService_iface.lpVtbl = &TaskService_vtbl;
|
||||||
|
@ -16,8 +16,37 @@
|
|||||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "wine/unicode.h"
|
||||||
|
|
||||||
HRESULT TaskService_create(void **obj) DECLSPEC_HIDDEN;
|
HRESULT TaskService_create(void **obj) DECLSPEC_HIDDEN;
|
||||||
HRESULT TaskFolder_create(const WCHAR *parent, const WCHAR *path, ITaskFolder **obj, BOOL create) 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;
|
HRESULT TaskFolderCollection_create(const WCHAR *path, ITaskFolderCollection **obj) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
const char *debugstr_variant(const VARIANT *v) 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;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user