Cache bin: simplify names and argument ordering.

We always start with the cache bin, then its info (if necessary).
This commit is contained in:
David Goldblatt
2020-02-28 19:12:07 -08:00
committed by David Goldblatt
parent e1dcc557d6
commit ff6acc6ed5
5 changed files with 51 additions and 48 deletions

View File

@@ -23,12 +23,12 @@ TEST_BEGIN(test_cache_bin) {
"Incorrect cache size");
bool success;
void *ret = cache_bin_alloc_easy(bin, &success, &tcache_bin_info[0]);
void *ret = cache_bin_alloc_easy(bin, &tcache_bin_info[0], &success);
expect_false(success, "Empty cache bin should not alloc");
expect_true(cache_bin_low_water_get(bin, &tcache_bin_info[0]) == 0,
"Incorrect low water mark");
cache_bin_ncached_set(bin, 0, &tcache_bin_info[0]);
cache_bin_ncached_set(bin, &tcache_bin_info[0], 0);
expect_ptr_eq(bin->cur_ptr.ptr, empty_position, "Bin should be empty");
for (cache_bin_sz_t i = 1; i < ncached_max + 1; i++) {
success = cache_bin_dalloc_easy(bin, (void *)(uintptr_t)i);
@@ -39,12 +39,12 @@ TEST_BEGIN(test_cache_bin) {
expect_false(success, "Bin should be full");
expect_ptr_eq(bin->cur_ptr.ptr, stack, "Incorrect bin cur_ptr");
cache_bin_ncached_set(bin, ncached_max, &tcache_bin_info[0]);
cache_bin_ncached_set(bin, &tcache_bin_info[0], ncached_max);
expect_ptr_eq(bin->cur_ptr.ptr, stack, "cur_ptr should not change");
/* Emulate low water after refill. */
bin->low_water_position = bin->full_position;
for (cache_bin_sz_t i = ncached_max; i > 0; i--) {
ret = cache_bin_alloc_easy(bin, &success, &tcache_bin_info[0]);
ret = cache_bin_alloc_easy(bin, &tcache_bin_info[0], &success);
cache_bin_sz_t ncached = cache_bin_ncached_get(bin,
&tcache_bin_info[0]);
expect_true(success && ncached == i - 1,
@@ -54,7 +54,7 @@ TEST_BEGIN(test_cache_bin) {
== ncached, "Incorrect low water mark");
}
ret = cache_bin_alloc_easy(bin, &success, &tcache_bin_info[0]);
ret = cache_bin_alloc_easy(bin, &tcache_bin_info[0], &success);
expect_false(success, "Empty cache bin should not alloc.");
expect_ptr_eq(bin->cur_ptr.ptr, stack + ncached_max,
"Bin should be empty");