diff options
author | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2005-09-29 12:55:10 +0000 |
---|---|---|
committer | Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> | 2005-09-29 12:55:10 +0000 |
commit | bee9eb1a9d04503d58070bd1946cc2c0538fcf95 (patch) | |
tree | 013e17fde8c199768a4195d057371372a330e765 /libbb/llist.c | |
parent | 3e245c9e21f991004b93c0892abdb5f040d37eff (diff) | |
download | busybox-w32-bee9eb1a9d04503d58070bd1946cc2c0538fcf95.tar.gz busybox-w32-bee9eb1a9d04503d58070bd1946cc2c0538fcf95.tar.bz2 busybox-w32-bee9eb1a9d04503d58070bd1946cc2c0538fcf95.zip |
- rename llist_add_to.c to llist.c
- move llist_add_to_end() from ifupdown.c to libbb/llist.c
Diffstat (limited to 'libbb/llist.c')
-rw-r--r-- | libbb/llist.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/libbb/llist.c b/libbb/llist.c new file mode 100644 index 000000000..cb87176c5 --- /dev/null +++ b/libbb/llist.c | |||
@@ -0,0 +1,43 @@ | |||
1 | #include <stdlib.h> | ||
2 | #include <string.h> | ||
3 | #include "unarchive.h" | ||
4 | #include "libbb.h" | ||
5 | |||
6 | #ifdef L_llist_add_to | ||
7 | extern llist_t *llist_add_to(llist_t *old_head, char *new_item) | ||
8 | { | ||
9 | llist_t *new_head; | ||
10 | |||
11 | new_head = xmalloc(sizeof(llist_t)); | ||
12 | new_head->data = new_item; | ||
13 | new_head->link = old_head; | ||
14 | |||
15 | return (new_head); | ||
16 | } | ||
17 | #endif | ||
18 | |||
19 | #ifdef L_llist_add_to_end | ||
20 | extern llist_t *llist_add_to_end(llist_t *list_head, char *data) | ||
21 | { | ||
22 | llist_t *new_item, *tmp, *prev; | ||
23 | |||
24 | new_item = xmalloc(sizeof(llist_t)); | ||
25 | new_item->data = data; | ||
26 | new_item->link = NULL; | ||
27 | |||
28 | prev = NULL; | ||
29 | tmp = list_head; | ||
30 | while (tmp) { | ||
31 | prev = tmp; | ||
32 | tmp = tmp->link; | ||
33 | } | ||
34 | if (prev) { | ||
35 | prev->link = new_item; | ||
36 | } else { | ||
37 | list_head = new_item; | ||
38 | } | ||
39 | |||
40 | return (list_head); | ||
41 | } | ||
42 | #endif | ||
43 | |||