td->type = RPM_STRING_ARRAY_TYPE;
td->data = list;
- td->freeData = 0;
return 0;
}
/* only return the first prefix of the array */
td->type = RPM_STRING_TYPE;
td->data = xstrdup(rpmtdGetString(&prefixes));
- td->freeData = 1;
+ td->flags = RPMTD_ALLOCED;
rpmtdFreeData(&prefixes);
return 0;
}
return 1;
td->type = RPM_INT32_TYPE;
- td->freeData = 1;
+ td->flags = RPMTD_ALLOCED;
if (filenames == NULL) {
usages = xcalloc((td->count), sizeof(usages));
char buf[5];
if (!hge(h, RPMTAG_TRIGGERNAME, &tnt, (rpm_data_t *) &names, &numNames)) {
- td->freeData = 0;
return 0;
}
xx = hge(h, RPMTAG_TRIGGERSCRIPTS, &tst, (rpm_data_t *) &s, &numScripts);
s = hfd(s, tst);
- td->freeData = 1;
+ td->flags = RPMTD_ALLOCED;
td->data = conds = xmalloc(sizeof(*conds) * numScripts);
td->count = numScripts;
td->type = RPM_STRING_ARRAY_TYPE;
rpm_flag_t * flags;
if (!hge(h, RPMTAG_TRIGGERINDEX, NULL, (rpm_data_t *) &indices, &numNames)) {
- td->freeData = 0;
return 1;
}
xx = hge(h, RPMTAG_TRIGGERSCRIPTS, &tst, (rpm_data_t *) &s, &numScripts);
s = hfd(s, tst);
- td->freeData = 1;
+ td->flags = RPMTD_ALLOCED | RPMTD_PTR_ALLOCED;
td->data = conds = xmalloc(sizeof(*conds) * numScripts);
td->count = numScripts;
td->type = RPM_STRING_ARRAY_TYPE;
td->type = RPM_STRING_ARRAY_TYPE;
rpmfiBuildFNames(h, RPMTAG_BASENAMES,
(const char ***) &(td->data), &(td->count));
- td->freeData = 1;
+ td->flags = RPMTD_ALLOCED;
return 0;
}
{
td->type = RPM_STRING_ARRAY_TYPE;
rpmfiBuildFClasses(h, (const char ***) &(td->data), &(td->count));
- td->freeData = 1;
+ td->flags = RPMTD_ALLOCED;
return 0;
}
td->type = RPM_STRING_ARRAY_TYPE;
rpmfiBuildFDeps(h, RPMTAG_PROVIDENAME,
(const char ***) &(td->data), &(td->count));
- td->freeData = 1;
+ td->flags = RPMTD_ALLOCED;
return 0;
}
td->type = RPM_STRING_ARRAY_TYPE;
rpmfiBuildFDeps(h, RPMTAG_REQUIRENAME,
(const char ***) &(td->data), &(td->count));
- td->freeData = 1;
+ td->flags = RPMTD_ALLOCED;
return 0;
}
td->type = RPM_STRING_TYPE;
td->data = NULL;
td->count = 0;
- td->freeData = 0;
if (dstring && *dstring) {
char *domain, *de;
td->data = dgettext(domain, msgid);
td->data = xstrdup(td->data); /* XXX xstrdup has side effects. */
td->count = 1;
- td->freeData = 1;
+ td->flags = RPMTD_ALLOCED;
}
dstring = _free(dstring);
free(msgkey);
#include <rpm/rpmtypes.h>
#include <rpm/argv.h>
+typedef enum rpmtdFlags_e {
+ RPMTD_NONE = 0,
+ RPMTD_ALLOCED = (1 << 0), /* was memory allocated? */
+ RPMTD_PTR_ALLOCED = (1 << 1), /* were array pointers allocated? */
+ RPMTD_IMMUTABLE = (1 << 2), /* header data or modifiable? */
+} rpmtdFlags;
+
/** \ingroup rpmtd
* Container for rpm tag data (from headers or extensions).
* @todo Make this opaque (at least outside rpm itself)
rpmTagType type; /* data type */
rpm_count_t count; /* number of entries */
rpm_data_t data; /* pointer to actual data */
- int freeData; /* was data malloced */
+ rpmtdFlags flags; /* flags on memory allocation etc */
int ix; /* iteration index */
};