diff options
author | Jason Evans <jasone@canonware.com> | 2014-10-06 00:54:10 (GMT) |
---|---|---|
committer | Jason Evans <jasone@canonware.com> | 2014-10-06 08:45:13 (GMT) |
commit | 155bfa7da18cab0d21d87aa2dce4554166836f5d (patch) | |
tree | 4689fe0ec9481715084fb8a84204d36d471c3b14 /test/unit/junk.c | |
parent | 3c3b3b1a94705c8019b973fb679dd99bd19305af (diff) | |
download | jemalloc-155bfa7da18cab0d21d87aa2dce4554166836f5d.zip jemalloc-155bfa7da18cab0d21d87aa2dce4554166836f5d.tar.gz jemalloc-155bfa7da18cab0d21d87aa2dce4554166836f5d.tar.bz2 |
Normalize size classes.
Normalize size classes to use the same number of size classes per size
doubling (currently hard coded to 4), across the intire range of size
classes. Small size classes already used this spacing, but in order to
support this change, additional small size classes now fill [4 KiB .. 16
KiB). Large size classes range from [16 KiB .. 4 MiB). Huge size
classes now support non-multiples of the chunk size in order to fill (4
MiB .. 16 MiB).
Diffstat (limited to 'test/unit/junk.c')
-rw-r--r-- | test/unit/junk.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/test/unit/junk.c b/test/unit/junk.c index 301428f..5b35a87 100644 --- a/test/unit/junk.c +++ b/test/unit/junk.c @@ -88,7 +88,6 @@ test_junk(size_t sz_min, size_t sz_max) if (xallocx(s, sz+1, 0, 0) == sz) { void *junked = (void *)s; - s = (char *)rallocx(s, sz+1, 0); assert_ptr_not_null((void *)s, "Unexpected rallocx() failure"); @@ -134,13 +133,25 @@ TEST_END arena_ralloc_junk_large_t *arena_ralloc_junk_large_orig; static void *most_recently_trimmed; +static size_t +shrink_size(size_t size) +{ + size_t shrink_size; + + for (shrink_size = size - 1; nallocx(shrink_size, 0) == size; + shrink_size--) + ; /* Do nothing. */ + + return (shrink_size); +} + static void arena_ralloc_junk_large_intercept(void *ptr, size_t old_usize, size_t usize) { arena_ralloc_junk_large_orig(ptr, old_usize, usize); assert_zu_eq(old_usize, arena_maxclass, "Unexpected old_usize"); - assert_zu_eq(usize, arena_maxclass-PAGE, "Unexpected usize"); + assert_zu_eq(usize, shrink_size(arena_maxclass), "Unexpected usize"); most_recently_trimmed = ptr; } @@ -154,7 +165,7 @@ TEST_BEGIN(test_junk_large_ralloc_shrink) arena_ralloc_junk_large_orig = arena_ralloc_junk_large; arena_ralloc_junk_large = arena_ralloc_junk_large_intercept; - p2 = rallocx(p1, arena_maxclass-PAGE, 0); + p2 = rallocx(p1, shrink_size(arena_maxclass), 0); assert_ptr_eq(p1, p2, "Unexpected move during shrink"); arena_ralloc_junk_large = arena_ralloc_junk_large_orig; |