svn commit: trunk/busybox: archival coreutils debianutils editors f etc...
vda at busybox.net
vda at busybox.net
Sun Jun 15 05:40:57 UTC 2008
Author: vda
Date: 2008-06-14 22:40:56 -0700 (Sat, 14 Jun 2008)
New Revision: 22345
Log:
*: use llist_pop for traverse-and-free list operation
function old new delta
append_file_list_to_list 109 111 +2
udhcpc_main 2414 2413 -1
run_parts_main 325 324 -1
od_main 2324 2323 -1
getopt_main 709 707 -2
env_main 253 251 -2
sed_main 659 656 -3
ps_main 522 519 -3
traceroute_main 3960 3954 -6
sort_main 844 838 -6
diff_main 866 858 -8
------------------------------------------------------------------------------
(add/remove: 0/0 grow/shrink: 1/10 up/down: 2/-33) Total: -31 bytes
Modified:
trunk/busybox/archival/tar.c
trunk/busybox/coreutils/env.c
trunk/busybox/coreutils/od_bloaty.c
trunk/busybox/coreutils/sort.c
trunk/busybox/debianutils/run_parts.c
trunk/busybox/editors/diff.c
trunk/busybox/editors/sed.c
trunk/busybox/findutils/xargs.c
trunk/busybox/libbb/getopt32.c
trunk/busybox/networking/traceroute.c
trunk/busybox/networking/udhcp/dhcpc.c
trunk/busybox/networking/wget.c
trunk/busybox/procps/ps.c
trunk/busybox/util-linux/getopt.c
Changeset:
Modified: trunk/busybox/archival/tar.c
===================================================================
--- trunk/busybox/archival/tar.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/archival/tar.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -659,16 +659,11 @@
static llist_t *append_file_list_to_list(llist_t *list)
{
FILE *src_stream;
- llist_t *cur = list;
- llist_t *tmp;
char *line;
llist_t *newlist = NULL;
- while (cur) {
- src_stream = xfopen(cur->data, "r");
- tmp = cur;
- cur = cur->link;
- free(tmp);
+ while (list) {
+ src_stream = xfopen(llist_pop(&list), "r");
while ((line = xmalloc_fgetline(src_stream)) != NULL) {
/* kill trailing '/' unless the string is just "/" */
char *cp = last_char_is(line, '/');
Modified: trunk/busybox/coreutils/env.c
===================================================================
--- trunk/busybox/coreutils/env.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/coreutils/env.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -62,8 +62,7 @@
environ = cleanenv;
} else {
while (unset_env) {
- unsetenv(unset_env->data);
- unset_env = unset_env->link;
+ unsetenv(llist_pop(&unset_env));
}
}
Modified: trunk/busybox/coreutils/od_bloaty.c
===================================================================
--- trunk/busybox/coreutils/od_bloaty.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/coreutils/od_bloaty.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -1281,8 +1281,7 @@
if (opt & OPT_o) decode_format_string("o2");
//if (opt & OPT_t)...
while (lst_t) {
- decode_format_string(lst_t->data);
- lst_t = lst_t->link;
+ decode_format_string(llist_pop(&lst_t));
}
if (opt & OPT_v) verbose = 1;
if (opt & OPT_x) decode_format_string("x2");
Modified: trunk/busybox/coreutils/sort.c
===================================================================
--- trunk/busybox/coreutils/sort.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/coreutils/sort.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -314,7 +314,7 @@
0
};
struct sort_key *key = add_key();
- char *str_k = lst_k->data;
+ char *str_k = llist_pop(&lst_k);
const char *temp2;
i = 0; /* i==0 before comma, 1 after (-k3,6) */
@@ -344,8 +344,6 @@
str_k++;
}
}
- /* leaking lst_k... */
- lst_k = lst_k->link;
}
#endif
/* global b strips leading and trailing spaces */
Modified: trunk/busybox/debianutils/run_parts.c
===================================================================
--- trunk/busybox/debianutils/run_parts.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/debianutils/run_parts.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -42,7 +42,7 @@
#define cur (G.cur )
#define cmd (G.cmd )
-enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(struct globals)) / sizeof(cmd[0]) };
+enum { NUM_CMD = (COMMON_BUFSIZE - sizeof(G)) / sizeof(cmd[0]) - 1 };
enum {
OPT_r = (1 << 0),
@@ -130,9 +130,7 @@
n = 1;
while (arg_list && n < NUM_CMD) {
- cmd[n] = arg_list->data;
- arg_list = arg_list->link;
- n++;
+ cmd[n++] = llist_pop(&arg_list);
}
/* cmd[n] = NULL; - is already zeroed out */
Modified: trunk/busybox/editors/diff.c
===================================================================
--- trunk/busybox/editors/diff.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/editors/diff.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -1289,14 +1289,9 @@
while (L_arg) {
if (label1 && label2)
bb_show_usage();
- if (!label1)
- label1 = L_arg->data;
- else { /* then label2 is NULL */
+ if (label1) /* then label2 is NULL */
label2 = label1;
- label1 = L_arg->data;
- }
- /* we leak L_arg here... */
- L_arg = L_arg->link;
+ label1 = llist_pop(&L_arg);
}
/*
Modified: trunk/busybox/editors/sed.c
===================================================================
--- trunk/busybox/editors/sed.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/editors/sed.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -1267,21 +1267,17 @@
if (opt & 0x2) G.regex_type |= REG_EXTENDED; // -r
//if (opt & 0x4) G.be_quiet++; // -n
while (opt_e) { // -e
- add_cmd_block(opt_e->data);
- opt_e = opt_e->link;
- /* we leak opt_e here... */
+ add_cmd_block(llist_pop(&opt_e));
}
while (opt_f) { // -f
char *line;
FILE *cmdfile;
- cmdfile = xfopen(opt_f->data, "r");
+ cmdfile = xfopen(llist_pop(&opt_f), "r");
while ((line = xmalloc_fgetline(cmdfile)) != NULL) {
add_cmd(line);
free(line);
}
fclose(cmdfile);
- opt_f = opt_f->link;
- /* we leak opt_f here... */
}
/* if we didn't get a pattern from -e or -f, use argv[0] */
if (!(opt & 0x18)) {
Modified: trunk/busybox/findutils/xargs.c
===================================================================
--- trunk/busybox/findutils/xargs.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/findutils/xargs.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -502,7 +502,7 @@
if (child_error > 0 && child_error != 123) {
break;
}
- }
+ } /* while */
if (ENABLE_FEATURE_CLEAN_UP)
free(max_chars);
return child_error;
Modified: trunk/busybox/libbb/getopt32.c
===================================================================
--- trunk/busybox/libbb/getopt32.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/libbb/getopt32.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -137,7 +137,7 @@
opt_complementary = "vv:b::b-c:c-b";
f = getopt32(argv, "vb:c", &my_b, &verbose_level);
if (f & 2) // -c after -b unsets -b flag
- while (my_b) { dosomething_with(my_b->data); my_b = my_b->link; }
+ while (my_b) dosomething_with(llist_pop(&my_b));
if (my_b) // but llist is stored if -b is specified
free_llist(my_b);
if (verbose_level) printf("verbose level is %d\n", verbose_level);
Modified: trunk/busybox/networking/traceroute.c
===================================================================
--- trunk/busybox/networking/traceroute.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/networking/traceroute.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -1001,17 +1001,11 @@
#if ENABLE_FEATURE_TRACEROUTE_SOURCE_ROUTE
if (source_route_list) {
- llist_t *l_sr;
-
- l_sr = source_route_list;
- while (l_sr) {
+ while (source_route_list) {
if (lsrr >= NGATEWAYS)
bb_error_msg_and_die("no more than %d gateways", NGATEWAYS);
- getaddr(gwlist + lsrr, l_sr->data);
+ getaddr(gwlist + lsrr, llist_pop(&source_route_list));
++lsrr;
- l_sr = l_sr->link;
- free(source_route_list);
- source_route_list = l_sr;
}
optlen = (lsrr + 1) * sizeof(gwlist[0]);
}
Modified: trunk/busybox/networking/udhcp/dhcpc.c
===================================================================
--- trunk/busybox/networking/udhcp/dhcpc.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/networking/udhcp/dhcpc.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -259,12 +259,11 @@
if (opt & OPT_o)
client_config.no_default_options = 1;
while (list_O) {
- int n = index_in_strings(dhcp_option_strings, list_O->data);
+ int n = index_in_strings(dhcp_option_strings, llist_pop(&list_O));
if (n < 0)
bb_error_msg_and_die("unknown option '%s'", list_O->data);
n = dhcp_options[n].code;
client_config.opt_mask[n >> 3] |= 1 << (n & 7);
- list_O = list_O->link;
}
if (read_interface(client_config.interface, &client_config.ifindex,
Modified: trunk/busybox/networking/wget.c
===================================================================
--- trunk/busybox/networking/wget.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/networking/wget.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -469,8 +469,7 @@
}
extra_headers = cp = xmalloc(size);
while (headers_llist) {
- cp += sprintf(cp, "%s\r\n", headers_llist->data);
- headers_llist = headers_llist->link;
+ cp += sprintf(cp, "%s\r\n", (char*)llist_pop(&headers_llist));
}
}
#endif
Modified: trunk/busybox/procps/ps.c
===================================================================
--- trunk/busybox/procps/ps.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/procps/ps.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -443,8 +443,7 @@
USE_SELINUX(opt =) getopt32(argv, "Zo:aAdefl", &opt_o);
if (opt_o) {
do {
- parse_o(opt_o->data);
- opt_o = opt_o->link;
+ parse_o(llist_pop(&opt_o));
} while (opt_o);
} else {
/* Below: parse_o() needs char*, NOT const char*... */
Modified: trunk/busybox/util-linux/getopt.c
===================================================================
--- trunk/busybox/util-linux/getopt.c 2008-06-15 05:40:08 UTC (rev 22344)
+++ trunk/busybox/util-linux/getopt.c 2008-06-15 05:40:56 UTC (rev 22345)
@@ -329,8 +329,7 @@
&optstr, &name, &s_arg, &l_arg);
/* Effectuate the read options for the applet itself */
while (l_arg) {
- long_options = add_long_options(long_options, l_arg->data);
- l_arg = l_arg->link;
+ long_options = add_long_options(long_options, llist_pop(&l_arg));
}
#endif
More information about the busybox-cvs
mailing list