pike.git / src / block_allocator.c

version» Context lines:

pike.git/src/block_allocator.c:36:   static INLINE struct ba_layout ba_get_layout(const struct block_allocator * a, int i) {    struct ba_layout l = a->l;    ba_inc_layout(&l, i);    return l;   }      struct ba_block_header {    struct ba_block_header * next;   };    + #ifdef HAVE_VALGRIND_MACROS + # ifndef VALGRIND_CREATE_MEMPOOL + # define VALGRIND_CREATE_MEMPOOL(a, b, c) + # define VALGRIND_MEMPOOL_ALLOC(a, p, l) VALGRIND_MAKE_MEM_UNDEFINED((p), (l)) + # define VALGRIND_MEMPOOL_FREE(a, p) VALGRIND_MAKE_MEM_NOACCESS((p), (a)->l.block_size) + # endif + #endif +  +    static struct ba_page * ba_alloc_page(struct block_allocator * a, int i) {    struct ba_layout l = ba_get_layout(a, i);    size_t n = l.offset + l.block_size + sizeof(struct ba_page);    struct ba_page * p = (struct ba_page*)xalloc(n);    p->h.first = BA_BLOCKN(a->l, p, 0);    p->h.first->next = BA_ONE;    p->h.used = 0;   #ifdef HAVE_VALGRIND_MACROS    VALGRIND_MAKE_MEM_NOACCESS(p+1, n - sizeof(struct ba_page));   #endif
pike.git/src/block_allocator.c:120:    Pike_error("Out of memory.");    }    a->pages[a->size] = ba_alloc_page(a, a->size);    a->alloc = a->size;    a->size++;    } else {    ba_init(a, a->l.block_size, a->l.blocks);    }   }    - #ifndef VALGRIND_MEMPOOL_ALLOC - # define VALGRIND_MEMPOOL_ALLOC(a, p, l) VALGRIND_MAKE_MEM_UNDEFINED((p), (l)) - # define VALGRIND_MEMPOOL_FREE(a, p) VALGRIND_MAKE_MEM_NOACCESS((p), (a)->l.block_size) - #endif -  +    ATTRIBUTE((malloc))   PMOD_EXPORT void * ba_alloc(struct block_allocator * a) {    struct ba_page * p = a->pages[a->alloc];    struct ba_block_header * ptr;       if (!p || !p->h.first) {    ba_low_alloc(a);    p = a->pages[a->alloc];    }