aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-05-26 23:44:51 +0000
committerlandley <landley@69ca8d6d-28ef-0310-b511-8ec308f3f277>2006-05-26 23:44:51 +0000
commitab1c37300f2a6a0215c17cd683df316d8a1e8f59 (patch)
treeb717c772c6fef53c34b723341a8c5b12ccb57902 /libbb
parentc806c321575528e76c4479666d398a0534cb81d8 (diff)
downloadbusybox-w32-ab1c37300f2a6a0215c17cd683df316d8a1e8f59.tar.gz
busybox-w32-ab1c37300f2a6a0215c17cd683df316d8a1e8f59.tar.bz2
busybox-w32-ab1c37300f2a6a0215c17cd683df316d8a1e8f59.zip
Change llist_add_* to take the address of the list rather than returning the new
head, and change all the callers. git-svn-id: svn://busybox.net/trunk/busybox@15199 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r--libbb/getopt_ulflags.c3
-rw-r--r--libbb/llist.c28
2 files changed, 11 insertions, 20 deletions
diff --git a/libbb/getopt_ulflags.c b/libbb/getopt_ulflags.c
index 76bdeed75..dc40095ee 100644
--- a/libbb/getopt_ulflags.c
+++ b/libbb/getopt_ulflags.c
@@ -474,8 +474,7 @@ loop_arg_is_opt:
474 if(on_off->counter) 474 if(on_off->counter)
475 (*(on_off->counter))++; 475 (*(on_off->counter))++;
476 if(on_off->list_flg) { 476 if(on_off->list_flg) {
477 *(llist_t **)(on_off->optarg) = 477 llist_add_to((llist_t **)(on_off->optarg), optarg);
478 llist_add_to(*(llist_t **)(on_off->optarg), optarg);
479 } else if (on_off->optarg) { 478 } else if (on_off->optarg) {
480 *(char **)(on_off->optarg) = optarg; 479 *(char **)(on_off->optarg) = optarg;
481 } 480 }
diff --git a/libbb/llist.c b/libbb/llist.c
index dd80436c6..fde25e8b7 100644
--- a/libbb/llist.c
+++ b/libbb/llist.c
@@ -14,37 +14,29 @@
14 14
15#ifdef L_llist_add_to 15#ifdef L_llist_add_to
16/* Add data to the start of the linked list. */ 16/* Add data to the start of the linked list. */
17llist_t *llist_add_to(llist_t *old_head, void *data) 17void llist_add_to(llist_t **old_head, void *data)
18{ 18{
19 llist_t *new_head; 19 llist_t *new_head = xmalloc(sizeof(llist_t));
20
21 new_head = xmalloc(sizeof(llist_t));
22 new_head->data = data; 20 new_head->data = data;
23 new_head->link = old_head; 21 new_head->link = *old_head;
24 22 *old_head = new_head;
25 return (new_head);
26} 23}
27#endif 24#endif
28 25
29#ifdef L_llist_add_to_end 26#ifdef L_llist_add_to_end
30/* Add data to the end of the linked list. */ 27/* Add data to the end of the linked list. */
31llist_t *llist_add_to_end(llist_t *list_head, void *data) 28void llist_add_to_end(llist_t **list_head, void *data)
32{ 29{
33 llist_t *new_item; 30 llist_t *new_item = xmalloc(sizeof(llist_t));
34
35 new_item = xmalloc(sizeof(llist_t));
36 new_item->data = data; 31 new_item->data = data;
37 new_item->link = NULL; 32 new_item->link = NULL;
38 33
39 if (list_head == NULL) { 34 if (!*list_head) *list_head = new_item;
40 list_head = new_item; 35 else {
41 } else { 36 llist_t *tail = *list_head;
42 llist_t *tail = list_head; 37 while (tail->link) tail = tail->link;
43 while (tail->link)
44 tail = tail->link;
45 tail->link = new_item; 38 tail->link = new_item;
46 } 39 }
47 return list_head;
48} 40}
49#endif 41#endif
50 42