improve memory allocation logic
This commit is contained in:
@@ -24,8 +24,7 @@ dynrdat* rdat = NULL;
|
|||||||
|
|
||||||
static inline ull pow2_ceil(ull x) {
|
static inline ull pow2_ceil(ull x) {
|
||||||
x -= !!x; // if x=0, remains 0; else x -= 1
|
x -= !!x; // if x=0, remains 0; else x -= 1
|
||||||
int lz = __builtin_clzll(x | 1); // get leading zeroes
|
return 1ULL << ((sizeof(ull) * 8) - __builtin_clzll(x | 1));
|
||||||
return (~0ULL >> lz) + 1; // bit-shift the maximum value by this amount of leading zeroes
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void quit(void) {
|
static void quit(void) {
|
||||||
|
|||||||
Reference in New Issue
Block a user