#include <config.h>
#endif
#include "avl.h"
+#include "log.h"
/* Private methods */
int _avl_removeroot(avl_tree* t);
void avl_init(avl_tree* t, int (*compar)(void* a, void* b)) {
t->root = NULL;
t->compar = compar;
+
+ int lock;
#ifdef AVL_LOCK_WITH_MUTEX
- pthread_mutex_init(&t->mutex, NULL);
+ lock = pthread_mutex_init(&t->mutex, NULL);
#else
- pthread_rwlock_init(&t->rwlock, NULL);
+ lock = pthread_rwlock_init(&t->rwlock, NULL);
#endif
+
+ if(lock != 0)
+ fatal("Failed to initialize AVL mutex/rwlock, error: %d", lock);
}
if(st->enabled) {
st->thread = malloc(sizeof(pthread_t));
+ if(!st->thread)
+ fatal("Cannot allocate pthread_t memory");
info("Starting thread %s.", st->name);
d->classes_index.root = NULL;
d->classes_index.compar = tc_class_compare;
+
+ int lock;
#ifdef AVL_LOCK_WITH_MUTEX
- pthread_mutex_init(&d->classes_index.mutex, NULL);
+ lock = pthread_mutex_init(&d->classes_index.mutex, NULL);
#else
- pthread_rwlock_init(&d->classes_index.rwlock, NULL);
+ lock = pthread_rwlock_init(&d->classes_index.rwlock, NULL);
#endif
+ if(lock != 0)
+ fatal("Failed to initialize plugin_tc mutex/rwlock, return code %d.", lock);
tc_device_index_add(d);
*buf = malloc(strlen(str) * 3 + 1),
*pbuf = buf;
+ if(!buf)
+ fatal("Cannot allocate memory.");
+
while (*pstr) {
if (isalnum(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~')
*pbuf++ = *pstr;
*buf = malloc(strlen(str) + 1),
*pbuf = buf;
- if(!buf) fatal("Cannot allocate memory.");
+ if(!buf)
+ fatal("Cannot allocate memory.");
while (*pstr) {
if (*pstr == '%') {