if (headerGetEntry(h, RPMTAG_PREFIXES, NULL,
(void **) &paths, &c) && (c == 1)) {
- defaultReloc->oldPath = paths[0];
+ defaultReloc->oldPath = strdup(paths[0]);
free(paths);
} else {
headerGetEntry(h, RPMTAG_NAME, NULL, (void **) &name,
return numPackages;
}
- if (defaultReloc)
+ if (defaultReloc) {
+ free(defaultReloc->oldPath);
defaultReloc->oldPath = NULL;
+ }
fdClose(fd);
numBinaryPackages++;
static void alFree(struct availableList * al) {
int i;
+ rpmRelocation * r;
for (i = 0; i < al->size; i++) {
if (al->list[i].provides)
if (al->list[i].files)
free(al->list[i].files);
headerFree(al->list[i].h);
+
+ if (al->list[i].relocs) {
+ r = al->list[i].relocs;
+ while (r->oldPath || r->newPath) {
+ if (r->oldPath) free(r->oldPath);
+ if (r->newPath) free(r->newPath);
+ r++;
+ }
+
+ free(al->list[i].relocs);
+ }
}
if (al->alloced) free(al->list);
Header h, const void * key,
FD_t fd, rpmRelocation * relocs) {
struct availablePackage * p;
+ rpmRelocation * r;
+ int i;
if (al->size == al->alloced) {
al->alloced += 5;
headerRemoveEntry(h, RPMTAG_FILEGIDS);
p->key = key;
- p->relocs = relocs;
p->fd = fd;
+ if (relocs) {
+ for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++);
+ p->relocs = malloc(sizeof(*p->relocs) * (i + 1));
+
+ for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++) {
+ p->relocs[i].oldPath = r->oldPath ? strdup(r->oldPath) : NULL;
+ p->relocs[i].newPath = r->newPath ? strdup(r->newPath) : NULL;
+ }
+ p->relocs[i].oldPath = NULL;
+ p->relocs[i].newPath = NULL;
+ } else {
+ p->relocs = NULL;
+ }
+
alFreeIndex(al);
return p;
#define GETOPT_SHOWRC 1018
#define GETOPT_EXCLUDEPATH 1019
#define GETOPT_DEFINEMACRO 1020
-#define GETOPT_PREFIX 1021 /* XXX hack to avoid prefix dump */
char * version = VERSION;
{ "oldpackage", '\0', 0, &oldPackage, 0, NULL, NULL},
{ "percent", '\0', 0, &showPercents, 0, NULL, NULL},
{ "pipe", '\0', POPT_ARG_STRING, &pipeOutput, 0, NULL, NULL},
- { "prefix", '\0', POPT_ARG_STRING, &prefix, GETOPT_PREFIX, NULL, NULL},
+ { "prefix", '\0', POPT_ARG_STRING, &prefix, 0, NULL, NULL},
{ "query", 'q', 0, NULL, 'q', NULL, NULL},
{ "querytags", '\0', 0, &queryTags, 0, NULL, NULL},
{ "quiet", '\0', 0, &quiet, 0, NULL, NULL},
rpmDefineMacro(NULL, optArg, RMIL_CMDLINE);
break;
- case GETOPT_PREFIX:
- relocations = realloc(relocations,
- sizeof(*relocations) * (numRelocations + 1));
- relocations[numRelocations].oldPath = NULL;
- relocations[numRelocations++].newPath = optArg;
- break;
-
case GETOPT_TIMECHECK:
tce = NULL;
timeCheck = strtoul(optArg, &tce, 10);