qxl-wddm-dod/qxldod/BaseObject.cpp
Christophe Fergeau 4332d07c73 Change licence to Apache v2
A more permissive licence is more in line with what Microsoft requires
for its WHQL certification

Signed-off-by: Christophe Fergeau <cfergeau@redhat.com>
Acked-by: Frediano Ziglio <fziglio@redhat.com>
2016-11-04 11:18:09 +00:00

94 lines
1.9 KiB
C++
Executable File

/*
* Copyright 2013-2016 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
*
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*/
#include "BaseObject.h"
#pragma code_seg("PAGE")
#define QXLTAG 'LXQd'
//
// New and delete operators
//
_When_((PoolType & NonPagedPoolMustSucceed) != 0,
__drv_reportError("Must succeed pool allocations are forbidden. "
"Allocation failures cause a system crash"))
void* __cdecl operator new(size_t Size, POOL_TYPE PoolType)
{
PAGED_CODE();
Size = (Size != 0) ? Size : 1;
void* pObject = ExAllocatePoolWithTag(PoolType, Size, QXLTAG);
if (pObject != NULL)
{
#if DBG
RtlFillMemory(pObject, Size, 0xCD);
#else
RtlZeroMemory(pObject, Size);
#endif // DBG
}
return pObject;
}
_When_((PoolType & NonPagedPoolMustSucceed) != 0,
__drv_reportError("Must succeed pool allocations are forbidden. "
"Allocation failures cause a system crash"))
void* __cdecl operator new[](size_t Size, POOL_TYPE PoolType)
{
PAGED_CODE();
Size = (Size != 0) ? Size : 1;
void* pObject = ExAllocatePoolWithTag(PoolType, Size, QXLTAG);
if (pObject != NULL)
{
#if DBG
RtlFillMemory(pObject, Size, 0xCD);
#else
RtlZeroMemory(pObject, Size);
#endif // DBG
}
return pObject;
}
void __cdecl operator delete(void* pObject)
{
PAGED_CODE();
if (pObject != NULL)
{
ExFreePool(pObject);
}
}
void __cdecl operator delete[](void* pObject)
{
PAGED_CODE();
if (pObject != NULL)
{
ExFreePool(pObject);
}
}
void __cdecl operator delete(void *pObject, size_t s)
{
PAGED_CODE();
UNREFERENCED_PARAMETER(s);
if (pObject != NULL) {
ExFreePool(pObject);
}
}