Index: ext/libicpf/src/dumpctx.cpp =================================================================== diff -u -re17c80d36eaa0430313e7d1058aa7a301d1510af -r338a33bbdb8c82416f0351408eea3243520784e5 --- ext/libicpf/src/dumpctx.cpp (.../dumpctx.cpp) (revision e17c80d36eaa0430313e7d1058aa7a301d1510af) +++ ext/libicpf/src/dumpctx.cpp (.../dumpctx.cpp) (revision 338a33bbdb8c82416f0351408eea3243520784e5) @@ -1,6 +1,6 @@ /*************************************************************************** - * Copyright (C) 2004 by J�zef Starosczyk * - * copyhandler@o2.pl * + * Copyright (C) 2004-2006 by J�zef Starosczyk * + * ixen@draknet.sytes.net * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU Library General Public License as * @@ -23,7 +23,6 @@ #include "dumpctx.h" #include #include "log.h" -#include "macros.h" BEGIN_ICPF_NAMESPACE @@ -35,7 +34,13 @@ * \param[in] uiType - type of dump (one of the DCX_*) * \param[in] pParam - additional param - the type of theis param depends on the ulType */ -dumpctx::dumpctx(uint_t uiType, ptr_t pParam) +dumpctx::dumpctx(uint_t uiType, ptr_t pParam) : + m_lock(), + m_strBuffer(), + m_szBuffer(), + m_uiType(uiType), + m_pParam(pParam) + { m_uiType=uiType; if (uiType == DCX_FILE) @@ -44,8 +49,6 @@ m_pParam=(ptr_t)new char_t[tLen+1]; strcpy((char_t*)m_pParam, (const char_t*)pParam); } - else - m_pParam=pParam; } /** Destructor frees the internal data if needed @@ -54,6 +57,8 @@ { if (m_uiType == DCX_FILE) delete [] (char_t*)m_pParam; + else + m_pParam=NULL; // we won't have a leak here, since we don't alloc memory for case m_uiType != DCX_FILE } /** Function opens the dump. It means initializing the internal string @@ -62,7 +67,7 @@ */ void dumpctx::open(const char_t* pszObject) { - m_lock.lock(); + MLOCK(m_lock); m_strBuffer=pszObject; m_strBuffer+="\n"; } @@ -102,12 +107,14 @@ ((log_file*)m_pParam)->logd(m_strBuffer); break; } + default: + break; } // clean the internal buffer m_strBuffer.clear(); - m_lock.unlock(); + MUNLOCK(m_lock); } /** Function dumps (stores in the internal string object) the given ansi string. @@ -119,7 +126,9 @@ { snprintf(m_szBuffer, MAX_DUMP, STRFMT " (string):\n\t" PTRFMT " (\"" STRFMT "\")\n", pszName, pszValue, pszValue); m_szBuffer[MAX_DUMP-1]='\0'; + MLOCK(m_lock); m_strBuffer+=m_szBuffer; + MUNLOCK(m_lock); } /** Function dumps (stores in the internal string object) the given unicode string. @@ -131,7 +140,9 @@ { snprintf(m_szBuffer, MAX_DUMP, STRFMT " (wide string):\n\t" PTRFMT " (\"" WSTRFMT "\")\n", pszName, pszValue, pszValue); m_szBuffer[MAX_DUMP-1]='\0'; + MLOCK(m_lock); m_strBuffer+=m_szBuffer; + MUNLOCK(m_lock); } /** Function dumps (stores in the internal string object) the given character. @@ -142,7 +153,9 @@ { snprintf(m_szBuffer, MAX_DUMP, STRFMT " (char_t):\n\t'" CHARFMT "' (hex: " CXFMT " / dec: " CFMT ")\n", pszName, cValue, (short_t)cValue, (short_t)cValue); m_szBuffer[MAX_DUMP-1]='\0'; + MLOCK(m_lock); m_strBuffer+=m_szBuffer; + MUNLOCK(m_lock); } /** Function dumps (stores in the internal string object) the given short_t. @@ -153,7 +166,9 @@ { snprintf(m_szBuffer, MAX_DUMP, STRFMT " (short_t):\n\t" SFMT " (hex: " SXFMT ")\n", pszName, sValue, sValue); m_szBuffer[MAX_DUMP-1]='\0'; + MLOCK(m_lock); m_strBuffer+=m_szBuffer; + MUNLOCK(m_lock); } /** Function dumps (stores in the internal string object) the given int_t. @@ -164,7 +179,9 @@ { snprintf(m_szBuffer, MAX_DUMP, STRFMT " (int_t):\n\t" LFMT " (hex: " LXFMT ")\n", pszName, iValue, iValue); m_szBuffer[MAX_DUMP-1]='\0'; + MLOCK(m_lock); m_strBuffer+=m_szBuffer; + MUNLOCK(m_lock); } /** Function dumps (stores in the internal string object) the given uchar_t. @@ -175,7 +192,9 @@ { snprintf(m_szBuffer, MAX_DUMP, STRFMT " (uchar_t):\n\t'" UCHARFMT "' (hex: " UCXFMT " / dec: " UCFMT ")\n", pszName, ucValue, (ushort_t)ucValue, (ushort_t)ucValue); m_szBuffer[MAX_DUMP-1]='\0'; + MLOCK(m_lock); m_strBuffer+=m_szBuffer; + MUNLOCK(m_lock); } /** Function dumps (stores in the internal string object) the given ushort_t. @@ -186,7 +205,9 @@ { snprintf(m_szBuffer, MAX_DUMP, STRFMT " (ushort_t):\n\t" USFMT " (hex: " USXFMT ")\n", pszName, usValue, usValue); m_szBuffer[MAX_DUMP-1]='\0'; + MLOCK(m_lock); m_strBuffer+=m_szBuffer; + MUNLOCK(m_lock); } /** Function dumps (stores in the internal string object) the given uint_t. @@ -197,7 +218,9 @@ { snprintf(m_szBuffer, MAX_DUMP, STRFMT " (uint_t):\n\t" ULFMT " (hex: " ULXFMT ")\n", pszName, uiValue, uiValue); m_szBuffer[MAX_DUMP-1]='\0'; + MLOCK(m_lock); m_strBuffer+=m_szBuffer; + MUNLOCK(m_lock); } /** Function dumps (stores in the internal string object) the longlong_t. @@ -208,7 +231,9 @@ { snprintf(m_szBuffer, MAX_DUMP, STRFMT " (longlong_t):\n\t" LLFMT " (hex: " LLXFMT ")\n", pszName, llValue, llValue); m_szBuffer[MAX_DUMP-1]='\0'; + MLOCK(m_lock); m_strBuffer+=m_szBuffer; + MUNLOCK(m_lock); } /** Function dumps (stores in the internal string object) the ulonglong_t. @@ -219,7 +244,9 @@ { snprintf(m_szBuffer, MAX_DUMP, STRFMT " (ulonglong_t):\n\t" ULLFMT " (hex: " ULLXFMT ")\n", pszName, ullValue, ullValue); m_szBuffer[MAX_DUMP-1]='\0'; + MLOCK(m_lock); m_strBuffer+=m_szBuffer; + MUNLOCK(m_lock); } /** Function dumps (stores in the internal string object) the untyped pointer. @@ -230,7 +257,9 @@ { snprintf(m_szBuffer, MAX_DUMP, STRFMT " (ptr_t):\n\t" PTRFMT "\n", pszName, pValue); m_szBuffer[MAX_DUMP-1]='\0'; + MLOCK(m_lock); m_strBuffer+=m_szBuffer; + MUNLOCK(m_lock); } END_ICPF_NAMESPACE