… | |
… | |
469 | LOG (llevError, "fork abort: %s\n", msg); |
469 | LOG (llevError, "fork abort: %s\n", msg); |
470 | } |
470 | } |
471 | |
471 | |
472 | void *salloc_ (int n) throw (std::bad_alloc) |
472 | void *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 0xa1b2c35543deadL |
503 | #define MAGIC 0xa1b2c35543deadLL |
504 | |
504 | |
505 | void *g_slice_alloc (unsigned long size) |
505 | void *g_slice_alloc (unsigned long size) |
506 | { |
506 | { |
507 | unsigned long *p = (unsigned long *) (g_slice_alloc)(size + sizeof (unsigned long)); |
507 | unsigned long *p = (unsigned long *) (g_slice_alloc)(size + sizeof (unsigned long)); |
508 | *p++ = size ^ MAGIC; |
508 | *p++ = size ^ MAGIC; |
… | |
… | |
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); |