From 3fe1e7ca64bcd3724b00cf399ed9ae6f60e0a008 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Wed, 22 Nov 2023 16:52:33 -0500 Subject: alloc: New is_aligned() helper --- src/alloc.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/alloc.h') 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 +/** 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); -- cgit v1.2.3