summaryrefslogtreecommitdiff
path: root/lib/rpmtd.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2008-05-13 11:02:45 +0300
committerPanu Matilainen <pmatilai@redhat.com>2008-05-13 11:02:45 +0300
commita83cfce188a4545756a8fa5791f3b9cbe20190ed (patch)
treec6b2c6424dbd7aec18bf8eca25a65a62aa9df1c9 /lib/rpmtd.c
parent6fd646f238b402d2e47c8af8520d3ffa48ebd91e (diff)
downloadlibrpm-tizen-a83cfce188a4545756a8fa5791f3b9cbe20190ed.tar.gz
librpm-tizen-a83cfce188a4545756a8fa5791f3b9cbe20190ed.tar.bz2
librpm-tizen-a83cfce188a4545756a8fa5791f3b9cbe20190ed.zip
New "tag data" container struct + some basic methods to deal with it
- to be used for passing around header and extension data - inspired by similar changes in rpm5.org, details and implementation differ
Diffstat (limited to 'lib/rpmtd.c')
-rw-r--r--lib/rpmtd.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/rpmtd.c b/lib/rpmtd.c
new file mode 100644
index 000000000..50d2b0800
--- /dev/null
+++ b/lib/rpmtd.c
@@ -0,0 +1,47 @@
+#include "system.h"
+
+#include <rpm/rpmtd.h>
+#include <rpm/rpmstring.h>
+
+#include "debug.h"
+
+rpmtd rpmtdNew(void)
+{
+ rpmtd td = xmalloc(sizeof(*td));
+ rpmtdReset(td);
+ return td;
+}
+
+rpmtd rpmtdFree(rpmtd td)
+{
+ /* permit free on NULL td */
+ if (td != NULL) {
+ /* XXX should we free data too - a flag maybe? */
+ free(td);
+ }
+ return NULL;
+}
+
+void rpmtdReset(rpmtd td)
+{
+ assert(td != NULL);
+
+ memset(td, 0, sizeof(*td));
+ td->ix = -1;
+}
+
+void rpmtdFreeData(rpmtd td)
+{
+ assert(td != NULL);
+
+ if (td->freeData) {
+ free(td->data);
+ }
+ rpmtdReset(td);
+}
+
+rpm_count_t rpmtdCount(rpmtd td)
+{
+ assert(td != NULL);
+ return td->count;
+}