changeset 549:8cf7d6fba366

#12: Delete custom drop implementation, which caused memory leaks
author Lewin Bormann <lbo@spheniscida.de>
date Sun, 06 Mar 2022 20:13:10 +0100
parents cb5111b68cf1
children faa58d765e30
files src/skipmap.rs
diffstat 1 files changed, 1 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/src/skipmap.rs	Sat Mar 05 22:50:12 2022 +0100
+++ b/src/skipmap.rs	Sun Mar 06 20:13:10 2022 +0100
@@ -20,26 +20,6 @@
     value: Vec<u8>,
 }
 
-impl Drop for Node {
-    fn drop(&mut self) {
-        // large object should drop
-        if let Some(mut next) = self.next.take() {
-            while let Some(child) = next.next.take() {
-                next = child;
-            }
-        }
-        unsafe {
-            for skip in self.skips.iter_mut() {
-                if let Some(mut next) = skip.take() {
-                    while let Some(child) = (*next).next.take() {
-                        next = Box::into_raw(child);
-                    }
-                }
-            }
-        }
-    }
-}
-
 /// Implements the backing store for a `MemTable`. The important methods are `insert()` and
 /// `contains()`; in order to get full key and value for an entry, use a `SkipMapIter` instance,
 /// `seek()` to the key to look up (this is as fast as any lookup in a skip map), and then call
@@ -253,7 +233,7 @@
         }
 
         // Construct new node
-        let mut new_skips = Vec::with_capacity(new_height);
+        let mut new_skips = Vec::new();
         new_skips.resize(new_height, None);
         let mut new = Box::new(Node {
             skips: new_skips,