The parameter "block" points to mem_info::chunks space. It's not quite
clear about the function of "reinterpret_cast<mem_info *>(block) - 1;".
Get the mem_info::chunks address and minus the member offset from struct
head to get mem_info address.
Signed-off-by: Changcheng Liu <changcheng.liu@aliyun.com>
mem_info *m;
std::lock_guard l{lock};
- m = reinterpret_cast<mem_info *>(block) - 1;
+ Chunk *mem_info_chunk = reinterpret_cast<Chunk *>(block);
+ m = reinterpret_cast<mem_info *>(reinterpret_cast<char *>(mem_info_chunk) - offsetof(mem_info, chunks));
m->ctx->update_stats(-m->nbufs);
ibv_dereg_mr(m->mr);
m->ctx->manager->free(m);