static void reheap_down(pj_timer_heap_t *ht, pj_timer_entry *moved_node, size_t slot, size_t child) { PJ_CHECK_STACK(); // Restore the heap property after a deletion. while (child < ht->cur_size) { // Choose the smaller of the two children. if (child + 1 < ht->cur_size && PJ_TIME_VAL_LT(ht->heap[child + 1]->_timer_value, ht->heap[child]->_timer_value)) child++; // Perform a <copy> if the child has a larger timeout value than // the <moved_node>. if (PJ_TIME_VAL_LT(ht->heap[child]->_timer_value, moved_node->_timer_value)) { copy_node( ht, slot, ht->heap[child]); slot = child; child = HEAP_LEFT(child); } else // We've found our location in the heap. break; } copy_node( ht, slot, moved_node); }
static void SE_addto_summary(IPA_cgraph_edgelist_e edge_type, IPA_cgraph_node_t *src_node, IPA_cgraph_node_t *dst_node, IPA_cgraph_edge_data_t *edata) { IPA_cgraph_node_t *ls; IPA_cgraph_node_t *ld; if (src_node->cgraph == local_sum) { ls = src_node; } else { assert(src_node->cgraph == cg); ls = copy_node(local_sum, src_node, 0); } if (dst_node->cgraph == local_sum) { ld = dst_node; } else { assert(dst_node->cgraph == cg); ld = copy_node(local_sum, dst_node, 0); } if (IPA_FLAG_ISSET(src_node->flags, IPA_CG_NODE_FLAGS_GLOBAL) || IPA_FLAG_ISSET(dst_node->flags, IPA_CG_NODE_FLAGS_GLOBAL)) { assert(0); } if (IPA_FLAG_ISSET(src_node->flags, IPA_CG_NODE_FLAGS_NOCNTXT) || IPA_FLAG_ISSET(dst_node->flags, IPA_CG_NODE_FLAGS_NOCNTXT)) { assert(0); } IPA_FLAG_SET(src_node->flags, EA_PERMANENT); IPA_FLAG_SET(dst_node->flags, EA_PERMANENT); #if DB_EFF printf("Final Effect : "); IPA_cg_node_print(stdout, dst_node, IPA_PRINT_ASCI); printf(" <- %14s %d,%d,%d - ", edge_types[edge_type], edata->target_offset, edata->assign_size, edata->source_offset); IPA_cg_node_print(stdout, src_node, IPA_PRINT_ASCI); printf("\n"); #endif IPA_consg_ensure_edge_d (edge_type, ls, ld, edata, (IPA_CG_EDGE_FLAGS_EXPLICIT | IPA_CG_EDGE_FLAGS_HZ)); }
int add_polynomial(const polynomial ppoly1, const polynomial ppoly2, polynomial poly_sum) { int temp_coe; position poly1 = ppoly1->next; position poly2 = ppoly2->next; ppoly1->next->exponent = 10000; printf("----start to add----\n"); while(poly1 && poly2){ if(poly1->exponent > poly2->exponent){ copy_node(poly1,&poly_sum); poly1 = poly1->next; } else if(poly1->exponent < poly2->exponent){ copy_node(poly2,&poly_sum); poly2 = poly2->next; } else{ temp_coe = poly1->coefficient + poly2->coefficient; if(temp_coe){ polynomial new_node = malloc(sizeof(struct node)); if(new_node == NULL){ printf("out of space\n"); return 0; } new_node->coefficient = temp_coe; new_node->exponent = poly1->exponent; new_node->next = NULL; copy_node(new_node,&poly_sum); poly1 = poly1->next; poly2 = poly2->next; } } } while(poly1){ copy_node(poly1,&poly_sum); poly1 = poly1->next; } while(poly2){ copy_node(poly2,&poly_sum); poly2 = poly2->next; } }
graph add_node_graph(graph g, node s){ int newSize = graph_get_nbNodes(g)+1; graph d = realloc(g, sizeof(int) + sizeof(node) * newSize); d->nodes[newSize-1] = copy_node(s); d->nbNodes = newSize; return d; }
void sort_list(node_t *node_list, int count) { /* Insertion Sort - Ascending Order based on tag. */ int i=0, j=0; node_t x; for (j=1 ; j < count ; j++) { copy_node(&x, &node_list[j]); i = j - 1; while (i >= 0 && node_list[i].tag > x.tag) { copy_node(&node_list[i+1], &node_list[i]); i -= 1; } copy_node(&node_list[i+1], &x); } }
SERD_API SerdStatus serd_writer_end_anon(SerdWriter* writer, const SerdNode* node) { if (writer->syntax == SERD_NTRIPLES) { return SERD_SUCCESS; } if (serd_stack_is_empty(&writer->anon_stack) || writer->indent == 0) { w_err(writer, SERD_ERR_UNKNOWN, "unexpected end of anonymous node\n"); return SERD_ERR_UNKNOWN; } --writer->indent; write_sep(writer, SEP_ANON_END); reset_context(writer, true); writer->context = *anon_stack_top(writer); serd_stack_pop(&writer->anon_stack, sizeof(WriteContext)); const bool is_subject = serd_node_equals(node, &writer->context.subject); if (is_subject) { copy_node(&writer->context.subject, node); writer->context.predicate.type = SERD_NOTHING; } return SERD_SUCCESS; }
static Node remove_discr_ref(Node expr_node, Node object) /*;remove_discr_ref*/ { /* Within the record definition, a discriminant reference can be replaced * by a selected component for the instance of the record being built. */ Node e; int i, nk; Tuple tup; if (N_KIND(expr_node) == as_discr_ref) return new_selector_node(object, N_UNQ(expr_node)); else if (N_KIND(expr_node) == as_opt) return OPT_NODE; else { e = copy_node(expr_node); nk = N_KIND(e); if (N_AST1_DEFINED(nk) && N_AST1(e)!=(Node)0) N_AST1(e) = remove_discr_ref(N_AST1(e), object); if (N_AST2_DEFINED(nk) && N_AST2(e)!=(Node)0) N_AST2(e) = remove_discr_ref(N_AST2(e), object); if (N_AST3_DEFINED(nk) && N_AST3(e)!=(Node)0) N_AST3(e) = remove_discr_ref(N_AST3(e), object); if (N_AST4_DEFINED(nk) && N_AST4(e)!=(Node)0) N_AST4(e) = remove_discr_ref(N_AST4(e), object); } /*N_LIST(e) = [remove_discr_ref(n, object): n in N_LIST(e)];*/ if (N_LIST_DEFINED(nk) && N_LIST(e)!=(Tuple)0) { tup = N_LIST(e); for (i = 1; i <= tup_size(tup); i++) tup[i] = (char *) remove_discr_ref((Node) tup[i], object); } return e; }
static void write_pred(SerdWriter* writer, SerdStatementFlags flags, const SerdNode* pred) { write_node(writer, pred, NULL, NULL, FIELD_PREDICATE, flags); write_sep(writer, SEP_P_O); copy_node(&writer->context.predicate, pred); }
/* extract_abbreviations -- traverse node tree and find abbreviation definitions */ void extract_abbreviations(node *list, scratch_pad *scratch) { node *temp; while (list != NULL) { switch (list->key) { case ABBREVIATION: temp = copy_node(list); list->key = KEY_COUNTER; /* Mark this as dead; we will use it elsewhere */ trim_trailing_whitespace(temp->str); scratch->abbreviations = cons(temp, scratch->abbreviations); break; case HEADINGSECTION: case RAW: case LIST: case BLOCKQUOTEMARKER: case BLOCKQUOTE: extract_abbreviations(list->children, scratch); break; default: /* Try to boost performance by skipping dead ends */ break; } list = list->next; } }
// 'chr // [...] // "..." // begin-end inline bool do_CopyNode() { if (!allocate(true)) return false; copy_node(); result->type = node->type; result->done = true; return true; }
tree pushdecl (tree decl) { if (global_bindings_p ()) DECL_CONTEXT (decl) = current_translation_unit; else { /* External objects aren't nested. For debug info insert a copy of the decl into the binding level. */ if (DECL_EXTERNAL (decl)) { tree orig = decl; decl = copy_node (decl); DECL_CONTEXT (orig) = NULL_TREE; } DECL_CONTEXT (decl) = current_function_decl; } /* Put the declaration on the list. */ DECL_CHAIN (decl) = current_binding_level->names; current_binding_level->names = decl; /* For the declaration of a type, set its name if it is not already set. */ if (TREE_CODE (decl) == TYPE_DECL && TYPE_NAME (TREE_TYPE (decl)) == 0) { if (DECL_SOURCE_LINE (decl) == 0) TYPE_NAME (TREE_TYPE (decl)) = decl; else TYPE_NAME (TREE_TYPE (decl)) = DECL_NAME (decl); } return decl; }
graph new_full_graph(node *tabNodes, int nbNodes){ graph newGraph = malloc(sizeof(int) + sizeof(node)*nbNodes); newGraph->nbNodes = nbNodes; for(int i=0; i<nbNodes; i++){ newGraph->nodes[i] = copy_node(tabNodes[i]); } return newGraph; }
/* extract_references -- go through node tree and find elements we need to reference; e.g. links, images, citations, footnotes Copy them from main parse tree */ void extract_references(node *list, scratch_pad *scratch) { node *temp; char * temp_str; link_data *l; while (list != NULL) { switch (list->key) { case LINKREFERENCE: l = list->link_data; temp_str = lower_string(l->label); temp = mk_link(list->children, temp_str, l->source, l->title, NULL); temp->link_data->attr = copy_node_tree(l->attr); /* store copy of link reference */ scratch->links = cons(temp, scratch->links); free(temp_str); break; case NOTESOURCE: case GLOSSARYSOURCE: temp = copy_node(list); scratch->notes = cons(temp, scratch->notes); break; case H1: case H2: case H3: case H4: case H5: case H6: if ((list->children->key != AUTOLABEL) && !(scratch->extensions & EXT_NO_LABELS) && !(scratch->extensions & EXT_COMPATIBILITY)) { char *label = label_from_node_tree(list->children); /* create a label from header */ temp = mk_autolink(label); scratch->links = cons(temp, scratch->links); free(label); } break; case TABLE: if (list->children->key != TABLELABEL) { char *label = label_from_node(list->children); /* create a label from header */ temp = mk_autolink(label); scratch->links = cons(temp, scratch->links); free(label); } break; case HEADINGSECTION: case RAW: case LIST: extract_references(list->children, scratch); break; default: break; } list = list->next; } }
list list_copy(const list p) { list ls = make_nil(); for (node *q = p; q != NULL; q = q->next) { node *pnew = copy_node(q); append_node(&ls, pnew); } return ls; }
void copy_node(node *f, node *t) { int i; t->n=f->n; if (t->n<=0) return; t->t=f->t; t->child=new node [t->n]; for (i=0;i<t->n;i++) copy_node(&f->child[i],&t->child[i]); }
Pix BaseDLList::ins_after(Pix p, const void *datum) { if (p == 0) return prepend(datum); BaseDLNode* u = (BaseDLNode*) p; BaseDLNode* t = copy_node(datum); t->bk = u; t->fd = u->fd; u->fd->bk = t; u->fd = t; return Pix(t); }
// Assumes children is empty void copy_children_from(const node_t& rhs) { child_iterator_range c_range(rhs.children.begin(), rhs.children.end()); for(child_iterator it = c_range.begin(); it != c_range.end(); ++it) { node_descriptor c = *it; children.push_back(copy_node(c)); static_cast< node_t* >(children.back())->parent = this; } }
Pix BaseDLList::ins_before(Pix p, const void *datum) { if (p == 0) error("null Pix"); BaseDLNode* u = (BaseDLNode*) p; BaseDLNode* t = copy_node(datum); t->bk = u->bk; t->fd = u; u->bk->fd = t; u->bk = t; if (u == h) h = t; return Pix(t); }
void hash_set(hash_table_t *table, node_t *key, node_t *value) { //*key is function name. *value is arguments of function. int bucket = 0; //value of func_hash /*entry に 関数名key と関数の引数リストvalueを代入。*/ hash_entry_t *entry = (hash_entry_t*) malloc (sizeof (hash_entry_t)); entry->key = (const char*) malloc (sizeof (strlen (key->car->character))+1); strcpy ((char*)entry->key, key->car->character); // 関数名を entry の key にコピーする。 entry->value = copy_node ( value ); // ( x y ) (+ x y)引数のリストをコピーする。 bucket = func_hash ( entry->key ); //table の bucket番目のentryに入れる。 table->entry[bucket] = entry; //stack. table->entry[bucket]->next = top[bucket]; top[bucket] = table->entry[bucket]; }
symtab_node * symtab_nonoverwritable_alias (symtab_node *node) { tree new_decl; symtab_node *new_node = NULL; /* First try to look up existing alias or base object (if that is already non-overwritable). */ node = symtab_alias_ultimate_target (node, NULL); gcc_assert (!node->alias && !node->weakref); symtab_for_node_and_aliases (node, symtab_nonoverwritable_alias_1, (void *)&new_node, true); if (new_node) return new_node; #ifndef ASM_OUTPUT_DEF /* If aliases aren't supported by the assembler, fail. */ return NULL; #endif /* Otherwise create a new one. */ new_decl = copy_node (node->decl); DECL_DLLIMPORT_P (new_decl) = 0; DECL_NAME (new_decl) = clone_function_name (node->decl, "localalias"); if (TREE_CODE (new_decl) == FUNCTION_DECL) DECL_STRUCT_FUNCTION (new_decl) = NULL; DECL_INITIAL (new_decl) = NULL; SET_DECL_ASSEMBLER_NAME (new_decl, DECL_NAME (new_decl)); SET_DECL_RTL (new_decl, NULL); /* Update the properties. */ DECL_EXTERNAL (new_decl) = 0; if (DECL_ONE_ONLY (node->decl)) DECL_SECTION_NAME (new_decl) = NULL; DECL_COMDAT_GROUP (new_decl) = 0; TREE_PUBLIC (new_decl) = 0; DECL_COMDAT (new_decl) = 0; DECL_WEAK (new_decl) = 0; DECL_VIRTUAL_P (new_decl) = 0; if (TREE_CODE (new_decl) == FUNCTION_DECL) { DECL_STATIC_CONSTRUCTOR (new_decl) = 0; DECL_STATIC_DESTRUCTOR (new_decl) = 0; new_node = cgraph_create_function_alias (new_decl, node->decl); } else new_node = varpool_create_variable_alias (new_decl, node->decl); symtab_resolve_alias (new_node, node); gcc_assert (decl_binds_to_current_def_p (new_decl)); return new_node; }
void CJournal::add_signal ( const SignalArgs & signal_node ) { rapidxml::xml_attribute<> * type_attr = signal_node.node.content->first_attribute("type"); if( m_options["RecordReplies"].value<bool>() || (type_attr != nullptr && std::strcmp(type_attr->value(), "signal") == 0) ) { XmlNode copy = copy_node(signal_node.node, m_signals_map.content); boost::posix_time::ptime now = boost::posix_time::second_clock::local_time(); copy.set_attribute("time", boost::posix_time::to_simple_string(now)); } }
void BaseDLList::copy(const BaseDLList& a) { if (a.h == 0) h = 0; else { BaseDLNode* p = a.h; BaseDLNode* t = copy_node(p->item()); if(t==0) DBG(); h = t; p = p->fd; while (p != a.h) { BaseDLNode* n = copy_node(p->item()); if(n==0) DBG(); t->fd = n; n->bk = t; t = n; p = p->fd; } t->fd = h; h->bk = t; return; } }
Pix BaseDLList::append(const void *datum) { BaseDLNode* t = copy_node(datum); if(t==0) DBG(); if (h == 0) t->fd = t->bk = h = t; else { t->bk = h->bk; t->bk->fd = t; t->fd = h; h->bk = t; } return Pix(t); }
static btsort_pyobject * copy_tree(btsort_pyobject *tree) { btsort_pyobject *result = PyObject_GC_New( btsort_pyobject, &btsort_pytypeobj); PyObject_GC_Track(result); result->order = tree->order; result->depth = tree->depth; result->flags = 0; result->root = copy_node(tree->root, 0, tree->depth, tree->order); result->flags = BT_FLAG_INITED; return result; }
static void reheap_up( pj_timer_heap_t *ht, pj_timer_entry *moved_node, size_t slot, size_t parent) { // Restore the heap property after an insertion. while (slot > 0) { // If the parent node is greater than the <moved_node> we need // to copy it down. if (PJ_TIME_VAL_LT(moved_node->_timer_value, ht->heap[parent]->_timer_value)) { copy_node(ht, slot, ht->heap[parent]); slot = parent; parent = HEAP_PARENT(slot); } else break; } // Insert the new node into its proper resting place in the heap and // update the corresponding slot in the parallel <timer_ids> array. copy_node(ht, slot, moved_node); }
typename QuadTree<DATA>::Tree_Node * QuadTree<DATA>::node_deep_copy(Tree_Node * oldNode) { if (oldNode ==NULL) { return NULL; } Tree_Node * subroot=copy_node(oldNode); ((*subroot).North)=node_deep_copy((*subroot).North); ((*subroot).South)=node_deep_copy((*subroot).South); ((*subroot).East)=node_deep_copy((*subroot).East); ((*subroot).West) =node_deep_copy((*subroot).West); }
OlyStatus push_node(OlyNode **stack, OlyNode *node ) { OlyStatus status = OLY_OKAY; OlyNode *stack_copy; status = new_oly_node( &stack_copy ); HANDLE_STATUS_AND_RETURN(status); if ((*stack) != NULL) { node->parent_node = (*stack); } status = copy_node( node, stack_copy ); HANDLE_STATUS_AND_RETURN(status); (*stack) = stack_copy; return status; }
int cman_get_nodes(cman_handle_t handle, int maxnodes, int *retnodes, cman_node_t *nodes) { struct cman_handle *h = (struct cman_handle *)handle; struct cl_cluster_node *cman_nodes; int status; int buflen; int count = 0; VALIDATE_HANDLE(h); if (!retnodes || !nodes || maxnodes < 1) { errno = EINVAL; return -1; } buflen = sizeof(struct cl_cluster_node) * maxnodes; cman_nodes = malloc(buflen); if (!cman_nodes) return -1; status = info_call(h, CMAN_CMD_GETALLMEMBERS, NULL, 0, cman_nodes, buflen); if (status < 0) { int saved_errno = errno; free(cman_nodes); errno = saved_errno; return -1; } if (cman_nodes[0].size != sizeof(struct cl_cluster_node)) { free(cman_nodes); errno = EINVAL; return -1; } if (status > maxnodes) status = maxnodes; for (count = 0; count < status; count++) { copy_node(&nodes[count], &cman_nodes[count]); } free(cman_nodes); *retnodes = status; return 0; }
/* * Return a type like TYPE except that its TREE_READONLY * is CONSTP and its TREE_VOLATILE is VOLATILEP. * * Such variant types already made are recorded so that * duplicates are not made. * * A variant types should never be used as the type of * an expression. Always copy the variant information into * the TREE_READONLY and TREE_VOLATILE of the expression, * and then give the expression as its type the * "main variant", the variant whose TREE_READONLY * and TREE_VOLATILE are zero. Use TYPE_MAIN_VARIANT * to find the main variant. */ tree build_type_variant (tree type, int constp, int volatilep) { register tree t, m = TYPE_MAIN_VARIANT (type); register OBSTACK *ambient_obstack = current_obstack; /* * Treat any nonzero argument as 1. */ constp = !!constp; volatilep = !!volatilep; /* * First search the chain variants for one * that is what we want. */ for (t = m; t; t = TYPE_NEXT_VARIANT (t)) { if (constp == TREE_READONLY (t) && volatilep == TREE_VOLATILE (t)) return t; } /* * We need a new one. */ current_obstack = TREE_PERMANENT (type) ? &permanent_obstack : saveable_obstack; t = copy_node (type); TREE_READONLY (t) = constp; TREE_VOLATILE (t) = volatilep; TYPE_POINTER_TO (t) = NULL_TREE; TYPE_REFERENCE_TO (t) = NULL_TREE; /* * Add this type to the chain of variants of TYPE. */ TYPE_NEXT_VARIANT (t) = TYPE_NEXT_VARIANT (m); TYPE_NEXT_VARIANT (m) = t; current_obstack = ambient_obstack; return (t); } /* end build_type_variant */
/* * shallow copy of a sorted_btree object */ static bt_node_t * copy_node(bt_node_t *node, int depth, int leaf_depth, int order) { int i; bt_node_t *result = allocate_node(depth < leaf_depth, order); for (i = 0; i < node->filled; ++i) { result->values[i] = node->values[i]; Py_INCREF(node->values[i]); } result->filled = node->filled; if (depth < leaf_depth) for (i = 0; i <= node->filled; ++i) { ((bt_branch_t *)result)->children[i] = copy_node( ((bt_branch_t *)node)->children[i], depth + 1, leaf_depth, order); } return result; }