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

Comparing deliantra/server/common/utils.C (file contents):
Revision 1.68 by root, Thu Nov 8 19:43:24 2007 UTC vs.
Revision 1.69 by root, Tue Jan 22 15:53:01 2008 UTC

493 else 493 else
494 memset (ptr, 0, n); 494 memset (ptr, 0, n);
495 495
496 return ptr; 496 return ptr;
497} 497}
498
499/******************************************************************************/
500
501#ifdef DEBUG_SALLOC
502
503#define MAGIC 0xa1b2c35543deadL
504
505void *g_slice_alloc (unsigned long size)
506{
507 unsigned long *p = (unsigned long *) (g_slice_alloc)(size + sizeof (unsigned long));
508 *p++ = size ^ MAGIC;
509 //fprintf (stderr, "g_slice_alloc %ld %p\n", size, p);//D
510 return (void *)p;
511}
512
513void *g_slice_alloc0 (unsigned long size)
514{
515 return memset (g_slice_alloc (size), 0, size);
516}
517
518void g_slice_free1 (unsigned long size, void *ptr)
519{
520 if (expect_true (ptr))
521 {
522 //fprintf (stderr, "g_slice_free %ld %p\n", size, ptr);//D
523 unsigned long *p = (unsigned long *)ptr;
524 unsigned long s = *--p ^ MAGIC;
525
526 if ((*p ^ MAGIC) != size)
527 LOG (logBacktrace | llevError, "slice free size (%lx) doesn't match alloc size (%lx)\n", size, s);
528
529 *p = MAGIC;
530
531 (g_slice_free1)(s + sizeof (unsigned long), p);
532 }
533}
534
535#endif
536
537/******************************************************************************/
498 538
499void assign (char *dst, const char *src, int maxlen) 539void assign (char *dst, const char *src, int maxlen)
500{ 540{
501 if (!src) 541 if (!src)
502 src = ""; 542 src = "";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines