Skip to content

v3 的ThreadCache::allocate存在错误 #16

@yanhuojiyusheng

Description

@yanhuojiyusheng
        freeListSize_[index]--; // 

        // 检查线程本地自由链表
        // 如果 freeList_[index] 不为空,表示该链表中有可用内存块
        if (void *ptr = freeList_[index])
        {
            freeList_[index] = *reinterpret_cast<void **>(ptr); // 将freeList_[index]指向的内存块的下一个内存块地址(取决于内存块的实现)
            return ptr;
        }```

更新链表大小的操作应该放到if 里面否则 在初始为空的时候会出现0-1达到负数,size_t 下会变成超大无符号数

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions