--- deliantra/server/common/shstr.C 2006/09/11 23:33:28 1.14 +++ deliantra/server/common/shstr.C 2006/09/14 18:13:01 1.20 @@ -1,4 +1,3 @@ - /* * shstr.C */ @@ -10,26 +9,18 @@ #include -#include "shstr.h" -#include "util.h" +#include "global.h" -typedef -std::tr1::unordered_set < const char *, - str_hash, - str_equal > - HT; +typedef std::tr1::unordered_set , true> HT; -static HT - 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; @@ -39,11 +30,15 @@ return v; } -const char * - shstr::null = makevec (""); +static const char * +makenull () +{ + const char *s = makevec ("(null)"); + shstr::length (s) = 0; + return s; +} -// what weird misoptimisation is this again? -const shstr undead_name ("undead"); +const char *shstr::null = makenull (); const char * shstr::find (const char *s) @@ -51,7 +46,7 @@ if (!s) return s; - HT::iterator i = ht.find (s); + AUTODECL (i, ht.find (s)); return i != ht.end ()? *i : 0; } @@ -78,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 (); + AUTODECL (i, curpos ? ht.find (curpos) : ht.begin ()); if (i == ht.end ()) i = ht.begin (); @@ -102,7 +94,7 @@ break; else if (!refcnt (*i)) { - HT::iterator o = i++; + AUTODECL (o, i++); const char *s = *o; ht.erase (o); @@ -117,6 +109,11 @@ curpos = *i; } +shstr skill_names[NUM_SKILLS]; + +// what weird misoptimisation is this again? +const shstr undead_name ("undead"); + //TODO: this should of course not be here /* buf_overflow() - we don't want to exceed the buffer size of