scratch.cpp
· 436 B · C++
Raw
inline Arena *get_scratch(Arena **conflicts, u64 count) {
if (!g_thread_ctx.scratch_arenas[0]) {
thread_ctx_init();
}
for (u64 i = 0; i < 2; i++) {
bool has_conflict = false;
for (u64 j = 0; j < count; j++) {
if (g_thread_ctx.scratch_arenas[i] == conflicts[j]) {
has_conflict = true;
break;
}
}
if (!has_conflict) {
return g_thread_ctx.scratch_arenas[i];
}
}
TRAP();
}
| 1 | inline Arena *get_scratch(Arena **conflicts, u64 count) { |
| 2 | if (!g_thread_ctx.scratch_arenas[0]) { |
| 3 | thread_ctx_init(); |
| 4 | } |
| 5 | for (u64 i = 0; i < 2; i++) { |
| 6 | bool has_conflict = false; |
| 7 | for (u64 j = 0; j < count; j++) { |
| 8 | if (g_thread_ctx.scratch_arenas[i] == conflicts[j]) { |
| 9 | has_conflict = true; |
| 10 | break; |
| 11 | } |
| 12 | } |
| 13 | if (!has_conflict) { |
| 14 | return g_thread_ctx.scratch_arenas[i]; |
| 15 | } |
| 16 | } |
| 17 | TRAP(); |
| 18 | } |