diff options
author | Denis Vlasenko | 2008-07-08 05:14:36 +0000 |
---|---|---|
committer | Denis Vlasenko | 2008-07-08 05:14:36 +0000 |
commit | deeed59de0a9bcc068ebd14d7496a6b26e45b890 (patch) | |
tree | 7dafd469e9f6bca107adbf930fe77fff9958a0b6 /archival/dpkg.c | |
parent | 493829207c1c2a36d55aaa13abf806533d0cb87f (diff) | |
download | busybox-deeed59de0a9bcc068ebd14d7496a6b26e45b890.zip busybox-deeed59de0a9bcc068ebd14d7496a6b26e45b890.tar.gz |
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/dpkg.c')
-rw-r--r-- | archival/dpkg.c | 14 |
1 files changed, 7 insertions, 7 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 */ |