equal
deleted
inserted
replaced
|
1 /* |
|
2 * $Id: list.c 107 2008-04-17 01:01:43Z mbroeker $ |
|
3 * $URL: http://localhost/svn/c/lsflib/trunk/src/list.c $ |
|
4 * |
|
5 */ |
|
6 |
|
7 #include <stdio.h> |
|
8 #include <stdlib.h> |
|
9 #include <string.h> |
|
10 |
|
11 #include <list.h> |
|
12 |
|
13 Node *addnode (Node * node, char *data) |
|
14 { |
|
15 Node *n; |
|
16 |
|
17 if ((n = malloc (sizeof (Node))) == NULL) { |
|
18 fprintf (stderr, "malloc fails: %s\n", data); |
|
19 return NULL; |
|
20 } |
|
21 |
|
22 if (!(n->data = strdup (data))) { |
|
23 fprintf (stderr, "strdup fails: %s\n", data); |
|
24 free (n); |
|
25 return NULL; |
|
26 } |
|
27 |
|
28 n->next = NULL; |
|
29 |
|
30 if (node != NULL) { |
|
31 node->next = n; |
|
32 node = n; |
|
33 } else |
|
34 node = n; |
|
35 |
|
36 return node; |
|
37 } |
|
38 |
|
39 Node *getnode (Node * aktuell) |
|
40 { |
|
41 Node *begin; |
|
42 |
|
43 free (aktuell->data); |
|
44 begin = aktuell->next; |
|
45 free (aktuell); |
|
46 |
|
47 return begin; |
|
48 } |