From 88a3a585e701ffa0ad7747b485327bfbba98f2fb Mon Sep 17 00:00:00 2001 From: Nilstrieb <48135649+Nilstrieb@users.noreply.github.com> Date: Fri, 31 Dec 2021 17:35:16 +0100 Subject: [PATCH] free interned strings --- src/gc.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/gc.rs b/src/gc.rs index e5019f9..9098445 100644 --- a/src/gc.rs +++ b/src/gc.rs @@ -148,6 +148,17 @@ impl RtAlloc { } } +impl Drop for RtAlloc { + fn drop(&mut self) { + // free all interned strings + for str in &self.symbols { + let raw = str.0.as_ptr(); + // SAFETY: No one has free these, see `Gc` + let _ = unsafe { Box::from_raw(raw) }; + } + } +} + impl Symbol { pub fn new(gc: Gc) -> Self { Self { gc }