Improve xbps_end() and use it before exit(3)ing.

- Simplify xbps_repo_open::repo_get_dict().
- Use xbps_end() in the utils where necessary.
- Make xbps_end() call xbps_pkgdb_unlock() if necessary.
- Make xbps_end() release rpool resources.
- Make xbps_end() release resources from xbps_handle.
- Fixed 90% of reported leaks (still reachable at exit) from valgrind.

That was to silence valgrind's memcheck with --leak-check=full.
This commit is contained in:
Juan RP
2015-01-10 19:11:31 +01:00
parent d98442d84e
commit ee175a2a68
11 changed files with 50 additions and 55 deletions

View File

@ -237,7 +237,7 @@ main(int argc, char **argv)
for (i = optind; i < argc; i++) {
rv = update_pkg(&xh, argv[i]);
if (rv != 0) {
xbps_pkgdb_unlock(&xh);
xbps_end(&xh);
exit(rv);
}
}
@ -250,15 +250,13 @@ main(int argc, char **argv)
if (npkgs >= 2 && rv == EEXIST) {
rv = 0;
} else if (rv != 0) {
xbps_pkgdb_unlock(&xh);
xbps_end(&xh);
exit(rv);
}
}
rv = exec_transaction(&xh, maxcols, yes, drun);
}
if (!drun)
xbps_pkgdb_unlock(&xh);
xbps_end(&xh);
exit(rv);
}