Skip to content

Commit

Permalink
Add clarifying comment
Browse files Browse the repository at this point in the history
  • Loading branch information
serban300 committed Sep 9, 2024
1 parent 5b1b387 commit a8c3184
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/codec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,12 @@ pub trait Input {
fn ascend_ref(&mut self) {}

/// Hook that is called before allocating memory on the heap.
///
/// The aim is to get a reasonable approximation of memory usage, especially with variably
/// sized types like `Vec`s. Depending on the structure, it is acceptable to be off by a bit.
/// For example for structures like `BTreeMap` we don't track the memory used by the internal
/// tree nodes etc. Also we don't take alignment or memory layouts into account.
/// But we should always track the memory used by the decoded data inside the type.
fn on_before_alloc_mem(&mut self, _size: usize) -> Result<(), Error> {
Ok(())
}
Expand Down

0 comments on commit a8c3184

Please sign in to comment.