forked from ariadne/pkgconf
cache: clear the cache with pkgconf_cache_remove
Which results in more code re-use.
parent
2b310c570f
commit
2133830c21
|
@ -174,7 +174,9 @@ pkgconf_cache_remove(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
|
||||||
|
|
||||||
if (slot == NULL)
|
if (slot == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
(*slot)->flags &= ~PKGCONF_PKG_PROPF_CACHED;
|
(*slot)->flags &= ~PKGCONF_PKG_PROPF_CACHED;
|
||||||
|
pkgconf_pkg_unref(client, *slot);
|
||||||
*slot = NULL;
|
*slot = NULL;
|
||||||
|
|
||||||
qsort(client->cache_table, client->cache_count,
|
qsort(client->cache_table, client->cache_count,
|
||||||
|
@ -201,18 +203,6 @@ pkgconf_cache_remove(pkgconf_client_t *client, pkgconf_pkg_t *pkg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
|
||||||
clear_dependency_matches(pkgconf_list_t *list)
|
|
||||||
{
|
|
||||||
pkgconf_node_t *iter;
|
|
||||||
|
|
||||||
PKGCONF_FOREACH_LIST_ENTRY(list->head, iter)
|
|
||||||
{
|
|
||||||
pkgconf_dependency_t *dep = iter->data;
|
|
||||||
dep->match = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* !doc
|
* !doc
|
||||||
*
|
*
|
||||||
|
@ -230,31 +220,9 @@ pkgconf_cache_free(pkgconf_client_t *client)
|
||||||
if (client->cache_table == NULL)
|
if (client->cache_table == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
pkgconf_pkg_t **cache_table;
|
while (client->cache_count > 0)
|
||||||
size_t i, count;
|
pkgconf_cache_remove(client, client->cache_table[0]);
|
||||||
|
|
||||||
cache_table = pkgconf_reallocarray(NULL, client->cache_count, sizeof (void *));
|
|
||||||
memcpy(cache_table, client->cache_table,
|
|
||||||
client->cache_count * sizeof (void *));
|
|
||||||
|
|
||||||
/* first we clear cached match pointers */
|
|
||||||
for (i = 0, count = client->cache_count; i < count; i++)
|
|
||||||
{
|
|
||||||
pkgconf_pkg_t *pkg = cache_table[i];
|
|
||||||
|
|
||||||
clear_dependency_matches(&pkg->required);
|
|
||||||
clear_dependency_matches(&pkg->requires_private);
|
|
||||||
clear_dependency_matches(&pkg->provides);
|
|
||||||
clear_dependency_matches(&pkg->conflicts);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* now forcibly free everything */
|
|
||||||
for (i = 0, count = client->cache_count; i < count; i++)
|
|
||||||
{
|
|
||||||
pkgconf_pkg_t *pkg = cache_table[i];
|
|
||||||
pkgconf_pkg_free(client, pkg);
|
|
||||||
}
|
|
||||||
free(cache_table);
|
|
||||||
free(client->cache_table);
|
free(client->cache_table);
|
||||||
client->cache_table = NULL;
|
client->cache_table = NULL;
|
||||||
client->cache_count = 0;
|
client->cache_count = 0;
|
||||||
|
|
Loading…
Reference in New Issue