irods  4.2.8
About: iRODS (the integrated Rule Oriented Data System) is a distributed data-management system for creating data grids, digital libraries, persistent archives, and real-time data systems.
  Fossies Dox: irods-4.2.8.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

list.cpp
Go to the documentation of this file.
1 /* For copyright information please refer to files in the COPYRIGHT directory
2  */
3 #include "irods_list.h"
4 #include <cstdlib>
5 
6 List *newList( Region *r ) {
7  List *l = ( List * )region_alloc( r, sizeof( List ) );
8  l->head = l->tail = NULL;
9  l->size = 0;
10  return l;
11 }
12 
14  List *l = ( List * )malloc( sizeof( List ) );
15  l->head = l->tail = NULL;
16  l->size = 0;
17  return l;
18 }
19 
21  ListNode *l = ( ListNode * )malloc( sizeof( ListNode ) );
22  l->next = NULL;
23  l->value = value;
24  return l;
25 }
27  ListNode *l = ( ListNode * )region_alloc( r, sizeof( ListNode ) );
28  l->next = NULL;
29  l->value = value;
30  return l;
31 }
32 
33 
34 void listAppendNoRegion( List *list, void *value ) {
36  if ( list->head != NULL ) {
37  list->tail = list->tail->next = ln;
38  }
39  else {
40  list->head = list->tail = ln;
41 
42  }
43  list->size++;
44 }
45 void listAppend( List *list, void *value, Region *r ) {
46  ListNode *ln = newListNode( value, r );
47  if ( list->head != NULL ) {
48  list->tail = list->tail->next = ln;
49  }
50  else {
51  list->head = list->tail = ln;
52  }
53  list->size++;
54 }
55 
57  ListNode *ln = newListNode( value, r );
58  if ( node->next != NULL ) {
59  ln->next = node->next;
60  node->next = ln;
61  }
62  else {
63  node->next = list->tail = ln;
64  }
65  list->size++;
66 }
67 
69  ListNode *prev = NULL, *curr = list->head;
70  while ( curr != NULL ) {
71  if ( curr == node ) {
72  if ( prev == NULL ) {
73  list->head = node->next;
74  }
75  else {
76  prev->next = node->next;
77  }
78  /*free(node); */
79  break;
80  }
81  prev = curr;
82  curr = curr->next;
83  }
84  if ( list->tail == node ) {
85  list->tail = prev;
86  }
87  list->size--;
88 
89 }
90 void listRemoveNoRegion2( List *l, void *v ) {
91  ListNode *node = l->head;
92  while ( node != NULL ) {
93  if ( node->value == v ) {
95  break;
96  }
97  node = node->next;
98  }
99 }
101  ListNode *prev = NULL, *curr = list->head;
102  while ( curr != NULL ) {
103  if ( curr == node ) {
104  if ( prev == NULL ) {
105  list->head = node->next;
106  }
107  else {
108  prev->next = node->next;
109  }
110  free( node );
111  break;
112  }
113  prev = curr;
114  curr = curr->next;
115  }
116  if ( list->tail == node ) {
117  list->tail = prev;
118  }
119  list->size--;
120 }
121 
123 
124  free( list );
125 }
127  while ( list->head != NULL ) {
129  }
130 }
131 
132 
133 
NULL
#define NULL
Definition: rodsDef.h:70
irods_list.h
listNode
Definition: irods_list.h:8
region_alloc
void * region_alloc(Region *r, size_t s)
Definition: region.cpp:138
newListNode
ListNode * newListNode(void *value, Region *r)
Definition: list.cpp:26
list::size
int size
Definition: irods_list.h:14
newListNoRegion
List * newListNoRegion()
Definition: list.cpp:13
node
Definition: restructs.hpp:244
deleteListNoRegion
void deleteListNoRegion(List *list)
Definition: list.cpp:122
listAppendNoRegion
void listAppendNoRegion(List *list, void *value)
Definition: list.cpp:34
list::tail
ListNode * tail
Definition: irods_list.h:16
newListNodeNoRegion
ListNode * newListNodeNoRegion(void *value)
Definition: list.cpp:20
listRemove
void listRemove(List *list, ListNode *node)
Definition: list.cpp:68
listRemoveNoRegion2
void listRemoveNoRegion2(List *l, void *v)
Definition: list.cpp:90
listAppend
void listAppend(List *list, void *value, Region *r)
Definition: list.cpp:45
get_irods_version.value
dictionary value
Definition: get_irods_version.py:27
region
Definition: region.h:45
listRemoveNoRegion
void listRemoveNoRegion(List *list, ListNode *node)
Definition: list.cpp:100
clearListNoRegion
void clearListNoRegion(List *list)
Definition: list.cpp:126
list::head
ListNode * head
Definition: irods_list.h:15
get_db_schema_version.l
l
Definition: get_db_schema_version.py:19
listNode::next
ListNode * next
Definition: irods_list.h:9
newList
List * newList(Region *r)
Definition: list.cpp:6
listAppendToNode
void listAppendToNode(List *list, ListNode *node, void *value, Region *r)
Definition: list.cpp:56
list
Definition: irods_list.h:13