mirror of
https://github.com/zeek/zeek.git
synced 2025-10-12 19:48:20 +00:00
Avoid calling safe_realloc unnecessarily from ODesc::Grow()
This commit is contained in:
parent
e8e6fa8fed
commit
c9127715c0
1 changed files with 6 additions and 1 deletions
|
@ -373,10 +373,15 @@ void ODesc::AddBytesRaw(const void* bytes, unsigned int n)
|
|||
|
||||
void ODesc::Grow(unsigned int n)
|
||||
{
|
||||
bool size_changed = false;
|
||||
while ( offset + n + SLOP >= size )
|
||||
{
|
||||
size *= 2;
|
||||
size_changed = true;
|
||||
}
|
||||
|
||||
base = util::safe_realloc(base, size);
|
||||
if ( size_changed )
|
||||
base = util::safe_realloc(base, size);
|
||||
}
|
||||
|
||||
void ODesc::Clear()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue