mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-06-01 17:54:16 +03:00
Convert all tsd variables to reside in a single tsd structure.
This commit is contained in:
parent
42f5955938
commit
5460aa6f66
22 changed files with 1027 additions and 935 deletions
|
|
@ -2,20 +2,25 @@
|
|||
|
||||
TEST_BEGIN(test_new_delete)
|
||||
{
|
||||
tsd_t *tsd;
|
||||
ckh_t ckh;
|
||||
|
||||
assert_false(ckh_new(&ckh, 2, ckh_string_hash, ckh_string_keycomp),
|
||||
"Unexpected ckh_new() error");
|
||||
ckh_delete(&ckh);
|
||||
tsd = tsd_tryget();
|
||||
assert_ptr_not_null(tsd, "Unexpected tsd failure");
|
||||
|
||||
assert_false(ckh_new(&ckh, 3, ckh_pointer_hash, ckh_pointer_keycomp),
|
||||
assert_false(ckh_new(tsd, &ckh, 2, ckh_string_hash, ckh_string_keycomp),
|
||||
"Unexpected ckh_new() error");
|
||||
ckh_delete(&ckh);
|
||||
ckh_delete(tsd, &ckh);
|
||||
|
||||
assert_false(ckh_new(tsd, &ckh, 3, ckh_pointer_hash,
|
||||
ckh_pointer_keycomp), "Unexpected ckh_new() error");
|
||||
ckh_delete(tsd, &ckh);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_count_insert_search_remove)
|
||||
{
|
||||
tsd_t *tsd;
|
||||
ckh_t ckh;
|
||||
const char *strs[] = {
|
||||
"a string",
|
||||
|
|
@ -26,7 +31,10 @@ TEST_BEGIN(test_count_insert_search_remove)
|
|||
const char *missing = "A string not in the hash table.";
|
||||
size_t i;
|
||||
|
||||
assert_false(ckh_new(&ckh, 2, ckh_string_hash, ckh_string_keycomp),
|
||||
tsd = tsd_tryget();
|
||||
assert_ptr_not_null(tsd, "Unexpected tsd failure");
|
||||
|
||||
assert_false(ckh_new(tsd, &ckh, 2, ckh_string_hash, ckh_string_keycomp),
|
||||
"Unexpected ckh_new() error");
|
||||
assert_zu_eq(ckh_count(&ckh), 0,
|
||||
"ckh_count() should return %zu, but it returned %zu", ZU(0),
|
||||
|
|
@ -34,7 +42,7 @@ TEST_BEGIN(test_count_insert_search_remove)
|
|||
|
||||
/* Insert. */
|
||||
for (i = 0; i < sizeof(strs)/sizeof(const char *); i++) {
|
||||
ckh_insert(&ckh, strs[i], strs[i]);
|
||||
ckh_insert(tsd, &ckh, strs[i], strs[i]);
|
||||
assert_zu_eq(ckh_count(&ckh), i+1,
|
||||
"ckh_count() should return %zu, but it returned %zu", i+1,
|
||||
ckh_count(&ckh));
|
||||
|
|
@ -79,7 +87,7 @@ TEST_BEGIN(test_count_insert_search_remove)
|
|||
vp = (i & 2) ? &v.p : NULL;
|
||||
k.p = NULL;
|
||||
v.p = NULL;
|
||||
assert_false(ckh_remove(&ckh, strs[i], kp, vp),
|
||||
assert_false(ckh_remove(tsd, &ckh, strs[i], kp, vp),
|
||||
"Unexpected ckh_remove() error");
|
||||
|
||||
ks = (i & 1) ? strs[i] : (const char *)NULL;
|
||||
|
|
@ -95,20 +103,24 @@ TEST_BEGIN(test_count_insert_search_remove)
|
|||
ckh_count(&ckh));
|
||||
}
|
||||
|
||||
ckh_delete(&ckh);
|
||||
ckh_delete(tsd, &ckh);
|
||||
}
|
||||
TEST_END
|
||||
|
||||
TEST_BEGIN(test_insert_iter_remove)
|
||||
{
|
||||
#define NITEMS ZU(1000)
|
||||
tsd_t *tsd;
|
||||
ckh_t ckh;
|
||||
void **p[NITEMS];
|
||||
void *q, *r;
|
||||
size_t i;
|
||||
|
||||
assert_false(ckh_new(&ckh, 2, ckh_pointer_hash, ckh_pointer_keycomp),
|
||||
"Unexpected ckh_new() error");
|
||||
tsd = tsd_tryget();
|
||||
assert_ptr_not_null(tsd, "Unexpected tsd failure");
|
||||
|
||||
assert_false(ckh_new(tsd, &ckh, 2, ckh_pointer_hash,
|
||||
ckh_pointer_keycomp), "Unexpected ckh_new() error");
|
||||
|
||||
for (i = 0; i < NITEMS; i++) {
|
||||
p[i] = mallocx(i+1, 0);
|
||||
|
|
@ -119,7 +131,7 @@ TEST_BEGIN(test_insert_iter_remove)
|
|||
size_t j;
|
||||
|
||||
for (j = i; j < NITEMS; j++) {
|
||||
assert_false(ckh_insert(&ckh, p[j], p[j]),
|
||||
assert_false(ckh_insert(tsd, &ckh, p[j], p[j]),
|
||||
"Unexpected ckh_insert() failure");
|
||||
assert_false(ckh_search(&ckh, p[j], &q, &r),
|
||||
"Unexpected ckh_search() failure");
|
||||
|
|
@ -134,13 +146,13 @@ TEST_BEGIN(test_insert_iter_remove)
|
|||
for (j = i + 1; j < NITEMS; j++) {
|
||||
assert_false(ckh_search(&ckh, p[j], NULL, NULL),
|
||||
"Unexpected ckh_search() failure");
|
||||
assert_false(ckh_remove(&ckh, p[j], &q, &r),
|
||||
assert_false(ckh_remove(tsd, &ckh, p[j], &q, &r),
|
||||
"Unexpected ckh_remove() failure");
|
||||
assert_ptr_eq(p[j], q, "Key pointer mismatch");
|
||||
assert_ptr_eq(p[j], r, "Value pointer mismatch");
|
||||
assert_true(ckh_search(&ckh, p[j], NULL, NULL),
|
||||
"Unexpected ckh_search() success");
|
||||
assert_true(ckh_remove(&ckh, p[j], &q, &r),
|
||||
assert_true(ckh_remove(tsd, &ckh, p[j], &q, &r),
|
||||
"Unexpected ckh_remove() success");
|
||||
}
|
||||
|
||||
|
|
@ -176,13 +188,13 @@ TEST_BEGIN(test_insert_iter_remove)
|
|||
for (i = 0; i < NITEMS; i++) {
|
||||
assert_false(ckh_search(&ckh, p[i], NULL, NULL),
|
||||
"Unexpected ckh_search() failure");
|
||||
assert_false(ckh_remove(&ckh, p[i], &q, &r),
|
||||
assert_false(ckh_remove(tsd, &ckh, p[i], &q, &r),
|
||||
"Unexpected ckh_remove() failure");
|
||||
assert_ptr_eq(p[i], q, "Key pointer mismatch");
|
||||
assert_ptr_eq(p[i], r, "Value pointer mismatch");
|
||||
assert_true(ckh_search(&ckh, p[i], NULL, NULL),
|
||||
"Unexpected ckh_search() success");
|
||||
assert_true(ckh_remove(&ckh, p[i], &q, &r),
|
||||
assert_true(ckh_remove(tsd, &ckh, p[i], &q, &r),
|
||||
"Unexpected ckh_remove() success");
|
||||
dallocx(p[i], 0);
|
||||
}
|
||||
|
|
@ -190,7 +202,7 @@ TEST_BEGIN(test_insert_iter_remove)
|
|||
assert_zu_eq(ckh_count(&ckh), 0,
|
||||
"ckh_count() should return %zu, but it returned %zu", ZU(0),
|
||||
ckh_count(&ckh));
|
||||
ckh_delete(&ckh);
|
||||
ckh_delete(tsd, &ckh);
|
||||
#undef NITEMS
|
||||
}
|
||||
TEST_END
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue