static void free_nodes(dict_t *dict, dnode_t *node, dnode_t *nil) { if (node == nil) return; free_nodes(dict, node->left, nil); free_nodes(dict, node->right, nil); dict->freenode(node, dict->context); }
void free_nodes(Node *root) { if (root == NULL) return; free_nodes(root->left); free_nodes(root->right); free(root); }
void free_nodes(Node* node) { if (node->fsa.fst != NULL) node->fsa.cleanup(); if (node->fst.fst != NULL) node->fst.cleanup(); if (node->left != NULL) free_nodes(node->left); if (node->right != NULL) free_nodes(node->right); if (node->next != NULL) free_nodes(node->next); delete node; }
static void free_nodes(rope* n) { if (n == NULL) { return; } free_nodes(n->left); free_nodes(n->right); free(n); }
static void free_nodes( TA_Libc *libHandle, dict_t *dict, dnode_t *node, dnode_t *nil) { if (node == nil) return; free_nodes( libHandle, dict, node->left, nil); free_nodes( libHandle, dict, node->right, nil); dict->freenode( libHandle, node, dict->context); }
void free_nodes(struct Node *node) { if (node == NULL) return; free_nodes(node->left); free_nodes(node->right); free_node(node); }
inline void free_nodes(struct BTreeNode *root) { if (root == NULL) return; free_nodes(root->l_child); free_nodes(root->r_child); free(root); }
static void free_nodes (TreeNode *root) { if (root) { free_aliases ((_hostent*)root->info); free_nodes (root->left); free_nodes (root->right); } }
static void free_nodes(struct hcnode *node) { struct hcnode *l, *r; l = node->left; r = node->right; xfree(node); if (l) free_nodes(l); if (r) free_nodes(r); }
/*========================================================= * intersect_nodes -- Return intersection of two node trees * UNUSED CODE *=======================================================*/ NODE intersect_nodes (NODE node1, NODE node2, BOOLEAN kids) /* children matter */ { NODE prev1, curs1, next1, prev2, curs2, next2; NODE node3, curs3; if (!node1 || !node2) return NULL; node1 = copy_nodes(node1, TRUE, TRUE); node2 = copy_nodes(node2, TRUE, TRUE); node3 = curs3 = NULL; prev1 = NULL; curs1 = node1; while (curs1) { prev2 = NULL; curs2 = node2; while (curs2 && !iso_nodes(curs1, curs2, kids, FALSE)) { prev2 = curs2; curs2 = nsibling(curs2); } if (curs2) { next2 = nsibling(curs2); nsibling(curs2) = NULL; if (node3) curs3 = nsibling(curs3) = curs2; else node3 = curs3 = curs2; if (prev2) nsibling(prev2) = next2; else node2 = next2; next1 = nsibling(curs1); nsibling(curs1) = NULL; free_nodes(curs1); if (prev1) nsibling(prev1) = next1; else node1 = next1; curs1 = next1; } else { prev1 = curs1; curs1 = nsibling(curs1); } } free_nodes(node1); free_nodes(node2); return node3; }
// Release memory allocated to nodes void free_nodes(Node *pNode) { if(!pNode) // If there's no node... return; // ...we are done. if(pNode->pLeft) // If there's a left sub-tree... free_nodes(pNode->pLeft); // ...free memory for those nodes. if(pNode->pRight) // If there's a right sub-tree... free_nodes(pNode->pRight); // ...free memory for those nodes. free(pNode); // Free current node memory }
static void free_nodes(struct mtree_trie_node *u, mtree_trie_free_fn f) { if (u->left != NULL && u->left->bit > u->bit) free_nodes(u->left, f); if (u->right != NULL && u->right->bit > u->bit) free_nodes(u->right, f); if (f != NULL) f(u->item); free(u->key); free(u); }
void ensure_deleted( struct work_task *ptask) /* I */ { struct batch_request *preq; job *pjob; preq = ptask->wt_parm1; if ((pjob = find_job(preq->rq_ind.rq_delete.rq_objname)) == NULL) { /* job doesn't exist, we're done */ return; } sprintf(log_buffer, "purging job without checking MOM"); log_event( PBSEVENT_JOB, PBS_EVENTCLASS_JOB, pjob->ji_qs.ji_jobid, log_buffer); free_nodes(pjob); if (pjob->ji_qhdr->qu_qs.qu_type == QTYPE_Execution) { set_resc_assigned(pjob, DECR); } job_purge(pjob); } /* END ensure_deleted() */
static __inline__ gint __del_value_internal(rw_file *fp, const gchar *section, const gchar *name, gboolean all) { GList *list; rw_node *node; rw_section *sec; gint n = 0; list = g_list_find_custom(fp->list_items, section, is_the_same_section); if (list) { sec = (rw_section*)list->data; while ( TRUE ) { list = g_list_find_custom(sec->list, name, is_the_right_node); if (!list) break; ++n; node = (rw_node*)list->data; sec->list = g_list_delete_link(sec->list, list); free_nodes(node, fp); if (!all) return n; } } return n; }
void step() { int i, epoch = 0; float fx, fy; clock_t timer_start, timer_end; double time_elapsed = 0; float time_per_frame; while (steps > 0 && epoch < steps) { printf("[STEP %d]\n", epoch+1); timer_start = clock(); make_tree(); for (i = 0; i < n_bodies; i++) { compute_force(i, 0, &fx, &fy); update_pos(i, fx, fy); } timer_end = clock(); time_elapsed += timer_end-timer_start; if (is_print_tree) print_tree(0, 0, "root"); if (is_print_bodies) print_bodies("[UPDATED POSITION]"); free_nodes(); epoch += 1; } time_per_frame = (time_elapsed/(double)CLOCKS_PER_SEC)/epoch; printf("\n[TIME]\n"); printf("Time per iteration: %f s\n", time_per_frame); printf("Iteration per second: %f\n", 1/time_per_frame); }
static void deque_free(void *ptr) { if (ptr) { deque *deque = ptr; free_nodes(deque->front); free(deque); } }
const std::vector<disque_node*>* disque::hello() { free_nodes(); size_t argc = 1; const char* argv[1]; size_t lens[1]; argv[0] = "HELLO"; lens[0] = sizeof("HELLO") - 1; build_request(argc, argv, lens); const redis_result* rr = run(); if (rr == NULL) return NULL; size_t n; const redis_result** children = rr->get_children(&n); if (children == NULL || n < 3) return NULL; if (children[0]->get_type() == REDIS_RESULT_INTEGER) version_ = children[0]->get_integer(); if (children[1]->get_type() == REDIS_RESULT_STRING) children[1]->argv_to_string(myid_); for (size_t i = 2; i < n; i++) { disque_node* node = create_node(children[i]); if (node != NULL) nodes_.push_back(node); } return &nodes_; }
disque::~disque() { free_nodes(); if (job_) delete job_; free_jobs(); }
/*======================================================================== * difference_nodes -- Return difference of two node lists -- all in node1 * that are not in node2 * UNUSED CODE *======================================================================*/ NODE difference_nodes (NODE node1, NODE node2, BOOLEAN kids) /* children matter */ { NODE prev1, next1, curs1, curs2; node1 = copy_nodes(node1, TRUE, TRUE); prev1 = NULL; curs1 = node1; while (curs1) { curs2 = node2; while (curs2 && !iso_nodes(curs1, curs2, kids, FALSE)) curs2 = nsibling(curs2); if (curs2) { next1 = nsibling(curs1); nsibling(curs1) = NULL; free_nodes(curs1); if (!prev1) node1 = next1; else nsibling(prev1) = next1; curs1 = next1; } else { prev1 = curs1; curs1 = nsibling(curs1); } } return node1; }
/*====================================================================== * unique_nodes -- Remove duplicates from list of nodes -- original list * is modified *====================================================================*/ NODE unique_nodes (NODE node, BOOLEAN kids) /* children matter */ { NODE node0 = node, prev, this, next; if (!node) return NULL; while (node) { prev = node; this = nsibling(node); while (this) { if (iso_nodes(node, this, kids, FALSE)) { nsibling(prev) = next = nsibling(this); nsibling(this) = NULL; free_nodes(this); this = next; } else { prev = this; this = nsibling(this); } } node = nsibling(node); } return node0; }
void force_purge_work( job *pjob) { char log_buf[LOCAL_LOG_BUF_SIZE]; pbs_queue *pque; snprintf(log_buf, sizeof(log_buf), "purging job %s without checking MOM", pjob->ji_qs.ji_jobid); log_event(PBSEVENT_JOB,PBS_EVENTCLASS_JOB,pjob->ji_qs.ji_jobid,log_buf); free_nodes(pjob); if ((pque = get_jobs_queue(&pjob)) != NULL) { if (pjob->ji_qhdr->qu_qs.qu_type == QTYPE_Execution) { unlock_queue(pque, __func__, NULL, LOGLEVEL); set_resc_assigned(pjob, DECR); } else unlock_queue(pque, __func__, NULL, LOGLEVEL); } if (pjob != NULL) svr_job_purge(pjob); } /* END force_purge_work() */
int main(void) { // offer the user two options while (true) { printf("Please choose an option (0, 1, 2): "); int option = GetInt(); switch (option) { // quit case 0: free_nodes(head); printf("Goodbye!\n"); return 0; // insert int into linked list case 1: printf("Please enter an int: "); int v = GetInt(); char* success = insert_node(v) ? "was" : "was not"; printf("The insert %s successful.\n", success); break; // print all ints case 2: print_nodes(head); break; default: printf("Not a valid option.\n"); break; } } }
void free_stack(struct Stack *stack) { if(stack->top != NULL) free_nodes(stack->top, stack->length); free(stack); }
void clear_line(void) { free_nodes(); line = NULL; tail = NULL; line_len = 0; num_words = 0; }
int XC::DriftRecorder::alloc_nodes(const int &numNodes,const int &timeOffset) { free_nodes(); theNodes= std::vector<Node *>(2*numNodes,static_cast<Node *>(nullptr)); oneOverL= Vector(numNodes); data= Vector(numNodes+timeOffset); // data(0) allocated for time return 0; }
void clear_deque(deque *a_deque) { if(a_deque->front) free_nodes(a_deque->front); a_deque->size = 0; a_deque->front = NULL; a_deque->back = NULL; return; }
inline void free_tree(struct BTree *tree) { free_nodes(tree->root); free(tree->depth); free(tree->count); free(tree->display); free(tree->name); free(tree); }
void post_job_delete_nanny( batch_request *preq_sig) { int rc; job *pjob; char log_buf[LOCAL_LOG_BUF_SIZE]; long nanny = 0; if (preq_sig == NULL) return; rc = preq_sig->rq_reply.brp_code; get_svr_attr_l(SRV_ATR_JobNanny, &nanny); if (!nanny) { /* the admin disabled nanny within the last minute or so */ free_br(preq_sig); return; } /* extract job id from task */ pjob = svr_find_job(preq_sig->rq_ind.rq_signal.rq_jid, FALSE); if (pjob == NULL) { sprintf(log_buf, "job delete nanny: the job disappeared (this is a BUG!)"); log_event(PBSEVENT_ERROR,PBS_EVENTCLASS_JOB,preq_sig->rq_ind.rq_signal.rq_jid,log_buf); } else if (rc == PBSE_UNKJOBID) { sprintf(log_buf, "job delete nanny returned, but does not exist on mom"); log_event(PBSEVENT_ERROR,PBS_EVENTCLASS_JOB,preq_sig->rq_ind.rq_signal.rq_jid,log_buf); free_nodes(pjob); set_resc_assigned(pjob, DECR); free_br(preq_sig); svr_job_purge(pjob); return; } unlock_ji_mutex(pjob, __func__, "1", LOGLEVEL); /* free task */ free_br(preq_sig); return; } /* END post_job_delete_nanny() */
void mtree_trie_free(struct mtree_trie *trie) { assert(trie != NULL); if (trie->top->left != trie->top) free_nodes(trie->top->left, trie->free_fn); free(trie); }
void mtree_trie_free(struct mtree_trie *trie, mtree_trie_free_fn f) { assert(trie != NULL); if (trie->left != trie) free_nodes(trie->left, f); free(trie); }