Skip to content

Commit

Permalink
#12: Delete custom drop implementation, which caused memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
dermesser committed Mar 6, 2022
1 parent ad2bdb4 commit c31e1f0
Showing 1 changed file with 1 addition and 21 deletions.
22 changes: 1 addition & 21 deletions src/skipmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,6 @@ struct Node {
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
Expand Down Expand Up @@ -253,7 +233,7 @@ impl InnerSkipMap {
}

// 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,
Expand Down

0 comments on commit c31e1f0

Please sign in to comment.