The Netsukuku Project  0.0.9
An Alternative routing method
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros
llist.c File Reference
This graph shows which files directly or indirectly include this file:

Data Structures

struct  linked_list
 

Macros

#define LLIST_C
 
#define LLIST_HDR(_struct)   _struct *next, *prev
 
#define is_list_zero(list)
 
#define list_copy(list, new)
 
#define list_dup(list)
 
#define list_init(list, new)
 
#define list_last(list)
 
#define list_head(tail)
 
#define list_append(_head, _tail, _new)
 
#define list_add(_head, _new)
 
#define list_join(head, list)
 
#define list_free(list)
 
#define list_del(head, list)
 
#define list_ins(list, new)
 
#define list_substitute(old_list, new_list)
 
#define list_swap(a, b)
 
#define list_moveback(list)
 
#define list_movefwd(list)
 
#define list_moveontop(_head, _list)
 
#define list_for(i)   for(; (i); (i)=(typeof (i))(i)->next)
 
#define list_count(_head)
 
#define list_safe_for(_ii, _next_ptr)
 
#define list_pos(list, pos)
 
#define list_get_pos(head, list)
 
#define list_destroy(list)
 
#define list_copy_some(list, check_func, func_args...)
 
#define list_copy_all_yes(_nil)   (1)
 
#define list_copy_all(list)   list_copy_some((list), list_copy_all_yes)
 
#define clist_add(_head, _counter, _list)
 
#define clist_append(_head, _tail, _counter, _list)
 
#define clist_del(_head, _counter, _list)
 
#define clist_ins(_head, _counter, _list)
 
#define clist_join(_head, _counter, _list)
 
#define clist_init(_counter)
 
#define clist_destroy(_head, _counter)
 
#define clist_qsort(_new_head, _head, _counter, _cmp_func)
 

Typedefs

typedef struct linked_list l_list
 

Variables

struct linked_list linked_list
 

Macro Definition Documentation

#define clist_add (   _head,
  _counter,
  _list 
)
Value:
do{ \
if(!(*(_counter)) || !(*(_head))) \
list_init(*(_head), (_list)); \
else \
*((_head))=list_add(*(_head), (_list)); \
(*(_counter))++; \
}while(0)
#define list_add(_head, _new)
Definition: llist.c:183
#define list_init(list, new)
Definition: llist.c:105
#define clist_append (   _head,
  _tail,
  _counter,
  _list 
)
Value:
do{ \
l_list *_tca=0, **_targv=(l_list **)(_tail); \
if((_tail)) \
_tca=*_targv; \
if(!(*(_counter)) || !(*(_head))) \
list_init(*(_head), (_list)); \
else { \
_tca=(l_list *)list_append(*(_head), _tca, (_list)); \
if(_targv) \
(*_targv)=_tca; \
} \
(*(_counter))++; \
}while(0)
struct linked_list l_list
Definition: llist.c:50
#define list_append(_head, _tail, _new)
Definition: llist.c:158
#define list_init(list, new)
Definition: llist.c:105
Definition: llist.c:46
#define clist_del (   _head,
  _counter,
  _list 
)
Value:
do{ \
if((*(_counter)) > 0) { \
*((_head))=list_del(*(_head), (_list)); \
(*(_counter))--; \
} \
}while(0)
#define list_del(head, list)
Definition: llist.c:231
#define clist_destroy (   _head,
  _counter 
)
Value:
({ \
list_destroy(*((_head))); \
(*(_head))=0; \
(*(_counter))=0; \
0; \
})
#define list_destroy(list)
Definition: llist.c:459
#define clist_init (   _counter)
Value:
({ \
*(_counter)=0; \
0; \
})
#define clist_ins (   _head,
  _counter,
  _list 
)
Value:
do{ \
if(!(*(_counter)) || !(*(_head))) \
clist_add((_head), (_counter), (_list)); \
else { \
list_ins(*(_head), (_list)); \
(*(_counter))++; \
} \
}while(0)
#define clist_add(_head, _counter, _list)
Definition: llist.c:520
#define list_ins(list, new)
Definition: llist.c:246
#define clist_join (   _head,
  _counter,
  _list 
)
Value:
do{ \
if((*(_counter)) > 0) { \
*((_head))=list_join((*(_head)), _list); \
(*(_counter))--; \
} \
} while(0)
#define list_join(head, list)
Definition: llist.c:207
#define clist_qsort (   _new_head,
  _head,
  _counter,
  _cmp_func 
)
Value:
({ \
l_list *_hcq=(l_list *)(_head), *_ncq, *_hecq, *_tcq; \
int _icq=0, _ccq; \
\
_ccq = !(_counter) ? list_count(_hcq) : (_counter); \
l_list *_tmp_list[_ccq]; \
\
_ncq=_hcq; \
list_for(_ncq) { \
_tmp_list[_icq]=_ncq; \
_icq++; \
} \
\
qsort(_tmp_list, _ccq, sizeof(l_list *), (_cmp_func)); \
\
_tcq=0; \
_hecq=_tmp_list[0]; \
for(_icq=0; _icq<_ccq; _icq++) \
_tcq=(l_list *)list_append(0, _tcq, _tmp_list[_icq]); \
\
_new_head = (typeof((_head)))_hecq; \
}) \
#define list_count(_head)
Definition: llist.c:379
struct linked_list l_list
Definition: llist.c:50
#define list_append(_head, _tail, _new)
Definition: llist.c:158
#define list_for(i)
Definition: llist.c:372
Definition: llist.c:46
#define is_list_zero (   list)
Value:
({ \
int _iz, _rz=1; \
char *_a=(char *)(list); \
for(_iz=0; _iz<sizeof(typeof(*(list))); _iz++, _a++) \
if(*_a) { \
_rz=0; \
break; \
} \
_rz; \
})
#define list_add (   _head,
  _new 
)
Value:
({ \
l_list *_hd, *_nd; \
_hd=(l_list *)(_head); \
_nd=(l_list *)(_new); \
if(_hd != _nd) { \
_nd->next=_hd; \
_nd->prev=0; \
if(_hd) \
_hd->prev=_nd; \
} \
(typeof((_head)))_nd; \
})
struct linked_list * next
Definition: llist.c:48
struct linked_list * prev
Definition: llist.c:48
struct linked_list l_list
Definition: llist.c:50
Definition: llist.c:46
#define list_append (   _head,
  _tail,
  _new 
)
Value:
({ \
l_list *_tt, *_na; \
_tt=(_tail) ? (l_list *)(_tail) : (l_list *)list_last((_head)); \
_na=(l_list *)(_new); \
if(_na != _tt) { \
if(_tt) \
_tt->next=_na; \
if(_na) { \
_na->prev=_tt; \
_na->next=0; \
} \
} \
_new; \
})
struct linked_list l_list
Definition: llist.c:50
#define list_last(list)
Definition: llist.c:124
Definition: llist.c:46
#define list_copy (   list,
  new 
)
Value:
do{ \
l_list _oc, *_lc=(l_list *)(list); \
if((new)) { \
_oc.prev=_lc->prev; \
_oc.next=_lc->next; \
memcpy((list), (new), sizeof(typeof(*(new)))); \
_lc->prev=_oc.prev; \
_lc->next=_oc.next; \
} \
} while(0)
struct linked_list * next
Definition: llist.c:48
struct linked_list * prev
Definition: llist.c:48
struct linked_list l_list
Definition: llist.c:50
Definition: llist.c:46
#define list_copy_all (   list)    list_copy_some((list), list_copy_all_yes)
#define list_copy_all_yes (   _nil)    (1)
#define list_copy_some (   list,
  check_func,
  func_args... 
)
Value:
({ \
l_list *_ncs=0, *_hcs=0, *_tcs=0, *_lcs=(l_list *)(list); \
list_for(_lcs) { \
if(!check_func(((typeof((list)))_lcs), ## func_args )) \
continue; \
\
_ncs=(l_list *)list_dup(((typeof((list)))_lcs)); \
if(!_hcs) _hcs=_ncs; \
\
_tcs=list_append(0, _tcs, _ncs); \
} \
\
(typeof((list)))_hcs; \
})
#define list_dup(list)
Definition: llist.c:87
struct linked_list l_list
Definition: llist.c:50
#define list_append(_head, _tail, _new)
Definition: llist.c:158
#define list_for(i)
Definition: llist.c:372
Definition: llist.c:46
#define list_count (   _head)
Value:
({ \
l_list *_lc=(l_list *)(_head); \
int _ic=0; \
list_for(_lc) \
_ic++; \
_ic; \
})
struct linked_list l_list
Definition: llist.c:50
#define list_for(i)
Definition: llist.c:372
Definition: llist.c:46
#define list_del (   head,
  list 
)
Value:
({ \
l_list *_lid=(l_list *)(list), *_hed=(l_list *)(head); \
\
_hed=(l_list *)list_join((head), _lid); \
list_free(_lid); \
(typeof((head)))_hed; \
})
#define list_free(list)
Definition: llist.c:218
struct linked_list l_list
Definition: llist.c:50
#define list_join(head, list)
Definition: llist.c:207
Definition: llist.c:46
#define list_destroy (   list)
Value:
do{ \
l_list *_xd=(l_list *)(list), *_id, *_nextd; \
_id=_xd; \
list_safe_for(_id, _nextd) \
_xd=list_del(_xd, _id); \
(list)=0; \
}while(0)
#define list_safe_for(_ii, _next_ptr)
Definition: llist.c:412
struct linked_list l_list
Definition: llist.c:50
#define list_del(head, list)
Definition: llist.c:231
Definition: llist.c:46
#define list_dup (   list)
Value:
({ \
l_list *_dd; \
_dd=xmalloc(sizeof(typeof(*(list)))); \
memset(_dd, 0, sizeof(typeof(*(list)))); \
list_copy(_dd, (list)); \
(typeof((list)))_dd; \
})
void * xmalloc(size_t size)
Definition: xmalloc.c:44
struct linked_list l_list
Definition: llist.c:50
#define list_copy(list, new)
Definition: llist.c:70
#define list_for (   i)    for(; (i); (i)=(typeof (i))(i)->next)
#define list_free (   list)
Value:
do { \
memset((list), 0, sizeof(typeof(*(list)))); \
xfree((list)); \
} while(0)
#define xfree(__pptr)
Definition: xmalloc.h:49
#define list_get_pos (   head,
  list 
)
Value:
({ \
int _igp=0, _egp=0; \
l_list *_xgp=(l_list *)(head); \
list_for(_xgp) { \
if(_xgp == (l_list *)(list)) { \
_egp=1; \
break; \
} else \
_igp++; \
} \
_egp ? _igp : -1; \
})
struct linked_list l_list
Definition: llist.c:50
#define list_for(i)
Definition: llist.c:372
Definition: llist.c:46
#define list_head (   tail)
Value:
({ \
l_list *_ih=(l_list *)(list); \
for(; _ih && _ih->prev; _ih=(l_list *)_ih->prev); \
(typeof((list)))_ih; \
})
struct linked_list l_list
Definition: llist.c:50
Definition: llist.c:46
#define list_init (   list,
  new 
)
Value:
do { \
l_list *_li; \
if((new)) \
(list)=(new); \
else \
(list)=(typeof (list))xmalloc(sizeof(typeof(*(list)))); \
_li=(l_list *)(list); \
_li->prev=0; \
_li->next=0; \
if(!(new)) \
memset((list), 0, sizeof(typeof(*(list)))); \
} while (0)
void * xmalloc(size_t size)
Definition: xmalloc.c:44
struct linked_list l_list
Definition: llist.c:50
Definition: llist.c:46
#define list_ins (   list,
  new 
)
Value:
do { \
l_list *_lin=(l_list *)(list), *_n=(l_list *)(new); \
if(_lin->next) \
_lin->next->prev=_n; \
_n->next=_lin->next; \
_lin->next=_n; \
_n->prev=_lin; \
} while (0)
struct linked_list * next
Definition: llist.c:48
struct linked_list * prev
Definition: llist.c:48
struct linked_list l_list
Definition: llist.c:50
Definition: llist.c:46
#define list_join (   head,
  list 
)
Value:
({ \
l_list *_lj=(l_list *)(list), *_hj=(l_list *)(head), *_ret; \
if(_lj->next) \
_lj->next->prev=_lj->prev; \
if(_lj->prev) \
_lj->prev->next=_lj->next; \
_ret = _lj == _hj ? _lj->next : _hj; \
(typeof((head)))_ret; \
})
struct linked_list * next
Definition: llist.c:48
struct linked_list * prev
Definition: llist.c:48
struct linked_list l_list
Definition: llist.c:50
Definition: llist.c:46
#define list_last (   list)
Value:
({ \
l_list *_il=(l_list *)(list); \
for(; _il && _il->next; _il=(l_list *)_il->next); \
(typeof((list)))_il; \
})
struct linked_list l_list
Definition: llist.c:50
Definition: llist.c:46
#define list_moveback (   list)
Value:
do{ \
l_list *_lm=(l_list *)(list); \
if(_lm->prev) \
list_swap(_lm->prev, _lm); \
}while(0)
struct linked_list l_list
Definition: llist.c:50
#define list_swap(a, b)
Definition: llist.c:285
Definition: llist.c:46
#define list_movefwd (   list)
Value:
do{ \
l_list *_lmf=(l_list *)(list); \
if(_lmf->next) \
list_swap(_lmf->next, _lmf); \
}while(0)
struct linked_list l_list
Definition: llist.c:50
#define list_swap(a, b)
Definition: llist.c:285
Definition: llist.c:46
#define list_moveontop (   _head,
  _list 
)
Value:
({ \
l_list *_hmt=(l_list *)(_head), *_lmt=(l_list *)(_list); \
\
if(_hmt != _lmt) { \
_hmt=(l_list *)list_join((typeof((_head)))_hmt, _lmt); \
_hmt=(l_list *)list_add((typeof((_head)))_hmt, _lmt); \
} \
(typeof((_head)))_hmt; \
})
#define list_add(_head, _new)
Definition: llist.c:183
struct linked_list l_list
Definition: llist.c:50
#define list_join(head, list)
Definition: llist.c:207
Definition: llist.c:46
#define list_pos (   list,
  pos 
)
Value:
({ \
int _ip=0; \
l_list *_xp=(l_list *)(list); \
list_for(_xp) { \
if(_ip==(pos)) \
break; \
else \
_ip++; \
} \
(typeof((list)))_xp; \
})
struct linked_list l_list
Definition: llist.c:50
#define list_for(i)
Definition: llist.c:372
Definition: llist.c:46
#define list_safe_for (   _ii,
  _next_ptr 
)
Value:
for((_ii) ? (_next_ptr)=(typeof (_ii))(_ii)->next : 0; (_ii); \
(_ii)=(_next_ptr), (_ii) ? (_next_ptr)=(typeof (_ii))(_ii)->next : 0)
#define list_substitute (   old_list,
  new_list 
)
Value:
do{ \
l_list *_ns, *_os; \
_ns=(l_list *)(new_list); \
_os=(l_list *)(old_list); \
if(_os->next != _ns) \
_ns->next=_os->next; \
if(_os->prev != _ns) \
_ns->prev=_os->prev; \
if(_ns->next) \
_ns->next->prev=_ns; \
if(_ns->prev) \
_ns->prev->next=_ns; \
}while(0)
struct linked_list * next
Definition: llist.c:48
struct linked_list * prev
Definition: llist.c:48
struct linked_list l_list
Definition: llist.c:50
Definition: llist.c:46
#define list_swap (   a,
 
)
Value:
do{ \
l_list _ltmp, *_aa, *_bb; \
_aa=(l_list *)(a); \
_bb=(l_list *)(b); \
if(_aa->next == _bb) { \
list_substitute(_aa, _bb); \
list_ins(_bb, _aa); \
} else if(_aa->prev == _bb) { \
list_substitute(_bb, _aa); \
list_ins(_aa, _bb); \
} else { \
_ltmp.next=(l_list *)_bb->next; \
_ltmp.prev=(l_list *)_bb->prev; \
list_substitute(_aa, _bb); \
list_substitute(&_ltmp, _aa); \
} \
}while(0)
struct linked_list l_list
Definition: llist.c:50
#define list_substitute(old_list, new_list)
Definition: llist.c:263
Definition: llist.c:46
#define list_ins(list, new)
Definition: llist.c:246
#define LLIST_C
#define LLIST_HDR (   _struct)    _struct *next, *prev

Typedef Documentation

typedef struct linked_list l_list

Variable Documentation