Esempio n. 1
0
void context_free(context_t *context)
{
	if (context) {
		pki_passport_destroy(context->passport);
		linkst_free(context->linkst);
		ftable_delete(context->ftable);
		ctable_delete(context->ctable);
		ctable_delete(context->atable);
		bitpool_free(context->bitpool);
		session_free(context->access_session);
		free(context);
	}
}
Esempio n. 2
0
int main()
{
	int init_matrix_size = 1;
	linkst_t *linkst = NULL;

	/* there is 4 active nodee */
	int idx_a, idx_b, idx_c, idx_d;

	idx_a = 1;
	idx_b = 2;
	idx_c = 3;
	idx_d = 100;

	linkst = linkst_new(100, 3);

	linkst_join(linkst, idx_a, idx_b);

	if (linkst_joined(linkst, idx_a, idx_b) != 1) {
		printf("%d // %d\n", idx_a, idx_b);
		goto out;
	}

	linkst_join(linkst, idx_a, idx_d);

	if (linkst_joined(linkst, idx_a, idx_d) != 1) {
		printf("%d // %d\n", idx_a, idx_d);
		goto out;
	}

	int state;
	int i = 4;

	while (i--) {

		state = linkst_joined(linkst, idx_a, idx_b);
		printf("state [%d] || [%d] %s [%d]\n", state, idx_a, state == 1 ? "<==>": "//", idx_b);

		state = linkst_joined(linkst, idx_a, idx_c);
		printf("state [%d] || [%d] %s [%d]\n", state, idx_a, state == 1 ? "<==>": "//", idx_c);

		printf("\n\n");

		sleep(1);
	}
	printf("out of loop\n");

	linkst_join(linkst, idx_a, idx_b);
	linkst_join(linkst, idx_a, idx_d);

	linkst_disjoin(linkst, idx_a);

	state = linkst_joined(linkst, idx_a, idx_b);
	printf("state [%d] || [%d] %s [%d]\n", state, idx_a, state == 1 ? "<==>": "//", idx_b);

	state = linkst_joined(linkst, idx_a, idx_c);
	printf("state [%d] || [%d] %s [%d]\n", state, idx_a, state == 1 ? "<==>": "//", idx_c);

	printf("\n\n");

out:
	linkst_free(linkst);
}