luaur_reduce_cli/methods/
reducer_reallocate_statements.rs1use alloc::vec::Vec;
2
3use luaur_ast::records::ast_stat::AstStat;
4
5use crate::records::reducer::Reducer;
6
7impl Reducer {
8 pub fn reallocate_statements(&mut self, statements: &Vec<*mut AstStat>) -> *mut *mut AstStat {
18 let count = statements.len();
19 if count == 0 {
20 return core::ptr::null_mut();
21 }
22
23 let bytes = core::mem::size_of::<*mut AstStat>() * count;
24 let new_data = self.allocator.allocate(bytes) as *mut *mut AstStat;
25
26 unsafe {
27 core::ptr::copy_nonoverlapping(statements.as_ptr(), new_data, count);
28 }
29
30 new_data
31 }
32}
33
34pub fn reducer_reallocate_statements(
35 this: &mut Reducer,
36 statements: &Vec<*mut AstStat>,
37) -> *mut *mut AstStat {
38 this.reallocate_statements(statements)
39}