diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2017-09-12 01:51:17 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2017-09-12 01:51:17 +0300 |
commit | 53a76972f56688f4e0c7889e295d87b91ae85bc5 (patch) | |
tree | 479eae73397f1204bf0761a1012334f2343b42d9 /libpkgconf/pkg.c | |
parent | 4beec8f055fd3b0cc4ef618cce8b52c58dd0ee08 (diff) |
Fix leaks and package not caching
Diffstat (limited to 'libpkgconf/pkg.c')
-rw-r--r-- | libpkgconf/pkg.c | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/libpkgconf/pkg.c b/libpkgconf/pkg.c index bcfb486..59957ff 100644 --- a/libpkgconf/pkg.c +++ b/libpkgconf/pkg.c @@ -16,6 +16,8 @@ #include <libpkgconf/config.h> #include <libpkgconf/libpkgconf.h> +#include <assert.h> + /* * !doc * @@ -407,6 +409,13 @@ pkgconf_pkg_new_from_file(pkgconf_client_t *client, const char *filename, FILE * void pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg) { + // The function leaks (issue #132 is reported). The whole concept of "static" + // packages is quite murky, so it's better just not to use it, at least + // until fixed by the library owners. In particular don't use + // pkgconf_queue_* functions. + // + assert (pkg == NULL || (pkg->flags & PKGCONF_PKG_PROPF_STATIC) == 0); + if (pkg == NULL || pkg->flags & PKGCONF_PKG_PROPF_STATIC) return; @@ -672,6 +681,10 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name) if (pkg != NULL) { pkgconf_path_add(pkg_get_parent_dir(pkg), &client->dir_list, true); + + // Add the package to the cache (issue #133 is reported). + // + pkgconf_cache_add(client, pkg); return pkg; } } |