pike.git / src / block_allocator.c

version» Context lines:

pike.git/src/block_allocator.c:78:    ba_page p = BA_PAGE(a, i);    fprintf(stderr, "%d\t%f\t(%u %d) --> (prev: %p | next: %p)\n",    i, p->blocks_used/(double)a->blocks * 100,    p->blocks_used,    p->blocks_used,    p->prev, p->next);       }   }    + //#define BA_ALIGNMENT 8 +    PMOD_EXPORT INLINE void ba_init(struct block_allocator * a,    uint32_t block_size, ba_page_t blocks) { -  uint32_t page_size = block_size * blocks; +  uint32_t page_size;    -  + #ifdef BA_ALIGNMENT +  if (block_size & (BA_ALIGNMENT - 1)) +  block_size += (BA_ALIGNMENT - (block_size & (BA_ALIGNMENT - 1))); + #endif +  +  page_size = block_size * blocks; +     a->first = NULL;    a->last_free = NULL;    a->last_free_num = 0;       if ((page_size & (page_size - 1))) {    page_size = round_up32(page_size);    a->blocks = page_size/block_size;    } else a->blocks = blocks;       a->magnitude = (uint16_t)ctz32(page_size);