hlink_private.h 1.9 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
/*
 * Copyright 2007 Jacek Caban for CodeWeavers
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#include <stdarg.h>

#define COBJMACROS

#include "winerror.h"
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "ole2.h"
#include "hlink.h"

30 31
#include "wine/unicode.h"

32 33
extern HRESULT HLink_Constructor(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
extern HRESULT HLinkBrowseContext_Constructor(IUnknown*,REFIID,void**) DECLSPEC_HIDDEN;
34

35
static inline void *heap_alloc(size_t len)
36 37 38 39
{
    return HeapAlloc(GetProcessHeap(), 0, len);
}

40
static inline void *heap_alloc_zero(size_t len)
41 42 43 44
{
    return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}

45
static inline BOOL heap_free(void *mem)
46 47 48 49 50 51 52 53 54 55 56 57
{
    return HeapFree(GetProcessHeap(), 0, mem);
}

static inline LPWSTR hlink_strdupW(LPCWSTR str)
{
    LPWSTR ret = NULL;

    if(str) {
        DWORD size;

        size = (strlenW(str)+1)*sizeof(WCHAR);
58
        ret = heap_alloc(size);
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
        memcpy(ret, str, size);
    }

    return ret;
}

static inline LPWSTR hlink_co_strdupW(LPCWSTR str)
{
    LPWSTR ret = NULL;

    if(str) {
        DWORD size;

        size = (strlenW(str)+1)*sizeof(WCHAR);
        ret = CoTaskMemAlloc(size);
        memcpy(ret, str, size);
    }

    return ret;
}