Co-authored-by: morgan.szygenda <morgan.szygenda@scle.fr>
This commit is contained in:
parent
cda80854eb
commit
d386bb96b0
|
|
@ -40,16 +40,14 @@ const std::chrono::high_resolution_clock::time_point etcdv3::Action::startTimepo
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string etcdv3::detail::string_plus_one(std::string const &value) {
|
std::string etcdv3::detail::string_plus_one(std::string const &value) {
|
||||||
// referred from the Go implementation in etcd.
|
// Referred from the Go implementation in etcd.
|
||||||
char *s = static_cast<char *>(calloc(value.size() + 1, sizeof(char)));
|
for (int32_t i = value.size() - 1; i >= 0; --i) {
|
||||||
std::memcpy(s, value.c_str(), value.size());
|
if (static_cast<unsigned char>(value[i]) < 0xff) {
|
||||||
for (int i = value.size() - 1; i >= 0; --i) {
|
std::string s = value.substr(0, i + 1);
|
||||||
if (static_cast<unsigned char>(s[i]) < 0xff) {
|
|
||||||
s[i] = s[i] + 1;
|
s[i] = s[i] + 1;
|
||||||
std::string ret = std::string(s, i + 1);
|
return s;
|
||||||
free(s);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {etcdv3::NUL};
|
return {etcdv3::NUL};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue