lib.rs
Rust builds heap Layout from computed size
SHA-2569ff8a566d4bab2ad52e04428e8a4d51bfaae34863fb9668d9b536d4a99b33278
MaleculeH(Mg)
Evidence
1mod counter;
2
3use std::{
4 alloc::{GlobalAlloc, Layout},
5 marker::PhantomData,
6 ops::{Add, AddAssign},
7};
8
9use self::counter::{add, flush, get, remove, update};
10
11#[derive(Default, Clone, Debug)]
12pub struct AllocationInfo {
13 pub allocations: usize,
14 pub deallocati …
35:37… sub(self.deallocations)
36 }
37}
38
39impl Add<Self> for AllocationInfo {
40 type Output = Self;
41
42 fn add(self, other: Self) -> Self {
43 Self …
79:2… }
80}
81
82/// Turbo's preferred global allocator. This is a new type instead of a type
83/// alias because you can't use type aliases to instantiate uni …
84:12… TurboMalloc;
85
86impl TurboMalloc {
87 // Returns the current amount of memory
88 pub fn memory_usage() -> usize {
89 get()
90 }
91
92 pub fn t …
152:7… // `layout.align()` comes from a `Layout` and is thus guaranteed to be valid.
153 let new_layout = unsafe { Layout::from_size_align_unchecked(new_size, layout.align()) };
154 let new_size = unsafe { base_alloc_size(ret, new_layout) };
155 update(old_size …