(sz: c_uint)
| 187 | |
| 188 | #[inline] |
| 189 | pub unsafe fn lean_alloc_ctor_memory(sz: c_uint) -> *mut lean_object { |
| 190 | if LEAN_SMALL_ALLOCATOR { |
| 191 | let sz1 = lean_align(sz as usize, LEAN_OBJECT_SIZE_DELTA) as c_uint; |
| 192 | let slot_idx = lean_get_slot_idx(sz1); |
| 193 | debug_assert!(sz1 <= LEAN_MAX_SMALL_OBJECT_SIZE); |
| 194 | let r = lean_alloc_small(sz1, slot_idx); |
| 195 | if sz1 > sz { |
| 196 | //TODO: "two structurally equal objects"? |
| 197 | /* Initialize last word. |
| 198 | In our runtime `lean_object_byte_size` is always |
| 199 | a multiple of the machine word size for constructors. |
| 200 | |
| 201 | By setting the last word to 0, we make sure the sharing |
| 202 | maximizer procedures at `maxsharing.cpp` and `compact.cpp` are |
| 203 | not affected by uninitialized data at the (sz1 - sz) last bytes. |
| 204 | Otherwise, we may mistakenly assume to structurally equal |
| 205 | objects are not identical because of this uninitialized memory. */ |
| 206 | let end = (r as *mut u8).add(sz1 as usize) as *mut usize; |
| 207 | *end.sub(1) = 0; |
| 208 | } |
| 209 | r as *mut lean_object |
| 210 | } else if LEAN_MIMALLOC { |
| 211 | let sz1 = lean_align(sz as usize, LEAN_OBJECT_SIZE_DELTA) as c_uint; |
| 212 | let r = lean_alloc_small_object(sz1); |
| 213 | if sz1 > sz { |
| 214 | *r.byte_add(sz1 as usize).cast::<usize>().sub(1) = 0; |
| 215 | } |
| 216 | r |
| 217 | } else { |
| 218 | lean_alloc_small_object(sz) |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | #[inline(always)] |
| 223 | pub unsafe fn lean_small_object_size(o: *mut lean_object) -> c_uint { |
no test coverage detected