diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-01-22 16:02:52 +0200 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-01-22 16:22:52 +0200 |
commit | 22f5fe49d60ea43524a902408b3112a78f2c5aae (patch) | |
tree | 873fd6ca0023a2e71eaf78292ead57af6f07e7f6 /ubi-utils/src/list.c | |
parent | f1d0f2363471837b89bf89410251f263680b683a (diff) |
ubi-utils: massive changes
This commit basically removes most of the old ubi utilities
as they are barely maintainamble.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/src/list.c')
-rw-r--r-- | ubi-utils/src/list.c | 52 |
1 files changed, 23 insertions, 29 deletions
diff --git a/ubi-utils/src/list.c b/ubi-utils/src/list.c index 6eb716b..a701158 100644 --- a/ubi-utils/src/list.c +++ b/ubi-utils/src/list.c @@ -24,36 +24,30 @@ #include "list.h" -list_t -mk_empty(void) -{ - return (list_t) NULL; -} - int -is_empty(list_t l) +is_empty(struct list_entry *l) { return l == NULL; } info_t -head(list_t l) +head(struct list_entry *l) { assert(!is_empty(l)); return l->info; } -list_t -tail(list_t l) +struct list_entry * +tail(struct list_entry *l) { assert(!is_empty(l)); return l->next; } -list_t -remove_head(list_t l) +struct list_entry * +remove_head(struct list_entry *l) { - list_t res; + struct list_entry *res; assert(!is_empty(l)); res = l->next; @@ -61,10 +55,10 @@ remove_head(list_t l) return res; } -list_t -cons(info_t e, list_t l) +struct list_entry * +cons(info_t e, struct list_entry *l) { - list_t res = malloc(sizeof(*l)); + struct list_entry *res = malloc(sizeof(*l)); if (!res) return NULL; res->info = e; @@ -73,14 +67,14 @@ cons(info_t e, list_t l) return res; } -list_t -prepend_elem(info_t e, list_t l) +struct list_entry * +prepend_elem(info_t e, struct list_entry *l) { return cons(e,l); } -list_t -append_elem(info_t e, list_t l) +struct list_entry * +append_elem(info_t e, struct list_entry *l) { if (is_empty(l)) { return cons(e,l); @@ -90,8 +84,8 @@ append_elem(info_t e, list_t l) return l; } -list_t -insert_sorted(cmp_func_t cmp, info_t e, list_t l) +struct list_entry * +insert_sorted(cmp_func_t cmp, info_t e, struct list_entry *l) { if (is_empty(l)) return cons(e, l); @@ -112,12 +106,12 @@ insert_sorted(cmp_func_t cmp, info_t e, list_t l) return NULL; } -list_t -remove_all(free_func_t free_func, list_t l) +struct list_entry * +remove_all(free_func_t free_func, struct list_entry *l) { if (is_empty(l)) return l; - list_t lnext = l->next; + struct list_entry *lnext = l->next; if (free_func && l->info) { free_func(&(l->info)); @@ -129,7 +123,7 @@ remove_all(free_func_t free_func, list_t l) info_t -is_in(cmp_func_t cmp, info_t e, list_t l) +is_in(cmp_func_t cmp, info_t e, struct list_entry *l) { return (is_empty(l)) @@ -139,11 +133,11 @@ is_in(cmp_func_t cmp, info_t e, list_t l) void -apply(process_func_t process_func, list_t l) +apply(process_func_t process_func, struct list_entry *l) { - list_t ptr; + struct list_entry *ptr; void *i; - foreach(i, ptr, l) { + list_for_each(i, ptr, l) { process_func(i); } } |