diff --git a/lwmem/src/include/lwmem/lwmem_opt.h b/lwmem/src/include/lwmem/lwmem_opt.h index 0b135e0..4465f3f 100644 --- a/lwmem/src/include/lwmem/lwmem_opt.h +++ b/lwmem/src/include/lwmem/lwmem_opt.h @@ -82,7 +82,7 @@ extern "C" { * Usually alignment of `4` bytes fits to all processors. */ #ifndef LWMEM_CFG_ALIGN_NUM -#define LWMEM_CFG_ALIGN_NUM ((size_t)4) +#define LWMEM_CFG_ALIGN_NUM 4 #endif /** diff --git a/lwmem/src/lwmem/lwmem.c b/lwmem/src/lwmem/lwmem.c index b62929b..783db12 100644 --- a/lwmem/src/lwmem/lwmem.c +++ b/lwmem/src/lwmem/lwmem.c @@ -62,6 +62,11 @@ #define LWMEM_UPDATE_MIN_FREE(lwobj) #endif /* LWMEM_CFG_ENABLE_STATS */ +/* Verify alignment */ +#if (LWMEM_CFG_ALIGN_NUM & (LWMEM_CFG_ALIGN_NUM - 1) > 0) +#error "LWMEM_ALIGN_BITS must be power of 2" +#endif + /** * \brief LwMEM default structure used by application */ @@ -857,7 +862,7 @@ lwmem_assignmem_ex(lwmem_t* lwobj, const lwmem_region_t* regions) { lwobj = LWMEM_GET_LWOBJ(lwobj); /* Check first things first */ - if (regions == NULL || (((size_t)LWMEM_CFG_ALIGN_NUM) & (((size_t)LWMEM_CFG_ALIGN_NUM) - 1)) > 0 + if (regions == NULL #if LWMEM_CFG_FULL || lwobj->end_block != NULL /* Init function may only be called once per lwmem instance */ #else