mirror of
https://github.com/zeek/zeek.git
synced 2025-10-16 05:28:20 +00:00
Pre-allocate and re-use Vals for bool, int, count, enum and empty string
This commit is contained in:
parent
dcbef9cbe3
commit
2982765128
136 changed files with 1859 additions and 1811 deletions
|
@ -17,19 +17,18 @@ function get_orig_seq%(cid: conn_id%): count
|
|||
%{
|
||||
Connection* c = sessions->FindConnection(cid);
|
||||
if ( ! c )
|
||||
return new Val(0, TYPE_COUNT);
|
||||
return val_mgr->GetCount(0);
|
||||
|
||||
if ( c->ConnTransport() != TRANSPORT_TCP )
|
||||
return new Val(0, TYPE_COUNT);
|
||||
return val_mgr->GetCount(0);
|
||||
|
||||
analyzer::Analyzer* tc = c->FindAnalyzer("TCP");
|
||||
if ( tc )
|
||||
return new Val(static_cast<analyzer::tcp::TCP_Analyzer*>(tc)->OrigSeq(),
|
||||
TYPE_COUNT);
|
||||
return val_mgr->GetCount(static_cast<analyzer::tcp::TCP_Analyzer*>(tc)->OrigSeq());
|
||||
else
|
||||
{
|
||||
reporter->Error("connection does not have TCP analyzer");
|
||||
return new Val(0, TYPE_COUNT);
|
||||
return val_mgr->GetCount(0);
|
||||
}
|
||||
%}
|
||||
|
||||
|
@ -47,19 +46,18 @@ function get_resp_seq%(cid: conn_id%): count
|
|||
%{
|
||||
Connection* c = sessions->FindConnection(cid);
|
||||
if ( ! c )
|
||||
return new Val(0, TYPE_COUNT);
|
||||
return val_mgr->GetCount(0);
|
||||
|
||||
if ( c->ConnTransport() != TRANSPORT_TCP )
|
||||
return new Val(0, TYPE_COUNT);
|
||||
return val_mgr->GetCount(0);
|
||||
|
||||
analyzer::Analyzer* tc = c->FindAnalyzer("TCP");
|
||||
if ( tc )
|
||||
return new Val(static_cast<analyzer::tcp::TCP_Analyzer*>(tc)->RespSeq(),
|
||||
TYPE_COUNT);
|
||||
return val_mgr->GetCount(static_cast<analyzer::tcp::TCP_Analyzer*>(tc)->RespSeq());
|
||||
else
|
||||
{
|
||||
reporter->Error("connection does not have TCP analyzer");
|
||||
return new Val(0, TYPE_COUNT);
|
||||
return val_mgr->GetCount(0);
|
||||
}
|
||||
%}
|
||||
|
||||
|
@ -98,10 +96,10 @@ function set_contents_file%(cid: conn_id, direction: count, f: file%): bool
|
|||
%{
|
||||
Connection* c = sessions->FindConnection(cid);
|
||||
if ( ! c )
|
||||
return new Val(0, TYPE_BOOL);
|
||||
return val_mgr->GetBool(0);
|
||||
|
||||
c->GetRootAnalyzer()->SetContentsFile(direction, f);
|
||||
return new Val(1, TYPE_BOOL);
|
||||
return val_mgr->GetBool(1);
|
||||
%}
|
||||
|
||||
## Returns the file handle of the contents file of a connection.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue