align data
This commit is contained in:
parent
9109a7430c
commit
9ebed4deab
1 changed files with 3 additions and 2 deletions
|
@ -818,7 +818,8 @@ sparsemap(size_t size)
|
||||||
|
|
||||||
sparsemap_t *map = (sparsemap_t *)calloc(1, total_size);
|
sparsemap_t *map = (sparsemap_t *)calloc(1, total_size);
|
||||||
if (map) {
|
if (map) {
|
||||||
sparsemap_init(map, (uint8_t *)((uintptr_t)map + sizeof(sparsemap_t) + padding), size);
|
uint8_t *data = (uint8_t *)(((uintptr_t)map + sizeof(sparsemap_t)) & ~ (uintptr_t)7);
|
||||||
|
sparsemap_init(map, data, size);
|
||||||
__sm_when_diag({ __sm_assert(IS_8_BYTE_ALIGNED(map->m_data)); });
|
__sm_when_diag({ __sm_assert(IS_8_BYTE_ALIGNED(map->m_data)); });
|
||||||
}
|
}
|
||||||
sparsemap_clear(map);
|
sparsemap_clear(map);
|
||||||
|
@ -875,7 +876,7 @@ sparsemap_set_data_size(sparsemap_t *map, size_t size)
|
||||||
}
|
}
|
||||||
memset(((uint8_t *)m) + sizeof(sparsemap_t) + (m->m_capacity * sizeof(uint8_t)), 0, size - m->m_capacity + padding);
|
memset(((uint8_t *)m) + sizeof(sparsemap_t) + (m->m_capacity * sizeof(uint8_t)), 0, size - m->m_capacity + padding);
|
||||||
m->m_capacity = data_size;
|
m->m_capacity = data_size;
|
||||||
m->m_data = (uint8_t *)((uintptr_t)m + sizeof(sparsemap_t) + padding);
|
m->m_data = (uint8_t *)(((uintptr_t)m + sizeof(sparsemap_t)) & ~ (uintptr_t)7);
|
||||||
__sm_when_diag({ __sm_assert(IS_8_BYTE_ALIGNED(m->m_data)); }) return m;
|
__sm_when_diag({ __sm_assert(IS_8_BYTE_ALIGNED(m->m_data)); }) return m;
|
||||||
} else {
|
} else {
|
||||||
map->m_capacity = size;
|
map->m_capacity = size;
|
||||||
|
|
Loading…
Reference in a new issue