summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Cardell Widerkrantz <mc@hack.org>2011-03-04 14:24:20 +0100
committerMichael Cardell Widerkrantz <mc@hack.org>2011-03-08 12:14:38 +0100
commit5ac614a09854ff6e0d9602bd2e2ae37cd198d3b5 (patch)
treefbaf3f6653fa228a84346c144d82cf9f7cfb9763
parent0c99c2a608283603238943147cff341ae7629514 (diff)
downloadmcwm-5ac614a09854ff6e0d9602bd2e2ae37cd198d3b5.zip
We don't need movetonext().
-rw-r--r--list.c53
-rw-r--r--list.h18
2 files changed, 23 insertions, 48 deletions
diff --git a/list.c b/list.c
index 4751433..995d091 100644
--- a/list.c
+++ b/list.c
@@ -11,6 +11,9 @@
#define D(x)
#endif
+/*
+ * Move element in item to the head of list mainlist.
+ */
void movetohead(struct item **mainlist, struct item *item)
{
if (NULL == item || NULL == mainlist || NULL == *mainlist)
@@ -43,54 +46,10 @@ void movetohead(struct item **mainlist, struct item *item)
*mainlist = item;
}
-void movetonext(struct item **mainlist, struct item *item, struct item *next)
-{
- if (NULL == item || NULL == next || NULL == mainlist || NULL == *mainlist)
- {
- return;
- }
-
- if (item->next == next || item == next)
- {
- /* Already in position. Do nothing. */
- return;
- }
-
- /* Braid together the list where next used to be. */
-
- if (NULL != next->next)
- {
- next->next->prev = next->prev;
- }
-
- if (NULL != next->prev)
- {
- next->prev->next = next->next;
- }
- else
- {
- /* next is currently head. move head one step further along. */
- if (NULL != next->next)
- {
- *mainlist = next->next;
- next->next->prev = NULL;
- }
- }
-
- /* Position next after item and braid together list again. */
- next->prev = item;
- next->next = item->next;
-
- if (NULL != next->next)
- {
- next->next->prev = next;
- }
-
- /* Remember where next is now. */
- item->next = next;
-}
-
/*
+ * Create space for a new item and add it to the head of mainlist.
+ *
+ * Returns item or NULL if out of memory.
*/
struct item *additem(struct item **mainlist)
{
diff --git a/list.h b/list.h
index ee16e7e..ecd2bfb 100644
--- a/list.h
+++ b/list.h
@@ -5,8 +5,24 @@ struct item
struct item *next;
};
+/*
+ * Move element in item to the head of list mainlist.
+ */
void movetohead(struct item **mainlist, struct item *item);
-void movetonext(struct item **mainlist, struct item *item, struct item *next);
+
+/*
+ * Create space for a new item and add it to the head of mainlist.
+ *
+ * Returns item or NULL if out of memory.
+ */
struct item *additem(struct item **mainlist);
+
+/*
+ *
+ */
void delitem(struct item **mainlist, struct item *item);
+
+/*
+ *
+ */
void listitems(struct item *mainlist);