Skip to content

Commit 269d5bc

Browse files
committed
qstr: One more cast could be avoided.
1 parent 2d73ba2 commit 269d5bc

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

py/qstr.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,14 @@ STATIC qstr qstr_add(mp_uint_t hash, mp_uint_t len, const char *q_ptr) {
149149
new_pool_length = MICROPY_ALLOC_QSTR_ENTRIES_INIT;
150150
}
151151
#endif
152-
mp_uint_t pool_size = sizeof(qstr_pool_t) + sizeof(const char *) * new_pool_length;
153-
void *chunk = m_malloc_maybe(pool_size + sizeof(qstr_attr_t) * new_pool_length, true);
154-
if (chunk == NULL) {
152+
mp_uint_t pool_size = sizeof(qstr_pool_t)
153+
+ (sizeof(const char *) + sizeof(qstr_attr_t)) * new_pool_length;
154+
qstr_pool_t *pool = (qstr_pool_t *)m_malloc_maybe(pool_size, true);
155+
if (pool == NULL) {
155156
QSTR_EXIT();
156157
m_malloc_fail(new_pool_length);
157158
}
158-
qstr_pool_t *pool = (qstr_pool_t *)chunk;
159-
pool->attrs = (qstr_attr_t *)(void *)((char *)chunk + pool_size);
159+
pool->attrs = (qstr_attr_t *)(pool->qstrs + new_pool_length);
160160
pool->prev = MP_STATE_VM(last_pool);
161161
pool->total_prev_len = MP_STATE_VM(last_pool)->total_prev_len + MP_STATE_VM(last_pool)->len;
162162
pool->alloc = new_pool_length;

0 commit comments

Comments
 (0)