mem-pool: simplify alignment calculation

Use DIV_ROUND_UP in mem_pool_alloc() to round the allocation length to the next multiple of GIT_MAX_ALIGNMENT instead of twiddling bits explicitly. This is shorter and clearer, to the point that we no longer need the comment that explains what's being calculated. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

René Scharfe committed Dec 24, 2023 at 18:02 UTC c61740d6078b6da6219779844cfdd74ed430fb80
1 file changed +1 -3
mem-pool.c
+1 -3
@@ -89,9 +89,7 @@ void *mem_pool_alloc(struct mem_pool *pool, size_t len)
89 struct mp_block *p = NULL;
90 void *r;
91
92 - /* round up to a 'GIT_MAX_ALIGNMENT' alignment */
93 - if (len & (GIT_MAX_ALIGNMENT - 1))
94 - len += GIT_MAX_ALIGNMENT - (len & (GIT_MAX_ALIGNMENT - 1));
92 + len = DIV_ROUND_UP(len, GIT_MAX_ALIGNMENT) * GIT_MAX_ALIGNMENT;
93
94 if (pool->mp_block &&
95 pool->mp_block->end - pool->mp_block->next_free >= len)