Skip to content

Commit 3492ef6

Browse files
committed
Remove if, assert() is sufficient.
1 parent d7361d6 commit 3492ef6

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
@@ -2967,22 +2967,20 @@ arena_map_mark_used(uintptr_t arena_base, int is_used)
29672967
* again (do the full tree traversal).
29682968
*/
29692969
n_hi->arenas[i3].tail_hi = is_used ? tail : 0;
2970-
uintptr_t arena_next = arena_base + ARENA_SIZE;
2971-
/* If arena_base is a legit arena address, so is arena_next - 1
2972-
* (last address in arena). If arena_next overflows then it
2970+
uintptr_t arena_base_next = arena_base + ARENA_SIZE;
2971+
/* If arena_base is a legit arena address, so is arena_base_next - 1
2972+
* (last address in arena). If arena_base_next overflows then it
29732973
* must overflow to 0. However, that would mean arena_base was
29742974
* "ideal" and we should not be in this case. */
2975-
assert(arena_base < arena_next);
2976-
if (arena_next > arena_base) {
2977-
arena_map3_t *n_lo = arena_map_get((block *)arena_next, is_used);
2978-
if (n_lo == NULL) {
2979-
assert(is_used); /* otherwise should already exist */
2980-
n_hi->arenas[i3].tail_hi = 0;
2981-
return 0; /* failed to allocate space for node */
2982-
}
2983-
int i3_next = MAP3_INDEX(arena_next);
2984-
n_lo->arenas[i3_next].tail_lo = is_used ? tail : 0;
2975+
assert(arena_base < arena_base_next);
2976+
arena_map3_t *n_lo = arena_map_get((block *)arena_base_next, is_used);
2977+
if (n_lo == NULL) {
2978+
assert(is_used); /* otherwise should already exist */
2979+
n_hi->arenas[i3].tail_hi = 0;
2980+
return 0; /* failed to allocate space for node */
29852981
}
2982+
int i3_next = MAP3_INDEX(arena_base_next);
2983+
n_lo->arenas[i3_next].tail_lo = is_used ? tail : 0;
29862984
}
29872985
return 1;
29882986
}

0 commit comments

Comments
 (0)