mirror of
https://github.com/zeek/zeek.git
synced 2025-10-05 16:18:19 +00:00
Merge remote-tracking branch 'origin/fastpath'
* origin/fastpath: Fix reference counting for lookup_ID() usages.
This commit is contained in:
commit
a9eb31b461
10 changed files with 49 additions and 9 deletions
21
src/Var.cc
21
src/Var.cc
|
@ -385,6 +385,8 @@ void begin_func(ID* id, const char* module_name, function_flavor flavor,
|
|||
if ( arg_id && ! arg_id->IsGlobal() )
|
||||
arg_id->Error("argument name used twice");
|
||||
|
||||
Unref(arg_id);
|
||||
|
||||
arg_id = install_ID(arg_i->id, module_name, false, false);
|
||||
arg_id->SetType(arg_i->type->Ref());
|
||||
}
|
||||
|
@ -442,10 +444,13 @@ void end_func(Stmt* body, attr_list* attrs)
|
|||
Val* internal_val(const char* name)
|
||||
{
|
||||
ID* id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
|
||||
if ( ! id )
|
||||
reporter->InternalError("internal variable %s missing", name);
|
||||
|
||||
return id->ID_Val();
|
||||
Val* rval = id->ID_Val();
|
||||
Unref(id);
|
||||
return rval;
|
||||
}
|
||||
|
||||
Val* internal_const_val(const char* name)
|
||||
|
@ -457,13 +462,17 @@ Val* internal_const_val(const char* name)
|
|||
if ( ! id->IsConst() )
|
||||
reporter->InternalError("internal variable %s is not constant", name);
|
||||
|
||||
return id->ID_Val();
|
||||
Val* rval = id->ID_Val();
|
||||
Unref(id);
|
||||
return rval;
|
||||
}
|
||||
|
||||
Val* opt_internal_val(const char* name)
|
||||
{
|
||||
ID* id = lookup_ID(name, GLOBAL_MODULE_NAME);
|
||||
return id ? id->ID_Val() : 0;
|
||||
Val* rval = id ? id->ID_Val() : 0;
|
||||
Unref(id);
|
||||
return rval;
|
||||
}
|
||||
|
||||
double opt_internal_double(const char* name)
|
||||
|
@ -503,6 +512,8 @@ ListVal* internal_list_val(const char* name)
|
|||
return 0;
|
||||
|
||||
Val* v = id->ID_Val();
|
||||
Unref(id);
|
||||
|
||||
if ( v )
|
||||
{
|
||||
if ( v->Type()->Tag() == TYPE_LIST )
|
||||
|
@ -528,7 +539,9 @@ BroType* internal_type(const char* name)
|
|||
if ( ! id )
|
||||
reporter->InternalError("internal type %s missing", name);
|
||||
|
||||
return id->Type();
|
||||
BroType* rval = id->Type();
|
||||
Unref(id);
|
||||
return rval;
|
||||
}
|
||||
|
||||
Func* internal_func(const char* name)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue