Skip to content

Commit 7fe48c5

Browse files
committed
Small adjustment
1 parent d2b2243 commit 7fe48c5

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

libc/src/__support/GPU/allocator.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,13 +433,15 @@ static Slab *find_slab(uint32_t chunk_size) {
433433
lane_mask, cpp::countr_zero(available & uniform), candidate);
434434

435435
// Each uniform group will use the first empty slot they find.
436-
if (offset >= ARRAY_SIZE ||
437-
(index == cpp::numeric_limits<uint32_t>::max() &&
436+
if ((index == cpp::numeric_limits<uint32_t>::max() &&
438437
(available & uniform)))
439438
index = new_index;
440439

441-
if (offset >= ARRAY_SIZE)
440+
// Guaruntees that this loop will eventuall exit if there is no space.
441+
if (offset >= ARRAY_SIZE) {
442442
result = reinterpret_cast<Slab *>(SENTINEL);
443+
index = 0;
444+
}
443445
}
444446

445447
// Try to claim a slot for the found slot.

0 commit comments

Comments
 (0)