Skip to content

Instantly share code, notes, and snippets.

@tizoc
Created July 31, 2011 22:00
Show Gist options
  • Save tizoc/1117261 to your computer and use it in GitHub Desktop.
Save tizoc/1117261 to your computer and use it in GitHub Desktop.
bool level_db_get(leveldb::DB *db,
const leveldb::ReadOptions *options,
const leveldb::Slice *key,
char **value,
size_t *n) {
std::string result;
leveldb::Status status = db->Get(*options, *key, &result);
if (status.IsNotFound()) {
return false;
} else {
assert(status.ok());
*n = result.size();
*value = malloc(*n * sizeof(char));
memcpy(*value, result.data(), *n);
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment