****************************************************************************************************
*/
VOID* Object::ClientAlloc(
- size_t objSize, ///< [in] Size to allocate
+ size_t objSize, ///< [in] Size to allocate
const Client* pClient) ///< [in] Client pointer
{
VOID* pObjMem = NULL;
****************************************************************************************************
*/
VOID* Object::Alloc(
- size_t objSize) const ///< [in] Size to allocate
+ size_t objSize ///< [in] Size to allocate
+ ) const
{
return ClientAlloc(objSize, &m_client);
}
****************************************************************************************************
*/
VOID Object::ClientFree(
- VOID* pObjMem, ///< [in] User virtual address to free.
+ VOID* pObjMem, ///< [in] User virtual address to free.
const Client* pClient) ///< [in] Client pointer
{
if (pClient->callbacks.freeSysMem != NULL)
****************************************************************************************************
*/
VOID Object::Free(
- VOID* pObjMem) const ///< [in] User virtual address to free.
+ VOID* pObjMem ///< [in] User virtual address to free.
+ ) const
{
ClientFree(pObjMem, &m_client);
}
* Object::operator new
*
* @brief
-* Allocates memory needed for Object object. (with ADDR_CLIENT_HANDLE)
+* Placement new operator. (with pre-allocated memory pointer)
*
* @return
-* Returns NULL if unsuccessful.
+* Returns pre-allocated memory pointer.
****************************************************************************************************
*/
VOID* Object::operator new(
- size_t objSize, ///< [in] Size to allocate
- const Client* pClient) ///< [in] Client pointer
-{
- return ClientAlloc(objSize, pClient);
-}
-
-
-/**
-****************************************************************************************************
-* Object::operator delete
-*
-* @brief
-* Frees Object object memory.
-****************************************************************************************************
-*/
-VOID Object::operator delete(
- VOID* pObjMem, ///< [in] User virtual address to free.
- const Client* pClient) ///< [in] Client handle
+ size_t objSize, ///< [in] Size to allocate
+ VOID* pMem) ///< [in] Pre-allocated pointer
{
- ClientFree(pObjMem, pClient);
+ return pMem;
}
/**
****************************************************************************************************
*/
VOID Object::operator delete(
- VOID* pObjMem) ///< [in] User virtual address to free.
+ VOID* pObjMem) ///< [in] User virtual address to free.
{
Object* pObj = static_cast<Object*>(pObjMem);
ClientFree(pObjMem, &pObj->m_client);
*/
VOID Object::DebugPrint(
const CHAR* pDebugString, ///< [in] Debug string
- ...) const
+ ...
+ ) const
{
#if DEBUG
if (m_client.callbacks.debugPrint != NULL)
Object(const Client* pClient);
virtual ~Object();
- VOID* operator new(size_t size, const Client* pClient);
- VOID operator delete(VOID* pObj, const Client* pClient);
+ VOID* operator new(size_t size, VOID* pMem);
VOID operator delete(VOID* pObj);
+ /// Microsoft compiler requires a matching delete implementation, which seems to be called when
+ /// bad_alloc is thrown. But currently C++ exception isn't allowed so a dummy implementation is
+ /// added to eliminate the warning.
+ VOID operator delete(VOID* pObj, VOID* pMem) { ADDR_ASSERT_ALWAYS(); }
+
VOID* Alloc(size_t size) const;
VOID Free(VOID* pObj) const;
- VOID DebugPrint(
- const CHAR* pDebugString,
- ...) const;
+ VOID DebugPrint(const CHAR* pDebugString, ...) const;
const Client* GetClient() const {return &m_client;}
protected:
Client m_client;
-private:
static VOID* ClientAlloc(size_t size, const Client* pClient);
static VOID ClientFree(VOID* pObj, const Client* pClient);
+private:
// disallow the copy constructor
Object(const Object& a);