Skip to content

Commit 3f47c2c

Browse files
Barnadrotclaude
andcommitted
fmt: cargo fmt on zk-alloc
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 3b7c691 commit 3f47c2c

2 files changed

Lines changed: 3 additions & 9 deletions

File tree

crates/zk-alloc/src/lib.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::alloc::{GlobalAlloc, Layout};
22
use std::cell::Cell;
3-
use std::sync::atomic::{AtomicUsize, Ordering};
43
use std::sync::Once;
4+
use std::sync::atomic::{AtomicUsize, Ordering};
55

66
mod syscall;
77

@@ -78,9 +78,7 @@ unsafe fn arena_alloc_cold(size: usize, align: usize) -> *mut u8 {
7878
if idx >= MAX_THREADS {
7979
ARENA_BASE.set(1); // sentinel: this thread has no slab
8080
// SAFETY: size and align are from a valid Layout (caller contract).
81-
return unsafe {
82-
std::alloc::System.alloc(Layout::from_size_align_unchecked(size, align))
83-
};
81+
return unsafe { std::alloc::System.alloc(Layout::from_size_align_unchecked(size, align)) };
8482
}
8583
let slab_base = region + idx * SLAB_SIZE;
8684
ARENA_BASE.set(slab_base);

crates/zk-alloc/src/syscall.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,7 @@ unsafe fn syscall3(nr: usize, a1: usize, a2: usize, a3: usize) -> isize {
5959
pub unsafe fn mmap_anonymous(size: usize, hugetlb: bool) -> *mut u8 {
6060
let flags = MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | if hugetlb { MAP_HUGETLB } else { 0 };
6161
let ret = unsafe { syscall6(SYS_MMAP, 0, size, PROT_READ | PROT_WRITE, flags, usize::MAX, 0) };
62-
if ret < 0 {
63-
ptr::null_mut()
64-
} else {
65-
ret as *mut u8
66-
}
62+
if ret < 0 { ptr::null_mut() } else { ret as *mut u8 }
6763
}
6864

6965
#[inline]

0 commit comments

Comments
 (0)