Fix up for RPM_BIN_TYPE td->count abuse just once, in rpmtdCount()
authorPanu Matilainen <pmatilai@redhat.com>
Tue, 20 May 2008 09:18:14 +0000 (12:18 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Wed, 21 May 2008 09:04:51 +0000 (12:04 +0300)
lib/rpmtd.c
lib/rpmtd.h

index 6f411a4..90cc566 100644 (file)
@@ -48,7 +48,8 @@ void rpmtdFreeData(rpmtd td)
 rpm_count_t rpmtdCount(rpmtd td)
 {
     assert(td != NULL);
-    return td->count;
+    /* fix up for binary type abusing count as data length */
+    return (td->type == RPM_BIN_TYPE) ? 1 : td->count;
 }
 
 rpmTag rpmtdTag(rpmtd td)
@@ -77,11 +78,9 @@ int rpmtdNext(rpmtd td)
     assert(td != NULL);
 
     int i = -1;
-    /* fix up for binary type abusing count as data length */
-    int count = (td->type == RPM_BIN_TYPE) ? 1 : td->count;
     
     if (++td->ix >= 0) {
-       if (td->ix < count) {
+       if (td->ix < rpmtdCount(td)) {
            i = td->ix;
        } else {
            td->ix = i;
index 0edde14..bc6ed95 100644 (file)
@@ -45,7 +45,7 @@ void rpmtdReset(rpmtd td);
 void rpmtdFreeData(rpmtd td);
 
 /** \ingroup rpmtd
- * Retrieve number of entries in the container.
+ * Retrieve array size of the container. For non-array types this is always 1.
  * @param td           Tag data container
  * @return             Number of entries in contained data.
  */