forked from alukichev/bannerd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
string_list.h
53 lines (42 loc) · 1.02 KB
/
string_list.h
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
* Bitmap parsing
*
* Copyright (C) 2012 Alexander Lukichev
*
* Alexander Lukichev <[email protected]>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* version 2 as published by the Free Software Foundation.
*/
#ifndef STRING_LIST_H
#define STRING_LIST_H
#include <stdlib.h>
#include "log.h"
struct string_list {
char *s;
struct string_list *next;
};
static inline struct string_list *string_list_add(struct string_list **head,
struct string_list *tail, char *s)
{
struct string_list *new_tail = malloc(sizeof(struct string_list));
if (new_tail == NULL)
ERR_RET(NULL, "could not allocate memory");
new_tail->s = s;
new_tail->next = NULL;
if (tail)
tail->next = new_tail;
else
*head = new_tail;
return new_tail;
}
static inline void string_list_destroy(struct string_list *head)
{
while (head) {
struct string_list *new_head = head->next;
free(head);
head = new_head;
}
}
#endif /* STRING_LIST_H */