| ... | ... | @@ -358,14 +358,16 @@ fn alloc(ctx: *anyopaque, n: usize, alignment: Alignment, ret_addr: usize) ?[*]u |
| 358 | 358 | const end_index = @atomicRmw(usize, &node.end_index, .Add, alignable, .acquire); // acquire any memory that may have been freed |
| 359 | 359 | const aligned_index = alignedIndex(buf.ptr, end_index, alignment); |
| 360 | 360 | assert(end_index + alignable >= aligned_index + n); |
| 361 | | _ = @cmpxchgStrong( |
| 362 | | usize, |
| 363 | | &node.end_index, |
| 364 | | end_index + alignable, |
| 365 | | aligned_index + n, |
| 366 | | .monotonic, // no need to release alignment padding; there's no one accessing it! |
| 367 | | .monotonic, |
| 368 | | ); |
| 361 | if (end_index + alignable != aligned_index + n) { |
| 362 | _ = @cmpxchgStrong( |
| 363 | usize, |
| 364 | &node.end_index, |
| 365 | end_index + alignable, |
| 366 | aligned_index + n, |
| 367 | .monotonic, // no need to release alignment padding; there's no one accessing it! |
| 368 | .monotonic, |
| 369 | ); |
| 370 | } |
| 369 | 371 | |
| 370 | 372 | if (aligned_index + n > buf.len) break :first_node .{ node, buf.len }; |
| 371 | 373 | return buf[aligned_index..][0..n].ptr; |