Skip to main content

luaur_code_gen/methods/
code_allocator_free_pages.rs

1use crate::functions::free_pages_impl_code_allocator::free_pages_impl;
2use crate::records::code_allocator::CodeAllocator;
3
4impl CodeAllocator {
5    pub fn free_pages(&self, mem: *mut u8, size: usize) {
6        unsafe {
7            let page_aligned_size = CodeAllocator::align_to_page_size(size);
8
9            if let Some(callback) = self.allocation_callback {
10                callback(
11                    self.allocation_callback_context,
12                    mem.cast(),
13                    page_aligned_size,
14                    core::ptr::null_mut(),
15                    0,
16                );
17            }
18
19            free_pages_impl(mem, page_aligned_size);
20        }
21    }
22}