mirror of
https://github.com/ceph/ceph
synced 2025-03-07 00:40:00 +00:00
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:
parent
6ab35330e6
commit
9689fe0ae0
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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()
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user