define roc_alloc and friends in cli/src/lib.rs on windows

This commit is contained in:
Folkert 2022-08-25 21:50:51 +02:00 committed by Brian Carroll
parent f2b2adb550
commit 1f778db26c
No known key found for this signature in database
GPG key ID: 9CF4E3BF9C4722C7

View file

@ -1191,3 +1191,37 @@ impl std::str::FromStr for Target {
}
}
}
#[cfg(windows)]
use windows_roc_platform_functions::*;
#[cfg(windows)]
mod windows_roc_platform_functions {
use core::ffi::c_void;
/// # Safety
/// The Roc application needs this.
#[no_mangle]
pub unsafe fn roc_alloc(size: usize, _alignment: u32) -> *mut c_void {
libc::malloc(size)
}
/// # Safety
/// The Roc application needs this.
#[no_mangle]
pub unsafe fn roc_realloc(
c_ptr: *mut c_void,
new_size: usize,
_old_size: usize,
_alignment: u32,
) -> *mut c_void {
libc::realloc(c_ptr, new_size)
}
/// # Safety
/// The Roc application needs this.
#[no_mangle]
pub unsafe fn roc_dealloc(c_ptr: *mut c_void, _alignment: u32) {
libc::free(c_ptr)
}
}