mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Reformat Zeek in Spicy style
This largely copies over Spicy's `.clang-format` configuration file. The one place where we deviate is header include order since Zeek depends on headers being included in a certain order.
This commit is contained in:
parent
7b8e7ed72c
commit
f5a76c1aed
786 changed files with 131714 additions and 153609 deletions
49
src/UID.cc
49
src/UID.cc
|
@ -9,39 +9,36 @@
|
|||
|
||||
using namespace std;
|
||||
|
||||
namespace zeek
|
||||
{
|
||||
namespace zeek {
|
||||
|
||||
void UID::Set(zeek_uint_t bits, const uint64_t* v, size_t n)
|
||||
{
|
||||
initialized = true;
|
||||
void UID::Set(zeek_uint_t bits, const uint64_t* v, size_t n) {
|
||||
initialized = true;
|
||||
|
||||
for ( size_t i = 0; i < UID_LEN; ++i )
|
||||
uid[i] = 0;
|
||||
for ( size_t i = 0; i < UID_LEN; ++i )
|
||||
uid[i] = 0;
|
||||
|
||||
if ( bits > UID_LEN * 64 )
|
||||
bits = UID_LEN * 64;
|
||||
if ( bits > UID_LEN * 64 )
|
||||
bits = UID_LEN * 64;
|
||||
|
||||
div_t res = div(bits, 64);
|
||||
size_t size = res.rem ? res.quot + 1 : res.quot;
|
||||
div_t res = div(bits, 64);
|
||||
size_t size = res.rem ? res.quot + 1 : res.quot;
|
||||
|
||||
for ( size_t i = 0; i < size; ++i )
|
||||
uid[i] = v && i < n ? v[i] : util::calculate_unique_id();
|
||||
for ( size_t i = 0; i < size; ++i )
|
||||
uid[i] = v && i < n ? v[i] : util::calculate_unique_id();
|
||||
|
||||
if ( res.rem )
|
||||
uid[0] >>= 64 - res.rem;
|
||||
}
|
||||
if ( res.rem )
|
||||
uid[0] >>= 64 - res.rem;
|
||||
}
|
||||
|
||||
std::string UID::Base62(std::string prefix) const
|
||||
{
|
||||
if ( ! initialized )
|
||||
reporter->InternalError("use of uninitialized UID");
|
||||
std::string UID::Base62(std::string prefix) const {
|
||||
if ( ! initialized )
|
||||
reporter->InternalError("use of uninitialized UID");
|
||||
|
||||
char tmp[sizeof(uid) * 8 + 1]; // enough for even binary representation
|
||||
for ( size_t i = 0; i < UID_LEN; ++i )
|
||||
prefix.append(util::uitoa_n(uid[i], tmp, sizeof(tmp), 62));
|
||||
char tmp[sizeof(uid) * 8 + 1]; // enough for even binary representation
|
||||
for ( size_t i = 0; i < UID_LEN; ++i )
|
||||
prefix.append(util::uitoa_n(uid[i], tmp, sizeof(tmp), 62));
|
||||
|
||||
return prefix;
|
||||
}
|
||||
return prefix;
|
||||
}
|
||||
|
||||
} // namespace zeek
|
||||
} // namespace zeek
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue