/* libzz
*
* This program is distributed under the GNU General Public License, version 2.
* A copy of this license is included with this source.
*
* Copyright 2000-2006, Toni Thomsson <toni@tonjac.org>
*/
#ifndef zz_base_h
#define zz_base_h
#include <zz_export.h>
#ifdef _DEBUG
#include <stddef.h>
#include <malloc.h>
#include <memory.h>
#include "zz_allocmap.h"
/**
List with all allocated CzzBase objects on the heap.
List is created if the program is DEBUG compiled otherwise
no list is created.
*/
extern CzzAllocMap theAllocMap;
#endif
/**
Base class with automatic memory leakage control.
Memory leakage control is only performed when the
program is DEBUG compiled. When release compilation
is done checks are removed.
@author Toni Thomsson, toni@tonjac.org
*/
class ZZ_API CzzBase
{
public:
/**
Default constructor
*/
CzzBase();
virtual ~CzzBase();
#ifdef _DEBUG
/**
Allocates an object on the heap and saved it's
address in theAllocMap (If DEBUG compiled).
@param n Size in bytes
*/
void* operator new( size_t n );
/**
Allocates an object on the heap and saved it's
address in theAllocMap (if DEBUG compiled).
@param n Size in bytes
*/
void* operator new[]( size_t n );
/**
Frees a allocated object and removes it from
theAllocMap (if DEBUG compiled)
@param p Pointer to object
@param n Size in bytes
*/
void operator delete( void* p, size_t n );
/**
Frees a allocated object and removes it from
theAllocMap (if DEBUG compiled)
@param p Pointer to object
@param n Size in bytes
*/
void operator delete[]( void* p, size_t n );
#endif // _DEBUG
};
#endif