Commit b4f3c8c1 authored by 's avatar
Browse files

Add a search function (only for DiMAPI)

git-svn-id: file:///home/svn/mapi/trunk@346 8d5bb341-7cf1-0310-8cf6-ba355fef3186
parent ce011ac2
......@@ -208,3 +208,23 @@ void flist_reverse(flist_t* list)
return;
}
#ifdef DIMAPI
void *flist_search(flist_t *list, int (*comp)(void *, void *), void *user)
{
flist_node_t *n;
void *dataCopy;
//pthread_mutex_lock(&list->lock);
for(n = flist_head(list) ; n != NULL ; n = flist_next(n)) {
if ( comp(flist_data(n), user) == 0 ) {
dataCopy = flist_data(n);
// pthread_mutex_unlock(&list->lock);
return dataCopy;
}
}
//pthread_mutex_unlock(&list->lock);
return NULL;
}
#endif
......@@ -118,4 +118,18 @@ extern inline void* flist_get(flist_t *list,int id);
*/
extern inline int flist_get_next_id(flist_t *list,int id);
#ifdef DIMAPI
/** \brief Searches for a mathcing node and returns it
Returns only the first matching node.
\param list a pointer to an existing list
\param comp function reference to be used for comparison of nodes
\param cdata 2nd argument to be passed to comparison function
\return Reference to the matching node's data, or NULL if no node
was matched
*/
extern inline void *flist_search(flist_t *, int (*compar)(void *, void *), void *);
#endif
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment