void* olditem = osrfListRemove( list, position );
list->arrlist[position] = item;
- //if( list->size == 0 || list->size <= position )
if( list->size <= position ) list->size = position + 1;
return olditem;
}
-void* osrfListGetIndex( osrfList* list, unsigned int position ) {
- if(!list || position >= list->size) return NULL;
+void* osrfListGetIndex( const osrfList* list, unsigned int position ) {
+ if(!list || position >= list->size || position < 0) return NULL;
return list->arrlist[position];
}
free(list);
}
-void* osrfListRemove( osrfList* list, int position ) {
- if(!list || position >= list->size) return NULL;
+void* osrfListRemove( osrfList* list, unsigned int position ) {
+ if(!list || position >= list->size || position < 0) return NULL;
void* olditem = list->arrlist[position];
list->arrlist[position] = NULL;
}
-int osrfListFind( osrfList* list, void* addr ) {
+int osrfListFind( const osrfList* list, void* addr ) {
if(!(list && addr)) return -1;
int index;
for( index = 0; index < list->size; index++ ) {
}
-unsigned int osrfListGetCount( osrfList* list ) {
+unsigned int osrfListGetCount( const osrfList* list ) {
if(!list) return -1;
return list->size;
}
}
-osrfListIterator* osrfNewListIterator( osrfList* list ) {
+osrfListIterator* osrfNewListIterator( const osrfList* list ) {
if(!list) return NULL;
- //osrfListIterator* itr = safe_malloc(sizeof(osrfListIterator));
osrfListIterator* itr;
OSRF_MALLOC(itr, sizeof(osrfListIterator));
itr->list = list;
struct __osrfListIteratorStruct {
- osrfList* list;
+ const osrfList* list;
unsigned int current;
};
typedef struct __osrfListIteratorStruct osrfListIterator;
/**
Creates a new list iterator with the given list
*/
-osrfListIterator* osrfNewListIterator( osrfList* list );
+osrfListIterator* osrfNewListIterator( const osrfList* list );
/**
Returns the next non-NULL item in the list, return NULL when
@param list The list
@param postiont the position
*/
-void* osrfListGetIndex( osrfList* list, unsigned int position );
+void* osrfListGetIndex( const osrfList* list, unsigned int position );
/**
Frees the list and all list items (if the list has a "freeItem" function defined )
@return A pointer to the item removed if "freeItem" is not defined
for this list, returns NULL if it is.
*/
-void* osrfListRemove( osrfList* list, int position );
+void* osrfListRemove( osrfList* list, unsigned int position );
/**
Finds the list item whose void* is the same as the one passed in
@param addr The pointer connected to the list item we're to find
@return the index of the item, or -1 if the item was not found
*/
-int osrfListFind( osrfList* list, void* addr );
+int osrfListFind( const osrfList* list, void* addr );
void __osrfListSetSize( osrfList* list );
/**
@return The number of non-null items in the list
*/
-unsigned int osrfListGetCount( osrfList* list );
+unsigned int osrfListGetCount( const osrfList* list );
/**
* May be used as a default memory freeing call