summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-12-21 09:20:09 +0200
committerPanu Matilainen <pmatilai@redhat.com>2009-12-21 09:20:09 +0200
commit92884ca771905b4de2c2abc1fc5b144fecff8e55 (patch)
tree4c2c1d293ad2f1b12c282566e2b8260cee425be0 /lib
parentecf45122398c8f081f51b7574ec6cafb6ca2051d (diff)
downloadlibrpm-tizen-92884ca771905b4de2c2abc1fc5b144fecff8e55.tar.gz
librpm-tizen-92884ca771905b4de2c2abc1fc5b144fecff8e55.tar.bz2
librpm-tizen-92884ca771905b4de2c2abc1fc5b144fecff8e55.zip
Bury ordering structures and their alloc+free inside order.c
- nothing outside order.c needs this stuff, TSI alloc+free routines have no business being exported - for now we need to store a pointer to tsortInfo in the elements, its just an opaque pointer for ping-ponging the data through ts elements - all allocation + freeing is local to ordering code
Diffstat (limited to 'lib')
-rw-r--r--lib/order.c59
-rw-r--r--lib/rpmte.c27
-rw-r--r--lib/rpmte.h19
-rw-r--r--lib/rpmte_internal.h30
4 files changed, 59 insertions, 76 deletions
diff --git a/lib/order.c b/lib/order.c
index 1b1c73e97..8f24fb12e 100644
--- a/lib/order.c
+++ b/lib/order.c
@@ -30,6 +30,30 @@ struct scc_s {
typedef struct scc_s * scc;
+struct relation_s {
+ rpmte rel_suc; // pkg requiring this package
+ rpmsenseFlags rel_flags; // accumulated flags of the requirements
+ struct relation_s * rel_next;
+};
+
+typedef struct relation_s * relation;
+
+struct tsortInfo_s {
+ int degree; /*!< No. of immediate children. */
+ int npreds; /*!< No. of predecessors. */
+ int tree; /*!< Tree index. */
+ int depth; /*!< Depth in dependency tree. */
+ int tsi_count; // #pkgs this pkg requires
+ int tsi_qcnt; // #pkgs requiring this package
+ int tsi_reqx; // requires Idx/mark as (queued/loop)
+ struct relation_s * tsi_relations;
+ struct relation_s * tsi_forward_relations;
+ rpmte tsi_suc; // used for queuing (addQ)
+ int tsi_SccIdx; // # of the SCC the node belongs to
+ // (1 for trivial SCCs)
+ int tsi_SccLowlink; // used for SCC detection
+};
+
struct badDeps_s {
char * pname;
const char * qname;
@@ -107,6 +131,23 @@ static int ignoreDep(const rpmts ts, const rpmte p, const rpmte q)
return 0;
}
+static void rpmTSIFree(tsortInfo tsi)
+{
+ relation rel;
+
+ while (tsi->tsi_relations != NULL) {
+ rel = tsi->tsi_relations;
+ tsi->tsi_relations = tsi->tsi_relations->rel_next;
+ rel = _free(rel);
+ }
+ while (tsi->tsi_forward_relations != NULL) {
+ rel = tsi->tsi_forward_relations;
+ tsi->tsi_forward_relations = \
+ tsi->tsi_forward_relations->rel_next;
+ rel = _free(rel);
+ }
+}
+
/**
* Record next "q <- p" relation (i.e. "p" requires "q").
* @param ts transaction set
@@ -564,6 +605,8 @@ int rpmtsOrder(rpmts ts)
int rc;
rpmal erasedPackages = rpmalCreate(5, rpmtsColor(ts), prefcolor);
scc SCCs;
+ int nelem = rpmtsNElements(ts);
+ tsortInfo sortInfo = xcalloc(nelem, sizeof(struct tsortInfo_s));
(void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_ORDER), 0);
@@ -581,10 +624,9 @@ int rpmtsOrder(rpmts ts)
pi = rpmtsiFree(pi);
rpmalMakeIndex(erasedPackages);
- pi = rpmtsiInit(ts);
- while ((p = rpmtsiNext(pi, 0)) != NULL)
- rpmteNewTSI(p);
- pi = rpmtsiFree(pi);
+ for (int i = 0; i < nelem; i++) {
+ rpmteSetTSI(ts->order[i], &sortInfo[i]);
+ }
/* Record relations. */
rpmlog(RPMLOG_DEBUG, "========== recording tsort relations\n");
@@ -661,10 +703,11 @@ int rpmtsOrder(rpmts ts)
}
/* Clean up tsort data */
- pi = rpmtsiInit(ts);
- while ((p = rpmtsiNext(pi, 0)) != NULL)
- rpmteFreeTSI(p);
- pi = rpmtsiFree(pi);
+ for (int i = 0; i < nelem; i++) {
+ rpmteSetTSI(ts->order[i], NULL);
+ rpmTSIFree(&sortInfo[i]);
+ }
+ free(sortInfo);
assert(newOrderCount == ts->orderCount);
diff --git a/lib/rpmte.c b/lib/rpmte.c
index 9f44d6e36..b09556cd1 100644
--- a/lib/rpmte.c
+++ b/lib/rpmte.c
@@ -421,32 +421,9 @@ tsortInfo rpmteTSI(rpmte te)
return te->tsi;
}
-void rpmteFreeTSI(rpmte te)
+void rpmteSetTSI(rpmte te, tsortInfo tsi)
{
- relation rel;
- if (te == NULL || rpmteTSI(te) == NULL) return;
-
- while (te->tsi->tsi_relations != NULL) {
- rel = te->tsi->tsi_relations;
- te->tsi->tsi_relations = te->tsi->tsi_relations->rel_next;
- rel = _free(rel);
- }
- while (te->tsi->tsi_forward_relations != NULL) {
- rel = te->tsi->tsi_forward_relations;
- te->tsi->tsi_forward_relations = \
- te->tsi->tsi_forward_relations->rel_next;
- rel = _free(rel);
- }
- te->tsi = _free(te->tsi);
-}
-
-void rpmteNewTSI(rpmte te)
-{
- if (te != NULL) {
- rpmteFreeTSI(te);
- te->tsi = xcalloc(1, sizeof(*te->tsi));
- memset(te->tsi, 0, sizeof(*te->tsi));
- }
+ te->tsi = tsi;
}
void rpmteSetDependsOn(rpmte te, rpmte depends) {
diff --git a/lib/rpmte.h b/lib/rpmte.h
index f1edfe4be..905b31145 100644
--- a/lib/rpmte.h
+++ b/lib/rpmte.h
@@ -176,25 +176,6 @@ rpmte rpmteParent(rpmte te);
rpmte rpmteSetParent(rpmte te, rpmte pte);
/** \ingroup rpmte
- * Retrieve tsort info for transaction element.
- * @param te transaction element
- * @return tsort info
- */
-tsortInfo rpmteTSI(rpmte te);
-
-/** \ingroup rpmte
- * Destroy tsort info of transaction element.
- * @param te transaction element
- */
-void rpmteFreeTSI(rpmte te);
-
-/** \ingroup rpmte
- * Initialize tsort info of transaction element.
- * @param te transaction element
- */
-void rpmteNewTSI(rpmte te);
-
-/** \ingroup rpmte
* Destroy dependency set info of transaction element.
* @param te transaction element
*/
diff --git a/lib/rpmte_internal.h b/lib/rpmte_internal.h
index 0d0774dd3..357eead50 100644
--- a/lib/rpmte_internal.h
+++ b/lib/rpmte_internal.h
@@ -8,30 +8,6 @@
* Dependncy ordering information.
*/
-struct relation_s {
- rpmte rel_suc; // pkg requiring this package
- rpmsenseFlags rel_flags; // accumulated flags of the requirements
- struct relation_s * rel_next;
-};
-
-typedef struct relation_s * relation;
-
-struct tsortInfo_s {
- int degree; /*!< No. of immediate children. */
- int npreds; /*!< No. of predecessors. */
- int tree; /*!< Tree index. */
- int depth; /*!< Depth in dependency tree. */
- int tsi_count; // #pkgs this pkg requires
- int tsi_qcnt; // #pkgs requiring this package
- int tsi_reqx; // requires Idx/mark as (queued/loop)
- struct relation_s * tsi_relations;
- struct relation_s * tsi_forward_relations;
- rpmte tsi_suc; // used for queuing (addQ)
- int tsi_SccIdx; // # of the SCC the node belongs to
- // (1 for trivial SCCs)
- int tsi_SccLowlink; // used for SCC detection
-};
-
/**
*/
typedef struct sharedFileInfo_s * sharedFileInfo;
@@ -86,6 +62,12 @@ int rpmteHaveTransScript(rpmte te, rpmTag tag);
RPM_GNUC_INTERNAL
rpmps rpmteProblems(rpmte te);
+RPM_GNUC_INTERNAL
+tsortInfo rpmteTSI(rpmte te);
+
+RPM_GNUC_INTERNAL
+void rpmteSetTSI(rpmte te, tsortInfo tsi);
+
//RPM_GNUC_INTERNAL
rpmfs rpmteGetFileStates(rpmte te);