Skip to content

Commit

Permalink
Use the transaction set as argument in rpmalCreate()
Browse files Browse the repository at this point in the history
The rpmalCreate() function is called in two places, in both of
them the arguments are all read from the transaction set.

So simplify the code by passing the ts to rpmalCreate() and
getting the values in the constructor.
  • Loading branch information
mlschroe committed Feb 21, 2020
1 parent 9c5dd5c commit 4c43d26
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 22 deletions.
7 changes: 2 additions & 5 deletions lib/depends.c
Original file line number Diff line number Diff line change
Expand Up @@ -384,10 +384,8 @@ rpmal rpmtsCreateAl(rpmts ts, rpmElementTypes types)
if (ts) {
rpmte p;
rpmtsi pi;
rpmstrPool tspool = rpmtsPool(ts);

al = rpmalCreate(tspool, (rpmtsNElements(ts) / 4) + 1, rpmtsFlags(ts),
rpmtsColor(ts), rpmtsPrefColor(ts));
al = rpmalCreate(ts, (rpmtsNElements(ts) / 4) + 1);
pi = rpmtsiInit(ts);
while ((p = rpmtsiNext(pi, types)))
rpmalAdd(al, p);
Expand Down Expand Up @@ -455,8 +453,7 @@ static int addPackage(rpmts ts, Header h,
}

if (tsmem->addedPackages == NULL) {
tsmem->addedPackages = rpmalCreate(rpmtsPool(ts), 5, rpmtsFlags(ts),
tscolor, rpmtsPrefColor(ts));
tsmem->addedPackages = rpmalCreate(ts, 5);
}
rpmalAdd(tsmem->addedPackages, p);

Expand Down
17 changes: 7 additions & 10 deletions lib/rpmal.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#include "lib/rpmte_internal.h"
#include "lib/rpmds_internal.h"
#include "lib/rpmfi_internal.h"
#include "lib/rpmts_internal.h"

#include "debug.h"

Expand Down Expand Up @@ -92,26 +93,22 @@ static void rpmalFreeIndex(rpmal al)
al->fpc = fpCacheFree(al->fpc);
}

rpmal rpmalCreate(rpmstrPool pool, int delta, rpmtransFlags tsflags,
rpm_color_t tscolor, rpm_color_t prefcolor)
rpmal rpmalCreate(rpmts ts, int delta)
{
rpmal al = xcalloc(1, sizeof(*al));

/* transition time safe-guard */
assert(pool != NULL);

al->pool = rpmstrPoolLink(pool);
al->pool = rpmstrPoolLink(rpmtsPool(ts));
al->delta = delta;
al->size = 0;
al->alloced = al->delta;
al->list = xmalloc(sizeof(*al->list) * al->alloced);;
al->list = xmalloc(sizeof(*al->list) * al->alloced);

al->providesHash = NULL;
al->obsoletesHash = NULL;
al->fileHash = NULL;
al->tsflags = tsflags;
al->tscolor = tscolor;
al->prefcolor = prefcolor;
al->tsflags = rpmtsFlags(ts);
al->tscolor = rpmtsColor(ts);
al->prefcolor = rpmtsPrefColor(ts);

return al;
}
Expand Down
10 changes: 3 additions & 7 deletions lib/rpmal.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,13 @@ extern "C" {
typedef struct rpmal_s * rpmal;

/**
* Initialize available packckages, items, and directory list.
* @param pool shared string pool with base, dir and dependency names
* Initialize available packages, items, and directory list.
* @param ts transaction set
* @param delta no. of entries to add on each realloc
* @param tsflags transaction control flags
* @param tscolor transaction color bits
* @param prefcolor preferred color
* @return al new available list
*/
RPM_GNUC_INTERNAL
rpmal rpmalCreate(rpmstrPool pool, int delta, rpmtransFlags tsflags,
rpm_color_t tscolor, rpm_color_t prefcolor);
rpmal rpmalCreate(rpmts ts, int delta);

/**
* Free available packages, items, and directory members.
Expand Down

0 comments on commit 4c43d26

Please sign in to comment.