summaryrefslogtreecommitdiffstats
path: root/src/alloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/alloc.h')
-rw-r--r--src/alloc.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/alloc.h b/src/alloc.h
index 34f6949..15e4983 100644
--- a/src/alloc.h
+++ b/src/alloc.h
@@ -11,6 +11,11 @@
#include "config.h"
#include <stdlib.h>
+/** Check if a size is properly aligned. */
+static inline bool is_aligned(size_t align, size_t size) {
+ return (size & (align - 1)) == 0;
+}
+
/** Round down to a multiple of an alignment. */
static inline size_t align_floor(size_t align, size_t size) {
return size & ~(align - 1);