You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
1.5 KiB
49 lines
1.5 KiB
//--------------------------------------------------------------------------------------------------
|
|
// 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 );
|
|
}
|
|
|