Browse Source

Kill hsMalloc to the best of our ability.

Darryl Pogue 13 years ago committed by Adam Johnson
parent
commit
63a9eea771
  1. 45
      Sources/Plasma/CoreLib/hsMalloc.h
  2. 27
      Sources/Plasma/CoreLibExe/hsExeMalloc.cpp
  3. 49
      Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp
  4. 4
      Sources/Plasma/NucleusLib/pnOraLib/pnOraLib.cpp
  5. 3
      Sources/Plasma/PubUtilLib/plJPEG/plJPEG.cpp

45
Sources/Plasma/CoreLib/hsMalloc.h

@ -62,36 +62,8 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
extern "C" {
#endif
void * MemDup (const void * ptr, unsigned bytes, unsigned flags, const char file[], int line);
unsigned MemSize (void * ptr);
/****************************************************************************
*
* Manipulation functions
*
***/
int MemCmp (const void * buf1, const void * buf2, unsigned bytes);
void MemCopy (void * dest, const void * source, unsigned bytes);
void MemMove (void * dest, const void * source, unsigned bytes);
/*****************************************************************************
*
* Debugging functions
*
***/
void MemDumpAllocReport ();
void MemDumpUsageReport ();
void MemValidateNow ();
void MemSetValidation (unsigned on);
void MemPushDisableTracking ();
void MemPopDisableTracking ();
void MemSetColor (unsigned short color);
#ifdef __cplusplus
}
#endif
@ -109,20 +81,3 @@ void MemSetColor (unsigned short color);
#define NEWZERO(t) new(calloc(sizeof(t), 1)) t
#endif // __cplusplus
/****************************************************************************
*
* TypeInfo
* (needed for memory leak reporting)
*
***/
#ifdef __cplusplus
#if !defined(HS_NO_TYPEINFO)
#include <typeinfo>
#endif
#endif // ifdef __cplusplus

27
Sources/Plasma/CoreLibExe/hsExeMalloc.cpp

@ -62,10 +62,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
# define MEM_DEBUG
#endif
const unsigned kMemReallocInPlaceOnly = 1<<0;
const unsigned kMemZero = 1<<1;
const unsigned kMemIgnoreBlock = 1<<2; // don't track this allocation
#ifndef MEM_DEBUG
# define _malloc_dbg(s, t, f, l) malloc(s)
@ -467,26 +463,3 @@ unsigned MemSize (void * ptr) {
#endif
return result;
}
//===========================================================================
int MemCmp (const void * buf1, const void * buf2, unsigned bytes) {
return memcmp(buf1, buf2, bytes);
}
//===========================================================================
void MemCopy (void * dest, const void * source, unsigned bytes) {
memcpy(dest, source, bytes);
}
//===========================================================================
void MemMove (void * dest, const void * source, unsigned bytes) {
memmove(dest, source, bytes);
}
//===========================================================================
void * MemDup (const void * ptr, unsigned bytes, unsigned flags, const char file[], int line) {
void * dst = malloc(bytes);
MemCopy(dst, ptr, bytes);
return dst;
}

49
Sources/Plasma/FeatureLib/pfConsole/pfConsoleCommands.cpp

@ -648,55 +648,6 @@ PF_CONSOLE_CMD(Stats, ProfileAllAgeLoads, "", "Turns on Registry.LogReadTimes an
#endif // LIMIT_CONSOLE_COMMANDS
//////////////////////////////////////////////////////////////////////////////
//// Memory Commands ////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
#ifndef LIMIT_CONSOLE_COMMANDS
PF_CONSOLE_GROUP( Memory )
#ifdef HS_FIND_MEM_LEAKS
PF_CONSOLE_CMD( Memory, DumpAllocReport, // Group name, Function name
"", // Params
"Dump heap allocations to file." ) // Help string
{
MemDumpAllocReport();
}
PF_CONSOLE_CMD(Memory,
ValidateNow,
"",
"Validate all heap allocations")
{
MemValidateNow();
}
PF_CONSOLE_CMD(Memory,
SetValidation,
"bool on",
"Validate all heap allocations each time memory is alloced or freed.")
{
MemSetValidation((bool)params[0]);
}
PF_CONSOLE_CMD(Memory,
DumpUsage,
"",
"Dump heap usage to file")
{
MemDumpUsageReport();
}
#endif
#endif // LIMIT_CONSOLE_COMMANDS
//////////////////////////////////////////////////////////////////////////////
//// Console Group Commands //////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

4
Sources/Plasma/NucleusLib/pnOraLib/pnOraLib.cpp

@ -181,16 +181,12 @@ void OraConnPool::Initialize_CS () {
const unsigned minConns = 0;
const unsigned incConns = max(1, maxConns - 1);
// Some memory allocated by createEnvironment is leaked,
// so we disable memory tracking while calling it.
MemPushDisableTracking();
oraEnv.occiEnv = occi::Environment::createEnvironment(
"OCCIUTF16",
"OCCIUTF16",
occi::Environment::THREADED_MUTEXED,
nil
);
MemPopDisableTracking();
// Create the connection pool
oraEnv.occiPool = oraEnv.occiEnv->createStatelessConnectionPool(

3
Sources/Plasma/PubUtilLib/plJPEG/plJPEG.cpp

@ -115,8 +115,6 @@ const char *plJPEG::GetLastError( void )
plMipmap *plJPEG::IRead( hsStream *inStream )
{
MemPushDisableTracking();
plMipmap *newMipmap = nil;
uint8_t *jpegSourceBuffer = nil;
uint32_t jpegSourceSize;
@ -229,7 +227,6 @@ plMipmap *plJPEG::IRead( hsStream *inStream )
// Clean up the JPEG Library
jpeg_destroy_decompress( &cinfo );
MemPopDisableTracking();
// All done!
return newMipmap;

Loading…
Cancel
Save