summaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
Diffstat (limited to 'archival')
-rw-r--r--archival/dpkg.c14
-rw-r--r--archival/rpm.c4
2 files changed, 9 insertions, 9 deletions
diff --git a/archival/dpkg.c b/archival/dpkg.c
index 637afce..28913d2 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -382,9 +382,8 @@ static int search_for_provides(int needle, int start_at)
*/
static void add_edge_to_node(common_node_t *node, edge_t *edge)
{
- node->num_of_edges++;
- node->edge = xrealloc(node->edge, sizeof(edge_t) * (node->num_of_edges + 1));
- node->edge[node->num_of_edges - 1] = edge;
+ node->edge = xrealloc_vector(node->edge, 2, node->num_of_edges);
+ node->edge[node->num_of_edges++] = edge;
}
/*
@@ -972,7 +971,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count
* installed package for conflicts*/
while (deb_file[i] != NULL) {
const unsigned package_num = deb_file[i]->package;
- conflicts = xrealloc(conflicts, sizeof(int) * (conflicts_num + 1));
+ conflicts = xrealloc_vector(conflicts, 2, conflicts_num);
conflicts[conflicts_num] = package_num;
conflicts_num++;
/* add provides to conflicts list */
@@ -989,7 +988,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count
new_node->version = package_hashtable[package_num]->edge[j]->version;
package_hashtable[conflicts_package_num] = new_node;
}
- conflicts = xrealloc(conflicts, sizeof(int) * (conflicts_num + 1));
+ conflicts = xrealloc_vector(conflicts, 2, conflicts_num);
conflicts[conflicts_num] = conflicts_package_num;
conflicts_num++;
}
@@ -1170,7 +1169,8 @@ static char **create_list(const char *filename)
file_list = NULL;
count = 0;
while ((line = xmalloc_fgetline(list_stream)) != NULL) {
- file_list = xrealloc(file_list, sizeof(char *) * (count + 2));
+//TODO: zeroing xrealloc_vector?
+ file_list = xrealloc_vector(file_list, 2, count);
file_list[count++] = line;
file_list[count] = NULL;
}
@@ -1634,7 +1634,7 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv)
/* Read arguments and store relevant info in structs */
while (*argv) {
/* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */
- deb_file = xrealloc(deb_file, sizeof(deb_file[0]) * (deb_count + 2));
+ deb_file = xrealloc_vector(deb_file, 2, deb_count);
deb_file[deb_count] = xzalloc(sizeof(deb_file[0][0]));
if (opt & (OPT_install | OPT_unpack)) {
/* -i/-u: require filename */
diff --git a/archival/rpm.c b/archival/rpm.c
index c4bcd60..b3d7cd5 100644
--- a/archival/rpm.c
+++ b/archival/rpm.c
@@ -279,12 +279,12 @@ static rpm_index **rpm_gettags(int fd, int *num_tags)
tmpindex->type = ntohl(tmpindex->type);
tmpindex->count = ntohl(tmpindex->count);
tmpindex->offset = storepos + ntohl(tmpindex->offset);
- if (pass==0)
+ if (pass == 0)
tmpindex->tag -= 743;
}
xlseek(fd, header.size, SEEK_CUR); /* Seek past store */
/* Skip padding to 8 byte boundary after reading signature headers */
- if (pass==0)
+ if (pass == 0)
xlseek(fd, (8 - (xlseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR);
}
tags = xrealloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */