aboutsummaryrefslogtreecommitdiff
path: root/libbb/llist.c
diff options
context:
space:
mode:
authorvda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-04-08 15:08:42 +0000
committervda <vda@69ca8d6d-28ef-0310-b511-8ec308f3f277>2007-04-08 15:08:42 +0000
commitd9f0f6429acee15bbb6767440ce207a593b0927d (patch)
tree157087760d624a657c3ce11b142afb1c72bf225a /libbb/llist.c
parentbc44ebb91eed896d07ac0f951910f25d55e1f4eb (diff)
downloadbusybox-w32-d9f0f6429acee15bbb6767440ce207a593b0927d.tar.gz
busybox-w32-d9f0f6429acee15bbb6767440ce207a593b0927d.tar.bz2
busybox-w32-d9f0f6429acee15bbb6767440ce207a593b0927d.zip
getopt32: fix llist_t options ordering. llist_rev is not unused.
function old new delta tar_main 705 695 -10 sort_main 928 918 -10 decode_format_string 886 876 -10 run_parts_main 197 185 -12 ps_main 513 500 -13 wget_main 2764 2750 -14 awk_main 1014 1000 -14 od_main 2886 2866 -20 llist_rev 25 - -25 ------------------------------------------------------------------------------ (add/remove: 0/1 grow/shrink: 0/8 up/down: 0/-128) Total: -128 bytes git-svn-id: svn://busybox.net/trunk/busybox@18364 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb/llist.c')
-rw-r--r--libbb/llist.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/libbb/llist.c b/libbb/llist.c
index 2b34f762c..706751447 100644
--- a/libbb/llist.c
+++ b/libbb/llist.c
@@ -14,7 +14,7 @@
14#include "libbb.h" 14#include "libbb.h"
15 15
16/* Add data to the start of the linked list. */ 16/* Add data to the start of the linked list. */
17void 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 = xmalloc(sizeof(llist_t)); 19 llist_t *new_head = xmalloc(sizeof(llist_t));
20 20
@@ -24,7 +24,7 @@ void llist_add_to(llist_t ** old_head, void *data)
24} 24}
25 25
26/* Add data to the end of the linked list. */ 26/* Add data to the end of the linked list. */
27void llist_add_to_end(llist_t ** list_head, void *data) 27void llist_add_to_end(llist_t **list_head, void *data)
28{ 28{
29 llist_t *new_item = xmalloc(sizeof(llist_t)); 29 llist_t *new_item = xmalloc(sizeof(llist_t));
30 30
@@ -43,7 +43,7 @@ void llist_add_to_end(llist_t ** list_head, void *data)
43} 43}
44 44
45/* Remove first element from the list and return it */ 45/* Remove first element from the list and return it */
46void *llist_pop(llist_t ** head) 46void *llist_pop(llist_t **head)
47{ 47{
48 void *data, *next; 48 void *data, *next;
49 49
@@ -81,7 +81,7 @@ void llist_unlink(llist_t **head, llist_t *elm)
81 81
82/* Recursively free all elements in the linked list. If freeit != NULL 82/* Recursively free all elements in the linked list. If freeit != NULL
83 * call it on each datum in the list */ 83 * call it on each datum in the list */
84void llist_free(llist_t * elm, void (*freeit) (void *data)) 84void llist_free(llist_t *elm, void (*freeit) (void *data))
85{ 85{
86 while (elm) { 86 while (elm) {
87 void *data = llist_pop(&elm); 87 void *data = llist_pop(&elm);
@@ -91,18 +91,19 @@ void llist_free(llist_t * elm, void (*freeit) (void *data))
91 } 91 }
92} 92}
93 93
94/* Reverse list order. Useful since getopt32 saves option params 94#ifdef UNUSED
95 * in reverse order */ 95/* Reverse list order. */
96llist_t *llist_rev(llist_t * list) 96llist_t *llist_rev(llist_t *list)
97{ 97{
98 llist_t *new = NULL; 98 llist_t *rev = NULL;
99 99
100 while (list) { 100 while (list) {
101 llist_t *next = list->link; 101 llist_t *next = list->link;
102 102
103 list->link = new; 103 list->link = rev;
104 new = list; 104 rev = list;
105 list = next; 105 list = next;
106 } 106 }
107 return new; 107 return rev;
108} 108}
109#endif