Permalink
Browse files

Added a primitive linked list implementation.

  • Loading branch information...
1 parent 9873a91 commit 10280d54c3fffc25167406f8939240cce0d9ff7c Tilman Sauerbeck committed Nov 22, 2009
Showing with 89 additions and 1 deletion.
  1. +5 −1 Makefile
  2. +48 −0 src/list.c
  3. +36 −0 src/list.h
View
@@ -21,7 +21,11 @@ ifdef BIG_ENDIAN
endif
BINARY := bin/xmms2-scrobbler
-OBJECTS := src/xmms2-scrobbler.o src/queue.o src/strbuf.o src/md5.o \
+OBJECTS := src/xmms2-scrobbler.o \
+ src/list.o \
+ src/queue.o \
+ src/strbuf.o \
+ src/md5.o \
src/submission.o
all: $(BINARY)
View
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2008 Tilman Sauerbeck (tilman at xmms org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#include <stdlib.h>
+
+#include "list.h"
+
+List *
+list_prepend (List *list, void *data)
+{
+ List *link;
+
+ link = malloc (sizeof (List));
+ link->next = list;
+ link->data = data;
+
+ return link;
+}
+
+List *
+list_remove_head (List *list)
+{
+ List *new_head = list->next;
+
+ free (list);
+
+ return new_head;
+}
View
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2009 Tilman Sauerbeck (tilman at xmms org)
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sublicense, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+ * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+ * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ */
+
+#ifndef _LIST_H
+#define _LIST_H
+
+typedef struct __List {
+ struct __List *next;
+
+ void *data;
+} List;
+
+List *list_prepend (List *list, void *data);
+List *list_remove_head (List *list);
+
+#endif

0 comments on commit 10280d5

Please sign in to comment.