Example #1
0
void _ortp_logv_flush(int dummy, ...) {
	OList *elem;
	OList *msglist;
	va_list empty_va_list;
	va_start(empty_va_list, dummy);
	ortp_mutex_lock(&__log_stored_messages_mutex);
	msglist = __log_stored_messages_list;
	__log_stored_messages_list = NULL;
	ortp_mutex_unlock(&__log_stored_messages_mutex);
	for (elem = msglist; elem != NULL; elem = o_list_next(elem)) {
		ortp_stored_log_t *l = (ortp_stored_log_t *)elem->data;
#ifdef WIN32
		ortp_logv_out(l->level, l->msg, empty_va_list);
#else
		va_list cap;
		va_copy(cap, empty_va_list);
		ortp_logv_out(l->level, l->msg, cap);
		va_end(cap);
#endif
		ortp_free(l->msg);
		ortp_free(l);
	}
	o_list_free(msglist);
	va_end(empty_va_list);
}
Example #2
0
void o_database_close(struct o_database * db)
{
	try
	{
		if (db->referrers != 0)
		{
			int count = o_list_size(db->referrers);
			while (count > 0)
				*((struct o_database **) o_list_get(db->referrers, --count)) = 0;
			o_list_free(db->referrers);
			db->referrers = 0;
		}
		if (db->storage != 0)
			o_storage_close(db->storage);
		if (db->context != 0)
		{
			o_operation_context_release(db->context);
		}
	}
	catch(struct o_exception, ex)
	{
		DB_ERROR_NOTIFY(db, o_exception_code(ex), o_exception_message(ex));
		o_exception_free(ex);
	}
	end_try;
}
Example #3
0
void test_o_list_functions()
{
	struct o_list * list = o_list_new();
	o_list_add(list, (void *) 10);
	o_list_add(list, (void *) 20);
	assert_true(o_list_size(list) == 2, "the size of list not is the expected");
	assert_true(((long) o_list_get(list, 0)) == 10, "the first value retrieve is not the same of insert");
	assert_true(((long) o_list_get(list, 1)) == 20, "the second value retrieve is not the same of insert");
	o_list_remove(list, (void *) 20);
	assert_true(o_list_size(list) == 1, "after remove the size of list not is the expected");
	assert_true(((long) o_list_get(list, 1)) == 0, "the second value not removed as asked.");
	o_list_free(list);
}
Example #4
0
void test_o_list_iterator()
{
	struct o_list * list = o_list_new();
	o_list_add(list, (void *) 10);
	o_list_add(list, (void *) 20);
	struct o_list_iterator * iter = o_list_begin(list);
	assert_true(o_list_iterator_current(iter) == (void *) 10, "First value not is the same of insert");
	assert_true(o_list_iterator_next(iter), "Iterator Forward fail");
	assert_true(o_list_iterator_current(iter) == (void *) 20, "Second value not is the same of insert");
	assert_true(!o_list_iterator_next(iter), "Second Iterator Forward fail");
	assert_true(o_list_iterator_prev(iter), "Iterator backward fail");
	assert_true(o_list_iterator_current(iter) == (void *) 10, "First value after back fail");
	o_list_iterator_free(iter);
	struct o_list_iterator * back_iter = o_list_end(list);
	assert_true(o_list_iterator_current(back_iter) == (void *) 20, "Second value not is the same of insert");
	assert_true(o_list_iterator_next(back_iter), "Iterator Forward fail");
	assert_true(o_list_iterator_current(back_iter) == (void *) 10, "First value not is the same of insert");
	assert_true(!o_list_iterator_next(back_iter), "Second Iterator Forward fail");
	assert_true(o_list_iterator_prev(back_iter), "Iterator backward fail");
	assert_true(o_list_iterator_current(back_iter) == (void *) 20, "First value after back fail");
	o_list_iterator_free(back_iter);
	o_list_free(list);
}
Example #5
0
void test_o_list_create_destroy()
{
	struct o_list * list = o_list_new();
	o_list_free(list);
}