blob: 04154b71498b466862426fb3d4280047f5dd3ae4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
#include "sp_list.h"
#include <stdio.h>
#include <stdlib.h>
#include "php_snuffleupagus.h"
void sp_list_free(sp_node_t *node) {
while(node) {
sp_node_t *tmp = node->next;
pefree(node, 1);
node = tmp;
}
}
sp_node_t *sp_new_list() {
sp_node_t *new = pecalloc(sizeof(*new), 1, 1);
new->next = new->data = new->head = NULL;
return new;
}
void sp_list_insert(sp_node_t *list, void *data) {
if (list->head == NULL) {
list->data = data;
list->next = NULL;
list->head = list;
} else {
sp_node_t *new = pecalloc(sizeof(*new), 1, 1);
new->data = data;
new->next = NULL;
new->head = list;
while (list->next) {
list = list->next;
}
list->next = new;
}
}
|