mirror of
https://github.com/Expand-sys/CCash
synced 2025-12-17 00:22:14 +11:00
🐛 infinite allocate bug
This commit is contained in:
parent
98aac38958
commit
4a0b7cafa6
1 changed files with 3 additions and 8 deletions
|
|
@ -10,7 +10,7 @@ struct Log
|
|||
uint32_t end = 0;
|
||||
void AddTrans(Transaction &&v)
|
||||
{
|
||||
if (data.size() == end)
|
||||
if (data.size() <= end+1 && end+1 <= max_log_size) //if memory reserved is full
|
||||
{
|
||||
data.resize(data.size() + pre_log_size); //prefetching memory
|
||||
}
|
||||
|
|
@ -19,10 +19,7 @@ struct Log
|
|||
data[i] = std::move(data[i - 1]);
|
||||
}
|
||||
data[0] = std::move(v);
|
||||
if (end < max_log_size)
|
||||
{
|
||||
++end;
|
||||
}
|
||||
end += (end < max_log_size); //branchless
|
||||
}
|
||||
Json::Value Serialize() const
|
||||
{
|
||||
|
|
@ -36,6 +33,4 @@ struct Log
|
|||
}
|
||||
return res;
|
||||
}
|
||||
};
|
||||
|
||||
//[*][*][]
|
||||
};
|
||||
Loading…
Reference in a new issue