We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
static int merge_free_chunk(MemoryPool* mp, _MP_Memory* mm, _MP_Chunk* c) { _MP_Chunk *p0 = c, *p1 = c; while (p0->is_free) { p1 = p0; // bug:向前面搜索邻接内存块貌似有错?p0是作为内存块_MP_Chunk首地址,而不是分配给用户的内存空间的首地址,因此不应该减去MP_CHUNKHEADER // ++if ((char*) p0 - MP_CHUNKHEADER <= mm->start) break; // --if ((char*) p0 - MP_CHUNKEND - MP_CHUNKHEADER <= mm->start) break; p0 = *(_MP_Chunk**) ((char*) p0 - MP_CHUNKEND); } p0 = (_MP_Chunk*) ((char*) p1 + p1->alloc_mem); while ((char*) p0 < mm->start + mp->mempool_size && p0->is_free) { MP_DLINKLIST_DEL(mm->free_list, p0); p1->alloc_mem += p0->alloc_mem; p0 = (_MP_Chunk*) ((char*) p0 + p0->alloc_mem); } *(_MP_Chunk**) ((char*) p1 + p1->alloc_mem - MP_CHUNKEND) = p1; #ifdef _Z_MEMORYPOOL_THREAD_ MP_UNLOCK(mp); #endif return 0; }
The text was updated successfully, but these errors were encountered:
只是确保前面是个合法的chunk(chunk header、chunk end都存在),不过确实可有可无肯定都是合法的chunk,先留着了
Sorry, something went wrong.
userpro
No branches or pull requests
The text was updated successfully, but these errors were encountered: