Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Adam Osuchowski
Kea
Commits
61e6c39d
Commit
61e6c39d
authored
May 15, 2013
by
Michal 'vorner' Vaner
Browse files
[2836] Update Id generation
Use bigger type, check it never overflows.
parent
598d81ec
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/lib/datasrc/memory/segment_object_holder.cc
View file @
61e6c39d
...
...
@@ -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
));
}
}
...
...
src/lib/datasrc/memory/segment_object_holder.h
View file @
61e6c39d
...
...
@@ -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
();
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment