kv: fix string ctor usage

When constructing a string from a char* there is only a single
length argument, no offset.  The 3 argument variant we were using
was converting to a std::string first (an prematurely terminating
on \0).

Signed-off-by: Sage Weil <sage@redhat.com>
This commit is contained in:
Sage Weil 2015-11-09 13:40:41 -05:00
parent 6ab35330e6
commit 9689fe0ae0
3 changed files with 7 additions and 8 deletions

View File

@ -218,9 +218,9 @@ int KineticStore::split_key(string in_prefix, string *prefix, string *key)
// Fetch prefix and/or key directly from Slice
if (prefix)
*prefix = string(in_data, 0, prefix_len);
*prefix = string(in_data, prefix_len);
if (key)
*key = string(separator+1, 0, in_prefix.size()-prefix_len-1);
*key = string(separator+1, in_prefix.size()-prefix_len-1);
return 0;
}

View File

@ -275,12 +275,11 @@ int LevelDBStore::split_key(leveldb::Slice in, string *prefix, string *key)
if (prefix_len >= in.size())
return -EINVAL;
// Fetch prefix and/or key directly from Slice
if (prefix)
*prefix = string(in.data(), 0, prefix_len);
*prefix = string(in.data(), prefix_len);
if (key)
*key = string(separator+1, 0, in.size()-prefix_len-1);
return 0;
*key = string(separator+1, in.size() - prefix_len - 1);
return 0;
}
void LevelDBStore::compact()

View File

@ -342,9 +342,9 @@ int RocksDBStore::split_key(rocksdb::Slice in, string *prefix, string *key)
// Fetch prefix and/or key directly from Slice
if (prefix)
*prefix = string(in.data(), 0, prefix_len);
*prefix = string(in.data(), prefix_len);
if (key)
*key = string(separator+1, 0, in.size()-prefix_len-1);
*key = string(separator+1, in.size()-prefix_len-1);
return 0;
}