diff options
| author | Christian Walther <cwalther@gmx.ch> | 2020-11-30 23:33:07 +0100 |
|---|---|---|
| committer | Christian Walther <cwalther@gmx.ch> | 2020-11-30 23:33:38 +0100 |
| commit | d6f8a43f6cc755b90376a66b75818744fbe63320 (patch) | |
| tree | f7426f7c13368bb8ca0d2741f6d30a9a3b313f84 | |
| parent | 11ed6f86f02f61ace55951d2fff62a9d36cf3ac7 (diff) | |
Eliminate goto.
| -rwxr-xr-x | supervisor/shared/memory.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/supervisor/shared/memory.c b/supervisor/shared/memory.c index bc82804b7..480c322b0 100755 --- a/supervisor/shared/memory.c +++ b/supervisor/shared/memory.c @@ -105,23 +105,23 @@ void free_memory(supervisor_allocation* allocation) { else { // Check if it's in the list of embedded allocations. supervisor_allocation_node** emb = &MP_STATE_VM(first_embedded_allocation); - while (*emb != NULL) { - if (*emb == node) { - // Found, remove it from the list. - *emb = node->next; - m_free(node + while (*emb != NULL && *emb != node) { + emb = &((*emb)->next); + } + if (*emb != NULL) { + // Found, remove it from the list. + *emb = node->next; + m_free(node #if MICROPY_MALLOC_USES_ALLOCATED_SIZE - , sizeof(supervisor_allocation_node) + (node->length & ~FLAGS) + , sizeof(supervisor_allocation_node) + (node->length & ~FLAGS) #endif - ); - goto done; - } - emb = &((*emb)->next); + ); + } + else { + // Else it must be within the low or high ranges and becomes a hole. + node->length = ((node->length & ~FLAGS) | HOLE); } - // Else it must be within the low or high ranges and becomes a hole. - node->length = ((node->length & ~FLAGS) | HOLE); } -done: allocation->ptr = NULL; } |
