diff options
Diffstat (limited to 'src/sp_list.c')
| -rw-r--r-- | src/sp_list.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/sp_list.c b/src/sp_list.c index 04154b7..112d822 100644 --- a/src/sp_list.c +++ b/src/sp_list.c | |||
| @@ -35,3 +35,21 @@ void sp_list_insert(sp_node_t *list, void *data) { | |||
| 35 | list->next = new; | 35 | list->next = new; |
| 36 | } | 36 | } |
| 37 | } | 37 | } |
| 38 | |||
| 39 | void sp_list_prepend(sp_node_t *list, void *data) { | ||
| 40 | if (list->head == NULL) { | ||
| 41 | list->data = data; | ||
| 42 | list->next = NULL; | ||
| 43 | list->head = list; | ||
| 44 | } else { | ||
| 45 | sp_node_t *new = pecalloc(sizeof(*new), 1, 1); | ||
| 46 | |||
| 47 | new->next = list->next; | ||
| 48 | list->next = new; | ||
| 49 | |||
| 50 | new->head = list; | ||
| 51 | |||
| 52 | new->data = list->data; | ||
| 53 | list->data = data; | ||
| 54 | } | ||
| 55 | } \ No newline at end of file | ||
