libpkgconf: migrate cache to pkgconf_client_t which unfortunately requires it to be non-const :(

pull/100/head
William Pitcock 2016-12-02 00:29:33 -06:00
parent e7f4846508
commit c05ecdfc9d
5 changed files with 89 additions and 87 deletions

View File

@ -15,8 +15,6 @@
#include <libpkgconf/libpkgconf.h> #include <libpkgconf/libpkgconf.h>
static pkgconf_list_t pkg_cache = PKGCONF_LIST_INITIALIZER;
/* /*
* pkgconf_cache_lookup(id) * pkgconf_cache_lookup(id)
* *
@ -25,16 +23,16 @@ static pkgconf_list_t pkg_cache = PKGCONF_LIST_INITIALIZER;
* if present. * if present.
*/ */
pkgconf_pkg_t * pkgconf_pkg_t *
pkgconf_cache_lookup(const char *id) pkgconf_cache_lookup(const pkgconf_client_t *client, const char *id)
{ {
pkgconf_node_t *node; pkgconf_node_t *node;
PKGCONF_FOREACH_LIST_ENTRY(pkg_cache.head, node) PKGCONF_FOREACH_LIST_ENTRY(client->pkg_cache.head, node)
{ {
pkgconf_pkg_t *pkg = node->data; pkgconf_pkg_t *pkg = node->data;
if (!strcmp(pkg->id, id)) if (!strcmp(pkg->id, id))
return pkgconf_pkg_ref(pkg); return pkgconf_pkg_ref(client, pkg);
} }
return NULL; return NULL;
@ -47,13 +45,13 @@ pkgconf_cache_lookup(const char *id)
* the cache entry must be removed if the package is freed. * the cache entry must be removed if the package is freed.
*/ */
void void
pkgconf_cache_add(pkgconf_pkg_t *pkg) pkgconf_cache_add(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
{ {
if (pkg == NULL) if (pkg == NULL)
return; return;
pkgconf_pkg_ref(pkg); pkgconf_pkg_ref(client, pkg);
pkgconf_node_insert(&pkg->cache_iter, pkg, &pkg_cache); pkgconf_node_insert(&pkg->cache_iter, pkg, &client->pkg_cache);
} }
/* /*
@ -62,22 +60,24 @@ pkgconf_cache_add(pkgconf_pkg_t *pkg)
* deletes a package from the cache entry. * deletes a package from the cache entry.
*/ */
void void
pkgconf_cache_remove(pkgconf_pkg_t *pkg) pkgconf_cache_remove(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
{ {
if (pkg == NULL) if (pkg == NULL)
return; return;
pkgconf_node_delete(&pkg->cache_iter, &pkg_cache); pkgconf_node_delete(&pkg->cache_iter, &client->pkg_cache);
} }
void void
pkgconf_cache_free(void) pkgconf_cache_free(pkgconf_client_t *client)
{ {
pkgconf_node_t *iter, *iter2; pkgconf_node_t *iter, *iter2;
PKGCONF_FOREACH_LIST_ENTRY_SAFE(pkg_cache.head, iter2, iter) PKGCONF_FOREACH_LIST_ENTRY_SAFE(client->pkg_cache.head, iter2, iter)
{ {
pkgconf_pkg_t *pkg = iter->data; pkgconf_pkg_t *pkg = iter->data;
pkgconf_pkg_free(pkg); pkgconf_pkg_free(client, pkg);
} }
memset(&client->pkg_cache, 0, sizeof client->pkg_cache);
} }

View File

@ -129,12 +129,13 @@ struct pkgconf_pkg_ {
}; };
typedef bool (*pkgconf_pkg_iteration_func_t)(const pkgconf_pkg_t *pkg, void *data); typedef bool (*pkgconf_pkg_iteration_func_t)(const pkgconf_pkg_t *pkg, void *data);
typedef void (*pkgconf_pkg_traverse_func_t)(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags); typedef void (*pkgconf_pkg_traverse_func_t)(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags);
typedef bool (*pkgconf_queue_apply_func_t)(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flags); typedef bool (*pkgconf_queue_apply_func_t)(pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flags);
typedef bool (*pkgconf_error_handler_func_t)(const char *msg); typedef bool (*pkgconf_error_handler_func_t)(const char *msg);
struct pkgconf_client_ { struct pkgconf_client_ {
pkgconf_list_t dir_list; pkgconf_list_t dir_list;
pkgconf_list_t pkg_cache;
#ifdef XXX_NOTYET #ifdef XXX_NOTYET
pkgconf_list_t filter_libdirs; pkgconf_list_t filter_libdirs;
@ -188,21 +189,21 @@ void pkgconf_client_free(pkgconf_client_t *client);
bool pkgconf_error(const pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3); bool pkgconf_error(const pkgconf_client_t *client, const char *format, ...) PRINTFLIKE(2, 3);
bool pkgconf_default_error_handler(const char *msg); bool pkgconf_default_error_handler(const char *msg);
pkgconf_pkg_t *pkgconf_pkg_ref(pkgconf_pkg_t *pkg); pkgconf_pkg_t *pkgconf_pkg_ref(const pkgconf_client_t *client, pkgconf_pkg_t *pkg);
void pkgconf_pkg_unref(pkgconf_pkg_t *pkg); void pkgconf_pkg_unref(pkgconf_client_t *client, pkgconf_pkg_t *pkg);
void pkgconf_pkg_free(pkgconf_pkg_t *pkg); void pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg);
pkgconf_pkg_t *pkgconf_pkg_find(pkgconf_client_t *client, const char *name, unsigned int flags); pkgconf_pkg_t *pkgconf_pkg_find(pkgconf_client_t *client, const char *name, unsigned int flags);
unsigned int pkgconf_pkg_traverse(const pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_pkg_traverse_func_t func, void *data, int maxdepth, unsigned int flags); unsigned int pkgconf_pkg_traverse(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_pkg_traverse_func_t func, void *data, int maxdepth, unsigned int flags);
unsigned int pkgconf_pkg_verify_graph(const pkgconf_client_t *client, pkgconf_pkg_t *root, int depth, unsigned int flags); unsigned int pkgconf_pkg_verify_graph(pkgconf_client_t *client, pkgconf_pkg_t *root, int depth, unsigned int flags);
pkgconf_pkg_t *pkgconf_pkg_verify_dependency(const pkgconf_client_t *client, pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags); pkgconf_pkg_t *pkgconf_pkg_verify_dependency(pkgconf_client_t *client, pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags);
const char *pkgconf_pkg_get_comparator(const pkgconf_dependency_t *pkgdep); const char *pkgconf_pkg_get_comparator(const pkgconf_dependency_t *pkgdep);
int pkgconf_pkg_cflags(const pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags); int pkgconf_pkg_cflags(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags);
int pkgconf_pkg_libs(const pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags); int pkgconf_pkg_libs(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags);
pkgconf_pkg_comparator_t pkgconf_pkg_comparator_lookup_by_name(const char *name); pkgconf_pkg_comparator_t pkgconf_pkg_comparator_lookup_by_name(const char *name);
pkgconf_pkg_t *pkgconf_builtin_pkg_get(const char *name); pkgconf_pkg_t *pkgconf_builtin_pkg_get(const char *name);
int pkgconf_compare_version(const char *a, const char *b); int pkgconf_compare_version(const char *a, const char *b);
pkgconf_pkg_t *pkgconf_scan_all(const pkgconf_client_t *client, void *ptr, pkgconf_pkg_iteration_func_t func); pkgconf_pkg_t *pkgconf_scan_all(pkgconf_client_t *client, void *ptr, pkgconf_pkg_iteration_func_t func);
void pkgconf_pkg_dir_list_build(pkgconf_client_t *client, unsigned int flags); void pkgconf_pkg_dir_list_build(pkgconf_client_t *client, unsigned int flags);
/* parse.c */ /* parse.c */
@ -239,16 +240,16 @@ void pkgconf_tuple_define_global(pkgconf_client_t *client, const char *kv);
/* queue.c */ /* queue.c */
void pkgconf_queue_push(pkgconf_list_t *list, const char *package); void pkgconf_queue_push(pkgconf_list_t *list, const char *package);
bool pkgconf_queue_compile(const pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list); bool pkgconf_queue_compile(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list);
void pkgconf_queue_free(pkgconf_list_t *list); void pkgconf_queue_free(pkgconf_list_t *list);
bool pkgconf_queue_apply(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int maxdepth, unsigned int flags, void *data); bool pkgconf_queue_apply(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int maxdepth, unsigned int flags, void *data);
bool pkgconf_queue_validate(const pkgconf_client_t *client, pkgconf_list_t *list, int maxdepth, unsigned int flags); bool pkgconf_queue_validate(pkgconf_client_t *client, pkgconf_list_t *list, int maxdepth, unsigned int flags);
/* cache.c */ /* cache.c */
pkgconf_pkg_t *pkgconf_cache_lookup(const char *id); pkgconf_pkg_t *pkgconf_cache_lookup(const pkgconf_client_t *client, const char *id);
void pkgconf_cache_add(pkgconf_pkg_t *pkg); void pkgconf_cache_add(pkgconf_client_t *client, pkgconf_pkg_t *pkg);
void pkgconf_cache_remove(pkgconf_pkg_t *pkg); void pkgconf_cache_remove(pkgconf_client_t *client, pkgconf_pkg_t *pkg);
void pkgconf_cache_free(void); void pkgconf_cache_free(pkgconf_client_t *client);
/* audit.c */ /* audit.c */
void pkgconf_audit_open_log(FILE *auditf); void pkgconf_audit_open_log(FILE *auditf);

View File

@ -259,16 +259,16 @@ pkgconf_pkg_new_from_file(const pkgconf_client_t *client, const char *filename,
pkgconf_dependency_add(&pkg->provides, pkg->id, pkg->version, PKGCONF_CMP_EQUAL); pkgconf_dependency_add(&pkg->provides, pkg->id, pkg->version, PKGCONF_CMP_EQUAL);
return pkgconf_pkg_ref(pkg); return pkgconf_pkg_ref(client, pkg);
} }
void void
pkgconf_pkg_free(pkgconf_pkg_t *pkg) pkgconf_pkg_free(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
{ {
if (pkg == NULL || pkg->flags & PKGCONF_PKG_PROPF_VIRTUAL) if (pkg == NULL || pkg->flags & PKGCONF_PKG_PROPF_VIRTUAL)
return; return;
pkgconf_cache_remove(pkg); pkgconf_cache_remove(client, pkg);
pkgconf_dependency_free(&pkg->requires); pkgconf_dependency_free(&pkg->requires);
pkgconf_dependency_free(&pkg->requires_private); pkgconf_dependency_free(&pkg->requires_private);
@ -307,18 +307,20 @@ pkgconf_pkg_free(pkgconf_pkg_t *pkg)
} }
pkgconf_pkg_t * pkgconf_pkg_t *
pkgconf_pkg_ref(pkgconf_pkg_t *pkg) pkgconf_pkg_ref(const pkgconf_client_t *client, pkgconf_pkg_t *pkg)
{ {
(void) client;
pkg->refcount++; pkg->refcount++;
return pkg; return pkg;
} }
void void
pkgconf_pkg_unref(pkgconf_pkg_t *pkg) pkgconf_pkg_unref(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
{ {
pkg->refcount--; pkg->refcount--;
if (pkg->refcount <= 0) if (pkg->refcount <= 0)
pkgconf_pkg_free(pkg); pkgconf_pkg_free(client, pkg);
} }
static inline pkgconf_pkg_t * static inline pkgconf_pkg_t *
@ -344,7 +346,7 @@ pkgconf_pkg_try_specific_path(const pkgconf_client_t *client, const char *path,
} }
static pkgconf_pkg_t * static pkgconf_pkg_t *
pkgconf_pkg_scan_dir(const pkgconf_client_t *client, const char *path, void *data, pkgconf_pkg_iteration_func_t func) pkgconf_pkg_scan_dir(pkgconf_client_t *client, const char *path, void *data, pkgconf_pkg_iteration_func_t func)
{ {
DIR *dir; DIR *dir;
struct dirent *dirent; struct dirent *dirent;
@ -382,7 +384,7 @@ pkgconf_pkg_scan_dir(const pkgconf_client_t *client, const char *path, void *dat
goto out; goto out;
} }
pkgconf_pkg_unref(pkg); pkgconf_pkg_unref(client, pkg);
} }
} }
@ -392,7 +394,7 @@ out:
} }
pkgconf_pkg_t * pkgconf_pkg_t *
pkgconf_scan_all(const pkgconf_client_t *client, void *data, pkgconf_pkg_iteration_func_t func) pkgconf_scan_all(pkgconf_client_t *client, void *data, pkgconf_pkg_iteration_func_t func)
{ {
pkgconf_node_t *n; pkgconf_node_t *n;
pkgconf_pkg_t *pkg; pkgconf_pkg_t *pkg;
@ -474,7 +476,7 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name, unsigned int flags)
/* check cache */ /* check cache */
if (!(flags & PKGCONF_PKG_PKGF_NO_CACHE)) if (!(flags & PKGCONF_PKG_PKGF_NO_CACHE))
{ {
if ((pkg = pkgconf_cache_lookup(name)) != NULL) if ((pkg = pkgconf_cache_lookup(client, name)) != NULL)
{ {
pkg->flags |= PKGCONF_PKG_PROPF_CACHED; pkg->flags |= PKGCONF_PKG_PROPF_CACHED;
return pkg; return pkg;
@ -498,7 +500,7 @@ pkgconf_pkg_find(pkgconf_client_t *client, const char *name, unsigned int flags)
#endif #endif
out: out:
pkgconf_cache_add(pkg); pkgconf_cache_add(client, pkg);
return pkg; return pkg;
} }
@ -960,7 +962,7 @@ pkgconf_pkg_scan_provides_entry(const pkgconf_pkg_t *pkg, const pkgconf_pkg_scan
* scan all available packages to see if a Provides rule matches the pkgdep. * scan all available packages to see if a Provides rule matches the pkgdep.
*/ */
static pkgconf_pkg_t * static pkgconf_pkg_t *
pkgconf_pkg_scan_providers(const pkgconf_client_t *client, pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags) pkgconf_pkg_scan_providers(pkgconf_client_t *client, pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags)
{ {
pkgconf_pkg_t *pkg; pkgconf_pkg_t *pkg;
pkgconf_pkg_scan_providers_ctx_t ctx = { pkgconf_pkg_scan_providers_ctx_t ctx = {
@ -985,7 +987,7 @@ pkgconf_pkg_scan_providers(const pkgconf_client_t *client, pkgconf_dependency_t
* return the appropriate pkgconf_pkg_t object, else NULL. * return the appropriate pkgconf_pkg_t object, else NULL.
*/ */
pkgconf_pkg_t * pkgconf_pkg_t *
pkgconf_pkg_verify_dependency(const pkgconf_client_t *client, pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags) pkgconf_pkg_verify_dependency(pkgconf_client_t *client, pkgconf_dependency_t *pkgdep, unsigned int flags, unsigned int *eflags)
{ {
pkgconf_pkg_t *pkg = NULL; pkgconf_pkg_t *pkg = NULL;
@ -1025,13 +1027,13 @@ pkgconf_pkg_verify_dependency(const pkgconf_client_t *client, pkgconf_dependency
* pkgconf_pkg_traverse(). * pkgconf_pkg_traverse().
*/ */
unsigned int unsigned int
pkgconf_pkg_verify_graph(const pkgconf_client_t *client, pkgconf_pkg_t *root, int depth, unsigned int flags) pkgconf_pkg_verify_graph(pkgconf_client_t *client, pkgconf_pkg_t *root, int depth, unsigned int flags)
{ {
return pkgconf_pkg_traverse(client, root, NULL, NULL, depth, flags); return pkgconf_pkg_traverse(client, root, NULL, NULL, depth, flags);
} }
static unsigned int static unsigned int
pkgconf_pkg_report_graph_error(const pkgconf_client_t *client, pkgconf_pkg_t *parent, pkgconf_pkg_t *pkg, pkgconf_dependency_t *node, unsigned int eflags) pkgconf_pkg_report_graph_error(pkgconf_client_t *client, pkgconf_pkg_t *parent, pkgconf_pkg_t *pkg, pkgconf_dependency_t *node, unsigned int eflags)
{ {
static bool already_sent_notice = false; static bool already_sent_notice = false;
@ -1059,13 +1061,13 @@ pkgconf_pkg_report_graph_error(const pkgconf_client_t *client, pkgconf_pkg_t *pa
} }
if (pkg != NULL) if (pkg != NULL)
pkgconf_pkg_unref(pkg); pkgconf_pkg_unref(client, pkg);
return eflags; return eflags;
} }
static inline unsigned int static inline unsigned int
pkgconf_pkg_walk_list(const pkgconf_client_t *client, pkgconf_pkg_walk_list(pkgconf_client_t *client,
pkgconf_pkg_t *parent, pkgconf_pkg_t *parent,
pkgconf_list_t *deplist, pkgconf_list_t *deplist,
pkgconf_pkg_traverse_func_t func, pkgconf_pkg_traverse_func_t func,
@ -1098,7 +1100,7 @@ pkgconf_pkg_walk_list(const pkgconf_client_t *client,
if (pkgdep->flags & PKGCONF_PKG_PROPF_SEEN) if (pkgdep->flags & PKGCONF_PKG_PROPF_SEEN)
{ {
pkgconf_pkg_unref(pkgdep); pkgconf_pkg_unref(client, pkgdep);
continue; continue;
} }
@ -1107,14 +1109,14 @@ pkgconf_pkg_walk_list(const pkgconf_client_t *client,
pkgdep->flags |= PKGCONF_PKG_PROPF_SEEN; pkgdep->flags |= PKGCONF_PKG_PROPF_SEEN;
eflags |= pkgconf_pkg_traverse(client, pkgdep, func, data, depth - 1, flags); eflags |= pkgconf_pkg_traverse(client, pkgdep, func, data, depth - 1, flags);
pkgdep->flags &= ~PKGCONF_PKG_PROPF_SEEN; pkgdep->flags &= ~PKGCONF_PKG_PROPF_SEEN;
pkgconf_pkg_unref(pkgdep); pkgconf_pkg_unref(client, pkgdep);
} }
return eflags; return eflags;
} }
static inline unsigned int static inline unsigned int
pkgconf_pkg_walk_conflicts_list(const pkgconf_client_t *client, pkgconf_pkg_walk_conflicts_list(pkgconf_client_t *client,
pkgconf_pkg_t *root, pkgconf_list_t *deplist, unsigned int flags) pkgconf_pkg_t *root, pkgconf_list_t *deplist, unsigned int flags)
{ {
unsigned int eflags; unsigned int eflags;
@ -1144,12 +1146,12 @@ pkgconf_pkg_walk_conflicts_list(const pkgconf_client_t *client,
pkgconf_error(client, "It may be possible to ignore this conflict and continue, try the\n"); pkgconf_error(client, "It may be possible to ignore this conflict and continue, try the\n");
pkgconf_error(client, "PKG_CONFIG_IGNORE_CONFLICTS environment variable.\n"); pkgconf_error(client, "PKG_CONFIG_IGNORE_CONFLICTS environment variable.\n");
pkgconf_pkg_unref(pkgdep); pkgconf_pkg_unref(client, pkgdep);
return PKGCONF_PKG_ERRF_PACKAGE_CONFLICT; return PKGCONF_PKG_ERRF_PACKAGE_CONFLICT;
} }
pkgconf_pkg_unref(pkgdep); pkgconf_pkg_unref(client, pkgdep);
} }
} }
@ -1162,7 +1164,7 @@ pkgconf_pkg_walk_conflicts_list(const pkgconf_client_t *client,
* walk the dependency graph up to maxdepth levels. -1 means infinite recursion. * walk the dependency graph up to maxdepth levels. -1 means infinite recursion.
*/ */
unsigned int unsigned int
pkgconf_pkg_traverse(const pkgconf_client_t *client, pkgconf_pkg_traverse(pkgconf_client_t *client,
pkgconf_pkg_t *root, pkgconf_pkg_t *root,
pkgconf_pkg_traverse_func_t func, pkgconf_pkg_traverse_func_t func,
void *data, void *data,
@ -1203,7 +1205,7 @@ pkgconf_pkg_traverse(const pkgconf_client_t *client,
} }
static void static void
pkgconf_pkg_cflags_collect(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags) pkgconf_pkg_cflags_collect(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{ {
pkgconf_list_t *list = data; pkgconf_list_t *list = data;
pkgconf_node_t *node; pkgconf_node_t *node;
@ -1218,7 +1220,7 @@ pkgconf_pkg_cflags_collect(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, v
} }
static void static void
pkgconf_pkg_cflags_private_collect(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags) pkgconf_pkg_cflags_private_collect(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{ {
pkgconf_list_t *list = data; pkgconf_list_t *list = data;
pkgconf_node_t *node; pkgconf_node_t *node;
@ -1234,7 +1236,7 @@ pkgconf_pkg_cflags_private_collect(const pkgconf_client_t *client, pkgconf_pkg_t
} }
int int
pkgconf_pkg_cflags(const pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags) pkgconf_pkg_cflags(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
@ -1253,7 +1255,7 @@ pkgconf_pkg_cflags(const pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_
} }
static void static void
pkgconf_pkg_libs_collect(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags) pkgconf_pkg_libs_collect(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{ {
pkgconf_list_t *list = data; pkgconf_list_t *list = data;
pkgconf_node_t *node; pkgconf_node_t *node;
@ -1277,7 +1279,7 @@ pkgconf_pkg_libs_collect(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, voi
} }
int int
pkgconf_pkg_libs(const pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags) pkgconf_pkg_libs(pkgconf_client_t *client, pkgconf_pkg_t *root, pkgconf_list_t *list, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;

View File

@ -30,7 +30,7 @@ pkgconf_queue_push(pkgconf_list_t *list, const char *package)
} }
bool bool
pkgconf_queue_compile(const pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list) pkgconf_queue_compile(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list)
{ {
pkgconf_node_t *iter; pkgconf_node_t *iter;
@ -60,7 +60,7 @@ pkgconf_queue_free(pkgconf_list_t *list)
} }
static inline unsigned int static inline unsigned int
pkgconf_queue_verify(const pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list, int maxdepth, unsigned int flags) pkgconf_queue_verify(pkgconf_client_t *client, pkgconf_pkg_t *world, pkgconf_list_t *list, int maxdepth, unsigned int flags)
{ {
if (!pkgconf_queue_compile(client, world, list)) if (!pkgconf_queue_compile(client, world, list))
return PKGCONF_PKG_ERRF_DEPGRAPH_BREAK; return PKGCONF_PKG_ERRF_DEPGRAPH_BREAK;
@ -69,7 +69,7 @@ pkgconf_queue_verify(const pkgconf_client_t *client, pkgconf_pkg_t *world, pkgco
} }
bool bool
pkgconf_queue_apply(const pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int maxdepth, unsigned int flags, void *data) pkgconf_queue_apply(pkgconf_client_t *client, pkgconf_list_t *list, pkgconf_queue_apply_func_t func, int maxdepth, unsigned int flags, void *data)
{ {
pkgconf_pkg_t world = { pkgconf_pkg_t world = {
.id = "virtual:world", .id = "virtual:world",
@ -86,17 +86,17 @@ pkgconf_queue_apply(const pkgconf_client_t *client, pkgconf_list_t *list, pkgcon
if (!func(client, &world, data, maxdepth, flags)) if (!func(client, &world, data, maxdepth, flags))
{ {
pkgconf_pkg_free(&world); pkgconf_pkg_free(client, &world);
return false; return false;
} }
pkgconf_pkg_free(&world); pkgconf_pkg_free(client, &world);
return true; return true;
} }
bool bool
pkgconf_queue_validate(const pkgconf_client_t *client, pkgconf_list_t *list, int maxdepth, unsigned int flags) pkgconf_queue_validate(pkgconf_client_t *client, pkgconf_list_t *list, int maxdepth, unsigned int flags)
{ {
bool retval = true; bool retval = true;
pkgconf_pkg_t world = { pkgconf_pkg_t world = {
@ -112,7 +112,7 @@ pkgconf_queue_validate(const pkgconf_client_t *client, pkgconf_list_t *list, int
if (pkgconf_queue_verify(client, &world, list, maxdepth, flags) != PKGCONF_PKG_ERRF_OK) if (pkgconf_queue_verify(client, &world, list, maxdepth, flags) != PKGCONF_PKG_ERRF_OK)
retval = false; retval = false;
pkgconf_pkg_free(&world); pkgconf_pkg_free(client, &world);
return retval; return retval;
} }

41
main.c
View File

@ -184,7 +184,7 @@ print_libs(pkgconf_list_t *list)
} }
static void static void
print_modversion(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unused, unsigned int flags) print_modversion(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unused, unsigned int flags)
{ {
(void) client; (void) client;
(void) unused; (void) unused;
@ -195,7 +195,7 @@ print_modversion(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unuse
} }
static void static void
print_variables(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unused, unsigned int flags) print_variables(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unused, unsigned int flags)
{ {
pkgconf_node_t *node; pkgconf_node_t *node;
(void) client; (void) client;
@ -265,7 +265,7 @@ print_provides(pkgconf_pkg_t *pkg)
} }
static bool static bool
apply_provides(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags) apply_provides(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags)
{ {
pkgconf_node_t *iter; pkgconf_node_t *iter;
(void) unused; (void) unused;
@ -279,14 +279,14 @@ apply_provides(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unuse
pkg = pkgconf_pkg_verify_dependency(client, dep, flags, NULL); pkg = pkgconf_pkg_verify_dependency(client, dep, flags, NULL);
print_provides(pkg); print_provides(pkg);
pkgconf_pkg_free(pkg); pkgconf_pkg_free(&pkg_client, pkg);
} }
return true; return true;
} }
static void static void
print_digraph_node(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unused, unsigned int flags) print_digraph_node(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unused, unsigned int flags)
{ {
pkgconf_node_t *node; pkgconf_node_t *node;
(void) client; (void) client;
@ -304,7 +304,7 @@ print_digraph_node(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *unu
} }
static bool static bool
apply_digraph(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags) apply_digraph(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
@ -322,7 +322,7 @@ apply_digraph(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused
} }
static bool static bool
apply_modversion(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags) apply_modversion(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
@ -335,7 +335,7 @@ apply_modversion(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unu
} }
static bool static bool
apply_variables(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags) apply_variables(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
@ -353,7 +353,7 @@ typedef struct {
} var_request_t; } var_request_t;
static void static void
print_variable(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags) print_variable(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{ {
var_request_t *req = data; var_request_t *req = data;
const char *var; const char *var;
@ -385,7 +385,7 @@ print_variable(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, u
} }
static bool static bool
apply_variable(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *variable, int maxdepth, unsigned int flags) apply_variable(pkgconf_client_t *client, pkgconf_pkg_t *world, void *variable, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
@ -404,7 +404,7 @@ apply_variable(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *varia
} }
static bool static bool
apply_cflags(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *list_head, int maxdepth, unsigned int flags) apply_cflags(pkgconf_client_t *client, pkgconf_pkg_t *world, void *list_head, int maxdepth, unsigned int flags)
{ {
pkgconf_list_t *list = list_head; pkgconf_list_t *list = list_head;
int eflag; int eflag;
@ -424,7 +424,7 @@ apply_cflags(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *list_he
} }
static bool static bool
apply_libs(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *list_head, int maxdepth, unsigned int flags) apply_libs(pkgconf_client_t *client, pkgconf_pkg_t *world, void *list_head, int maxdepth, unsigned int flags)
{ {
pkgconf_list_t *list = list_head; pkgconf_list_t *list = list_head;
int eflag; int eflag;
@ -444,7 +444,7 @@ apply_libs(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *list_head
} }
static bool static bool
apply_requires(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags) apply_requires(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags)
{ {
pkgconf_node_t *iter; pkgconf_node_t *iter;
(void) unused; (void) unused;
@ -458,14 +458,14 @@ apply_requires(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unuse
pkg = pkgconf_pkg_verify_dependency(client, dep, flags, NULL); pkg = pkgconf_pkg_verify_dependency(client, dep, flags, NULL);
print_requires(pkg); print_requires(pkg);
pkgconf_pkg_free(pkg); pkgconf_pkg_free(&pkg_client, pkg);
} }
return true; return true;
} }
static bool static bool
apply_requires_private(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags) apply_requires_private(pkgconf_client_t *client, pkgconf_pkg_t *world, void *unused, int maxdepth, unsigned int flags)
{ {
pkgconf_node_t *iter; pkgconf_node_t *iter;
(void) unused; (void) unused;
@ -479,13 +479,13 @@ apply_requires_private(const pkgconf_client_t *client, pkgconf_pkg_t *world, voi
pkg = pkgconf_pkg_verify_dependency(client, dep, flags | PKGCONF_PKG_PKGF_SEARCH_PRIVATE, NULL); pkg = pkgconf_pkg_verify_dependency(client, dep, flags | PKGCONF_PKG_PKGF_SEARCH_PRIVATE, NULL);
print_requires_private(pkg); print_requires_private(pkg);
pkgconf_pkg_free(pkg); pkgconf_pkg_free(&pkg_client, pkg);
} }
return true; return true;
} }
static void static void
check_uninstalled(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags) check_uninstalled(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{ {
int *retval = data; int *retval = data;
(void) client; (void) client;
@ -496,7 +496,7 @@ check_uninstalled(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data
} }
static bool static bool
apply_uninstalled(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flags) apply_uninstalled(pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
@ -509,7 +509,7 @@ apply_uninstalled(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *da
} }
static void static void
print_graph_node(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags) print_graph_node(pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data, unsigned int flags)
{ {
pkgconf_node_t *n; pkgconf_node_t *n;
@ -541,7 +541,7 @@ print_graph_node(const pkgconf_client_t *client, pkgconf_pkg_t *pkg, void *data,
} }
static bool static bool
apply_simulate(const pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flags) apply_simulate(pkgconf_client_t *client, pkgconf_pkg_t *world, void *data, int maxdepth, unsigned int flags)
{ {
int eflag; int eflag;
@ -1111,7 +1111,6 @@ out_println:
out: out:
pkgconf_client_deinit(&pkg_client); pkgconf_client_deinit(&pkg_client);
pkgconf_cache_free();
if (logfile_out != NULL) if (logfile_out != NULL)
fclose(logfile_out); fclose(logfile_out);