aboutsummaryrefslogtreecommitdiff
path: root/archival
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-07-08 05:14:36 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-07-08 05:14:36 +0000
commitdeeed59de0a9bcc068ebd14d7496a6b26e45b890 (patch)
tree7dafd469e9f6bca107adbf930fe77fff9958a0b6 /archival
parent493829207c1c2a36d55aaa13abf806533d0cb87f (diff)
downloadbusybox-w32-deeed59de0a9bcc068ebd14d7496a6b26e45b890.tar.gz
busybox-w32-deeed59de0a9bcc068ebd14d7496a6b26e45b890.tar.bz2
busybox-w32-deeed59de0a9bcc068ebd14d7496a6b26e45b890.zip
libbb: introduce and use xrealloc_vector
function old new delta xrealloc_vector_helper - 51 +51 create_list 84 99 +15 getopt_main 690 695 +5 passwd_main 1049 1053 +4 get_cached 85 89 +4 msh_main 1377 1380 +3 add_match 42 41 -1 read_lines 720 718 -2 grave 1068 1066 -2 fill_match_lines 143 141 -2 add_to_dirlist 67 65 -2 add_input_file 49 47 -2 act 252 250 -2 fsck_main 2252 2246 -6 man_main 765 757 -8 bb_internal_initgroups 228 220 -8 cut_main 1052 1041 -11 add_edge_to_node 55 43 -12 dpkg_main 3851 3835 -16 ifupdown_main 2202 2178 -24 sort_main 838 812 -26 ------------------------------------------------------------------------------ (add/remove: 1/0 grow/shrink: 5/15 up/down: 82/-124) Total: -42 bytes
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 637afceef..28913d2e3 100644
--- a/archival/dpkg.c
+++ b/archival/dpkg.c
@@ -382,9 +382,8 @@ static int search_for_provides(int needle, int start_at)
382 */ 382 */
383static void add_edge_to_node(common_node_t *node, edge_t *edge) 383static void add_edge_to_node(common_node_t *node, edge_t *edge)
384{ 384{
385 node->num_of_edges++; 385 node->edge = xrealloc_vector(node->edge, 2, node->num_of_edges);
386 node->edge = xrealloc(node->edge, sizeof(edge_t) * (node->num_of_edges + 1)); 386 node->edge[node->num_of_edges++] = edge;
387 node->edge[node->num_of_edges - 1] = edge;
388} 387}
389 388
390/* 389/*
@@ -972,7 +971,7 @@ static int check_deps(deb_file_t **deb_file, int deb_start /*, int dep_max_count
972 * installed package for conflicts*/ 971 * installed package for conflicts*/
973 while (deb_file[i] != NULL) { 972 while (deb_file[i] != NULL) {
974 const unsigned package_num = deb_file[i]->package; 973 const unsigned package_num = deb_file[i]->package;
975 conflicts = xrealloc(conflicts, sizeof(int) * (conflicts_num + 1)); 974 conflicts = xrealloc_vector(conflicts, 2, conflicts_num);
976 conflicts[conflicts_num] = package_num; 975 conflicts[conflicts_num] = package_num;
977 conflicts_num++; 976 conflicts_num++;
978 /* add provides to conflicts list */ 977 /* 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
989 new_node->version = package_hashtable[package_num]->edge[j]->version; 988 new_node->version = package_hashtable[package_num]->edge[j]->version;
990 package_hashtable[conflicts_package_num] = new_node; 989 package_hashtable[conflicts_package_num] = new_node;
991 } 990 }
992 conflicts = xrealloc(conflicts, sizeof(int) * (conflicts_num + 1)); 991 conflicts = xrealloc_vector(conflicts, 2, conflicts_num);
993 conflicts[conflicts_num] = conflicts_package_num; 992 conflicts[conflicts_num] = conflicts_package_num;
994 conflicts_num++; 993 conflicts_num++;
995 } 994 }
@@ -1170,7 +1169,8 @@ static char **create_list(const char *filename)
1170 file_list = NULL; 1169 file_list = NULL;
1171 count = 0; 1170 count = 0;
1172 while ((line = xmalloc_fgetline(list_stream)) != NULL) { 1171 while ((line = xmalloc_fgetline(list_stream)) != NULL) {
1173 file_list = xrealloc(file_list, sizeof(char *) * (count + 2)); 1172//TODO: zeroing xrealloc_vector?
1173 file_list = xrealloc_vector(file_list, 2, count);
1174 file_list[count++] = line; 1174 file_list[count++] = line;
1175 file_list[count] = NULL; 1175 file_list[count] = NULL;
1176 } 1176 }
@@ -1634,7 +1634,7 @@ int dpkg_main(int argc UNUSED_PARAM, char **argv)
1634 /* Read arguments and store relevant info in structs */ 1634 /* Read arguments and store relevant info in structs */
1635 while (*argv) { 1635 while (*argv) {
1636 /* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */ 1636 /* deb_count = nb_elem - 1 and we need nb_elem + 1 to allocate terminal node [NULL pointer] */
1637 deb_file = xrealloc(deb_file, sizeof(deb_file[0]) * (deb_count + 2)); 1637 deb_file = xrealloc_vector(deb_file, 2, deb_count);
1638 deb_file[deb_count] = xzalloc(sizeof(deb_file[0][0])); 1638 deb_file[deb_count] = xzalloc(sizeof(deb_file[0][0]));
1639 if (opt & (OPT_install | OPT_unpack)) { 1639 if (opt & (OPT_install | OPT_unpack)) {
1640 /* -i/-u: require filename */ 1640 /* -i/-u: require filename */
diff --git a/archival/rpm.c b/archival/rpm.c
index c4bcd605d..b3d7cd5f7 100644
--- a/archival/rpm.c
+++ b/archival/rpm.c
@@ -279,12 +279,12 @@ static rpm_index **rpm_gettags(int fd, int *num_tags)
279 tmpindex->type = ntohl(tmpindex->type); 279 tmpindex->type = ntohl(tmpindex->type);
280 tmpindex->count = ntohl(tmpindex->count); 280 tmpindex->count = ntohl(tmpindex->count);
281 tmpindex->offset = storepos + ntohl(tmpindex->offset); 281 tmpindex->offset = storepos + ntohl(tmpindex->offset);
282 if (pass==0) 282 if (pass == 0)
283 tmpindex->tag -= 743; 283 tmpindex->tag -= 743;
284 } 284 }
285 xlseek(fd, header.size, SEEK_CUR); /* Seek past store */ 285 xlseek(fd, header.size, SEEK_CUR); /* Seek past store */
286 /* Skip padding to 8 byte boundary after reading signature headers */ 286 /* Skip padding to 8 byte boundary after reading signature headers */
287 if (pass==0) 287 if (pass == 0)
288 xlseek(fd, (8 - (xlseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR); 288 xlseek(fd, (8 - (xlseek(fd,0,SEEK_CUR) % 8)) % 8, SEEK_CUR);
289 } 289 }
290 tags = xrealloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */ 290 tags = xrealloc(tags, tagindex * sizeof(struct rpmtag *)); /* realloc tags to save space */