mirror of
https://github.com/MaJerle/lwmem.git
synced 2025-01-26 06:02:54 +08:00
remove casting, implement static alignment size check
This commit is contained in:
parent
187bc462eb
commit
dbf2cdfd4c
@ -82,7 +82,7 @@ extern "C" {
|
|||||||
* Usually alignment of `4` bytes fits to all processors.
|
* Usually alignment of `4` bytes fits to all processors.
|
||||||
*/
|
*/
|
||||||
#ifndef LWMEM_CFG_ALIGN_NUM
|
#ifndef LWMEM_CFG_ALIGN_NUM
|
||||||
#define LWMEM_CFG_ALIGN_NUM ((size_t)4)
|
#define LWMEM_CFG_ALIGN_NUM 4
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,6 +62,11 @@
|
|||||||
#define LWMEM_UPDATE_MIN_FREE(lwobj)
|
#define LWMEM_UPDATE_MIN_FREE(lwobj)
|
||||||
#endif /* LWMEM_CFG_ENABLE_STATS */
|
#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
|
* \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);
|
lwobj = LWMEM_GET_LWOBJ(lwobj);
|
||||||
|
|
||||||
/* Check first things first */
|
/* 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
|
#if LWMEM_CFG_FULL
|
||||||
|| lwobj->end_block != NULL /* Init function may only be called once per lwmem instance */
|
|| lwobj->end_block != NULL /* Init function may only be called once per lwmem instance */
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user