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.37 by root, Thu Jan 1 16:05:12 2009 UTC vs.
Revision 1.38 by root, Thu Jan 1 21:15:12 2009 UTC

39 39
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 int alloc = sizeof (uint32_t) * 2 + len + 1;
44 45
45 shstr_alloc += sizeof (uint32_t) * 2 + len + 1; 46 shstr_alloc += alloc;
46 const char *v = (const char *) (2 + (int *)g_slice_alloc (sizeof (uint32_t) * 2 + len + 1)); 47 char *v = (char *)g_slice_alloc (alloc);
48 v += sizeof (uint32_t) * 2;
47 49
48 shstr::length (v) = len; 50 shstr::length (v) = len;
49 shstr::refcnt (v) = 1; 51 shstr::refcnt (v) = 1;
50 52
51 memcpy ((char *) v, s, len + 1); 53 memcpy (v, s, len + 1);
52 54
53 return v; 55 return v;
54} 56}
55 57
56shstr_vec<sizeof "(null)"> shstr_tmp::nullvec = { 0, 0xffffffff, "(null)" }; 58shstr_vec<sizeof "(null)"> shstr_tmp::nullvec = { 0, 0xffffffff, "(null)" };
117 const char *s = *o; 119 const char *s = *o;
118 120
119 ht.erase (o); 121 ht.erase (o);
120 122
121 //printf ("GC %4d %3d %d >%s<%d\n", (int)ht.size (), n, shstr::refcnt (s), s, shstr::length (s)); 123 //printf ("GC %4d %3d %d >%s<%d\n", (int)ht.size (), n, shstr::refcnt (s), s, shstr::length (s));
122 shstr_alloc -= sizeof (uint32_t) * 2 + length (s) + 1; 124 int alloc = sizeof (uint32_t) * 2 + length (s) + 1;
123 g_slice_free1 (sizeof (uint32_t) * 2 + length (s) + 1, -2 + (int *) s); 125 shstr_alloc -= alloc;
126 g_slice_free1 (alloc, (void *)(s - sizeof (uint32_t) * 2));
124 } 127 }
125 else 128 else
126 ++i; 129 ++i;
127 } 130 }
128 131

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines