1
1
Fork 0
mirror of https://github.com/oxen-io/lokinet synced 2023-12-14 06:53:00 +01:00

don't use exp2 when allocating memory :D

This commit is contained in:
Jeff Becker 2018-02-18 13:22:10 -05:00
parent 3e4fe88b26
commit 3bcc5604a6
No known key found for this signature in database
GPG key ID: F357B3B42F6F9B05

View file

@ -5,7 +5,14 @@
namespace llarp {
template <typename T>
static constexpr size_t alignment() {
return std::exp2(1 + std::floor(std::log2(sizeof(T))));
size_t idx = 0;
size_t sz = sizeof(T);
while(sz)
{
++idx;
sz >>= 1;
}
return 1 << idx;
}
template <typename T>