50 lines
1.5 KiB
C++
50 lines
1.5 KiB
C++
//--------------------------------------------------------------------------------------------------
|
|
// qhMemory.cpp
|
|
//
|
|
// Copyright(C) 2011 by D. Gregorius. All rights reserved.
|
|
//--------------------------------------------------------------------------------------------------
|
|
#include "qhMemory.h"
|
|
#include "qhTypes.h"
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
// Local utilities
|
|
//--------------------------------------------------------------------------------------------------
|
|
static void* qhDefaultAlloc( size_t Bytes )
|
|
{
|
|
return malloc( Bytes );
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
static void qhDefaultFree( void* Address )
|
|
{
|
|
return free( Address );
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
// qhMemory
|
|
//--------------------------------------------------------------------------------------------------
|
|
void* (*qhAllocHook)( size_t ) = qhDefaultAlloc;
|
|
void (*qhFreeHook)( void* ) = qhDefaultFree;
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
void* qhAlloc( size_t Bytes )
|
|
{
|
|
QH_ASSERT( qhAllocHook != NULL );
|
|
return qhAllocHook( Bytes );
|
|
}
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
void qhFree( void* Address )
|
|
{
|
|
QH_ASSERT( qhFreeHook != NULL );
|
|
qhFreeHook( Address );
|
|
}
|
|
|