aboutsummaryrefslogtreecommitdiffstats
path: root/URPM.xs
diff options
context:
space:
mode:
Diffstat (limited to 'URPM.xs')
-rw-r--r--URPM.xs31
1 files changed, 18 insertions, 13 deletions
diff --git a/URPM.xs b/URPM.xs
index 8f19511..4e90a1b 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -1039,19 +1039,24 @@ parse_line(AV *depslist, HV *provides, HV *obsoletes, URPM__Package pkg, char *b
memset(pkg, 0, sizeof(struct s_Package));
} else if (!strcmp(tag, "filesize"))
pkg->filesize = atoi(data);
- else if (!strcmp(tag, "requires"))
- free(pkg->requires), pkg->requires = memcpy(malloc(data_len), data, data_len);
- else if (!strcmp(tag, "suggests"))
- free(pkg->suggests), pkg->suggests = memcpy(malloc(data_len), data, data_len);
- else if (!strcmp(tag, "obsoletes"))
- free(pkg->obsoletes), pkg->obsoletes = memcpy(malloc(data_len), data, data_len);
- else if (!strcmp(tag, "conflicts"))
- free(pkg->conflicts), pkg->conflicts = memcpy(malloc(data_len), data, data_len);
- else if (!strcmp(tag, "provides"))
- free(pkg->provides), pkg->provides = memcpy(malloc(data_len), data, data_len);
- else if (!strcmp(tag, "summary"))
- free(pkg->summary), pkg->summary = memcpy(malloc(data_len), data, data_len);
-
+ else {
+ char **ptr = NULL;
+ if (!strcmp(tag, "requires"))
+ ptr = &pkg->requires;
+ else if (!strcmp(tag, "suggests"))
+ ptr = &pkg->suggests;
+ else if (!strcmp(tag, "obsoletes"))
+ ptr = &pkg->obsoletes;
+ else if (!strcmp(tag, "conflicts"))
+ ptr = &pkg->conflicts;
+ else if (!strcmp(tag, "provides"))
+ ptr = &pkg->provides;
+ else if (!strcmp(tag, "summary"))
+ ptr = &pkg->summary;
+
+ if (ptr)
+ free(*ptr), *ptr = memcpy(malloc(data_len), data, data_len);
+ }
return 1;
} else {
fprintf(stderr, "bad line <%s>\n", buff);