Skip to content

Commit

Permalink
fix: remove stack limiter, add explainer for MB conversion
Browse files Browse the repository at this point in the history
  • Loading branch information
mikirov committed Aug 24, 2023
1 parent 9929a9f commit edf67eb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 120 deletions.
7 changes: 6 additions & 1 deletion src/injecting/injections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,12 @@ fn inject_noops(module: &mut Module, function_name: &str, size: Option<i16>) ->
module.map_function(function_name, |func_body: &mut FuncBody| {
let code = func_body.code_mut();
let size = size.expect("No size given");
let nops_count = (size as usize) * 1024 * 1024;

// MB and MiB both represent digital storage units, whereas Mb refers to data transmission rates.
// MB is based on decimal prefixes (1 MB = 1,000,000 bytes), while MiB uses binary prefixes (1 MiB = 1,048,576 bytes).
// To convert between Megabytes and Mebibytes, one can use the conversion factor of 1 MB ≈ 0.9537 MiB
// That's why we multiply by 1000 instead of 1024
let nops_count = (size as usize) * 1000 * 1000;

let mut nops = vec![Instruction::Nop; nops_count];
nops.append(code.elements_mut());
Expand Down
1 change: 0 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
//! ```

pub mod injecting;
pub mod stack_limiter;
pub mod util;

pub use self::injecting::injections::Injection;
Expand Down
118 changes: 0 additions & 118 deletions src/stack_limiter.rs

This file was deleted.

0 comments on commit edf67eb

Please sign in to comment.