free interned strings

This commit is contained in:
nora 2021-12-31 17:35:16 +01:00
parent 6215924049
commit 88a3a585e7

View file

@ -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<T>`
let _ = unsafe { Box::from_raw(raw) };
}
}
}
impl Symbol {
pub fn new(gc: Gc<str>) -> Self {
Self { gc }