RPM Package Manager, CVS Repository
http://rpm5.org/cvs/
____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson
Root: /v/rpm/cvs Email: jbj@rpm5.org
Module: rpm Date: 20-Oct-2007 17:58:29
Branch: HEAD Handle: 2007102016582801
Modified files:
rpm CHANGES
rpm/rpmdb header.c
Log:
- jbj: use tag data cache.
Summary:
Revision Changes Path
1.1743 +1 -0 rpm/CHANGES
1.103 +58 -40 rpm/rpmdb/header.c
____________________________________________________________________________
patch -p0 <<'@@ .'
Index: rpm/CHANGES
============================================================================
$ cvs diff -u -r1.1742 -r1.1743 CHANGES
--- rpm/CHANGES 20 Oct 2007 15:37:39 -0000 1.1742
+++ rpm/CHANGES 20 Oct 2007 15:58:28 -0000 1.1743
@@ -1,4 +1,5 @@
4.5 -> 5.0:
+ - jbj: use tag data cache.
- jbj: add tag data cache.
- jbj: eliminate rpmec data type.
- jbj: merge rpmec into HE_t.
@@ .
patch -p0 <<'@@ .'
Index: rpm/rpmdb/header.c
============================================================================
$ cvs diff -u -r1.102 -r1.103 header.c
--- rpm/rpmdb/header.c 20 Oct 2007 15:37:39 -0000 1.102
+++ rpm/rpmdb/header.c 20 Oct 2007 15:58:29 -0000 1.103
@@ -3456,6 +3456,53 @@
}
/**
+ * Create tag data cache.
+ * @param ntc no. of elements
+ * @return new tag data cache
+ */
+static /*@only@*/ HE_t
+rpmtcNew(int ntc)
+ /*@*/
+{
+ HE_t ec = xcalloc(ntc+1, sizeof(*ec));
+ return ec;
+}
+
+/**
+ * Clean a tag container.
+ * @param he tag container
+ */
+static void rpmtcClean(/*@null@*/ HE_t he)
+ /*@modifies he @*/
+{
+ if (he) {
+ if (he->freeData)
+ he->p.ptr = _free(he->p.ptr);
+ memset(he, 0, sizeof(*he));
+ }
+ return;
+}
+
+/**
+ * Destroy tag data cache.
+ * @param tc tag data cache
+ * @param ntc no. of elements
+ * @return NULL always
+ */
+static /*@null@*/ HE_t
+rpmtcFree(/*@only@*/ HE_t tc, int ntc)
+ /*@modifies ec @*/
+{
+ int i;
+
+ if (tc != NULL)
+ for (i = 0; i < ntc; i++)
+ rpmtcClean(tc + i);
+ tc = _free(tc);
+ return NULL;
+}
+
+/**
* Format a single item's value.
* @param hsa headerSprintf args
* @param tag tag
@@ -3466,7 +3513,7 @@
static char * formatValue(headerSprintfArgs hsa, sprintfTag tag, int element)
/*@modifies hsa @*/
{
- HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he));
+ HE_t he = hsa->tc + hsa->i;
char * val = NULL;
size_t need = 0;
char * t, * te;
@@ -3476,6 +3523,8 @@
HE_t vhe = memset(alloca(sizeof(*vhe)), 0, sizeof(*vhe));
int_64 ival = 0;
+ rpmtcClean(he);
+
if (tag->ext) {
if (getExtension(hsa, tag->ext, &he->t, &he->p, &he->c, hsa->ec + tag->extNum))
{
@@ -3492,6 +3541,7 @@
he->p.str = "(none)";
}
+#if !defined(DYING) /* XXX notyet */
/* XXX this test is unnecessary, array sizes are checked */
switch (he->t) {
default:
@@ -3511,20 +3561,24 @@
break;
}
he->freeData = 1;
+#endif
}
if (tag->arrayCount) {
+ countBuf = he->c;
+#ifdef DYING
/*@-modobserver -observertrans@*/
if (he->freeData) {
he->p.ptr = headerFreeData(he->p.ptr, he->t);
he->freeData = 0;
}
/*@=modobserver =observertrans@*/
-
- countBuf = he->c;
+#else
+ rpmtcClean(he);
+#endif
+ he->t = RPM_INT32_TYPE;
he->p.i32p = &countBuf;
he->c = 1;
- he->t = RPM_INT32_TYPE;
}
if (he->p.ptr)
@@ -3885,42 +3939,6 @@
return NULL;
}
-/**
- * Create tag data cache.
- * @param ntc no. of elements
- * @return new tag data cache
- */
-static /*@only@*/ HE_t
-rpmtcNew(int ntc)
- /*@*/
-{
- HE_t ec = xcalloc(ntc+1, sizeof(*ec));
- return ec;
-}
-
-/**
- * Destroy tag data cache.
- * @param tc tag data cache
- * @param ntc no. of elements
- * @return NULL always
- */
-static /*@null@*/ HE_t
-rpmtcFree(/*@only@*/ HE_t tc, int ntc)
- /*@modifies ec @*/
-{
- int i;
-
- if (tc != NULL)
- for (i = 0; i < ntc; i++) {
- HE_t he = tc + i;
- if (he->freeData)
- he->p.ptr = _free(he->p.ptr);
- memset(tc, 0, sizeof(*tc));
- }
- tc = _free(tc);
- return NULL;
-}
-
/** \ingroup header
* Return formatted output string from header tags.
* The returned string must be free()d.
@@ .
Received on Sat Oct 20 17:58:29 2007