提交 e90d748c 编写于 作者: Z zb0 提交者: LINGuanRen

fix the core detected by asan of slice alloc by using a heap variable to...

fix the core detected by asan of slice alloc by using a heap variable to record the class variable in advance
上级 46306437
......@@ -159,7 +159,8 @@ public:
}
bool recyle()
{
return inc_if_lt(2 * K, -K + total_) == -K + total_;
int32_t total = total_;
return inc_if_lt(2 * K, -K + total) == -K + total;
}
bool alloc_stock()
{
......@@ -167,9 +168,10 @@ public:
}
bool free_stock(bool& first_free)
{
int32_t ov = cas_or_inc(K + total_ - 1, -K + total_, 1);
int32_t total = total_;
int32_t ov = cas_or_inc(K + total - 1, -K + total, 1);
first_free = (ov == -K);
return ov == K + total_ - 1;
return ov == K + total - 1;
}
private:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册