in common/rusty_leveldb_sgx/src/skipmap.rs [155:190]
fn get_next_smaller<'a>(&'a self, key: &[u8]) -> Option<&'a Node> {
// Start at the highest skip link of the head node, and work down from there
let mut current = self.head.as_ref() as *const Node;
let mut level = self.head.skips.len() - 1;
loop {
unsafe {
if let Some(next) = (*current).skips[level] {
let ord = self.cmp.cmp((*next).key.as_slice(), key);
match ord {
Ordering::Less => {
current = next;
continue;
}
_ => (),
}
}
}
if level == 0 {
break;
}
level -= 1;
}
unsafe {
if current.is_null() || current == self.head.as_ref() {
// If we're past the end for some reason or at the head
return None;
} else if self.cmp.cmp(&(*current).key, key) != Ordering::Less {
return None;
} else {
return Some(&(*current));
}
}
}