* Released under GNU General Public License (GPL) version 2
*
*/
-#include <pthread.h>
-
#ifndef _AVL_H
#define _AVL_H 1
+#ifndef AVL_WITHOUT_PTHREADS
+#include <pthread.h>
+#endif /* AVL_WITHOUT_PTHREADS */
+
+// #define AVL_LOCK_WITH_MUTEX 1
+
/* Data structures */
/* One element of the AVL tree */
typedef struct avl_tree {
avl* root;
int (*compar)(void* a, void* b);
+
+#ifndef AVL_WITHOUT_PTHREADS
+#ifdef AVL_LOCK_WITH_MUTEX
+ pthread_mutex_t mutex;
+#else /* AVL_LOCK_WITH_MUTEX */
pthread_rwlock_t rwlock;
+#endif /* AVL_LOCK_WITH_MUTEX */
+#endif /* AVL_WITHOUT_PTHREADS */
} avl_tree;
/* Public methods */
* returns the last value returned by iterator or 0 if there were no calls
* Warning: a<=b must hold
*/
-int avl_range(avl_tree* t, avl* a, avl* b, int (*iter)(avl* a), avl** ret);
+int avl_range(avl_tree* t, avl* a, avl* b, int (*iter)(avl*), avl** ret);
/* Iterate through elements in t equal to a
* for each element calls iter(a) until it returns 0
* returns the last value returned by iterator or 0 if there were no calls
*/
-int avl_search(avl_tree* t, avl* a, int (*iter)(avl* a), avl** ret);
+int avl_search(avl_tree* t, avl* a, int (*iter)(avl*), avl** ret);
/* Initialize the avl_tree
*/