/usr/include/eztrace_list.h is in libeztrace-dev 1.1-2-1ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 | /* -*- c-file-style: "GNU" -*- */
/*
* Copyright (C) CNRS, INRIA, Universite Bordeaux 1, Telecom SudParis
* See COPYING in top-level directory.
*/
#ifndef EZTRACE_LIST_H
#define EZTRACE_LIST_H
#include <stdlib.h>
struct ezt_list_t;
struct ezt_list_token_t {
/* pointer to the user data */
void *data;
/* pointer to the list */
struct ezt_list_t *list;
/* pointer to the next token in the list */
struct ezt_list_token_t* next;
/* pointer to the previous token in the list */
struct ezt_list_token_t* prev;
};
struct ezt_list_t {
struct ezt_list_token_t *head;
struct ezt_list_token_t *tail;
int nb_item;
};
/* return true if the list is empty */
#define ezt_list_empty(l) ((l)->head == NULL)
/* iterate over the list */
#define ezt_list_foreach(l, t) for(t = (l)->head; t != NULL; t = (t)->next)
/* same as list_foreach, but supports list modifications
* for each iteration, t is the current value (that can be removed from the list)
* n is the next value (that should not be modified!)
*/
#define ezt_list_foreach_safe(l, t, n) for(t = (l)->head, (n) = ((l)->head?t->next:NULL); \
t != NULL; \
t = n, (n) = t?(t)->next:NULL)
/* return the first token of the list */
#define ezt_list_get_head(l) ((l)->head)
/* return the last token of the list */
#define ezt_list_get_tail(l) ((l)->tail)
/* initialize a list */
static inline void ezt_list_new(struct ezt_list_t*l) {
l->head = NULL;
l->tail = NULL;
l->nb_item = 0;
}
/* add a new token at the list tail */
static inline void ezt_list_add(struct ezt_list_t*l,
struct ezt_list_token_t *n) {
/* initialize the new token */
n->list = l;
n->next = NULL;
n->prev = l->tail;
if (ezt_list_empty(l)) {
l->head = n;
} else {
l->tail->next = n;
}
l->tail = n;
l->nb_item++;
}
/* remove a token from the list */
static inline void ezt_list_remove(struct ezt_list_token_t *t) {
if (t->prev)
t->prev->next = t->next;
else
t->list->head = t->next;
if (t->next)
t->next->prev = t->prev;
else
t->list->tail = t->prev;
if (t->list->head && !t->list->tail)
abort();
t->list->nb_item--;
}
#endif /* EZTRACE_LIST_H */
|