version 0.21.16:
src/frame/element_wise_helper.rs
pub struct TempBuffer {
pub layout: Layout,
pub buffer: *mut u8,
}
impl Default for TempBuffer {
fn default() -> Self {
TempBuffer { layout: Layout::new::<()>(), buffer: std::ptr::null_mut() }
}
}
impl TempBuffer {
pub fn ensure(&mut self, size: usize, alignment: usize) {
unsafe {
if size > self.layout.size() || alignment > self.layout.align() {
let size = size.max(self.layout.size());
let alignment = alignment.max(self.layout.align());
if !self.buffer.is_null() {
std::alloc::dealloc(self.buffer, self.layout);
}
self.layout = Layout::from_size_align_unchecked(size, alignment);
self.buffer = std::alloc::alloc(self.layout);
assert!(!self.buffer.is_null());
}
}
}
}
For the function ensure, std::alloc::dealloc requires:
However, public field layout and buffer make it hard to hold these requirements.
If you want, I can submit a PR for this and along with #1871
version 0.21.16:
src/frame/element_wise_helper.rs
For the function
ensure, std::alloc::dealloc requires:memory.
Reference: https://doc.rust-lang.org/alloc/alloc/trait.GlobalAlloc.html#tymethod.dealloc
However, public field layout and buffer make it hard to hold these requirements.
If you want, I can submit a PR for this and along with #1871