Revision 72cf2d4f envlist.c

b/envlist.c
1
#include <sys/queue.h>
2

  
3 1
#include <assert.h>
4 2
#include <errno.h>
5 3
#include <stdlib.h>
6 4
#include <string.h>
7 5
#include <unistd.h>
8 6

  
7
#include "qemu-queue.h"
9 8
#include "envlist.h"
10 9

  
11 10
struct envlist_entry {
12 11
	const char *ev_var;			/* actual env value */
13
	LIST_ENTRY(envlist_entry) ev_link;
12
	QLIST_ENTRY(envlist_entry) ev_link;
14 13
};
15 14

  
16 15
struct envlist {
17
	LIST_HEAD(, envlist_entry) el_entries;	/* actual entries */
16
	QLIST_HEAD(, envlist_entry) el_entries;	/* actual entries */
18 17
	size_t el_count;			/* number of entries */
19 18
};
20 19

  
......
33 32
	if ((envlist = malloc(sizeof (*envlist))) == NULL)
34 33
		return (NULL);
35 34

  
36
	LIST_INIT(&envlist->el_entries);
35
	QLIST_INIT(&envlist->el_entries);
37 36
	envlist->el_count = 0;
38 37

  
39 38
	return (envlist);
......
51 50

  
52 51
	while (envlist->el_entries.lh_first != NULL) {
53 52
		entry = envlist->el_entries.lh_first;
54
		LIST_REMOVE(entry, ev_link);
53
		QLIST_REMOVE(entry, ev_link);
55 54

  
56 55
		free((char *)entry->ev_var);
57 56
		free(entry);
......
159 158
	}
160 159

  
161 160
	if (entry != NULL) {
162
		LIST_REMOVE(entry, ev_link);
161
		QLIST_REMOVE(entry, ev_link);
163 162
		free((char *)entry->ev_var);
164 163
		free(entry);
165 164
	} else {
......
172 171
		free(entry);
173 172
		return (errno);
174 173
	}
175
	LIST_INSERT_HEAD(&envlist->el_entries, entry, ev_link);
174
	QLIST_INSERT_HEAD(&envlist->el_entries, entry, ev_link);
176 175

  
177 176
	return (0);
178 177
}
......
205 204
			break;
206 205
	}
207 206
	if (entry != NULL) {
208
		LIST_REMOVE(entry, ev_link);
207
		QLIST_REMOVE(entry, ev_link);
209 208
		free((char *)entry->ev_var);
210 209
		free(entry);
211 210

  

Also available in: Unified diff