#include "defs.h"
#include <iostream>
#include <sstream>
#include <stdio.h>
#include "tMemManager.h"
#include "tError.h"
#include "tList.h"
Go to the source code of this file.
Classes | |
class | tMockMutex |
class | tBottleNeck |
struct | tAllocationInfo |
class | tMemMan |
class | tMemManager |
struct | chunkinfo |
class | memblock |
Defines | |
#define | NEW |
#define | SAFETYBYTES 0 |
#define | PAD 197 |
#define | MAX_SIZE 109 |
Functions | |
static wchar_t * | wmemset (wchar_t *wcs, wchar_t wc, size_t n) throw () |
void | leak () |
void | begin_checkleaks () |
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 l) THROW_BADALLOC |
void | operator delete (void *ptr, const char *classname, 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 l) THROW_BADALLOC |
void | operator delete[] (void *ptr, const char *classname, const char *file, int line) THROW_NOTHING |
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) |
char * | tStrDup (char const *s) |
Variables | |
static bool | reported = false |
static tMockMutex | st_mutex |
static bool | inited = false |
static tMemManager | memman [MAX_SIZE+1] |
#define MAX_SIZE 109 |
#define NEW |
Definition at line 67 of file tMemManager.cpp.
#define PAD 197 |
Definition at line 160 of file tMemManager.cpp.
Referenced by memblock::Check(), and memblock::memblock().
#define SAFETYBYTES 0 |
Definition at line 158 of file tMemManager.cpp.
Referenced by memblock::Check(), memblock::chunk(), memblock::create(), memblock::data(), memblock::Dispose(), memblock::memblock(), memblock::safety(), and tMemManager::tMemManager().
void begin_checkleaks | ( | ) |
void leak | ( | ) |
Definition at line 134 of file tMemManager.cpp.
References NULL, tMemManBase::Profile(), and reported.
00134 { 00135 if (!reported) 00136 { 00137 reported=true; 00138 #ifdef DEBUG 00139 #ifdef WIN32 00140 MessageBox (NULL, "Memory leak detected!" , "Memory Leak", MB_OK); 00141 #else 00142 std::cerr << "\n\nMemory leak detected!\n\n"; 00143 #endif 00144 #endif 00145 tMemManBase::Profile(); 00146 } 00147 }
void operator delete | ( | void * | ptr, | |
const char * | classname, | |||
const char * | file, | |||
int | line | |||
) |
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 | ) |
void operator delete[] | ( | void * | ptr, | |
const char * | classname, | |||
const char * | file, | |||
int | line | |||
) |
void operator delete[] | ( | void * | ptr | ) |
void* operator new | ( | size_t | size, | |
const char * | classn, | |||
const char * | file, | |||
int | l | |||
) |
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 | l | |||
) |
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 | |||
) |
void real_free | ( | void * | ptr | ) |
void* real_malloc | ( | size_t | size | ) |
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 | |||
) |
char* real_strdup | ( | char const * | ptr | ) |
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 ) );
char* tStrDup | ( | char const * | s | ) |
Definition at line 1561 of file tMemManager.cpp.
References real_strmove(), and strdup.
static wchar_t* wmemset | ( | wchar_t * | wcs, | |
wchar_t | wc, | |||
size_t | n | |||
) | throw () [inline, static] |
Definition at line 122 of file tMemManager.cpp.
Referenced by memblock::Alloc(), and memblock::Dispose().
00123 { 00124 // fill memory 00125 for( size_t i = 0; i < n; ++i ) 00126 { 00127 wcs[i] = wc; 00128 } 00129 00130 return wcs; 00131 }
bool inited = false [static] |
Definition at line 246 of file tMemManager.cpp.
Referenced by nConfItemVersionWatcher::OnVersionChange(), and uPlayerPrototype::uPlayerPrototype().
tMemManager memman[MAX_SIZE+1] [static] |
Definition at line 945 of file tMemManager.cpp.
bool reported = false [static] |
tMockMutex st_mutex [static] |
Definition at line 103 of file tMemManager.cpp.