mirror of
https://github.com/tstack/lnav
synced 2024-11-03 23:15:38 +00:00
[debt] some more mem leaks
Defect Number: Reviewed By: Testing Done:
This commit is contained in:
parent
b924395ed2
commit
21f127cb56
@ -2186,10 +2186,8 @@ int main(int argc, char *argv[])
|
||||
register_regexp_vtab(lnav_data.ld_db.in());
|
||||
register_fstat_vtab(lnav_data.ld_db.in());
|
||||
|
||||
lnav_data.ld_vtab_manager =
|
||||
new log_vtab_manager(lnav_data.ld_db,
|
||||
lnav_data.ld_views[LNV_LOG],
|
||||
lnav_data.ld_log_source);
|
||||
lnav_data.ld_vtab_manager = std::make_unique<log_vtab_manager>(
|
||||
lnav_data.ld_db, lnav_data.ld_views[LNV_LOG], lnav_data.ld_log_source);
|
||||
|
||||
load_formats(lnav_data.ld_config_paths, loader_errors);
|
||||
|
||||
@ -2220,7 +2218,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
load_format_extra(lnav_data.ld_db.in(), lnav_data.ld_config_paths, loader_errors);
|
||||
load_format_vtabs(lnav_data.ld_vtab_manager, loader_errors);
|
||||
load_format_vtabs(lnav_data.ld_vtab_manager.get(), loader_errors);
|
||||
if (!loader_errors.empty()) {
|
||||
print_errors(loader_errors);
|
||||
return EXIT_FAILURE;
|
||||
|
@ -272,7 +272,7 @@ struct lnav_data_t {
|
||||
|
||||
vis_line_t ld_last_pretty_print_top;
|
||||
|
||||
log_vtab_manager * ld_vtab_manager;
|
||||
std::unique_ptr<log_vtab_manager> ld_vtab_manager;
|
||||
auto_mem<sqlite3, sqlite_close_wrapper> ld_db;
|
||||
|
||||
std::unordered_map<std::string, std::string> ld_table_ddl;
|
||||
|
@ -947,7 +947,7 @@ static int progress_callback(void *ptr)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (log_vtab_data.lvd_progress != NULL) {
|
||||
if (log_vtab_data.lvd_progress != nullptr) {
|
||||
retval = log_vtab_data.lvd_progress(log_cursor_latest);
|
||||
}
|
||||
|
||||
@ -963,6 +963,15 @@ log_vtab_manager::log_vtab_manager(sqlite3 *memdb,
|
||||
sqlite3_progress_handler(memdb, 32, progress_callback, nullptr);
|
||||
}
|
||||
|
||||
log_vtab_manager::~log_vtab_manager()
|
||||
{
|
||||
while (!this->vm_impls.empty()) {
|
||||
auto first_name = this->vm_impls.begin()->first;
|
||||
|
||||
this->unregister_vtab(first_name);
|
||||
}
|
||||
}
|
||||
|
||||
string log_vtab_manager::register_vtab(std::shared_ptr<log_vtab_impl> vi)
|
||||
{
|
||||
string retval;
|
||||
|
@ -234,6 +234,7 @@ public:
|
||||
log_vtab_manager(sqlite3 *db,
|
||||
textview_curses &tc,
|
||||
logfile_sub_source &lss);
|
||||
~log_vtab_manager();
|
||||
|
||||
textview_curses *get_view() const { return &this->vm_textview; };
|
||||
|
||||
|
@ -651,7 +651,7 @@ logfile_sub_source::rebuild_result logfile_sub_source::rebuild_index()
|
||||
size_t index_size = 0, start_size = this->lss_index.size();
|
||||
logline_cmp line_cmper(*this);
|
||||
|
||||
for (auto ld : this->lss_files) {
|
||||
for (auto& ld : this->lss_files) {
|
||||
std::shared_ptr<logfile> lf = ld->get_file();
|
||||
|
||||
if (lf == nullptr) {
|
||||
@ -666,7 +666,7 @@ logfile_sub_source::rebuild_result logfile_sub_source::rebuild_index()
|
||||
}
|
||||
|
||||
if (full_sort) {
|
||||
for (auto ld : this->lss_files) {
|
||||
for (auto& ld : this->lss_files) {
|
||||
shared_ptr<logfile> lf = ld->get_file();
|
||||
|
||||
if (lf == nullptr) {
|
||||
@ -691,7 +691,7 @@ logfile_sub_source::rebuild_result logfile_sub_source::rebuild_index()
|
||||
for (iter = this->lss_files.begin();
|
||||
iter != this->lss_files.end();
|
||||
iter++) {
|
||||
logfile_data *ld = *iter;
|
||||
logfile_data *ld = iter->get();
|
||||
shared_ptr<logfile> lf = ld->get_file();
|
||||
if (lf == NULL) {
|
||||
continue;
|
||||
@ -872,7 +872,7 @@ log_accel::direction_t logfile_sub_source::get_line_accel_direction(
|
||||
|
||||
void logfile_sub_source::text_filters_changed()
|
||||
{
|
||||
for (auto ld : *this) {
|
||||
for (auto& ld : *this) {
|
||||
shared_ptr<logfile> lf = ld->get_file();
|
||||
|
||||
if (lf != nullptr) {
|
||||
@ -973,7 +973,8 @@ bool logfile_sub_source::insert_file(const shared_ptr<logfile> &lf)
|
||||
return false;
|
||||
}
|
||||
|
||||
this->lss_files.push_back(new logfile_data(this->lss_files.size(), this->get_filters(), lf));
|
||||
this->lss_files.push_back(std::make_unique<logfile_data>(
|
||||
this->lss_files.size(), this->get_filters(), lf));
|
||||
}
|
||||
else {
|
||||
(*existing)->set_file(lf);
|
||||
@ -985,7 +986,7 @@ bool logfile_sub_source::insert_file(const shared_ptr<logfile> &lf)
|
||||
|
||||
void logfile_sub_source::set_sql_filter(std::string stmt_str, sqlite3_stmt *stmt)
|
||||
{
|
||||
for (auto ld : *this) {
|
||||
for (auto& ld : *this) {
|
||||
ld->ld_filter_state.lfo_filter_state.clear_filter_state(0);
|
||||
}
|
||||
|
||||
|
@ -467,7 +467,7 @@ public:
|
||||
int get_filtered_count_for(size_t filter_index) const {
|
||||
int retval = 0;
|
||||
|
||||
for (auto ld : this->lss_files) {
|
||||
for (auto& ld : this->lss_files) {
|
||||
retval += ld->ld_filter_state.lfo_filter_state.tfs_filter_hits[filter_index];
|
||||
}
|
||||
|
||||
@ -623,8 +623,8 @@ public:
|
||||
bool ld_visible;
|
||||
};
|
||||
|
||||
typedef std::vector<logfile_data *>::iterator iterator;
|
||||
typedef std::vector<logfile_data *>::const_iterator const_iterator;
|
||||
typedef std::vector<std::unique_ptr<logfile_data>>::iterator iterator;
|
||||
typedef std::vector<std::unique_ptr<logfile_data>>::const_iterator const_iterator;
|
||||
|
||||
iterator begin()
|
||||
{
|
||||
@ -665,9 +665,9 @@ public:
|
||||
};
|
||||
|
||||
nonstd::optional<logfile_data *> find_data(const std::shared_ptr<logfile>& lf) {
|
||||
for (auto ld : *this) {
|
||||
for (auto& ld : *this) {
|
||||
if (ld->ld_filter_state.lfo_filter_state.tfs_logfile == lf) {
|
||||
return ld;
|
||||
return ld.get();
|
||||
}
|
||||
}
|
||||
return nonstd::nullopt;
|
||||
@ -913,7 +913,7 @@ private:
|
||||
struct logfile_data_eq {
|
||||
explicit logfile_data_eq(std::shared_ptr<logfile> lf) : lde_file(std::move(lf)) { };
|
||||
|
||||
bool operator()(const logfile_data *ld)
|
||||
bool operator()(const std::unique_ptr<logfile_data>& ld) const
|
||||
{
|
||||
return this->lde_file == ld->get_file();
|
||||
}
|
||||
@ -945,7 +945,7 @@ private:
|
||||
size_t lss_filename_width = 0;
|
||||
unsigned long lss_flags{0};
|
||||
bool lss_force_rebuild{false};
|
||||
std::vector<logfile_data *> lss_files;
|
||||
std::vector<std::unique_ptr<logfile_data>> lss_files;
|
||||
|
||||
big_array<indexed_content> lss_index;
|
||||
std::vector<uint32_t> lss_filtered_index;
|
||||
|
@ -603,7 +603,7 @@ CREATE TABLE lnav_view_files (
|
||||
}
|
||||
|
||||
int get_column(cursor &vc, sqlite3_context *ctx, int col) {
|
||||
auto ld = *vc.iter;
|
||||
auto& ld = *vc.iter;
|
||||
|
||||
switch (col) {
|
||||
case 0:
|
||||
@ -633,7 +633,7 @@ CREATE TABLE lnav_view_files (
|
||||
|
||||
std::advance(iter, rowid);
|
||||
|
||||
auto ld = *iter;
|
||||
auto& ld = *iter;
|
||||
if (ld->ld_visible != visible) {
|
||||
ld->set_visibility(visible);
|
||||
lss.text_filters_changed();
|
||||
|
Loading…
Reference in New Issue
Block a user