Skip to content

初始化时,空闲块尾指针应当指向首地址 #16

@Zhichao-Yan

Description

@Zhichao-Yan

初始化内存池时,此时内存池作为一个大的空闲块,其尾部也应该有指针指向首地址,此次没有相应操作
像这样:
*(mp_chunk**)((char*)ck + ck->size - MP_CHUNK_POINTER) = ck;

#define MP_INIT_MEMORY_STRUCT(mm, mempool_sz)   \
    do {                                        \
        mm->mempool_size = mempool_sz;          \
        mm->alloc_mem = 0;                      \
        mm->alloc_prog_mem = 0;                 \
        mm->free_list = (_MP_Chunk*) mm->start; \
        mm->free_list->is_free = 1;             \
        mm->free_list->alloc_mem = mempool_sz;  \
        mm->free_list->prev = NULL;             \
        mm->free_list->next = NULL;             \
        mm->alloc_list = NULL;                  \
    } while (0)

Metadata

Metadata

Assignees

No one assigned

    Labels

    wontfixThis will not be worked on

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions