pike.git / src / block_allocator.c

version» Context lines:

pike.git/src/block_allocator.c:7:      #include <stdlib.h>      #define BA_BLOCKN(l, p, n) ((struct ba_block_header *)((char*)(p) + (l).doffset + (n)*((l).block_size)))   #define BA_LASTBLOCK(l, p) ((struct ba_block_header*)((char*)(p) + (l).doffset + (l).offset))   #define BA_CHECK_PTR(l, p, ptr) ((size_t)((char*)(ptr) - (char*)(p)) <= (l).offset + (l).doffset)      #define BA_ONE ((struct ba_block_header *)1)   #define BA_FLAG_SORTED 1u    + #ifdef PIKE_DEBUG   static void print_allocator(const struct block_allocator * a); -  + #endif      #ifdef PIKE_DEBUG   static void ba_check_ptr(struct block_allocator * a, int page, void * ptr, struct ba_block_header *loc,    int ln);   #endif      static INLINE unsigned INT32 ba_block_number(const struct ba_layout * l, const struct ba_page * p,    const void * ptr) {    return ((char*)ptr - (char*)BA_BLOCKN(*l, p, 0)) / l->block_size;   }
pike.git/src/block_allocator.c:324: Inside #if defined(PIKE_DEBUG)
   }   #ifdef PIKE_DEBUG    } else {    print_allocator(a);    Pike_fatal("ptr %p not in any page.\n", ptr);    }   #endif    PIKE_MEMPOOL_FREE(a, ptr, a->l.block_size);   }    + #ifdef PIKE_DEBUG   static void print_allocator(const struct block_allocator * a) {    int i;    struct ba_layout l;       for (i = a->size-1, l = ba_get_layout(a, i); i >= 0; ba_half_layout(&l), i--) {    struct ba_page * p = a->pages[i];    fprintf(stderr, "page: %p used: %u/%u last: %p p+offset: %p\n", a->pages[i],    p->h.used, l.blocks,    BA_BLOCKN(l, p, l.blocks-1), BA_LASTBLOCK(l, p));    }   }    - #ifdef PIKE_DEBUG -  +    #define Pike_nfatal(n) \    (fprintf(stderr,msg_fatal_error,__FILE__,(long)(n)),debug_fatal)      static void ba_check_ptr(struct block_allocator * a, int page, void * ptr, struct ba_block_header * loc,    int ln) {    struct ba_layout l = ba_get_layout(a, page);    struct ba_page * p = a->pages[page];       if (BA_BLOCKN(l, p, ba_block_number(&l, p, ptr)) != ptr) {    char * block = (char*)BA_BLOCKN(l, p, ba_block_number(&l, p, ptr));