From a9920b929913ccd627b817476dddd45aea1fd6b7 Mon Sep 17 00:00:00 2001 From: Panu Matilainen Date: Tue, 20 May 2008 12:18:14 +0300 Subject: [PATCH] Fix up for RPM_BIN_TYPE td->count abuse just once, in rpmtdCount() --- lib/rpmtd.c | 7 +++---- lib/rpmtd.h | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/rpmtd.c b/lib/rpmtd.c index 6f411a4..90cc566 100644 --- a/lib/rpmtd.c +++ b/lib/rpmtd.c @@ -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; diff --git a/lib/rpmtd.h b/lib/rpmtd.h index 0edde14..bc6ed95 100644 --- a/lib/rpmtd.h +++ b/lib/rpmtd.h @@ -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. */ -- 2.7.4