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.70 by root, Fri Jan 25 18:09:23 2008 UTC vs.
Revision 1.73 by root, Wed Apr 2 11:13:53 2008 UTC

469 LOG (llevError, "fork abort: %s\n", msg); 469 LOG (llevError, "fork abort: %s\n", msg);
470} 470}
471 471
472void *salloc_ (int n) throw (std::bad_alloc) 472void *salloc_ (int n) throw (std::bad_alloc)
473{ 473{
474#ifdef PREFER_MALLOC 474#if PREFER_MALLOC
475 void *ptr = malloc (n); 475 void *ptr = malloc (n);
476#else 476#else
477 slice_alloc += n; 477 slice_alloc += n;
478 void *ptr = g_slice_alloc (n); 478 void *ptr = g_slice_alloc (n);
479#endif 479#endif
496 return ptr; 496 return ptr;
497} 497}
498 498
499/******************************************************************************/ 499/******************************************************************************/
500 500
501#ifdef DEBUG_SALLOC 501#if DEBUG_SALLOC
502 502
503#define MAGIC 0xa1b2c35543deadLL 503#define MAGIC 0xa1b2c35543deadLL
504 504
505void *g_slice_alloc (unsigned long size) 505void *g_slice_alloc (unsigned long size)
506{ 506{
521 { 521 {
522 //fprintf (stderr, "g_slice_free %ld %p\n", size, ptr);//D 522 //fprintf (stderr, "g_slice_free %ld %p\n", size, ptr);//D
523 unsigned long *p = (unsigned long *)ptr; 523 unsigned long *p = (unsigned long *)ptr;
524 unsigned long s = *--p ^ MAGIC; 524 unsigned long s = *--p ^ MAGIC;
525 525
526 if ((*p ^ MAGIC) != size) 526 if (size != (unsigned long)(*p ^ MAGIC))
527 LOG (logBacktrace | llevError, "slice free size (%lx) doesn't match alloc size (%lx)\n", size, s); 527 LOG (logBacktrace | llevError, "slice free size (%lx) doesn't match alloc size (%lx)\n", size, s);
528 528
529 *p = MAGIC; 529 *p = MAGIC;
530 530
531 (g_slice_free1)(s + sizeof (unsigned long), p); 531 (g_slice_free1)(s + sizeof (unsigned long), p);
648 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL, 648 0xcdd70693UL, 0x54de5729UL, 0x23d967bfUL, 0xb3667a2eUL, 0xc4614ab8UL,
649 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL, 649 0x5d681b02UL, 0x2a6f2b94UL, 0xb40bbe37UL, 0xc30c8ea1UL, 0x5a05df1bUL,
650 0x2d02ef8dL 650 0x2d02ef8dL
651}; 651};
652 652
653void thread::start (void *(*start_routine)(void *), void *arg)
654{
655 sigset_t fullsigset, oldsigset;
656 sigfillset (&fullsigset);
657
658 pthread_sigmask (SIG_SETMASK, &fullsigset, &oldsigset);
659
660 if (pthread_create (&id, 0, start_routine, arg))
661 cleanup ("unable to create a new thread");
662
663 pthread_sigmask (SIG_SETMASK, &oldsigset, 0);
664}

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines