[Common] some scope and spacing formatting clean-ups
Miserably hated doing this commit. Couldn't tell which code was whose, which was copyrighted, which was foreign enough to Project64 that I'd probably best just leave-as is, which was even worth considering part of Project64, which cleanups to omit doing and ignore because some ugly practices were rampant throughout the entire file and distracted from the purpose of this pull request too much. So tried to stick to mostly just the braces/indentation changes here.
This commit is contained in:
parent
fe868a85d5
commit
ae04d23d86
|
@ -28,13 +28,15 @@ void CIniFileBase::fInsertSpaces ( int Pos, int NoOfSpaces )
|
|||
m_File.Seek(0,CFileBase::end);
|
||||
end = m_File.GetPosition();
|
||||
|
||||
if (NoOfSpaces > 0) {
|
||||
if (NoOfSpaces > 0)
|
||||
{
|
||||
stdstr_f SpaceBuffer(_T("%*c"),NoOfSpaces,' ');
|
||||
|
||||
do {
|
||||
SizeToRead = end - Pos;
|
||||
if (SizeToRead > fIS_MvSize) { SizeToRead = fIS_MvSize; }
|
||||
if (SizeToRead > 0) {
|
||||
if (SizeToRead > 0)
|
||||
{
|
||||
m_File.Seek(SizeToRead * -1,CFileBase::current);
|
||||
WritePos = m_File.GetPosition();
|
||||
memset(Data,0,sizeof(Data));
|
||||
|
@ -47,9 +49,12 @@ void CIniFileBase::fInsertSpaces ( int Pos, int NoOfSpaces )
|
|||
m_File.Seek(WritePos,CFileBase::begin);
|
||||
}
|
||||
} while (SizeToRead > 0);
|
||||
} if (NoOfSpaces < 0) {
|
||||
}
|
||||
if (NoOfSpaces < 0)
|
||||
{
|
||||
int ReadPos = Pos + (NoOfSpaces * -1);
|
||||
int WritePos = Pos;
|
||||
|
||||
do {
|
||||
SizeToRead = end - ReadPos;
|
||||
if (SizeToRead > fIS_MvSize) { SizeToRead = fIS_MvSize; }
|
||||
|
@ -60,6 +65,7 @@ void CIniFileBase::fInsertSpaces ( int Pos, int NoOfSpaces )
|
|||
ReadPos += SizeToRead;
|
||||
WritePos += SizeToRead;
|
||||
} while (SizeToRead > 0);
|
||||
|
||||
m_File.Seek(WritePos,CFileBase::begin);
|
||||
stdstr_f SpaceBuffer(_T("%*c"),(NoOfSpaces * -1),' ');
|
||||
m_File.Write(SpaceBuffer.c_str(),(ULONG)SpaceBuffer.length());
|
||||
|
@ -81,10 +87,12 @@ int CIniFileBase::GetStringFromFile ( char * & String, char * &Data, int & MaxDa
|
|||
DataSize = m_File.Read(&Data[DataSize],MaxDataSize);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
for (;;)
|
||||
{
|
||||
int count;
|
||||
|
||||
for (count = ReadPos; count < DataSize; count ++) {
|
||||
for (count = ReadPos; count < DataSize; count ++)
|
||||
{
|
||||
if (Data[count] == '\n')
|
||||
{
|
||||
int len = (count - ReadPos) + 1;
|
||||
|
@ -103,7 +111,9 @@ int CIniFileBase::GetStringFromFile ( char * & String, char * &Data, int & MaxDa
|
|||
}
|
||||
DataSize -= ReadPos;
|
||||
ReadPos = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//Increase buffer size
|
||||
int NewMaxDataSize = MaxDataSize + BufferIncrease;
|
||||
char * NewBuffer = new char[NewMaxDataSize];
|
||||
|
@ -159,13 +169,17 @@ void CIniFileBase::SaveCurrentSection ( void )
|
|||
if (m_File.GetLength() < (int)strlen(m_LineFeed))
|
||||
{
|
||||
sprintf(SectionName.get(),"[%s]%s",m_CurrentSection.c_str(),m_LineFeed);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
sprintf(SectionName.get(),"%s[%s]%s",m_LineFeed,m_CurrentSection.c_str(),m_LineFeed);
|
||||
}
|
||||
m_File.Write(SectionName.get(),(int)strlen(SectionName.get()));
|
||||
m_CurrentSectionFilePos = m_File.GetPosition();
|
||||
m_SectionsPos.insert(FILELOC::value_type(m_CurrentSection,m_CurrentSectionFilePos));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
//increase/decrease space needed
|
||||
int NeededBufferLen = 0;
|
||||
{
|
||||
|
@ -197,8 +211,7 @@ void CIniFileBase::SaveCurrentSection ( void )
|
|||
do {
|
||||
result = GetStringFromFile(Input,Data,MaxDataSize,DataSize,ReadPos);
|
||||
if (result <= 1) { continue; }
|
||||
if (strlen(CleanLine(Input)) <= 1 ||
|
||||
Input[0] != '[')
|
||||
if (strlen(CleanLine(Input)) <= 1 || Input[0] != '[')
|
||||
{
|
||||
EndPos = ((m_File.GetPosition() - DataSize) + ReadPos);
|
||||
|
||||
|
@ -270,7 +283,9 @@ bool CIniFileBase::MoveToSectionNameData ( LPCSTR lpSectionName, bool ChangeCurr
|
|||
}
|
||||
m_File.Seek(iter->second,CFileBase::begin);
|
||||
bFoundSection = true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_File.Seek(m_lastSectionSearch, CFileBase::begin);
|
||||
|
||||
//long Fpos;
|
||||
|
@ -287,7 +302,7 @@ bool CIniFileBase::MoveToSectionNameData ( LPCSTR lpSectionName, bool ChangeCurr
|
|||
//We Only care about sections
|
||||
char * CurrentSection = Input;
|
||||
|
||||
if(m_lastSectionSearch == 0 && !memcmp(CurrentSection, pUTF8, 3))
|
||||
if (m_lastSectionSearch == 0 && !memcmp(CurrentSection, pUTF8, 3))
|
||||
{
|
||||
CurrentSection += 3;
|
||||
}
|
||||
|
@ -301,14 +316,18 @@ bool CIniFileBase::MoveToSectionNameData ( LPCSTR lpSectionName, bool ChangeCurr
|
|||
m_lastSectionSearch = (m_File.GetPosition() - DataSize) + ReadPos;
|
||||
m_SectionsPos.insert(FILELOC::value_type(CurrentSection,m_lastSectionSearch));
|
||||
|
||||
if (_stricmp(lpSectionName,CurrentSection) != 0) {
|
||||
if (_stricmp(lpSectionName,CurrentSection) != 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ChangeCurrentSection)
|
||||
{
|
||||
m_CurrentSection = lpSectionName;
|
||||
m_CurrentSectionFilePos = m_lastSectionSearch;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_File.Seek(m_lastSectionSearch,CFileBase::begin);
|
||||
}
|
||||
bFoundSection = true;
|
||||
|
@ -329,7 +348,7 @@ bool CIniFileBase::MoveToSectionNameData ( LPCSTR lpSectionName, bool ChangeCurr
|
|||
char * Value = &Pos[1];
|
||||
|
||||
char * Pos1 = Pos-1;
|
||||
while(((*Pos1 == ' ') || (*Pos1 == '\t')) && (Pos1 > Input))
|
||||
while (((*Pos1 == ' ') || (*Pos1 == '\t')) && (Pos1 > Input))
|
||||
{
|
||||
Pos1--;
|
||||
}
|
||||
|
@ -348,38 +367,39 @@ const char * CIniFileBase::CleanLine ( char * const Line )
|
|||
char * Pos = Line;
|
||||
|
||||
//Remove any comment from the line
|
||||
while (Pos != NULL)
|
||||
while (Pos != NULL)
|
||||
{
|
||||
Pos = strchr(Pos,'/');
|
||||
if (Pos != NULL)
|
||||
if (Pos != NULL)
|
||||
{
|
||||
if (Pos[1] == '/')
|
||||
if (Pos[1] == '/')
|
||||
{
|
||||
if(Pos > Line)
|
||||
if (Pos > Line)
|
||||
{
|
||||
char * Pos_1 = Pos-1;
|
||||
|
||||
if(Pos_1[0] != ':')
|
||||
if (Pos_1[0] != ':')
|
||||
{
|
||||
Pos[0] = 0;
|
||||
Pos[0] = 0;
|
||||
}
|
||||
else
|
||||
Pos += 1;
|
||||
Pos += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos[0] = 0;
|
||||
Pos[0] = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Pos += 1;
|
||||
Pos += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//strip any spaces or line feeds from the end of the line
|
||||
for (int count = (int)strlen(&Line[0]) - 1; count >= 0; count --) {
|
||||
for (int count = (int)strlen(&Line[0]) - 1; count >= 0; count --)
|
||||
{
|
||||
if (Line[count] != ' ' && Line[count] != '\r') { break; }
|
||||
Line[count] = 0;
|
||||
}
|
||||
|
@ -421,13 +441,12 @@ void CIniFileBase::OpenIniFile(bool bCreate)
|
|||
|
||||
bool CIniFileBase::IsEmpty()
|
||||
{
|
||||
if(m_File.GetLength()==0)
|
||||
if (m_File.GetLength() == 0)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CIniFileBase::IsFileOpen ( void )
|
||||
bool CIniFileBase::IsFileOpen ( void )
|
||||
{
|
||||
return m_File.IsOpen();
|
||||
}
|
||||
|
@ -535,7 +554,9 @@ bool CIniFileBase::GetString ( LPCWSTR lpSectionName, LPCWSTR lpKeyName, LPCWSTR
|
|||
if (lpSectionName == NULL || wcslen(lpSectionName) == 0)
|
||||
{
|
||||
strSection = "default";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
stdstr::fromTString(lpSectionName,strSection);
|
||||
}
|
||||
|
||||
|
@ -570,7 +591,9 @@ ULONG CIniFileBase::GetString ( LPCTSTR lpSectionName, LPCTSTR lpKeyName, LPCT
|
|||
if (lpSectionName == NULL || _tcslen(lpSectionName) == 0)
|
||||
{
|
||||
strSection = "default";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
strSection = lpSectionName;
|
||||
}
|
||||
|
||||
|
@ -605,7 +628,9 @@ bool CIniFileBase::GetNumber ( LPCWSTR lpSectionName, LPCWSTR lpKeyName, ULONG n
|
|||
{
|
||||
stdstr::fromTString(lpSectionName,strSection);
|
||||
return GetNumber(strSection.c_str(),lpKeyName.c_str(),nDefault,Value);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return GetNumber(NULL,lpKeyName.c_str(),nDefault,Value);
|
||||
}
|
||||
}
|
||||
|
@ -660,7 +685,9 @@ void CIniFileBase::SaveString ( LPCTSTR lpSectionName, LPCTSTR lpKeyName, LPCTS
|
|||
if (lpSectionName == NULL || _tcslen(lpSectionName) == 0)
|
||||
{
|
||||
strSection = "default";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
strSection = lpSectionName;
|
||||
}
|
||||
|
||||
|
@ -681,12 +708,16 @@ void CIniFileBase::SaveString ( LPCTSTR lpSectionName, LPCTSTR lpKeyName, LPCTS
|
|||
iter->second = lpString;
|
||||
m_CurrentSectionDirty = true;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
m_CurrentSectionData.erase(iter);
|
||||
m_CurrentSectionDirty = true;
|
||||
}
|
||||
} else {
|
||||
if (lpString)
|
||||
}
|
||||
else
|
||||
{
|
||||
if (lpString)
|
||||
{
|
||||
m_CurrentSectionData.insert(KeyValueList::value_type(lpKeyName,lpString));
|
||||
m_CurrentSectionDirty = true;
|
||||
|
@ -744,20 +775,22 @@ void CIniFileBase::GetKeyList ( LPCTSTR lpSectionName, strlist &List )
|
|||
}
|
||||
}
|
||||
|
||||
void CIniFileBase::GetKeyValueData ( LPCTSTR lpSectionName, KeyValueData & List )
|
||||
void CIniFileBase::GetKeyValueData ( LPCTSTR lpSectionName, KeyValueData & List )
|
||||
{
|
||||
CGuard Guard(m_CS);
|
||||
if (!m_File.IsOpen())
|
||||
{
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
std::string strSection;
|
||||
std::string strSection;
|
||||
|
||||
if (lpSectionName == NULL || _tcslen(lpSectionName) == 0)
|
||||
{
|
||||
strSection = "default";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
strSection = lpSectionName;
|
||||
}
|
||||
|
||||
|
@ -779,13 +812,15 @@ void CIniFileBase::GetKeyValueData ( LPCTSTR lpSectionName, KeyValueData & List
|
|||
if (Data) { delete [] Data; Data = NULL; }
|
||||
}
|
||||
|
||||
void CIniFileBase::ClearSectionPosList( long FilePos )
|
||||
void CIniFileBase::ClearSectionPosList( long FilePos )
|
||||
{
|
||||
if (FilePos <= 0)
|
||||
{
|
||||
m_SectionsPos.clear();
|
||||
m_lastSectionSearch = 0;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
FILELOC::iterator iter = m_SectionsPos.begin();
|
||||
while (iter != m_SectionsPos.end())
|
||||
{
|
||||
|
@ -802,7 +837,7 @@ void CIniFileBase::ClearSectionPosList( long FilePos )
|
|||
|
||||
}
|
||||
|
||||
void CIniFileBase::GetVectorOfSections( SectionList & sections)
|
||||
void CIniFileBase::GetVectorOfSections( SectionList & sections)
|
||||
{
|
||||
sections.clear();
|
||||
|
||||
|
|
|
@ -11,7 +11,8 @@ CLog::CLog (void ) :
|
|||
{
|
||||
}
|
||||
|
||||
CLog::~CLog (void) {
|
||||
CLog::~CLog (void)
|
||||
{
|
||||
}
|
||||
|
||||
bool CLog::Open( LPCTSTR FileName, LOG_OPEN_MODE mode /* = Log_New */)
|
||||
|
@ -43,8 +44,7 @@ bool CLog::Open( LPCTSTR FileName, LOG_OPEN_MODE mode /* = Log_New */)
|
|||
m_hLogFile.Seek(0,mode == Log_Append ? CFile::end : CFile::begin);
|
||||
|
||||
#ifdef _UNICODE
|
||||
|
||||
if(m_hLogFile.GetLength()==0)
|
||||
if (m_hLogFile.GetLength() == 0)
|
||||
{
|
||||
WORD wUNICODE = 0xFEFF;
|
||||
|
||||
|
@ -93,7 +93,7 @@ void CLog::LogArgs(LPCTSTR Message, va_list & args )
|
|||
Log(L"Invalid message format");
|
||||
}
|
||||
|
||||
if(buffer)
|
||||
if (buffer)
|
||||
delete [] buffer;
|
||||
#else
|
||||
char* buffer = NULL;
|
||||
|
@ -110,7 +110,7 @@ void CLog::LogArgs(LPCTSTR Message, va_list & args )
|
|||
Log("Invalid message format");
|
||||
}
|
||||
|
||||
if(buffer)
|
||||
if (buffer)
|
||||
delete [] buffer;
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -24,13 +24,15 @@
|
|||
#define MB_SERVICE_NOTIFICATION 0x00200000L
|
||||
#endif
|
||||
|
||||
CMemList *MemList ( void ) {
|
||||
CMemList *MemList ( void )
|
||||
{
|
||||
static CMemList m_MemList;
|
||||
|
||||
return &m_MemList;
|
||||
}
|
||||
|
||||
CMemList::CMemList() {
|
||||
CMemList::CMemList()
|
||||
{
|
||||
MemList.clear();
|
||||
hSemaphone = CreateSemaphore(NULL, 1,1, NULL);
|
||||
State = Initialized;
|
||||
|
@ -51,11 +53,13 @@ CMemList::CMemList() {
|
|||
}
|
||||
}
|
||||
|
||||
CMemList::~CMemList() {
|
||||
CMemList::~CMemList()
|
||||
{
|
||||
size_t ItemsLeft = MemList.size();
|
||||
if (ItemsLeft > 0) {
|
||||
TCHAR path_buffer[_MAX_PATH], drive[_MAX_DRIVE] ,dir[_MAX_DIR];
|
||||
TCHAR fname[_MAX_FNAME],ext[_MAX_EXT], LogFileName[_MAX_PATH];
|
||||
if (ItemsLeft > 0)
|
||||
{
|
||||
TCHAR path_buffer[_MAX_PATH], drive[_MAX_DRIVE], dir[_MAX_DIR];
|
||||
TCHAR fname[_MAX_FNAME], ext[_MAX_EXT], LogFileName[_MAX_PATH];
|
||||
|
||||
memset(path_buffer, 0, sizeof(path_buffer));
|
||||
memset(drive, 0, sizeof(drive));
|
||||
|
@ -68,21 +72,28 @@ CMemList::~CMemList() {
|
|||
_tsplitpath( path_buffer, drive, dir, fname, ext );
|
||||
|
||||
_tmakepath( LogFileName, drive, dir, fname, _T("leak.csv") );
|
||||
|
||||
|
||||
|
||||
HANDLE hLogFile = INVALID_HANDLE_VALUE;
|
||||
do
|
||||
{
|
||||
hLogFile = CreateFile(LogFileName,GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,NULL,
|
||||
CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
|
||||
|
||||
hLogFile = CreateFile(
|
||||
LogFileName,
|
||||
GENERIC_WRITE,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL,
|
||||
CREATE_ALWAYS,
|
||||
FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN,
|
||||
NULL
|
||||
);
|
||||
if (hLogFile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
if (GetLastError() == ERROR_SHARING_VIOLATION) {
|
||||
if (GetLastError() == ERROR_SHARING_VIOLATION)
|
||||
{
|
||||
TCHAR Msg[3000];
|
||||
_stprintf(Msg,TEXT("%s\nCan not be opened for writing please close app using this file\n\nTry Again ?"),LogFileName);
|
||||
int Result = MessageBox(NULL,Msg,_T("Memory Leak"),MB_YESNO|MB_ICONQUESTION|MB_SETFOREGROUND | MB_SERVICE_NOTIFICATION);
|
||||
if (Result == IDNO) {
|
||||
if (Result == IDNO)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -112,7 +123,8 @@ CMemList::~CMemList() {
|
|||
TCHAR Msg[3000];
|
||||
_stprintf(Msg,TEXT("%s%s\n\nMemory Leaks detected\n\nOpen the Log File ?"),fname,ext);
|
||||
int Result = MessageBox(NULL,Msg,_T("Memory Leak"),MB_YESNO|MB_ICONQUESTION|MB_SETFOREGROUND| MB_SERVICE_NOTIFICATION);
|
||||
if (Result == IDYES) {
|
||||
if (Result == IDYES)
|
||||
{
|
||||
ShellExecute(NULL,_T("open"),LogFileName,NULL,NULL,SW_SHOW);
|
||||
}
|
||||
}
|
||||
|
@ -120,7 +132,7 @@ CMemList::~CMemList() {
|
|||
hSemaphone = NULL;
|
||||
State = NotInitialized;
|
||||
}
|
||||
|
||||
|
||||
void * CMemList::AddItem ( size_t size, char * filename, int line)
|
||||
{
|
||||
void *res = malloc(size);
|
||||
|
@ -135,10 +147,12 @@ void * CMemList::AddItem ( size_t size, char * filename, int line)
|
|||
void CMemList::RecordAddItem ( void * ptr, size_t size, const char * filename, int line)
|
||||
{
|
||||
__try {
|
||||
if (State == Initialized && hSemaphone != NULL) {
|
||||
if (State == Initialized && hSemaphone != NULL)
|
||||
{
|
||||
DWORD CurrentThread = GetCurrentThreadId();
|
||||
DWORD Result = WaitForSingleObject(hSemaphone,CurrentThread != ThreadID ? 30000: 0);
|
||||
if (Result != WAIT_TIMEOUT) {
|
||||
if (Result != WAIT_TIMEOUT)
|
||||
{
|
||||
ThreadID = CurrentThread;
|
||||
|
||||
DEBUG_LOCATION info;
|
||||
|
@ -166,17 +180,20 @@ void CMemList::Insert(void *res, DEBUG_LOCATION &info)
|
|||
|
||||
void * CMemList::ReAllocItem ( void * ptr, size_t size, const char * filename, int line)
|
||||
{
|
||||
void *res = realloc(ptr, size);
|
||||
if (res == NULL)
|
||||
void *res = realloc(ptr, size);
|
||||
if (res == NULL)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
if (ptr != res) {
|
||||
if (ptr != res)
|
||||
{
|
||||
__try {
|
||||
if (State == Initialized && hSemaphone != NULL) {
|
||||
if (State == Initialized && hSemaphone != NULL)
|
||||
{
|
||||
DWORD CurrentThread = GetCurrentThreadId();
|
||||
DWORD Result = WaitForSingleObject(hSemaphone,CurrentThread != ThreadID ? 30000 : 0);
|
||||
if (Result != WAIT_TIMEOUT) {
|
||||
if (Result != WAIT_TIMEOUT)
|
||||
{
|
||||
ThreadID = CurrentThread;
|
||||
//Add new pointer
|
||||
DEBUG_LOCATION info;
|
||||
|
@ -206,22 +223,26 @@ void CMemList::Remove(void *ptr)
|
|||
{
|
||||
//remove old pointer
|
||||
MEMLIST_ITER item = MemList.find(ptr);
|
||||
if (item != MemList.end()) {
|
||||
if (item != MemList.end())
|
||||
{
|
||||
MemList.erase(ptr);
|
||||
}
|
||||
}
|
||||
|
||||
void CMemList::removeItem (void * ptr, bool bFree )
|
||||
void CMemList::removeItem (void * ptr, bool bFree )
|
||||
{
|
||||
if (bFree)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
|
||||
__try {
|
||||
if (State == Initialized && hSemaphone != NULL) {
|
||||
if (State == Initialized && hSemaphone != NULL)
|
||||
{
|
||||
DWORD CurrentThread = GetCurrentThreadId();
|
||||
DWORD Result = WaitForSingleObject(hSemaphone,CurrentThread != ThreadID ? 30000 : 0);
|
||||
if (Result != WAIT_TIMEOUT) {
|
||||
if (Result != WAIT_TIMEOUT)
|
||||
{
|
||||
ThreadID = CurrentThread;
|
||||
|
||||
Remove(ptr);
|
||||
|
@ -236,15 +257,18 @@ void CMemList::removeItem (void * ptr, bool bFree )
|
|||
}
|
||||
}
|
||||
|
||||
void MemTest_AddLeak(char* Comment) {
|
||||
void MemTest_AddLeak(char* Comment)
|
||||
{
|
||||
MemList()->AddItem(1,Comment,-1);
|
||||
}
|
||||
|
||||
void* MemTest_malloc (size_t size, char* filename, int line) {
|
||||
void* MemTest_malloc (size_t size, char* filename, int line)
|
||||
{
|
||||
return MemList()->AddItem(size,filename,line);
|
||||
}
|
||||
|
||||
void* MemTest_realloc (void* ptr, size_t size, char* filename, int line) {
|
||||
void* MemTest_realloc (void* ptr, size_t size, char* filename, int line)
|
||||
{
|
||||
return MemList()->ReAllocItem(ptr, size,filename,line);
|
||||
}
|
||||
|
||||
|
|
|
@ -2,12 +2,14 @@
|
|||
|
||||
BOOL TraceClosed = FALSE;
|
||||
|
||||
class CTraceLog {
|
||||
class CTraceLog
|
||||
{
|
||||
std::vector<CTraceModule *> m_Modules;
|
||||
CriticalSection m_CS;
|
||||
|
||||
public:
|
||||
CTraceLog() {
|
||||
CTraceLog()
|
||||
{
|
||||
}
|
||||
~CTraceLog() { CloseTrace (); }
|
||||
|
||||
|
@ -54,8 +56,8 @@ void CTraceLog::CloseTrace ( void)
|
|||
|
||||
for (int i = 0; i < (int)m_Modules.size(); i++ )
|
||||
{
|
||||
if(m_Modules[i])
|
||||
delete m_Modules[i];
|
||||
if(m_Modules[i])
|
||||
delete m_Modules[i];
|
||||
}
|
||||
m_Modules.clear();
|
||||
}
|
||||
|
@ -102,7 +104,7 @@ void CTraceLog::WriteTrace ( TraceType Type, LPCTSTR Message)
|
|||
);
|
||||
|
||||
// show the debug level
|
||||
if (Type == TraceNone) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("None : ")); }
|
||||
if (Type == TraceNone) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("None : ")); }
|
||||
else if ((Type & TraceError) != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Error : ")); }
|
||||
else if ((Type & TraceSettings) != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Setting: ")); }
|
||||
else if ((Type & TraceGfxPlugin) != 0) { nPos += _stprintf(pBuffer+nPos,_T("%s"),_T("Gfx : ")); }
|
||||
|
|
|
@ -924,11 +924,15 @@ BOOL CPath::FindNext()
|
|||
{
|
||||
// Found a directory
|
||||
UpDirectory();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
SetNameExtension("");
|
||||
}
|
||||
AppendDirectory(FindData.cFileName);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Found a file
|
||||
if (IsDirectory())
|
||||
{
|
||||
|
@ -1110,4 +1114,4 @@ void CPath::EnsureLeadingBackslash(stdstr& Directory) const
|
|||
stdstr temp =Directory;
|
||||
Directory.Format(_T("%c%s"),DIRECTORY_DELIMITER,temp.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -159,7 +159,9 @@ stdstr & stdstr::Trim (const char * chars2remove)
|
|||
if (pos != std::string::npos)
|
||||
{
|
||||
erase(0,pos);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
erase(begin(), end()); // make empty
|
||||
}
|
||||
|
||||
|
@ -167,7 +169,9 @@ stdstr & stdstr::Trim (const char * chars2remove)
|
|||
if (pos != std::string::npos)
|
||||
{
|
||||
erase(pos+1);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
erase(begin(), end()); // make empty
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue