4 osrfList* osrfNewList() {
5 osrfList* list = safe_malloc(sizeof(osrfList));
6 list->list = (Pvoid_t) NULL;
13 int osrfListPush( osrfList* list, void* item ) {
14 if(!(list && item)) return -1;
16 unsigned long index = -1;
17 JLL(value, list->list, index );
18 osrfListSet( list, item, index+1 );
23 void* osrfListSet( osrfList* list, void* item, unsigned long position ) {
24 if(!list || position < 0) return NULL;
27 void* olditem = osrfListRemove( list, position );
29 JLI( value, list->list, position );
30 *value = (Word_t) item;
31 __osrfListSetSize( list );
37 void* osrfListGetIndex( osrfList* list, unsigned long position ) {
38 if(!list) return NULL;
41 JLG( value, list->list, position );
42 if(value) return (void*) *value;
46 void osrfListFree( osrfList* list ) {
50 unsigned long index = -1;
51 JLL(value, list->list, index );
54 while (value != NULL) {
55 JLD(retcode, list->list, index);
58 list->freeItem( (void*) *value );
59 *value = (Word_t) NULL;
62 JLP(value, list->list, index);
68 void* osrfListRemove( osrfList* list, int position ) {
69 if(!list) return NULL;
73 JLG( value, list->list, position );
78 olditem = (void*) *value;
80 JLD(retcode, list->list, position );
83 list->freeItem( olditem );
86 __osrfListSetSize( list );
95 int osrfListFind( osrfList* list, void* addr ) {
96 if(!(list && addr)) return -1;
99 unsigned long index = -1;
100 JLL(value, list->list, index );
102 while (value != NULL) {
103 if( (void*) *value == addr )
105 JLP(value, list->list, index);
113 void __osrfListSetSize( osrfList* list ) {
117 unsigned long index = -1;
118 JLL(value, list->list, index );
119 list->size = index + 1;
123 unsigned long osrfListGetCount( osrfList* list ) {
125 unsigned long retcode = -1;
126 JLC( retcode, list->list, 0, -1 );
131 osrfListIterator* osrfNewListIterator( osrfList* list ) {
132 if(!list) return NULL;
133 osrfListIterator* itr = safe_malloc(sizeof(osrfListIterator));
139 void* osrfListIteratorNext( osrfListIterator* itr ) {
140 if(!(itr && itr->list)) return NULL;
143 if(itr->current >= itr->list->size) return NULL;
144 JLF( value, itr->list->list, itr->current );
147 return (void*) *value;
152 void osrfListIteratorFree( osrfListIterator* itr ) {
159 void osrfListIteratorReset( osrfListIterator* itr ) {