ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/common/shstr.C
(Generate patch)

Comparing deliantra/server/common/shstr.C (file contents):
Revision 1.31 by root, Tue Jul 29 02:00:55 2008 UTC vs.
Revision 1.32 by root, Wed Dec 31 17:35:37 2008 UTC

40static const char * 40static const char *
41makevec (const char *s) 41makevec (const char *s)
42{ 42{
43 int len = strlen (s); 43 int len = strlen (s);
44 44
45 shstr_alloc += sizeof (int) * 2 + len + 1; 45 shstr_alloc += sizeof (unsigned int) * 2 + len + 1;
46 const char *v = (const char *) (2 + (int *)g_slice_alloc (sizeof (int) * 2 + len + 1)); 46 const char *v = (const char *) (2 + (int *)g_slice_alloc (sizeof (unsigned int) * 2 + len + 1));
47 47
48 shstr::length (v) = len; 48 shstr::length (v) = len;
49 shstr::refcnt (v) = 1; 49 shstr::refcnt (v) = 1;
50 50
51 memcpy ((char *) v, s, len + 1); 51 memcpy ((char *) v, s, len + 1);
55 55
56static const char * 56static const char *
57makenull () 57makenull ()
58{ 58{
59 const char *s = makevec ("(null)"); 59 const char *s = makevec ("(null)");
60 shstr::length (s) = 0; 60 shstr_tmp::length (s) = 0;
61 //shstr ::refcnt (s) = 0xffffffff; // useful for debugging
61 return s; 62 return s;
62} 63}
63 64
64const char *shstr::null = makenull (); 65const char *shstr_tmp::null = makenull ();
65 66
66const char * 67const char *
67shstr::find (const char *s) 68shstr::find (const char *s)
68{ 69{
69 if (!s) 70 if (!s)
125 const char *s = *o; 126 const char *s = *o;
126 127
127 ht.erase (o); 128 ht.erase (o);
128 129
129 //printf ("GC %4d %3d %d >%s<%d\n", (int)ht.size (), n, shstr::refcnt (s), s, shstr::length (s)); 130 //printf ("GC %4d %3d %d >%s<%d\n", (int)ht.size (), n, shstr::refcnt (s), s, shstr::length (s));
130 shstr_alloc -= sizeof (int) * 2 + length (s) + 1; 131 shstr_alloc -= sizeof (unsigned int) * 2 + length (s) + 1;
131 g_slice_free1 (sizeof (int) * 2 + length (s) + 1, -2 + (int *) s); 132 g_slice_free1 (sizeof (unsigned int) * 2 + length (s) + 1, -2 + (int *) s);
132 } 133 }
133 else 134 else
134 ++i; 135 ++i;
135 } 136 }
136 137

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines