Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Zhichao-Yan opened this issue Apr 10, 2024 · 1 comment
Open

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

Zhichao-Yan opened this issue Apr 10, 2024 · 1 comment
Labels
wontfix This will not be worked on

Comments

@Zhichao-Yan
Copy link

初始化内存池时,此时内存池作为一个大的空闲块,其尾部也应该有指针指向首地址,此次没有相应操作
像这样:
*(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)
@userpro
Copy link
Owner

userpro commented Oct 12, 2024

不是必要的,该块要么一直处于free链的尾部,merge free的时候不会有后面来的查找;要么被alloc出去后这里自然就被写上地址信息了

@userpro userpro added the wontfix This will not be worked on label Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants