fixed leak in string table
This commit is contained in:
parent
56e5f58cff
commit
cfd50e58f8
@ -13,7 +13,7 @@
|
|||||||
File: ZE_ZError.h <br>
|
File: ZE_ZError.h <br>
|
||||||
Description: Header file for ZEngine Error Object. <br>
|
Description: Header file for ZEngine Error Object. <br>
|
||||||
Author(s): James Turk <br>
|
Author(s): James Turk <br>
|
||||||
$Id: ZE_ZError.h,v 1.4 2003/01/16 05:46:39 cozman Exp $<br>
|
$Id: ZE_ZError.h,v 1.5 2003/01/26 00:55:52 cozman Exp $<br>
|
||||||
|
|
||||||
\file ZE_ZError.h
|
\file ZE_ZError.h
|
||||||
\brief Definition file for ZError.
|
\brief Definition file for ZError.
|
||||||
@ -66,7 +66,7 @@ class ZError
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
//! Static Array of Error Identifiers
|
//! Static Array of Error Identifiers
|
||||||
static string sErrorDesc[ZERR_LAST];
|
static string *sErrorDesc;
|
||||||
//! Error ID.
|
//! Error ID.
|
||||||
ZErrorCode rCode;
|
ZErrorCode rCode;
|
||||||
//! Error Description.
|
//! Error Description.
|
||||||
@ -77,6 +77,20 @@ class ZError
|
|||||||
unsigned int rLine;
|
unsigned int rLine;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
/*!
|
||||||
|
\brief Construct string table for error strings.
|
||||||
|
|
||||||
|
Constructs a string table for errors, enabling ZEngine to properly delete the table on exit.
|
||||||
|
**/
|
||||||
|
static void CreateStringTable();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Destroy string table of error strings.
|
||||||
|
|
||||||
|
Properly delete the string table, freeing all memory used by the strings.
|
||||||
|
**/
|
||||||
|
static void DestroyStringTable();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\brief Default constructor for ZError.
|
\brief Default constructor for ZError.
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
File: ZE_ZEngine.cpp <br>
|
File: ZE_ZEngine.cpp <br>
|
||||||
Description: Implementation source file for ZEngine library main singleton class. <br>
|
Description: Implementation source file for ZEngine library main singleton class. <br>
|
||||||
Author(s): James Turk <br>
|
Author(s): James Turk <br>
|
||||||
$Id: ZE_ZEngine.cpp,v 1.23 2003/01/25 19:55:13 cozman Exp $<br>
|
$Id: ZE_ZEngine.cpp,v 1.24 2003/01/26 00:55:52 cozman Exp $<br>
|
||||||
|
|
||||||
\file ZE_ZEngine.cpp
|
\file ZE_ZEngine.cpp
|
||||||
\brief Central source file for ZEngine.
|
\brief Central source file for ZEngine.
|
||||||
@ -56,6 +56,7 @@ ZEngine::ZEngine()
|
|||||||
mNextUpdate = mLastPause = mPausedTime = mLastTime = 0;
|
mNextUpdate = mLastPause = mPausedTime = mLastTime = 0;
|
||||||
mSecPerFrame = 0.0;
|
mSecPerFrame = 0.0;
|
||||||
|
|
||||||
|
ZError::CreateStringTable();
|
||||||
mLogAllErrors = true;
|
mLogAllErrors = true;
|
||||||
mErrlog = stderr;
|
mErrlog = stderr;
|
||||||
}
|
}
|
||||||
@ -72,6 +73,7 @@ void ZEngine::ReleaseInstance()
|
|||||||
{
|
{
|
||||||
if(sInstance)
|
if(sInstance)
|
||||||
{
|
{
|
||||||
|
ZError::DestroyStringTable();
|
||||||
sInstance->CloseDisplay();
|
sInstance->CloseDisplay();
|
||||||
delete sInstance;
|
delete sInstance;
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
File: ZE_ZError.cpp <br>
|
File: ZE_ZError.cpp <br>
|
||||||
Description: Implementation source file for core ZEngine Error Object. <br>
|
Description: Implementation source file for core ZEngine Error Object. <br>
|
||||||
Author(s): James Turk <br>
|
Author(s): James Turk <br>
|
||||||
$Id: ZE_ZError.cpp,v 1.2 2003/01/16 05:45:58 cozman Exp $<br>
|
$Id: ZE_ZError.cpp,v 1.3 2003/01/26 00:55:52 cozman Exp $<br>
|
||||||
|
|
||||||
\file ZE_ZError.cpp
|
\file ZE_ZError.cpp
|
||||||
\brief Source file for ZError.
|
\brief Source file for ZError.
|
||||||
@ -26,16 +26,39 @@ $Id: ZE_ZError.cpp,v 1.2 2003/01/16 05:45:58 cozman Exp $<br>
|
|||||||
namespace ZE
|
namespace ZE
|
||||||
{
|
{
|
||||||
|
|
||||||
string ZError::sErrorDesc[] =
|
string *ZError::sErrorDesc = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
void ZError::CreateStringTable()
|
||||||
{
|
{
|
||||||
"No Error. [%s]",
|
if(!sErrorDesc)
|
||||||
"SDL Error. [%s]",
|
{
|
||||||
"Error Initializing SDL: %s", "Error Initializing SDL_mixer: %s", "Error Initializing SDL_ttf: %s",
|
sErrorDesc = new string[ZERR_LAST];
|
||||||
"Error Creating Display: %s",
|
sErrorDesc[ZERR_NONE] = "No Error. [%s]";
|
||||||
"Failed to load Image: %s", "Failed to load Sound: %s", "Failed to load Music: %s", "Failed to load Font: %s",
|
sErrorDesc[ZERR_SDL_INTERNAL] = "SDL Error. [%s]";
|
||||||
"Called ZImage::%s with no Image loaded.", "Called ZSound::%s with no Sound loaded.",
|
sErrorDesc[ZERR_SDL_INIT] = "Error Initializing SDL: %s";
|
||||||
"Called ZMusic::%s with no Music loaded.", "Called ZFont::%s with no Font loaded."
|
sErrorDesc[ZERR_MIX_INIT] = "Error Initializing SDL_mixer: %s";
|
||||||
};
|
sErrorDesc[ZERR_TTF_INIT] = "Error Initializing SDL_ttf: %s";
|
||||||
|
sErrorDesc[ZERR_VIDMODE] = "Error Creating Display: %s";
|
||||||
|
sErrorDesc[ZERR_LOAD_IMAGE] = "Failed to load Image: %s";
|
||||||
|
sErrorDesc[ZERR_LOAD_SOUND] = "Failed to load Sound: %s";
|
||||||
|
sErrorDesc[ZERR_LOAD_MUSIC] = "Failed to load Music: %s";
|
||||||
|
sErrorDesc[ZERR_LOAD_FONT] = "Failed to load Font: %s";
|
||||||
|
sErrorDesc[ZERR_NOIMAGE] = "Called ZImage::%s with no Image loaded.";
|
||||||
|
sErrorDesc[ZERR_NOSOUND] = "Called ZSound::%s with no Sound loaded.";
|
||||||
|
sErrorDesc[ZERR_NOMUSIC] = "Called ZMusic::%s with no Music loaded.";
|
||||||
|
sErrorDesc[ZERR_NOFONT] = "Called ZFont::%s with no Font loaded.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ZError::DestroyStringTable()
|
||||||
|
{
|
||||||
|
if(sErrorDesc)
|
||||||
|
{
|
||||||
|
delete []sErrorDesc;
|
||||||
|
sErrorDesc = NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ZError::ZError(ZErrorCode code, string desc, string file, int line)
|
ZError::ZError(ZErrorCode code, string desc, string file, int line)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user