vm: add alignment parameter to cache allocator

caches with object size N, where N is a power of two, will naturally
align their objects on N-byte boundaries.

all other caches will align to an 8-byte boundary by default.
This commit is contained in:
2023-02-06 20:41:40 +00:00
parent 109616ec30
commit 5c7bde4fdf
3 changed files with 27 additions and 7 deletions

View File

@@ -2,7 +2,9 @@
#define SOCKS_UTIL_H_
#include <stddef.h>
#include <stdbool.h>
extern void data_size_to_string(size_t value, char *out, size_t outsz);
static inline bool power_of_2(size_t x) { return (x > 0 && (x & (x - 1)) == 0); }
#endif