Skip to content

Commit

Permalink
one more conversion to uthash
Browse files Browse the repository at this point in the history
  • Loading branch information
bapt committed Aug 23, 2021
1 parent e2eeea2 commit f8c80a5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
24 changes: 11 additions & 13 deletions libpkg/pkg_jobs_universe.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,8 +405,8 @@ pkg_jobs_universe_handle_provide(struct pkg_jobs_universe *universe,

rpkg = NULL;

HASH_FIND_STR(universe->provides, name, prhead);

e = pkghash_get(universe->provides, name);
prhead = e != NULL ? e->value : NULL;
while (pkgdb_it_next(it, &rpkg, flags) == EPKG_OK) {
/* Check for local packages */
unit = NULL;
Expand Down Expand Up @@ -464,14 +464,13 @@ pkg_jobs_universe_handle_provide(struct pkg_jobs_universe *universe,

if (prhead == NULL) {
DL_APPEND(prhead, pr);
HASH_ADD_KEYPTR(hh, universe->provides, pr->provide,
strlen(pr->provide), prhead);
pkghash_safe_add(universe->provides, pr->provide,
prhead, NULL);
pkg_debug (4, "universe: add new provide %s-%s(%s) for require %s",
pr->un->pkg->name, pr->un->pkg->version,
pr->un->pkg->type == PKG_INSTALLED ? "l" : "r",
pr->provide);
}
else {
} else {
DL_APPEND(prhead, pr);
pkg_debug (4, "universe: append provide %s-%s(%s) for require %s",
pr->un->pkg->name, pr->un->pkg->version,
Expand All @@ -487,15 +486,13 @@ static int
pkg_jobs_universe_process_shlibs(struct pkg_jobs_universe *universe,
struct pkg *pkg)
{
struct pkg_job_provide *pr;
struct pkgdb_it *it;
int rc;
pkghash_it hit;

hit = pkghash_iterator(pkg->shlibs_required);
while (pkghash_next(&hit)) {
HASH_FIND_STR(universe->provides, hit.key, pr);
if (pr != NULL)
if (pkghash_get(universe->provides, hit.key) != NULL)
continue;

/* Check for local provides */
Expand Down Expand Up @@ -534,16 +531,14 @@ static int
pkg_jobs_universe_process_provides_requires(struct pkg_jobs_universe *universe,
struct pkg *pkg)
{
struct pkg_job_provide *pr;
struct pkgdb_it *it;
int rc;
pkghash_it hit;


hit = pkghash_iterator(pkg->requires);
while(pkghash_next(&hit)) {
HASH_FIND_STR(universe->provides, hit.key, pr);
if (pr != NULL)
if (pkghash_get(universe->provides, hit.key) != NULL)
continue;

/* Check for local provides */
Expand Down Expand Up @@ -856,7 +851,10 @@ pkg_jobs_universe_free(struct pkg_jobs_universe *universe)
universe->items = NULL;
pkghash_destroy(universe->seen);
universe->seen = NULL;
HASH_FREE(universe->provides, pkg_jobs_universe_provide_free);
it = pkghash_iterator(universe->provides);
while (pkghash_next(&it))
pkg_jobs_universe_provide_free(it.value);
pkghash_destroy(universe->provides);
LL_FREE(universe->uid_replaces, pkg_jobs_universe_replacement_free);
}

Expand Down
4 changes: 3 additions & 1 deletion libpkg/pkg_solve.c
Original file line number Diff line number Diff line change
Expand Up @@ -510,10 +510,12 @@ pkg_solve_add_require_rule(struct pkg_solve_problem *problem,
struct pkg_job_provide *pr, *prhead;
struct pkg *pkg;
int cnt;
pkghash_entry *e;

pkg = var->unit->pkg;

HASH_FIND_STR(problem->j->universe->provides, requirement, prhead);
e = pkghash_get(problem->j->universe->provides, requirement);
prhead = e != NULL ? (struct pkg_job_provide *)e->value : NULL;
if (prhead != NULL) {
pkg_debug(4, "solver: Add require rule: %s-%s(%c) wants %s",
pkg->name, pkg->version, pkg->type == PKG_INSTALLED ? 'l' : 'r',
Expand Down
3 changes: 1 addition & 2 deletions libpkg/private/pkg_jobs.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ struct pkg_job_provide {
const char *provide;
bool is_shlib;
struct pkg_job_provide *next, *prev;
UT_hash_handle hh;
};

struct pkg_job_replace {
Expand All @@ -85,7 +84,7 @@ struct pkg_job_replace {
struct pkg_jobs_universe {
pkghash *items;
pkghash *seen;
struct pkg_job_provide *provides;
pkghash *provides;
struct pkg_job_replace *uid_replaces;
struct pkg_jobs *j;
size_t nitems;
Expand Down

0 comments on commit f8c80a5

Please sign in to comment.