--- deliantra/server/include/util.h 2012/01/03 11:23:41 1.117
+++ deliantra/server/include/util.h 2012/11/11 01:27:44 1.121
@@ -1,22 +1,22 @@
/*
* This file is part of Deliantra, the Roguelike Realtime MMORPG.
- *
- * Copyright (©) 2005,2006,2007,2008,2009,2010,2011 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
- *
+ *
+ * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
+ *
* Deliantra is free software: you can redistribute it and/or modify it under
* the terms of the Affero GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
- *
+ *
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
- *
+ *
* You should have received a copy of the Affero GNU General Public License
* and the GNU General Public License along with this program. If not, see
* .
- *
+ *
* The authors can be reached via e-mail to
*/
@@ -462,7 +462,7 @@
refcnt_buf (const refcnt_buf &src)
{
data = src.data;
- ++_refcnt ();
+ inc ();
}
~refcnt_buf ();
@@ -481,30 +481,37 @@
protected:
enum {
- overhead = sizeof (unsigned int) * 2
+ overhead = sizeof (uint32_t) * 2
};
- unsigned int &_size () const
+ uint32_t &_size () const
{
return ((unsigned int *)data)[-2];
}
- unsigned int &_refcnt () const
+ uint32_t &_refcnt () const
{
return ((unsigned int *)data)[-1];
}
- void _alloc (unsigned int size)
+ void _alloc (uint32_t size)
{
data = ((char *)salloc (size + overhead)) + overhead;
_size () = size;
_refcnt () = 1;
}
+ void _dealloc ();
+
+ void inc ()
+ {
+ ++_refcnt ();
+ }
+
void dec ()
{
if (!--_refcnt ())
- sfree (data - overhead, size () + overhead);
+ _dealloc ();
}
};
@@ -656,7 +663,7 @@
// This container blends advantages of linked lists
// (efficiency) with vectors (random access) by
-// by using an unordered vector and storing the vector
+// using an unordered vector and storing the vector
// index inside the object.
//
// + memory-efficient on most 64 bit archs
@@ -703,7 +710,7 @@
void erase (T *obj)
{
- unsigned int pos = obj->*indexmember;
+ object_vector_index pos = obj->*indexmember;
obj->*indexmember = 0;
if (pos < this->size ())