(sz: c_uint)
| 154 | |
| 155 | #[inline] |
| 156 | pub unsafe fn lean_alloc_small_object(sz: c_uint) -> *mut lean_object { |
| 157 | if LEAN_SMALL_ALLOCATOR { |
| 158 | let sz = lean_align(sz as usize, LEAN_OBJECT_SIZE_DELTA) as c_uint; |
| 159 | let slot_idx = lean_get_slot_idx(sz); |
| 160 | debug_assert!(sz <= LEAN_MAX_SMALL_OBJECT_SIZE); |
| 161 | lean_alloc_small(sz, slot_idx).cast() |
| 162 | } else { |
| 163 | lean_inc_heartbeat(); |
| 164 | if LEAN_MIMALLOC { |
| 165 | // HACK: emulate behavior of small allocator to avoid `leangz` breakage for now |
| 166 | let sz = lean_align(sz as usize, LEAN_OBJECT_SIZE_DELTA) as c_uint; |
| 167 | #[cfg(feature = "libmimalloc-sys")] |
| 168 | let mem = libmimalloc_sys::mi_malloc_small(sz as usize); |
| 169 | #[cfg(not(feature = "libmimalloc-sys"))] |
| 170 | let mem = core::ptr::null_mut::<c_void>(); |
| 171 | if mem.is_null() { |
| 172 | lean_internal_panic_out_of_memory() |
| 173 | } |
| 174 | let o = mem.cast::<lean_object>(); |
| 175 | (*o).m_cs_sz = sz as u16; |
| 176 | o |
| 177 | } else { |
| 178 | let mem = libc::malloc(size_of::<usize>() + sz as usize) as *mut usize; |
| 179 | if mem.is_null() { |
| 180 | lean_internal_panic_out_of_memory() |
| 181 | } |
| 182 | *mem = sz as usize; |
| 183 | mem.add(1).cast() |
| 184 | } |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | #[inline] |
| 189 | pub unsafe fn lean_alloc_ctor_memory(sz: c_uint) -> *mut lean_object { |
no test coverage detected