mirror of
https://github.com/zeek/zeek.git
synced 2025-10-02 14:48:21 +00:00
Tweak FuncInfo memory management
Idea being for everything to be automatically released when process exits just so there's less potential noise from leak profilers.
This commit is contained in:
parent
c7bec09e14
commit
7b2ee2514e
4 changed files with 30 additions and 37 deletions
|
@ -12,19 +12,19 @@ namespace zeek::detail {
|
|||
std::unordered_set<const Func*> non_recursive_funcs;
|
||||
|
||||
// Tracks all of the loaded functions (including event handlers and hooks).
|
||||
static std::vector<FuncInfo*> funcs;
|
||||
static std::vector<FuncInfo> funcs;
|
||||
|
||||
|
||||
FuncInfo::~FuncInfo()
|
||||
{
|
||||
delete pf;
|
||||
delete save_file;
|
||||
}
|
||||
FuncInfo::FuncInfo(ScriptFuncPtr _func, ScopePtr _scope, StmtPtr _body)
|
||||
: func(std::move(_func)), scope(std::move(_scope)), body(std::move(_body))
|
||||
{}
|
||||
|
||||
void FuncInfo::SetProfile(std::unique_ptr<ProfileFunc> _pf)
|
||||
{ pf = std::move(_pf); }
|
||||
|
||||
void analyze_func(ScriptFuncPtr f)
|
||||
{
|
||||
auto info = new FuncInfo(f, {NewRef{}, f->GetScope()}, f->CurrentBody());
|
||||
funcs.push_back(info);
|
||||
funcs.emplace_back(f, ScopePtr{NewRef{}, f->GetScope()}, f->CurrentBody());
|
||||
}
|
||||
|
||||
static void check_env_opt(const char* opt, bool& opt_flag)
|
||||
|
@ -50,8 +50,8 @@ void analyze_scripts(Options& opts)
|
|||
|
||||
for ( auto& f : funcs )
|
||||
{
|
||||
f->SetProfile(new ProfileFunc(true));
|
||||
f->Body()->Traverse(f->Profile());
|
||||
f.SetProfile(std::make_unique<ProfileFunc>(true));
|
||||
f.Body()->Traverse(f.Profile());
|
||||
}
|
||||
|
||||
Inliner* inl = nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue