Skip to content

Commit

Permalink
Made the initial event_buffer size to a const
Browse files Browse the repository at this point in the history
Also removed the unnecessary event_buffer.clear(), since we are already
resizing it
  • Loading branch information
mzfr committed Dec 30, 2024
1 parent d43487a commit 6846f9d
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions libafl/src/events/llmp/mgr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ use crate::{
Error, HasMetadata,
};

/// Default initial capacity of the event buffer - 4KB
const INITIAL_EVENT_BUFFER_SIZE: usize = 1024 * 4;

/// An [`EventManager`] that forwards all events to other attached fuzzers on shared maps or via tcp,
/// using low-level message passing, `llmp`.
pub struct LlmpEventManager<EMH, S, SP>
Expand Down Expand Up @@ -166,7 +169,7 @@ impl<EMH> LlmpEventManagerBuilder<EMH> {
time_ref,
phantom: PhantomData,
custom_buf_handlers: vec![],
event_buffer: Vec::with_capacity(1024 * 4),
event_buffer: Vec::with_capacity(INITIAL_EVENT_BUFFER_SIZE),
})
}

Expand Down Expand Up @@ -201,7 +204,7 @@ impl<EMH> LlmpEventManagerBuilder<EMH> {
time_ref,
phantom: PhantomData,
custom_buf_handlers: vec![],
event_buffer: Vec::with_capacity(1024 * 4),
event_buffer: Vec::with_capacity(INITIAL_EVENT_BUFFER_SIZE),
})
}

Expand Down Expand Up @@ -236,7 +239,7 @@ impl<EMH> LlmpEventManagerBuilder<EMH> {
time_ref,
phantom: PhantomData,
custom_buf_handlers: vec![],
event_buffer: Vec::with_capacity(1024 * 4),
event_buffer: Vec::with_capacity(INITIAL_EVENT_BUFFER_SIZE),
})
}

Expand Down Expand Up @@ -269,7 +272,7 @@ impl<EMH> LlmpEventManagerBuilder<EMH> {
time_ref,
phantom: PhantomData,
custom_buf_handlers: vec![],
event_buffer: Vec::with_capacity(1024 * 4),
event_buffer: Vec::with_capacity(INITIAL_EVENT_BUFFER_SIZE),
})
}
}
Expand Down Expand Up @@ -526,7 +529,6 @@ where
#[cfg(feature = "llmp_compression")]
let flags = LLMP_FLAG_INITIALIZED;

self.event_buffer.clear();
self.event_buffer.resize(self.event_buffer.capacity(), 0);

// Serialize the event, reallocating event_buffer if needed
Expand Down

0 comments on commit 6846f9d

Please sign in to comment.