From 64cb6068cfbf9fb981961a3b74db56ec7b63d8af Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Sat, 1 Feb 2025 00:44:32 +0000 Subject: [PATCH] Add an accessor for the `Allocator` that a `Dlmalloc` was constructed with --- src/dlmalloc.rs | 4 ++++ src/lib.rs | 6 ++++++ 2 files changed, 10 insertions(+) diff --git a/src/dlmalloc.rs b/src/dlmalloc.rs index 2649deb..36cfd4f 100644 --- a/src/dlmalloc.rs +++ b/src/dlmalloc.rs @@ -130,6 +130,10 @@ impl Dlmalloc { system_allocator, } } + + pub fn allocator(&self) -> &A { + &self.system_allocator + } } impl Dlmalloc { diff --git a/src/lib.rs b/src/lib.rs index f17e5db..0cb1e30 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -206,4 +206,10 @@ impl Dlmalloc { pub unsafe fn destroy(self) -> usize { self.0.destroy() } + + /// Get a reference the underlying [`Allocator`] that this `Dlmalloc` was + /// constructed with. + pub fn allocator(&self) -> &A { + self.0.allocator() + } }