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) {
56 list->freeItem( (void*) *value );
57 JLD(retcode, list->list, index);
58 JLP(value, list->list, index);
64 void* osrfListRemove( osrfList* list, int position ) {
65 if(!list) return NULL;
69 JLG( value, list->list, position );
74 olditem = (void*) *value;
76 JLD(retcode, list->list, position );
79 list->freeItem( olditem );
82 __osrfListSetSize( list );
91 int osrfListFind( osrfList* list, void* addr ) {
92 if(!(list && addr)) return -1;
95 unsigned long index = -1;
96 JLL(value, list->list, index );
98 while (value != NULL) {
99 if( (void*) *value == addr )
101 JLP(value, list->list, index);
109 void __osrfListSetSize( osrfList* list ) {
113 unsigned long index = -1;
114 JLL(value, list->list, index );
115 list->size = index + 1;
119 unsigned long osrfListGetCount( osrfList* list ) {
121 unsigned long retcode = -1;
122 JLC( retcode, list->list, 0, -1 );
127 void* osrfListPop( osrfList* list ) {
128 if(!list) return NULL;
129 return osrfListRemove( list, list->size - 1 );
133 osrfListIterator* osrfNewListIterator( osrfList* list ) {
134 if(!list) return NULL;
135 osrfListIterator* itr = safe_malloc(sizeof(osrfListIterator));
141 void* osrfListIteratorNext( osrfListIterator* itr ) {
142 if(!(itr && itr->list)) return NULL;
145 if(itr->current >= itr->list->size) return NULL;
146 JLF( value, itr->list->list, itr->current );
149 return (void*) *value;
154 void osrfListIteratorFree( osrfListIterator* itr ) {
161 void osrfListIteratorReset( osrfListIterator* itr ) {
167 void osrfListVanillaFree( void* item ) {
171 void osrfListSetDefaultFree( osrfList* list ) {
173 list->freeItem = osrfListVanillaFree;