Skip to content

Commit

Permalink
Restore original keybuf when iterating
Browse files Browse the repository at this point in the history
  • Loading branch information
benesch committed Dec 11, 2015
1 parent fb84cf6 commit 586d14c
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions masstree_iterator.hh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class basic_table<P>::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);

Expand Down Expand Up @@ -98,7 +102,10 @@ basic_table<P>::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_);
Expand Down

0 comments on commit 586d14c

Please sign in to comment.