Coconut Framework  beta
CNListItem.h
Go to the documentation of this file.
1 
8 #ifndef CNLISTITEM_H
9 #define CNLISTITEM_H
10 
11 #include "CNResource.h"
12 
16 struct CNListItem {
18  struct CNListItem * _nextItem ;
20  struct CNListItem * _prevItem ;
22  void * dataPtr ;
23 } ;
24 
33 static inline struct CNListItem *
34 CNAllocateListItem(void * data, struct CNResource * resource)
35 {
36  struct CNListItem * newitem = (struct CNListItem *) CNAllocateData(resource, sizeof(struct CNListItem)) ;
37  newitem->_prevItem = newitem->_nextItem = NULL ;
38  newitem->dataPtr = data ;
39  return newitem ;
40 }
41 
47 static inline void
48 CNReleaseListItem(struct CNResource * resource, struct CNListItem * item)
49 {
50  CNReleaseData(resource, sizeof(struct CNListItem), item) ;
51 }
52 
58 static inline struct CNListItem *
59 CNNextListItem(const struct CNListItem * src)
60 {
61  return src->_nextItem ;
62 }
63 
69 static inline struct CNListItem *
70 CNPrevListItem(const struct CNListItem * src)
71 {
72  return src->_prevItem ;
73 }
74 
80 static inline void *
81 CNDataOfListItem(const struct CNListItem * src)
82 {
83  return src->dataPtr ;
84 }
85 
86 #endif /* CNLISTITEM_H */
Single linked list item.
Definition: CNListItem.h:16
static struct CNListItem * CNNextListItem(const struct CNListItem *src)
Get next item of source list item.
Definition: CNListItem.h:59
Define CNResource data structure.
static void CNReleaseListItem(struct CNResource *resource, struct CNListItem *item)
Release CNListItem object.
Definition: CNListItem.h:48
struct CNListItem * _nextItem
Definition: CNListItem.h:18
void CNReleaseData(struct CNResource *resource, size_t size, void *src)
Release memory object into resource.
static void * CNDataOfListItem(const struct CNListItem *src)
Get data of list item.
Definition: CNListItem.h:81
void * dataPtr
Definition: CNListItem.h:22
void * CNAllocateData(struct CNResource *resource, size_t size)
Allocate data memory.
struct CNListItem * _prevItem
Definition: CNListItem.h:20
static struct CNListItem * CNPrevListItem(const struct CNListItem *src)
Get previous item of source list item.
Definition: CNListItem.h:70
static struct CNListItem * CNAllocateListItem(void *data, struct CNResource *resource)
Allocate CNListItem.
Definition: CNListItem.h:34