mirror of
https://github.com/tstack/lnav.git
synced 2024-10-26 21:19:54 +03:00
[valgrind] fix some memory leaks
This commit is contained in:
parent
dc4eb51214
commit
9872d5937d
@ -159,8 +159,7 @@ public:
|
||||
grep_highlighter(auto_ptr < grep_proc > gp,
|
||||
string hl_name,
|
||||
textview_curses::highlight_map_t &hl_map)
|
||||
: gh_code(gp->get_code()),
|
||||
gh_grep_proc(gp),
|
||||
: gh_grep_proc(gp),
|
||||
gh_hl_name(hl_name),
|
||||
gh_hl_map(hl_map) { };
|
||||
|
||||
@ -172,7 +171,6 @@ public:
|
||||
grep_proc *get_grep_proc() { return this->gh_grep_proc.get(); };
|
||||
|
||||
private:
|
||||
auto_mem<pcre> gh_code;
|
||||
auto_ptr<grep_proc> gh_grep_proc;
|
||||
string gh_hl_name;
|
||||
textview_curses::highlight_map_t gh_hl_map;
|
||||
|
@ -153,6 +153,7 @@ public:
|
||||
pcrepp(pcre *code) : p_code(code) {
|
||||
const char *errptr;
|
||||
|
||||
pcre_refcount(this->p_code, 1);
|
||||
this->p_code_extra = pcre_study(this->p_code, 0, &errptr);
|
||||
};
|
||||
|
||||
@ -168,6 +169,7 @@ public:
|
||||
throw error(errptr, eoff);
|
||||
}
|
||||
|
||||
pcre_refcount(this->p_code, 1);
|
||||
this->p_code_extra = pcre_study(this->p_code, 0, &errptr);
|
||||
};
|
||||
|
||||
@ -175,10 +177,16 @@ public:
|
||||
const char *errptr;
|
||||
|
||||
this->p_code = other.p_code;
|
||||
pcre_refcount(this->p_code, 1);
|
||||
this->p_code_extra = pcre_study(this->p_code, 0, &errptr);
|
||||
};
|
||||
|
||||
virtual ~pcrepp() { };
|
||||
virtual ~pcrepp() {
|
||||
if (pcre_refcount(this->p_code, -1) == 0) {
|
||||
free(this->p_code);
|
||||
this->p_code = 0;
|
||||
}
|
||||
};
|
||||
|
||||
bool match(pcre_context &pc, pcre_input &pi, int options = 0) {
|
||||
int count = pc.get_max_count();
|
||||
|
@ -100,6 +100,7 @@ int main(int argc, char *argv[])
|
||||
&errptr,
|
||||
&eoff,
|
||||
NULL);
|
||||
pcre_refcount(code, 1);
|
||||
assert(code != NULL);
|
||||
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user