Exemple #1
0
static void test_int_list(struct cag_test_series *tests)
{
	int i, total = 0;
	ilist l;
	iterator_ilist *it;
	new_ilist(&l);
	append_ilist(&l, 2);
	for (i = 1; i < 5; ++i)
		append_ilist(&l, i);
	for (i = 0, it = beg_ilist(&l); it != end_ilist(&l);
	     it = it->next, ++i)
		total += it->value;
	CAG_TEST(*tests, i == 5 && total == 12,
		 "cag_dlist: ilist append");
	free_ilist(&l);
	new_ilist(&l);
	total = 0;
	for (i = 1; i < 5; ++i)
		appendp_ilist(&l, &i);
	for (i = 0, it = beg_ilist(&l); it != end_ilist(&l);
	     it = it->next, ++i)
		total += it->value;
	CAG_TEST(*tests, i == 4 && total == 10,
		 "cag_dlist: ilist pappend");
	free_ilist(&l);
}
Exemple #2
0
opq_t *
opq_alloc(os_handler_t *os_hnd)
{
    int   rv;
    opq_t *opq;

    opq = ipmi_mem_alloc(sizeof(*opq));
    if (!opq)
	return NULL;
    memset(opq, 0, sizeof(*opq));

    opq->os_hnd = os_hnd;
    opq->in_handler = 0;
    opq->ops = alloc_ilist();
    if (!(opq->ops)) {
	ipmi_mem_free(opq);
	return NULL;
    }

    if (os_hnd->create_lock) {
	rv = os_hnd->create_lock(opq->os_hnd, &(opq->lock));
	if (rv) {
	    free_ilist(opq->ops);
	    ipmi_mem_free(opq);
	    return NULL;
	}
    } else {
	opq->lock = NULL;
    }

    return opq;
}
Exemple #3
0
void
keypad_free(keypad_t keypad)
{
    int i;

    for (i=0; i<NUM_KEY_ENTRIES; i++) {
	if (keypad->keys[i]) {
	    ilist_iter(keypad->keys[i], del_key_entry, NULL);
	    free_ilist(keypad->keys[i]);
	}
    }
    ipmi_mem_free(keypad);
}
Exemple #4
0
void
opq_destroy(opq_t *opq)
{
    /* Only allow this to be done once.  Callbacks might call this
       again. */
    opq_lock(opq);
    if (opq->in_destroy) {
	opq_unlock(opq);
	return;
    }
    opq->in_destroy = 1;
    opq_unlock(opq);

    ilist_iter(opq->ops, opq_destroy_item, NULL);
    free_ilist(opq->ops);
    if (opq->lock)
	opq->os_hnd->destroy_lock(opq->os_hnd, opq->lock);
    ipmi_mem_free(opq);
}