void do_tests() { plan(4); lf_alloc_init(&lf_allocator, sizeof(TLA), offsetof(TLA, not_used)); lf_hash_init(&lf_hash, sizeof(int), LF_HASH_UNIQUE, 0, sizeof(int), 0, &my_charset_bin); bad= my_atomic_initialize(); ok(!bad, "my_atomic_initialize() returned %d", bad); test_concurrently("lf_pinbox", test_lf_pinbox, N= THREADS, CYCLES); test_concurrently("lf_alloc", test_lf_alloc, N= THREADS, CYCLES); test_concurrently("lf_hash", test_lf_hash, N= THREADS, CYCLES/10); lf_hash_destroy(&lf_hash); lf_alloc_destroy(&lf_allocator); }
void lf_hash_destroy(LF_HASH *hash) { LF_SLIST *el, **head= (LF_SLIST **)_lf_dynarray_value(&hash->array, 0); if (head) { el= *head; while (el) { intptr next= el->link; if (el->hashnr & 1) lf_alloc_direct_free(&hash->alloc, el); /* normal node */ else my_free(el); /* dummy node */ el= (LF_SLIST *)next; } } lf_alloc_destroy(&hash->alloc); lf_dynarray_destroy(&hash->array); }