mirror of
https://github.com/lvgl/lvgl.git
synced 2025-01-14 06:42:58 +08:00
improve size rounding to 4 or 8 in lv_mem, and lv_ll
This commit is contained in:
parent
542fa7e76d
commit
a49e7e8295
@ -51,18 +51,12 @@ void _lv_ll_init(lv_ll_t * ll_p, uint32_t node_size)
|
||||
{
|
||||
ll_p->head = NULL;
|
||||
ll_p->tail = NULL;
|
||||
#ifdef LV_MEM_ENV64
|
||||
#ifdef LV_ARCH_64
|
||||
/*Round the size up to 8*/
|
||||
if(node_size & 0x7) {
|
||||
node_size = node_size & (~0x7);
|
||||
node_size += 8;
|
||||
}
|
||||
node_size = (node_size + 7) & (~0x7);
|
||||
#else
|
||||
/*Round the size up to 4*/
|
||||
if(node_size & 0x3) {
|
||||
node_size = node_size & (~0x3);
|
||||
node_size += 4;
|
||||
}
|
||||
node_size = node_size + 3 & (~0x3);
|
||||
#endif
|
||||
|
||||
ll_p->n_size = node_size;
|
||||
|
@ -157,16 +157,10 @@ void * lv_mem_alloc(size_t size)
|
||||
|
||||
#ifdef LV_ARCH_64
|
||||
/*Round the size up to 8*/
|
||||
if(size & 0x7) {
|
||||
size = size & (~0x7);
|
||||
size += 8;
|
||||
}
|
||||
size = (size + 7) & (~0x7);
|
||||
#else
|
||||
/*Round the size up to 4*/
|
||||
if(size & 0x3) {
|
||||
size = size & (~0x3);
|
||||
size += 4;
|
||||
}
|
||||
size = (size + 3) & (~0x7);
|
||||
#endif
|
||||
void * alloc = NULL;
|
||||
|
||||
@ -281,16 +275,10 @@ void * lv_mem_realloc(void * data_p, size_t new_size)
|
||||
|
||||
#ifdef LV_ARCH_64
|
||||
/*Round the size up to 8*/
|
||||
if(new_size & 0x7) {
|
||||
new_size = new_size & (~0x7);
|
||||
new_size += 8;
|
||||
}
|
||||
new_size = (new_size + 7) & (~0x7);
|
||||
#else
|
||||
/*Round the size up to 4*/
|
||||
if(new_size & 0x3) {
|
||||
new_size = new_size & (~0x3);
|
||||
new_size += 4;
|
||||
}
|
||||
new_size = (new_size + 3) & (~0x7
|
||||
#endif
|
||||
|
||||
/*data_p could be previously freed pointer (in this case it is invalid)*/
|
||||
@ -858,18 +846,13 @@ static void * ent_alloc(lv_mem_ent_t * e, size_t size)
|
||||
*/
|
||||
static void ent_trunc(lv_mem_ent_t * e, size_t size)
|
||||
{
|
||||
|
||||
#ifdef LV_ARCH_64
|
||||
/*Round the size up to 8*/
|
||||
if(size & 0x7) {
|
||||
size = size & (~0x7);
|
||||
size += 8;
|
||||
}
|
||||
size = (size + 7) & (~0x7);
|
||||
#else
|
||||
/*Round the size up to 4*/
|
||||
if(size & 0x3) {
|
||||
size = size & (~0x3);
|
||||
size += 4;
|
||||
}
|
||||
size = (size + 3) & (~0x7
|
||||
#endif
|
||||
|
||||
/*Don't let empty space only for a header without data*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user