[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gzz-commits] libvob/src/util Debug.cxx
From: |
Tuomas J. Lukka |
Subject: |
[Gzz-commits] libvob/src/util Debug.cxx |
Date: |
Wed, 12 Mar 2003 10:13:41 -0500 |
CVSROOT: /cvsroot/libvob
Module name: libvob
Changes by: Tuomas J. Lukka <address@hidden> 03/03/12 10:13:41
Modified files:
src/util : Debug.cxx
Log message:
Fix order-of-init. Now gl test actually displays the red bg and the
green triangle\!
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/libvob/libvob/src/util/Debug.cxx.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: libvob/src/util/Debug.cxx
diff -u libvob/src/util/Debug.cxx:1.1 libvob/src/util/Debug.cxx:1.2
--- libvob/src/util/Debug.cxx:1.1 Tue Mar 11 06:28:17 2003
+++ libvob/src/util/Debug.cxx Wed Mar 12 10:13:41 2003
@@ -47,27 +47,32 @@
}
};
- std::map<std::string, IntPtr> vars;
+ typedef std::map<std::string, IntPtr> VarMap;
+
+ static VarMap &vars() {
+ static VarMap v;
+ return v;
+ }
int& var(const char *name) {
- return *(vars[name].ptr);
+ return *(vars()[name].ptr);
}
int& extVar(const char *name, int *var) {
- if (vars.count(name) > 0) {
+ if (vars().count(name) > 0) {
std::cerr << "registerInt: " << name << " already defined: previous
definition replaced, but value preserved\n";
- IntPtr &prev = vars[name];
+ IntPtr &prev = vars()[name];
*var = *prev.ptr;
return *(prev.ptr = var);
}
- return *((vars[name] = IntPtr(var)).ptr);
+ return *((vars()[name] = IntPtr(var)).ptr);
}
std::vector<const char *> getVarNames() {
- std::vector<const char *> v(vars.size());
+ std::vector<const char *> v(vars().size());
int i = 0;
- for (std::map<std::string, IntPtr>::iterator p = vars.begin();
- p != vars.end(); ++p) {
+ for (std::map<std::string, IntPtr>::iterator p = vars().begin();
+ p != vars().end(); ++p) {
v[i++] = p->first.c_str();
}
return v;