src/tools/tMemManager.h File Reference

#include "aa_config.h"
#include <new>
#include <stdlib.h>
#include <ios>

Include dependency graph for tMemManager.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  tMemManBase

Defines

#define THROW_BADALLOC   throw (std::bad_alloc)
#define THROW_NOTHING   throw ()
#define malloc(SIZE)   static_cast<void *>(tNEW(char)[SIZE])
#define calloc(ELEMCOUNT, ELEMSIZE)   static_cast<void *>(tNEW(char)[(ELEMCOUNT)*(ELEMSIZE)])
#define free(BASEADR)   delete[] (reinterpret_cast< char* >(BASEADR))
#define realloc(BASEADR, NEWSIZE)   realloc not defined
#define strdup(ADR)   tStrDup(ADR)
#define tNEW(x)   new(#x,__FILE__,__LINE__) x
#define tMEMMANAGER(classname)   public:void *operator new(size_t s){return tMemMan::Alloc(s); } void operator delete(void *p){ if (p) tMemMan::Dispose(p); }

Functions

char * tStrDup (char const *s)
void * real_calloc (size_t nmemb, size_t size)
void * real_malloc (size_t size)
void real_free (void *ptr)
void * real_realloc (void *ptr, size_t size)
char * real_strdup (char const *ptr)
void * real_mmove (void *ptr, size_t size)
char * real_strmove (char *ptr)
void *_cdecl operator new (size_t size) THROW_BADALLOC
void _cdecl operator delete (void *ptr) THROW_NOTHING
void operator delete (void *ptr, bool keep) THROW_NOTHING
void * operator new (size_t size, const char *classn, const char *file, int line) THROW_BADALLOC
void operator delete (void *ptr, const char *classn, const char *file, int line) THROW_NOTHING
void * operator new[] (size_t size) THROW_BADALLOC
void operator delete[] (void *ptr) THROW_NOTHING
void * operator new[] (size_t size, const char *classn, const char *file, int line) THROW_BADALLOC
void operator delete[] (void *ptr, const char *classname, const char *file, int line) THROW_NOTHING
void * operator new (size_t cb, int nBlockUse, const char *szFileName, int nLine)
void operator delete (void *ptr, int nBlockUse, const char *szFileName, int nLine)


Define Documentation

#define calloc ( ELEMCOUNT,
ELEMSIZE   )     static_cast<void *>(tNEW(char)[(ELEMCOUNT)*(ELEMSIZE)])

Definition at line 85 of file tMemManager.h.

Referenced by br_strndup().

#define free ( BASEADR   )     delete[] (reinterpret_cast< char* >(BASEADR))

Definition at line 86 of file tMemManager.h.

Referenced by tMemStackItem::Alloc(), tCommandLineData::Analyse(), closedir(), GrowingArrayBase::Delete(), memblock::destroy(), memblock::Dispose(), eh_getdir(), expand_home(), tPath::GetWritePath(), tPathResource::GetWritePath(), tResourceManager::locateResource(), myFetch(), myHTTPFetch(), opendir(), gParser::parseAxes(), GrowingArrayBase::ResizeBase(), SDL_SavePNG(), SWIG_Ruby_define_class(), SWIG_Ruby_NewPointerObj(), eWavData::Unload(), gAutoStringArray::~gAutoStringArray(), and tMemStackItem::~tMemStackItem().

#define malloc ( SIZE   )     static_cast<void *>(tNEW(char)[SIZE])

Definition at line 84 of file tMemManager.h.

Referenced by tMemStackItem::Alloc(), tMemMan::Alloc(), tMemManager::AllocDefault(), memblock::create(), eh_getdir(), GrowingArrayBase::GrowingArrayBase(), eWavData::Load(), tResourceManager::locateResource(), main(), myFetch(), myHTTPFetch(), opendir(), gParser::parseAxes(), GrowingArrayBase::ResizeBase(), SDL_SavePNG(), SWIG_Ruby_define_class(), and SWIG_Ruby_NewPointerObj().

#define realloc ( BASEADR,
NEWSIZE   )     realloc not defined

Definition at line 87 of file tMemManager.h.

#define strdup ( ADR   )     tStrDup(ADR)

Definition at line 90 of file tMemManager.h.

Referenced by br_strndup(), eh_getdir(), tPath::GetWritePath(), tPathResource::GetWritePath(), gAutoStringArray::Store(), and tStrDup().

#define THROW_BADALLOC   throw (std::bad_alloc)

Definition at line 71 of file tMemManager.h.

#define THROW_NOTHING   throw ()

Definition at line 72 of file tMemManager.h.

#define tMEMMANAGER ( classname   )     public:void *operator new(size_t s){return tMemMan::Alloc(s); } void operator delete(void *p){ if (p) tMemMan::Dispose(p); }

Definition at line 132 of file tMemManager.h.

#define tNEW ( x   )     new(#x,__FILE__,__LINE__) x

Definition at line 130 of file tMemManager.h.

Referenced by nServerInfoBase::AccessAddress(), gCycleMovement::AddDestination(), tOutput::AddLiteral(), tOutput::AddLocale(), tOutput::AddSpace(), AITeam(), gAITeam::BalanceWithAIs(), nNetObject::ClearAll(), tOutputItem< T >::Clone(), tOutputItemTemplate::Clone(), tOutputItemSpace::Clone(), tOutputItemLocale::Clone(), tConfItemBase::ConfItemMap(), gCycleMovement::CopyFrom(), eGrid::Create(), gNetPlayerWall::CreateEdge(), CreateGServer(), eVoteItem::CreateMessage(), eVoteItem::CreateMessageLegacy(), ePlayerNetID::CreateNewTeam(), tCrypt::CreatePrivateEncrypt(), tCrypt::CreatePublicEncrypt(), CreateServerInfo(), tCrypt::CreateSymmetricCrypt(), gLogo::Display(), eVoteItemKickServerControlled::DoCheckValid(), eVoteItemHarm::DoCheckValid(), nBandwidthTaskCreate::DoExecute(), nBandwidthTaskSync::DoExecute(), eGrid::DrawLine(), gParser::DrawRim(), gAIPlayer::EmergencySurvive(), eTeam::Enforce(), gMenuItemPlayer::Enter(), ePlayer::ePlayer(), eTempEdge::eTempEdge(), tLocaleItem::Find(), tLanguage::Find(), FinishHandlePasswordRequest(), gFriends::FriendsMenu(), gCustomConnectEntries::Generate(), nServerInfo::GetFromLAN(), nServerInfo::GetFromLANContinuously(), nServerInfo::GetFromMaster(), gCycleMovement::GetMaxSpaceAhead(), nNetObject::GetObserver(), GetQueryMessageStats(), eFace::GetReplacementStorage(), eVoter::GetVoter(), gFriends::gFriends(), nServerInfo::GiveBigServerInfoCommon(), nServerInfo::GiveSmallServerInfo(), eGrid::Grow(), GrowingArrayBase::GrowingArrayBase(), gServerFavoriteMenuEntries::gServerFavoriteMenuEntries(), gServerMenu::gServerMenu(), eVoter::HandleChat(), gGame::Init(), eMusicTrack::Init(), ePlayer::Init(), eHalfEdge::IntersectWith(), eVoter::KickMenu(), gCycle::Kill(), tLocaleItem::Load(), gCycleVisuals::LoadModelSafe(), gCycleVisuals::LoadTextureSafe(), gCycleVisuals::LoadTextureSafe2(), eWavData::Loop(), MainMenu(), gCycle::MyInitAfterCreation(), nServerInfo::NetReadThis(), uBindPlayer::NewBind(), gArena::NewSpawnPoint(), tTextFileRecorder::Open(), operator<<(), own_game(), gParser::parseZoneArthemis_v1(), gNetPlayerWall::PartialCopyIntoGrid(), nServerInfo::QueryServer(), gCycle::ReadSync(), rec_peer(), gCycleMemory::Remember(), nServerLag::Report(), gCycle::ResetExtrapolator(), GrowingArrayBase::ResizeBase(), nServerInfo::RunMaster(), s_InputConfigGeneric(), se_HandleKickVote(), se_HandleNewServerVote(), se_MakeGameTimer(), se_NewChatMessage(), se_ServerControlledChatMessageConsole(), eVoteItemServerControlled::SendChanged(), gAIPlayer::SetNumberOfAIs(), tOutput::SetTemplateParameter(), sg_CreateWinDeathZone(), sg_EditServers(), sg_GenerateConnectionItems(), sg_GetSensor(), sg_HostGame(), ePlayerNetID::SilenceMenu(), sn_GetStrongWatchers(), gPlayerWall::Split(), gWallRim::Split(), eWall::Split(), eHalfEdge::Split(), sr_glRendererInit(), gTeam::TeamMenu(), nServerInfo::TellMasterAboutMe(), gCycle::Timestep(), tOutput::tOutput(), gServerMenu::Update(), ePlayerNetID::Update(), eVoteItem::Vote(), and eVoter::VotingMenu().


Function Documentation

void operator delete ( void *  ptr,
int  nBlockUse,
const char *  szFileName,
int  nLine 
)

void operator delete ( void *  ptr,
const char *  classn,
const char *  file,
int  line 
)

Definition at line 1327 of file tMemManager.cpp.

01330                                                                                                   {
01331     tAllocationInfo info( false );

void operator delete ( void *  ptr,
bool  keep 
)

Definition at line 1279 of file tMemManager.cpp.

01282                                                         {
01283     tAllocationInfo info( false );
01284 
01285     if (ptr){
01286         if (keep)
01287             tMemMan::DisposeButKeep(info, ptr);
01288         else
01289             tMemMan::Dispose(info, ptr);

void _cdecl operator delete ( void *  ptr  ) 

Definition at line 1272 of file tMemManager.cpp.

01275                                                      {
01276     tAllocationInfo info( false );
01277 

void operator delete[] ( void *  ptr,
const char *  classname,
const char *  file,
int  line 
)

Definition at line 1386 of file tMemManager.cpp.

01389                                                                                                      {
01390     tAllocationInfo info( true );

void operator delete[] ( void *  ptr  ) 

Definition at line 1343 of file tMemManager.cpp.

01346                                                  {
01347     tAllocationInfo info( true );
01348 

void* operator new ( size_t  cb,
int  nBlockUse,
const char *  szFileName,
int  nLine 
)

void* operator new ( size_t  size,
const char *  classn,
const char *  file,
int  line 
)

Definition at line 1293 of file tMemManager.cpp.

01296                                                                                               {
01297     tAllocationInfo info( false );
01298 #ifdef LEAKFINDER
01299     info.filename=file;
01300     info.classname=classn;
01301     info.line=l;
01302 
01303     info.checksum =
01304 #ifndef PROFILER 
01305         size +
01306 #endif 
01307         info.line * 19671;
01308 
01309     int c=1379;
01310     while (*file){
01311         info.checksum = (info.checksum + (*file)*c) % MAXCHECKSUM;
01312         c             = (c * 79              ) % MAXCHECKSUM;
01313         file++;
01314     }
01315     while (*classn){
01316         info.checksum = (info.checksum + (*classn)*c) % MAXCHECKSUM;
01317         c             = (c * 79                ) % MAXCHECKSUM;
01318         classn++;
01319     }
01320 
01321 #ifdef PROFILER
01322     while (checksum_filename[info.checksum] && (checksum_filename[info.checksum] != info.filename || checksum_line[info.checksum] != info.line))
01323     info.checksum = (info.checksum+1) % MAXCHECKSUM;
01324 #endif
01325 

void* _cdecl operator new ( size_t  size  ) 

Definition at line 1261 of file tMemManager.cpp.

01264                                                             {
01265     tAllocationInfo info( false );
01266 
01267 #ifdef LEAKFINDER
01268 #ifndef HAVE_LIBZTHREAD
01269     info.checksum = size;
01270 #endif

void* operator new[] ( size_t  size,
const char *  classn,
const char *  file,
int  line 
)

Definition at line 1352 of file tMemManager.cpp.

01355                                                                                                {
01356     tAllocationInfo info( true );
01357 #ifdef LEAKFINDER
01358     info.filename=file;
01359     info.classname=classn;
01360     info.line=l;
01361 
01362     info.checksum =
01363 #ifndef PROFILER 
01364     size +
01365 #endif 
01366     info.line * 19671;
01367     
01368     int c=1379;
01369     while (*file){
01370         info.checksum = (info.checksum + (*file)*c) % MAXCHECKSUM;
01371         c             = (c * 79              ) % MAXCHECKSUM;
01372         file++;
01373     }
01374     while (*classn){
01375         info.checksum = (info.checksum + (*classn)*c) % MAXCHECKSUM;
01376         c             = (c * 79                ) % MAXCHECKSUM;
01377         classn++;
01378     }
01379     
01380 #ifdef PROFILER
01381     while (checksum_filename[info.checksum] && (checksum_filename[info.checksum] != info.filename || checksum_line[info.checksum] != info.line))
01382     info.checksum = (info.checksum+1) % MAXCHECKSUM;
01383 #endif
01384 

void* operator new[] ( size_t  size  ) 

Definition at line 1333 of file tMemManager.cpp.

01336                                                     {
01337     tAllocationInfo info( true );
01338 #ifdef LEAKFINDER
01339 #ifndef HAVE_LIBZTHREAD
01340     info.checksum = size % MAXCHECKSUM;
01341 #endif

void* real_calloc ( size_t  nmemb,
size_t  size 
)

Definition at line 1516 of file tMemManager.cpp.

01520 {

void real_free ( void *  ptr  ) 

Definition at line 1526 of file tMemManager.cpp.

01530 {

void* real_malloc ( size_t  size  ) 

Definition at line 1521 of file tMemManager.cpp.

01525 {

void* real_mmove ( void *  ptr,
size_t  size 
)

Definition at line 1541 of file tMemManager.cpp.

01545 {
01546     // create new memory, copy, free old memory
01547     void * ret = tNEW(char)[size];
01548     memcpy( ret, ptr, size );
01549     real_free( ptr );

void* real_realloc ( void *  ptr,
size_t  size 
)

Definition at line 1531 of file tMemManager.cpp.

01535 {

char* real_strdup ( char const *  ptr  ) 

Definition at line 1536 of file tMemManager.cpp.

01540 {

char* real_strmove ( char *  ptr  ) 

Definition at line 1551 of file tMemManager.cpp.

Referenced by tStrDup().

01555 {
01556     if ( ptr )
01557         return static_cast< char * >( real_mmove( ptr, strlen( ptr ) + 1 ) );

Here is the caller graph for this function:

char* tStrDup ( char const *  s  ) 

Definition at line 1561 of file tMemManager.cpp.

References real_strmove(), and strdup.

01565 {

Here is the call graph for this function:


Generated on Sat Mar 15 23:12:08 2008 for Armagetron Advanced by  doxygen 1.5.4