Commit 61e6c39d authored by Michal 'vorner' Vaner's avatar Michal 'vorner' Vaner
Browse files

[2836] Update Id generation

Use bigger type, check it never overflows.
parent 598d81ec
......@@ -16,6 +16,8 @@
#include <boost/lexical_cast.hpp>
#include <cassert>
namespace isc {
namespace datasrc {
namespace memory {
......@@ -23,9 +25,13 @@ namespace detail {
std::string
getNextHolderName() {
static size_t index = 0;
static uint64_t index = 0;
++index;
// in practice we should be able to assume this, uint64 is large
// and should not overflow
assert(index != 0);
return ("Segment object holder auto name " +
boost::lexical_cast<std::string>(index ++));
boost::lexical_cast<std::string>(index));
}
}
......
......@@ -27,9 +27,10 @@ namespace detail {
// Internal function to get next yet unused name of segment holder.
// We need the names of holders to be unique per segment at any given
// momemnt. This just keeps incrementing number after a prefix with
// each call, it should be enough (the holder should no longer be
// alive when the counter wraps around, if that ever happens with
// presumably 64bit counters).
// each call, it should be enough (we assert it does not wrap around,
// but 64bits should be enough).
//
// Also, it is not thread safe.
std::string
getNextHolderName();
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment