pike.git / src / block_allocator.c

version» Context lines:

pike.git/src/block_allocator.c:37:   #ifdef BA_HASH_THLD   # define BA_BYTES(a) ( (sizeof(ba_page) + ((a->allocated > BA_HASH_THLD) ? sizeof(ba_page_t) : 0)) * ((a)->allocated) )   #else   # define BA_BYTES(a) ( (sizeof(ba_page) * ((a)->allocated) )   #endif      #define PRINT_NODE(a, name) do {\    fprintf(stderr, #name": %p\n", a->name);\   } while (0)    - /* goto considered harmful */ - #define LOW_PAGE_LOOP2(a, label, C) do { \ -  ba_page_t __n, stop = 0; \ -  for (__n = 0; __n < a->allocated; __n++) { \ -  ba_page p = a->pages[__n]; \ -  while (p) { \ -  ba_page t = p->hchain; \ -  do { C; goto SURVIVE ## label; } while(0); \ -  goto label; SURVIVE ## label: p = t; \ -  } \ -  } \ - label: \ -  0; \ - } while(0) - #define LOW_PAGE_LOOP(a, l, C) LOW_PAGE_LOOP2(a, l, C) - #define PAGE_LOOP(a, C) LOW_PAGE_LOOP(a, PIKE_XCONCAT(page_loop_label, __LINE__), C) +       PMOD_EXPORT void ba_show_pages(const struct block_allocator * a) {    unsigned int i = 0;       fprintf(stderr, "allocated: %u\n", a->allocated);    fprintf(stderr, "num_pages: %u\n", a->num_pages);    fprintf(stderr, "max_empty_pages: %u\n", a->max_empty_pages);    fprintf(stderr, "empty_pages: %u\n", a->empty_pages);    fprintf(stderr, "magnitude: %u\n", a->magnitude);    PRINT_NODE(a, empty);