// ************************************************************************************************************
// Author: Marcin Załęczny
// Release Date: 2010-11-10
// Licence: The GNU Lesser General Public License, version 3.0 (LGPLv3)
// ************************************************************************************************************
#include "mzstdxpsblanketsCommon.h"

#ifdef MZSTDXPSBLANKETS_DLL
#ifdef MZSTDXPSBLANKETS_INTERNAL
// Memory management functions we are compiling only if dll library is to be build
VOID* __cdecl operator new(size_t size) {
    HANDLE heap = GetProcessHeap();
    if (!heap) {
        return NULL;
    }
    VOID* pv = HeapAlloc(heap, 0, size);
    if (!pv) {
        return NULL;
    }
    return pv;
}

VOID* __cdecl operator new(size_t size, CHAR ch) {
    HANDLE heap = GetProcessHeap();
    if (!heap) {
        return NULL;
    }
    VOID* pv = HeapAlloc(heap, 0, size);
    if (!pv) {
        return NULL;
    }
    memset(pv, ch, size);
    return pv;
}

VOID* __cdecl operator new[](size_t size) {
    HANDLE heap = GetProcessHeap();
    if (!heap) {
        return NULL;
    }
    VOID* pv = HeapAlloc(heap, 0, size);
    if (!pv) {
        return NULL;
    }
    return pv;
}

VOID  __cdecl operator delete(VOID* p) {
    HANDLE heap = GetProcessHeap();
    if (!heap) return;
    HeapFree(heap, 0, p);
}

VOID  __cdecl operator delete[](VOID* p) {
    HANDLE heap = GetProcessHeap();
    if (!heap) return;
    HeapFree(heap, 0, p);
}
#endif // MZSTDXPSBLANKETS_DLL
#endif // MZSTDXPSBLANKETS_INTERNAL
