--- deliantra/server/common/shstr.C 2006/09/12 00:53:56 1.16 +++ deliantra/server/common/shstr.C 2007/04/16 15:41:26 1.21 @@ -1,4 +1,3 @@ - /* * shstr.C */ @@ -12,18 +11,16 @@ #include "global.h" -typedef std::tr1::unordered_set HT; +typedef std::tr1::unordered_set , true> HT; static HT ht; static const char * makevec (const char *s) { - int - len = strlen (s); + int len = strlen (s); - const char * - v = (const char *) (2 + (int *) g_slice_alloc (sizeof (int) * 2 + len + 1)); + const char *v = (const char *) (2 + (int *)g_slice_alloc (sizeof (int) * 2 + len + 1)); shstr::length (v) = len; shstr::refcnt (v) = 1; @@ -33,7 +30,15 @@ return v; } -const char *shstr::null = makevec (""); +static const char * +makenull () +{ + const char *s = makevec ("(null)"); + shstr::length (s) = 0; + return s; +} + +const char *shstr::null = makenull (); const char * shstr::find (const char *s) @@ -41,7 +46,7 @@ if (!s) return s; - HT::iterator i = ht.find (s); + auto (i, ht.find (s)); return i != ht.end ()? *i : 0; } @@ -68,12 +73,9 @@ void shstr::gc () { -return; //D -//D currently disabled: some datastructures might still store them -//D but their pointers will become invalidated static const char *curpos; - HT::iterator i = curpos ? ht.find (curpos) : ht.begin (); + auto (i, curpos ? ht.find (curpos) : ht.begin ()); if (i == ht.end ()) i = ht.begin (); @@ -92,7 +94,7 @@ break; else if (!refcnt (*i)) { - HT::iterator o = i++; + auto (o, i++); const char *s = *o; ht.erase (o);