From 586d14c3ba787a149ccf85a69419c0701bd1b327 Mon Sep 17 00:00:00 2001 From: Nikhil Benesch Date: Fri, 11 Dec 2015 11:15:48 -0500 Subject: [PATCH] Restore original keybuf when iterating --- masstree_iterator.hh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/masstree_iterator.hh b/masstree_iterator.hh index 4b60208..3f1cb8e 100644 --- a/masstree_iterator.hh +++ b/masstree_iterator.hh @@ -50,6 +50,10 @@ class basic_table

::iterator ikey_type x[(MASSTREE_MAXKEYLEN + sizeof(ikey_type) - 1)/sizeof(ikey_type)]; char s[MASSTREE_MAXKEYLEN]; } keybuf_; + union { + ikey_type x[(MASSTREE_MAXKEYLEN + sizeof(ikey_type) - 1)/sizeof(ikey_type)]; + char s[MASSTREE_MAXKEYLEN]; + } keybuf2_; void advance(bool emit_equal = false); @@ -98,7 +102,10 @@ basic_table

::iterator::advance(bool emit_equal) { Str suffix; char suffixbuf[MASSTREE_MAXKEYLEN]; + memcpy(keybuf2_.s, keybuf_.s, sizeof(keybuf_)); + retry_root: + memcpy(keybuf_.s, keybuf2_.s, sizeof(keybuf2_)); ka_.unshift_all(); root = table_->root(); n = root->reach_leaf(ka_, v, *ti_);