ps2sdk  1.1
A collection of Open Source libraries used for developing applications on Sony's PlayStation 2® (PS2).
list.h File Reference

Go to the source code of this file.

Data Structures

struct  list_t
 

Macros

#define LIST_INIT(name)   { &(name), &(name) }
 
#define list_for_each(dir, pos, head)    for (pos = (head)->dir; pos != (head); pos = pos->dir)
 

Functions

static int list_empty (void *l)
 
static void list_insert (void *l, void *i)
 
static list_tlist_remove (void *i)
 

Detailed Description

Simple list support.

Definition in file list.h.

Macro Definition Documentation

◆ list_for_each

#define list_for_each (   dir,
  pos,
  head 
)     for (pos = (head)->dir; pos != (head); pos = pos->dir)

Iterate over a list. Dir is 'next' to iterate forward and 'prev' to iterate in reverse.

Definition at line 56 of file list.h.

◆ LIST_INIT

#define LIST_INIT (   name)    { &(name), &(name) }

Definition at line 24 of file list.h.

Function Documentation

◆ list_empty()

static int list_empty ( void *  l)
inlinestatic

Definition at line 26 of file list.h.

27 {
28  list_t *list = (list_t *)l;
29 
30  return list->next == list && list->prev == list;
31 }
Definition: list.h:19
struct _list * prev
Definition: list.h:21
struct _list * next
Definition: list.h:20

References list_t::next, and list_t::prev.

◆ list_insert()

static void list_insert ( void *  l,
void *  i 
)
inlinestatic

Insert an item after the given list.

Definition at line 34 of file list.h.

35 {
36  list_t *list = (list_t *)l, *item = (list_t *)i;
37 
38  item->prev = list;
39  item->next = list->next;
40  list->next->prev = item;
41  list->next = item;
42 }

References list_t::next, and list_t::prev.

◆ list_remove()

static list_t* list_remove ( void *  i)
inlinestatic

Remove the item from the list and return the item.

Definition at line 45 of file list.h.

46 {
47  list_t *item = (list_t *)i;
48 
49  item->prev->next = item->next;
50  item->next->prev = item->prev;
51  return item;
52 }

References list_t::next, and list_t::prev.