diff options
author | John Wiegley <johnw@newartisans.com> | 2007-04-20 02:14:53 +0000 |
---|---|---|
committer | John Wiegley <johnw@newartisans.com> | 2008-04-13 03:38:28 -0400 |
commit | b84f676946941df6f7e8476d77d1db0cbe7736c5 (patch) | |
tree | 9ee7c7a2d3b7496b38ad127519210adfeced2241 /debug.cc | |
parent | 539370ff1b37772e9f11439f652ffd3583beeedb (diff) | |
download | ledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.tar.gz ledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.tar.bz2 ledger-b84f676946941df6f7e8476d77d1db0cbe7736c5.zip |
Did some optimization and memory cleanup
Diffstat (limited to 'debug.cc')
-rw-r--r-- | debug.cc | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -1,4 +1,5 @@ #include "debug.h" +#include "error.h" #ifdef DEBUG_ENABLED @@ -94,12 +95,15 @@ void operator delete[](void * ptr, const std::nothrow_t&) throw() { std::ostream * _debug_stream = &std::cerr; bool _free_debug_stream = false; +boost::regex _debug_regex; +bool _set_debug_regex = false; bool _debug_active(const char * const cls) { - if (char * debug = std::getenv("DEBUG_CLASS")) { - return boost::regex_match(cls, boost::regex(debug)); + if (! _set_debug_regex) { + _debug_regex = std::getenv("DEBUG_CLASS"); + _set_debug_regex = true; } - return false; + return boost::regex_match(cls, _debug_regex); } static struct init_streams { @@ -125,11 +129,11 @@ static struct init_streams { #include <string> -void debug_assert(const std::string& reason, - const std::string& file, - unsigned long line) +void debug_assert(const ledger::string& reason, + const ledger::string& file, + unsigned long line) { - throw new fatal_assert(reason, new file_context(file, line)); + throw new ledger::fatal_assert(reason, new ledger::file_context(file, line)); } #endif |