src/memory/source/tlsf.cc
static block_header_t* block_split(block_header_t* block, size_t size) {
    /* Calculate the amount of space left in the remaining block. */
    block_header_t* remaining = offset_to_block(block_to_ptr(block), size - block_header_overhead);

    const size_t remain_size = block_size(block) - (size + block_header_overhead);

    tlsf_assert(block_to_ptr(remaining) == align_ptr(block_to_ptr(remaining), ALIGN_SIZE) &&
                "remaining block not aligned properly");

    tlsf_assert(block_size(block) == remain_size + size + block_header_overhead);
    block_set_size(remaining, remain_size);
    tlsf_assert(block_size(remaining) >= block_size_min && "block split with invalid size");

    block_set_size(block, size);
    block_mark_as_free(remaining);

    return remaining;
}
/* Split a block into two, the second of which is free. */
Split a block into two, the second of which is free.
Split a block into two the second of which is free .
static block_header_t* block_split(block_header_t* block, size_t size) {
    block_header_t* remaining = offset_to_block(block_to_ptr(block), size - block_header_overhead);
    const size_t remain_size = block_size(block) - (size + block_header_overhead);
    tlsf_assert(block_to_ptr(remaining) == align_ptr(block_to_ptr(remaining), ALIGN_SIZE) &&
                "remaining block not aligned properly");
    tlsf_assert(block_size(block) == remain_size + size + block_header_overhead);
    block_set_size(remaining, remain_size);
    tlsf_assert(block_size(remaining) >= block_size_min && "block split with invalid size");
    block_set_size(block, size);
    block_mark_as_free(remaining);
    return remaining;
}
static block_header_t * block_split ( block_header_t * block , size_t size ) { block_header_t * remaining = offset_to_block ( block_to_ptr ( block ) , size - block_header_overhead ) ; const size_t remain_size = block_size ( block ) - ( size + block_header_overhead ) ; tlsf_assert ( block_to_ptr ( remaining ) == align_ptr ( block_to_ptr ( remaining ) , ALIGN_SIZE ) && " " ) ; tlsf_assert ( block_size ( block ) == remain_size + size + block_header_overhead ) ; block_set_size ( remaining , remain_size ) ; tlsf_assert ( block_size ( remaining ) >= block_size_min && " " ) ; block_set_size ( block , size ) ; block_mark_as_free ( remaining ) ; return remaining ; }
Split a block into two, the second of which is free.
Split a block into two the second of which is free .
/* Calculate the amount of space left in the remaining block. */