int main(int argc, char **argv){ mc_collector_t *mc; mc = NULL; void *data; data = (void *) mc_calloc(&mc, 15); acseg_list_t *list; list = acseg_list_init(&mc); acseg_queue_push(list, data, &mc); acseg_queue_pop(list); mc_free(data); mc_destory(mc); }
void acseg_index_fix(acseg_index_t *acseg_index) { mc_collector_t *local_mc; acseg_list_t *queue, *child_queue; acseg_rbtree_t *rbtree, *child_rbtree; acseg_index_item_t *index_item, *parent_failure; acseg_index_item_t *tmp_index_item, *child_item; local_mc = NULL; queue = acseg_list_init(&local_mc); child_queue = acseg_list_init(&local_mc); rbtree = acseg_index->root->childs_rbtree; add_all_item_to_queue(rbtree->root, rbtree->sentinel, queue, &local_mc); set_index_item_failure(queue, acseg_index->root); while ( (index_item = acseg_queue_pop(queue)) ){ child_rbtree = index_item->childs_rbtree; add_all_item_to_queue(child_rbtree->root, child_rbtree->sentinel, child_queue, &local_mc); child_item = acseg_queue_pop(child_queue); while (child_item) { acseg_queue_push(queue, child_item, &local_mc); parent_failure = index_item->failure; while (1) { tmp_index_item = find_child_index_item(parent_failure, &(child_item->atom)); if (tmp_index_item == NULL) { if (parent_failure == acseg_index->root) { tmp_index_item = parent_failure; break; } else { parent_failure = parent_failure->failure; } } else { break; } } child_item->failure = tmp_index_item; acseg_list_extend(child_item->extra_outputs, tmp_index_item->output, &(acseg_index->mc)); acseg_list_extend(child_item->extra_outputs, tmp_index_item->extra_outputs, &(acseg_index->mc)); child_item = acseg_queue_pop(child_queue); } } mc_destory(local_mc); acseg_index->state = AC_INDEX_FIXED; }