summaryrefslogtreecommitdiff
path: root/ubi-utils/sort-me-out/list.c
diff options
context:
space:
mode:
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-01-23 19:34:52 +0200
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-01-23 19:34:52 +0200
commit3ad29ab55ad71d706152781b70a43d9f6be407b9 (patch)
tree4e5a41b23e771faef0f633c6570210a42bd9c037 /ubi-utils/sort-me-out/list.c
parent22f5fe49d60ea43524a902408b3112a78f2c5aae (diff)
ubi-utils: remove all old tools
Remove all old tools because I cannot maintain them and the original authors do not seem to have time for this. Some of the tools do not work properly, some are just vague and undocumented and seem to be oriented to the environment of the IBM guys. Nevertheless, I'll return the tool as is in the next commit, becouse they are still useful. This commit also adds a ubinize utility to generate UBI images. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'ubi-utils/sort-me-out/list.c')
-rw-r--r--ubi-utils/sort-me-out/list.c149
1 files changed, 0 insertions, 149 deletions
diff --git a/ubi-utils/sort-me-out/list.c b/ubi-utils/sort-me-out/list.c
deleted file mode 100644
index 6eb716b..0000000
--- a/ubi-utils/sort-me-out/list.c
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
- * Copyright (c) International Business Machines Corp., 2006
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
- * the GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * Author: Oliver Lohmann
- */
-
-#include <stdlib.h>
-#include <assert.h>
-#include <stdio.h>
-
-#include "list.h"
-
-list_t
-mk_empty(void)
-{
- return (list_t) NULL;
-}
-
-int
-is_empty(list_t l)
-{
- return l == NULL;
-}
-
-info_t
-head(list_t l)
-{
- assert(!is_empty(l));
- return l->info;
-}
-
-list_t
-tail(list_t l)
-{
- assert(!is_empty(l));
- return l->next;
-}
-
-list_t
-remove_head(list_t l)
-{
- list_t res;
- assert(!is_empty(l));
-
- res = l->next;
- free(l);
- return res;
-}
-
-list_t
-cons(info_t e, list_t l)
-{
- list_t res = malloc(sizeof(*l));
- if (!res)
- return NULL;
- res->info = e;
- res->next = l;
-
- return res;
-}
-
-list_t
-prepend_elem(info_t e, list_t l)
-{
- return cons(e,l);
-}
-
-list_t
-append_elem(info_t e, list_t l)
-{
- if (is_empty(l)) {
- return cons(e,l);
- }
- l->next = append_elem(e, l->next);
-
- return l;
-}
-
-list_t
-insert_sorted(cmp_func_t cmp, info_t e, list_t l)
-{
- if (is_empty(l))
- return cons(e, l);
-
- switch (cmp(e, l->info)) {
- case -1:
- case 0:
- return l;
- break;
- case 1:
- l->next = insert_sorted(cmp, e, l);
- break;
- default:
- break;
- }
-
- /* never reached */
- return NULL;
-}
-
-list_t
-remove_all(free_func_t free_func, list_t l)
-{
- if (is_empty(l))
- return l;
- list_t lnext = l->next;
-
- if (free_func && l->info) {
- free_func(&(l->info));
- }
- free(l);
-
- return remove_all(free_func, lnext);
-}
-
-
-info_t
-is_in(cmp_func_t cmp, info_t e, list_t l)
-{
- return
- (is_empty(l))
- ? NULL
- : (cmp(e, l->info)) == 0 ? l->info : is_in(cmp, e, l->next);
-}
-
-
-void
-apply(process_func_t process_func, list_t l)
-{
- list_t ptr;
- void *i;
- foreach(i, ptr, l) {
- process_func(i);
- }
-}