qstr: One more cast could be avoided.

This commit is contained in:
Artyom Skrobov 2021-05-05 09:01:47 +03:00
parent 2d73ba2186
commit 269d5bc80a

View File

@ -149,14 +149,14 @@ STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) {
new_pool_length = MICROPY_ALLOC_QSTR_ENTRIES_INIT; new_pool_length = MICROPY_ALLOC_QSTR_ENTRIES_INIT;
} }
#endif #endif
mp_uint_t pool_size = sizeof(qstr_pool_t) + sizeof(const char *) * new_pool_length; mp_uint_t pool_size = sizeof(qstr_pool_t)
void *chunk = m_malloc_maybe(pool_size + sizeof(qstr_attr_t) * new_pool_length, true); + (sizeof(const char *) + sizeof(qstr_attr_t)) * new_pool_length;
if (chunk == NULL) { qstr_pool_t *pool = (qstr_pool_t *)m_malloc_maybe(pool_size, true);
if (pool == NULL) {
QSTR_EXIT(); QSTR_EXIT();
m_malloc_fail(new_pool_length); m_malloc_fail(new_pool_length);
} }
qstr_pool_t *pool = (qstr_pool_t *)chunk; pool->attrs = (qstr_attr_t *)(pool->qstrs + new_pool_length);
pool->attrs = (qstr_attr_t *)(void *)((char *)chunk + pool_size);
pool->prev = MP_STATE_VM(last_pool); pool->prev = MP_STATE_VM(last_pool);
pool->total_prev_len = MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len; pool->total_prev_len = MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len;
pool->alloc = new_pool_length; pool->alloc = new_pool_length;