mirror of
https://github.com/zeek/zeek.git
synced 2025-10-04 23:58:20 +00:00
Cleanup/improve PList usage and Event API
Majority of PLists are now created as automatic/stack objects, rather than on heap and initialized either with the known-capacity reserved upfront or directly from an initializer_list (so there's no wasted slack in the memory that gets allocated for lists containing a fixed/known number of elements). Added versions of the ConnectionEvent/QueueEvent methods that take a val_list by value. Added a move ctor/assign-operator to Plists to allow passing them around without having to copy the underlying array of pointers.
This commit is contained in:
parent
78dcbcc71a
commit
8bc65f09ec
92 changed files with 1585 additions and 1679 deletions
20
src/File.cc
20
src/File.cc
|
@ -65,10 +65,8 @@ void RotateTimer::Dispatch(double t, int is_expire)
|
|||
{
|
||||
if ( raise )
|
||||
{
|
||||
val_list* vl = new val_list;
|
||||
Ref(file);
|
||||
vl->append(new Val(file));
|
||||
mgr.QueueEvent(rotate_interval, vl);
|
||||
mgr.QueueEvent(rotate_interval, {new Val(file)});
|
||||
}
|
||||
|
||||
file->InstallRotateTimer();
|
||||
|
@ -641,19 +639,15 @@ void BroFile::CloseCachedFiles()
|
|||
// Send final rotate events (immediately).
|
||||
if ( f->rotate_interval )
|
||||
{
|
||||
val_list* vl = new val_list;
|
||||
Ref(f);
|
||||
vl->append(new Val(f));
|
||||
Event* event = new Event(::rotate_interval, vl);
|
||||
Event* event = new Event(::rotate_interval, {new Val(f)});
|
||||
mgr.Dispatch(event, true);
|
||||
}
|
||||
|
||||
if ( f->rotate_size )
|
||||
{
|
||||
val_list* vl = new val_list;
|
||||
Ref(f);
|
||||
vl->append(new Val(f));
|
||||
Event* event = new ::Event(::rotate_size, vl);
|
||||
Event* event = new ::Event(::rotate_size, {new Val(f)});
|
||||
mgr.Dispatch(event, true);
|
||||
}
|
||||
|
||||
|
@ -801,9 +795,7 @@ int BroFile::Write(const char* data, int len)
|
|||
|
||||
if ( rotate_size && current_size < rotate_size && current_size + len >= rotate_size )
|
||||
{
|
||||
val_list* vl = new val_list;
|
||||
vl->append(new Val(this));
|
||||
mgr.QueueEvent(::rotate_size, vl);
|
||||
mgr.QueueEvent(::rotate_size, {new Val(this)});
|
||||
}
|
||||
|
||||
// This does not work if we seek around. But none of the logs does that
|
||||
|
@ -818,10 +810,8 @@ void BroFile::RaiseOpenEvent()
|
|||
if ( ! ::file_opened )
|
||||
return;
|
||||
|
||||
val_list* vl = new val_list;
|
||||
Ref(this);
|
||||
vl->append(new Val(this));
|
||||
Event* event = new ::Event(::file_opened, vl);
|
||||
Event* event = new ::Event(::file_opened, {new Val(this)});
|
||||
mgr.Dispatch(event, true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue