"last question, for my library..." <- > <@ragarnoy:matrix.org> last question, for my library, the hal also requires an alloc and free function, any tips on how to handle it and how to give a static evaluated pool size ? > The signature as always is inflexible so no context can be passed... > This is my current super naive impl but the size is fixed: > > ```rs > static mut MEM: [u8; 42 * 1024] = [0; 42 * 1024]; > unsafe extern "C" fn mem_alloc(size: usize) -> *mut c_void { > let ptr = MEM.as_mut_ptr(); > let mut ptr = ptr.add(size); > ptr = ptr.offset(-(size as isize)); > ptr as *mut c_void > } > > unsafe extern "C" fn mem_free(ptr: *mut c_void) { > let ptr = ptr as *mut u8; > let size = MEM.as_mut_ptr().offset_from(ptr) as usize; > core::ptr::write_bytes(ptr, 0, size); > } > ``` > any idea ? This impl doesn't look right btw