MCPcopy Create free account
hub / github.com/MultiFuzz/MultiFuzz / init_coverage_array

Function init_coverage_array

hail-fuzz/src/coverage.rs:117–127  ·  view source on GitHub ↗

Create a zero initialized coverage array on the heap (note: we do this instead of directly initializing the value [0; _], to avoid excess stack usage in debug mode).

()

Source from the content-addressed store, hash-verified

115/// Create a zero initialized coverage array on the heap (note: we do this instead of directly
116/// initializing the value [0; _], to avoid excess stack usage in debug mode).
117fn init_coverage_array() -> Box<[u64; MAP_SIZE / 8]> {
118 let layout = std::alloc::Layout::new::<[u64; MAP_SIZE / 8]>();
119 // Safety: `layout` has a non-zero size and `[u64; _]` is valid when zero initializated.
120 unsafe {
121 let ptr: *mut [u64; MAP_SIZE / 8] = std::alloc::alloc_zeroed(layout).cast();
122 if ptr.is_null() {
123 panic!("failed to allocate {} bytes for coverage array.", layout.size())
124 }
125 Box::from_raw(ptr)
126 }
127}
128
129type EdgeCountSnapshot = Vec<u8>;
130

Callers 1

with_strategyMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected