int main(int argc, char *argv[]) { pthread_t thrs[NWORKER]; # if (CHECK) char *ret; # endif int i; sa_init(&sa, 37, NWORKER*CONCURRENT); for (i=0; i<NWORKER; i++) pthread_create(thrs+i, NULL, worker, NULL); for (i=0; i<NWORKER; i++) pthread_join(thrs[i], NULL); # if (CHECK) if ((ret=(char *)sa_check(&sa))) { fprintf(stderr, "StackAllocator check failed!\n"); switch ((int)ret) { case 1 : fprintf(stderr, "Count doesn't match.\n"); break; default : fprintf(stderr, "Invalid block %p\n", ret); } sa_dump(&sa, stderr); } else { fprintf(stderr, "StackAllocator check passed!\n"); } # endif return 0; }
/* Report all the SAs to the report channel. */ void sa_report(void) { struct sa *sa; int i; for (i = 0; i <= bucket_mask; i++) for (sa = LIST_FIRST(&sa_tab[i]); sa; sa = LIST_NEXT(sa, link)) sa_dump(LOG_REPORT, 0, "sa_report", sa); }