src/sysdep/psp/malloc.c
static void add_to_free_list(MallocHeap *heap, HeapBlock *block,
                             uint32_t size)
{
    /* Set up the block's header and footer, and link it into the proper
     * free list for the block's size. */

    block->free.size = size;
    const unsigned index = ubound((block->free.size / MALLOC_BLOCK_SIZE) - 1,
                                  lenof(heap->first_free) - 1);
    block->free.next = heap->first_free[index];
    if (heap->first_free[index]) {
        BlockFooter *footer = GET_BLOCK_FOOTER(heap->first_free[index]);
        footer->prev = block;
    }
    heap->first_free[index] = block;
    BlockFooter *footer = GET_BLOCK_FOOTER(block);
    footer->prev = NULL;
    footer->this = block;

    /* Update the global free list as well if (1) there is no free block
     * of this size or (2) the free block listed belongs to this or a
     * later heap. */

    if (!first_free[index].block || heap <= first_free[index].heap) {
        first_free[index].block = block;
        first_free[index].heap = heap;
    }
}
/*************************************************************************/
/***************** Local routines: Free list management ******************/
/*************************************************************************/
Local routines: Free list management
Local routines : Free list management
static void add_to_free_list(MallocHeap *heap, HeapBlock *block,
                             uint32_t size)
{
    block->free.size = size;
    const unsigned index = ubound((block->free.size / MALLOC_BLOCK_SIZE) - 1,
                                  lenof(heap->first_free) - 1);
    block->free.next = heap->first_free[index];
    if (heap->first_free[index]) {
        BlockFooter *footer = GET_BLOCK_FOOTER(heap->first_free[index]);
        footer->prev = block;
    }
    heap->first_free[index] = block;
    BlockFooter *footer = GET_BLOCK_FOOTER(block);
    footer->prev = NULL;
    footer->this = block;
    if (!first_free[index].block || heap <= first_free[index].heap) {
        first_free[index].block = block;
        first_free[index].heap = heap;
    }
}
static void add_to_free_list ( MallocHeap * heap , HeapBlock * block , uint32_t size ) { block -> free . size = size ; const unsigned index = ubound ( ( block -> free . size / MALLOC_BLOCK_SIZE ) - 1 , lenof ( heap -> first_free ) - 1 ) ; block -> free . next = heap -> first_free [ index ] ; if ( heap -> first_free [ index ] ) { BlockFooter * footer = GET_BLOCK_FOOTER ( heap -> first_free [ index ] ) ; footer -> prev = block ; } heap -> first_free [ index ] = block ; BlockFooter * footer = GET_BLOCK_FOOTER ( block ) ; footer -> prev = NULL ; footer -> this = block ; if ( ! first_free [ index ] . block || heap <= first_free [ index ] . heap ) { first_free [ index ] . block = block ; first_free [ index ] . heap = heap ; } }
Local routines: Free list management
Local routines : Free list management
/* Set up the block's header and footer, and link it into the proper
     * free list for the block's size. */ /* Update the global free list as well if (1) there is no free block
     * of this size or (2) the free block listed belongs to this or a
     * later heap. */