mirror of
https://github.com/zeek/zeek.git
synced 2025-10-10 10:38: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
|
@ -699,25 +699,27 @@ int DNS_Mgr::Save()
|
|||
return 1;
|
||||
}
|
||||
|
||||
void DNS_Mgr::Event(EventHandlerPtr e, DNS_Mapping* dm)
|
||||
{
|
||||
if ( ! e )
|
||||
return;
|
||||
|
||||
mgr.QueueEvent(e, {BuildMappingVal(dm)});
|
||||
}
|
||||
|
||||
void DNS_Mgr::Event(EventHandlerPtr e, DNS_Mapping* dm, ListVal* l1, ListVal* l2)
|
||||
{
|
||||
if ( ! e )
|
||||
return;
|
||||
|
||||
val_list* vl = new val_list;
|
||||
vl->append(BuildMappingVal(dm));
|
||||
Unref(l1);
|
||||
Unref(l2);
|
||||
|
||||
if ( l1 )
|
||||
{
|
||||
vl->append(l1->ConvertToSet());
|
||||
if ( l2 )
|
||||
vl->append(l2->ConvertToSet());
|
||||
|
||||
Unref(l1);
|
||||
Unref(l2);
|
||||
}
|
||||
|
||||
mgr.QueueEvent(e, vl);
|
||||
mgr.QueueEvent(e, {
|
||||
BuildMappingVal(dm),
|
||||
l1->ConvertToSet(),
|
||||
l2->ConvertToSet(),
|
||||
});
|
||||
}
|
||||
|
||||
void DNS_Mgr::Event(EventHandlerPtr e, DNS_Mapping* old_dm, DNS_Mapping* new_dm)
|
||||
|
@ -725,10 +727,10 @@ void DNS_Mgr::Event(EventHandlerPtr e, DNS_Mapping* old_dm, DNS_Mapping* new_dm)
|
|||
if ( ! e )
|
||||
return;
|
||||
|
||||
val_list* vl = new val_list;
|
||||
vl->append(BuildMappingVal(old_dm));
|
||||
vl->append(BuildMappingVal(new_dm));
|
||||
mgr.QueueEvent(e, vl);
|
||||
mgr.QueueEvent(e, {
|
||||
BuildMappingVal(old_dm),
|
||||
BuildMappingVal(new_dm),
|
||||
});
|
||||
}
|
||||
|
||||
Val* DNS_Mgr::BuildMappingVal(DNS_Mapping* dm)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue