mirror of
https://github.com/zeek/zeek.git
synced 2025-10-14 04:28:20 +00:00
Var: pass IntrusivePtr to add_global(), add_local() etc.
Those functions don't have a well-defined reference passing API, and we had lots of memory leaks here. By using IntrusivePtr, reference ownership is well-defined.
This commit is contained in:
parent
17a2f1a3ab
commit
2c0ece7376
5 changed files with 85 additions and 101 deletions
13
src/Var.h
13
src/Var.h
|
@ -2,6 +2,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "IntrusivePtr.h"
|
||||
#include "ID.h"
|
||||
#include "Type.h"
|
||||
|
||||
|
@ -16,17 +17,17 @@ class ListVal;
|
|||
|
||||
typedef enum { VAR_REGULAR, VAR_CONST, VAR_REDEF, VAR_OPTION, } decl_type;
|
||||
|
||||
extern void add_global(ID* id, BroType* t, init_class c, Expr* init,
|
||||
extern void add_global(ID* id, IntrusivePtr<BroType> t, init_class c, IntrusivePtr<Expr> init,
|
||||
attr_list* attr, decl_type dt);
|
||||
extern Stmt* add_local(ID* id, BroType* t, init_class c, Expr* init,
|
||||
extern IntrusivePtr<Stmt> add_local(IntrusivePtr<ID> id, IntrusivePtr<BroType> t, init_class c, IntrusivePtr<Expr> init,
|
||||
attr_list* attr, decl_type dt);
|
||||
extern Expr* add_and_assign_local(ID* id, Expr* init, Val* val = 0);
|
||||
extern IntrusivePtr<Expr> add_and_assign_local(IntrusivePtr<ID> id, IntrusivePtr<Expr> init, IntrusivePtr<Val> val = nullptr);
|
||||
|
||||
extern void add_type(ID* id, BroType* t, attr_list* attr);
|
||||
extern void add_type(ID* id, IntrusivePtr<BroType> t, attr_list* attr);
|
||||
|
||||
extern void begin_func(ID* id, const char* module_name, function_flavor flavor,
|
||||
int is_redef, FuncType* t, attr_list* attrs = nullptr);
|
||||
extern void end_func(Stmt* body);
|
||||
int is_redef, IntrusivePtr<FuncType> t, attr_list* attrs = nullptr);
|
||||
extern void end_func(IntrusivePtr<Stmt> body);
|
||||
|
||||
// Gather all IDs referenced inside a body that aren't part of a given scope.
|
||||
extern id_list gather_outer_ids(Scope* scope, Stmt* body);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue