aboutsummaryrefslogtreecommitdiff
path: root/src/batch.rs
diff options
context:
space:
mode:
authorSimon Thoby <git@nightmared.fr>2023-02-26 00:09:39 +0100
committerSimon Thoby <git@nightmared.fr>2023-02-26 00:09:39 +0100
commite5c2b423473bb147763c8f6a73aec73212980e4b (patch)
tree456763343d97fba976f9c3aa69033ad3dfa5e999 /src/batch.rs
parentc7ef0c961cc8c7a7955754a55df3118c74e8bef7 (diff)
reduce the amount of unsafe code
Diffstat (limited to 'src/batch.rs')
-rw-r--r--src/batch.rs1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/batch.rs b/src/batch.rs
index b5c88b8..980194b 100644
--- a/src/batch.rs
+++ b/src/batch.rs
@@ -33,6 +33,7 @@ impl Batch {
pub fn new() -> Self {
// TODO: use a pinned Box ?
let mut buf = Box::new(Vec::with_capacity(default_batch_page_size() as usize));
+ // Safe because we hold onto the buffer for as long as `writer` exists
let mut writer = NfNetlinkWriter::new(unsafe {
std::mem::transmute(Box::as_mut(&mut buf) as *mut Vec<u8>)
});