lsmem: make it without leaks for non-error output

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2020-07-08 08:48:45 +02:00
parent 2b41c409e7
commit bf1d0a4ea0
1 changed files with 13 additions and 0 deletions

View File

@ -431,6 +431,18 @@ static int is_mergeable(struct lsmem *lsmem, struct memory_block *blk)
return 1;
}
static void free_info(struct lsmem *lsmem)
{
int i;
if (!lsmem)
return;
free(lsmem->blocks);
for (i = 0; i < lsmem->ndirs; i++)
free(lsmem->dirs[i]);
free(lsmem->dirs);
}
static void read_info(struct lsmem *lsmem)
{
struct memory_block blk;
@ -742,5 +754,6 @@ int main(int argc, char **argv)
scols_unref_table(lsmem->table);
ul_unref_path(lsmem->sysmem);
free_info(lsmem);
return 0;
}