--- deliantra/server/common/utils.C 2006/09/03 00:18:40 1.3 +++ deliantra/server/common/utils.C 2006/09/04 11:07:59 1.4 @@ -1,6 +1,6 @@ /* * static char *rcsid_utils_c = - * "$Id: utils.C,v 1.3 2006/09/03 00:18:40 root Exp $"; + * "$Id: utils.C,v 1.4 2006/09/04 11:07:59 root Exp $"; */ /* @@ -34,6 +34,8 @@ #include #include +#include + /* * The random functions here take luck into account when rolling random * dice or numbers. This function has less of an impact the larger the @@ -483,18 +485,28 @@ return; } +//TODO: overhead due to specifying size twice void * zero_initialised::operator new (size_t s) { - void *p = malloc (s); - - memset (p, 0, s); - return p; + return g_slice_alloc0 (s); +} + +void * +zero_initialised::operator new [] (size_t s) +{ + return g_slice_alloc0 (s); } void zero_initialised::operator delete (void *p, size_t s) { - free (p); + g_slice_free1 (s, p); +} + +void +zero_initialised::operator delete [] (void *p, size_t s) +{ + g_slice_free1 (s, p); }