diff options
Diffstat (limited to 'src/fastd.h')
-rw-r--r-- | src/fastd.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/fastd.h b/src/fastd.h index c24781f..2c3de6a 100644 --- a/src/fastd.h +++ b/src/fastd.h @@ -407,8 +407,12 @@ static inline int fastd_rand(fastd_context_t *ctx, int min, int max) { (type *)( (char *)__mptr - offsetof(type,member) );}) +static inline size_t block_count(size_t l, size_t a) { + return (l+a-1)/a; +} + static inline size_t alignto(size_t l, size_t a) { - return ((l+a-1)/a)*a; + return block_count(l, a)*a; } static inline fastd_buffer_t fastd_buffer_alloc(const fastd_context_t *ctx, size_t len, size_t head_space, size_t tail_space) { |