luaur_code_gen/functions/
free_pages_impl_code_allocator.rs1use crate::functions::free_pages_impl_code_allocator_alt_b::free_pages_impl_mut;
2use crate::macros::codegen_assert::CODEGEN_ASSERT;
3
4#[allow(non_snake_case)]
5pub fn free_pages_impl(mem: *mut u8, size: usize) {
6 CODEGEN_ASSERT!(
7 size == crate::records::code_allocator::CodeAllocator::align_to_page_size(size)
8 );
9
10 #[cfg(target_os = "windows")]
11 {
12 use core::ffi::c_void;
13 use windows_sys::Win32::System::Memory::{VirtualFree, MEM_RELEASE};
14
15 unsafe {
16 if VirtualFree(mem as *mut c_void, 0, MEM_RELEASE) == 0 {
17 CODEGEN_ASSERT!(false);
18 }
19 }
20 }
21 #[cfg(not(target_os = "windows"))]
22 {
23 free_pages_impl_mut(mem, size);
24 }
25}