Skip to content

Commit 1e8297a

Browse files
committed
Remove if, assert() is sufficient.
1 parent b33d636 commit 1e8297a

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

Objects/obmalloc.c

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2973,22 +2973,20 @@ arena_map_mark_used(uintptr_t arena_base, int is_used)
29732973
* again (do the full tree traversal).
29742974
*/
29752975
n_hi->arenas[i3].tail_hi = is_used ? tail : 0;
2976-
uintptr_t arena_next = arena_base + ARENA_SIZE;
2977-
/* If arena_base is a legit arena address, so is arena_next - 1
2978-
* (last address in arena). If arena_next overflows then it
2976+
uintptr_t arena_base_next = arena_base + ARENA_SIZE;
2977+
/* If arena_base is a legit arena address, so is arena_base_next - 1
2978+
* (last address in arena). If arena_base_next overflows then it
29792979
* must overflow to 0. However, that would mean arena_base was
29802980
* "ideal" and we should not be in this case. */
2981-
assert(arena_base < arena_next);
2982-
if (arena_next > arena_base) {
2983-
arena_map3_t *n_lo = arena_map_get((block *)arena_next, is_used);
2984-
if (n_lo == NULL) {
2985-
assert(is_used); /* otherwise should already exist */
2986-
n_hi->arenas[i3].tail_hi = 0;
2987-
return 0; /* failed to allocate space for node */
2988-
}
2989-
int i3_next = MAP3_INDEX(arena_next);
2990-
n_lo->arenas[i3_next].tail_lo = is_used ? tail : 0;
2981+
assert(arena_base < arena_base_next);
2982+
arena_map3_t *n_lo = arena_map_get((block *)arena_base_next, is_used);
2983+
if (n_lo == NULL) {
2984+
assert(is_used); /* otherwise should already exist */
2985+
n_hi->arenas[i3].tail_hi = 0;
2986+
return 0; /* failed to allocate space for node */
29912987
}
2988+
int i3_next = MAP3_INDEX(arena_base_next);
2989+
n_lo->arenas[i3_next].tail_lo = is_used ? tail : 0;
29922990
}
29932991
return 1;
29942992
}

0 commit comments

Comments
 (0)