Mercurial > lbo > hg > leveldb-rs
changeset 541:18b686c68c1f
Update skipmap.rs
solve overflowed its stack
author | sonyshang <shangsong@buaa.edu.cn> |
---|---|
date | Thu, 02 Sep 2021 13:51:40 +0800 |
parents | 98819897a01e |
children | dd6737e643d4 aeebdeb1c5ec |
files | src/skipmap.rs |
diffstat | 1 files changed, 20 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/src/skipmap.rs Tue Jul 27 09:57:23 2021 +0200 +++ b/src/skipmap.rs Thu Sep 02 13:51:40 2021 +0800 @@ -20,6 +20,26 @@ 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