static void bibl_duplicateparams( param *np, param *op ) { list_init( &(np->asis) ); list_init( &(np->corps) ); list_copy( &(np->asis), &(op->asis ) ); list_copy( &(np->corps), &(op->corps ) ); if ( !op->progname ) np->progname = NULL; else np->progname = strdup( op->progname ); np->readformat = op->readformat; np->writeformat = op->writeformat; np->charsetin = op->charsetin; np->charsetin_src = op->charsetin_src; np->utf8in = op->utf8in; np->latexin = op->latexin; np->xmlin = op->xmlin; np->charsetout = op->charsetout; np->charsetout_src = op->charsetout_src; np->utf8out = op->utf8out; np->utf8bom = op->utf8bom; np->latexout = op->latexout; np->xmlout = op->xmlout; np->verbose = op->verbose; np->format_opts = op->format_opts; np->addcount = op->addcount; np->output_raw = op->output_raw; np->singlerefperfile = op->singlerefperfile; }
CMD * cmd_new( RULE * rule, LIST * targets, LIST * sources, LIST * shell ) { CMD * cmd = (CMD *)BJAM_MALLOC( sizeof( CMD ) ); FRAME frame[ 1 ]; assert( cmd ); cmd->rule = rule; cmd->shell = shell; cmd->next = 0; cmd->noop = 0; lol_init( &cmd->args ); lol_add( &cmd->args, targets ); lol_add( &cmd->args, sources ); string_new( cmd->buf ); frame_init( frame ); frame->module = rule->module; lol_init( frame->args ); lol_add( frame->args, list_copy( targets ) ); lol_add( frame->args, list_copy( sources ) ); function_run_actions( rule->actions->command, frame, stack_global(), cmd->buf ); frame_free( frame ); return cmd; }
LIST *property_set_create( PARSE *parse, FRAME *frame ) { LIST* properties = lol_get( frame->args, 0 ); LIST* sorted = 0; LIST* order_sensitive = 0; LIST* unique; LIST* tmp; LIST* val; string var[1]; #if 0 /* Sort all properties which are not order sensitive */ for(tmp = properties; tmp; tmp = tmp->next) { LIST* g = get_grist(tmp->string); LIST* att = call_rule("feature.attributes", frame, g, 0); if (list_in(att, "order-sensitive")) { order_sensitive = list_new( order_sensitive, tmp->string); } else { sorted = list_new( sorted, tmp->string); } list_free(att); } sorted = list_sort(sorted); sorted = list_append(sorted, order_sensitive); unique = list_unique(sorted); #endif sorted = list_sort(properties); unique = list_unique(sorted); string_new(var); string_append(var, ".ps."); for(tmp = unique; tmp; tmp = tmp->next) { string_append(var, tmp->string); string_push_back(var, '-'); } val = var_get(var->value); if (val == 0) { val = call_rule("new", frame, list_append(list_new(0, "property-set"), unique), 0); var_set(newstr(var->value), list_copy(0, val), VAR_SET); } else { val = list_copy(0, val); } string_free(var); /* The 'unique' variable is freed in 'call_rule'. */ list_free(sorted); return val; }
foreach(joinCell, joinList) { JoinExpr *joinExpr = (JoinExpr *) lfirst(joinCell); List *onClauseList = list_copy((List *) joinExpr->quals); List *joinClauseList = list_copy((List *) joinExpr->quals); JoinType joinType = joinExpr->jointype; RangeTblRef *nextRangeTableRef = NULL; TableEntry *nextTable = NULL; JoinOrderNode *nextJoinNode = NULL; Node *rightArg = joinExpr->rarg; /* get the table on the right hand side of the join */ if (IsA(rightArg, RangeTblRef)) { nextRangeTableRef = (RangeTblRef *) rightArg; } else { ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot perform distributed planning on this query"), errdetail("Subqueries in outer joins are not supported"))); } nextTable = FindTableEntry(tableEntryList, nextRangeTableRef->rtindex); if (joinType == JOIN_INNER) { /* also consider WHERE clauses for INNER joins */ joinClauseList = list_concat(joinClauseList, joinWhereClauseList); } /* find the best join rule type */ nextJoinNode = EvaluateJoinRules(joinedTableList, currentJoinNode, nextTable, joinClauseList, joinType); if (nextJoinNode->joinRuleType >= SINGLE_HASH_PARTITION_JOIN) { /* re-partitioning for OUTER joins is not implemented */ ereport(ERROR, (errcode(ERRCODE_FEATURE_NOT_SUPPORTED), errmsg("cannot run outer join query if join is not on the " "partition column"), errdetail("Outer joins requiring repartitioning are not " "supported."))); } if (joinType != JOIN_INNER) { /* preserve non-join clauses for OUTER joins */ nextJoinNode->joinClauseList = onClauseList; } /* add next node to the join order */ joinOrderList = lappend(joinOrderList, nextJoinNode); joinedTableList = lappend(joinedTableList, nextTable); currentJoinNode = nextJoinNode; }
int main() { struct element * moja_lista; struct element * moja_lista2; moja_lista = list_init(); moja_lista = list_push(moja_lista, 3.0); moja_lista = list_push(moja_lista, 1.0); moja_lista = list_push(moja_lista, 5.0); moja_lista = list_push(moja_lista, 3.0); moja_lista = list_push(moja_lista, 7.0); moja_lista = list_push(moja_lista, 2.0); moja_lista = list_push(moja_lista, 9.0); moja_lista = list_push(moja_lista, 6.0); moja_lista2 = list_copy(moja_lista); // Zamiast "wyświetl listę" można użyć "status" - jest to funkcja, która wyświetla listę // w sposób bardziej przystępny do debugowania programu (lub do sprawdzania jak działa) printf("DANIE NIEPOSORTOWANE:\n"); wyswietl_liste(moja_lista); printf("SORTOWANIE QUICK_SORT:\n"); quick_sort(&moja_lista); wyswietl_liste(moja_lista); printf("SORTOWANIE INSERTION_SORT:\n"); insertion_sort(&moja_lista); wyswietl_liste(moja_lista); return 0; }
struct list* inotify_map_get_path(int wd) { struct list *list = wd_lookup(wd); if (list) return list_copy(list); return NULL; }
/* * Find the ObjectAddress for an attribute. */ static ObjectAddress get_object_address_attribute(ObjectType objtype, List *objname, Relation *relp, LOCKMODE lockmode) { ObjectAddress address; List *relname; Oid reloid; Relation relation; const char *attname; /* Extract relation name and open relation. */ attname = strVal(lfirst(list_tail(objname))); relname = list_truncate(list_copy(objname), list_length(objname) - 1); relation = relation_openrv(makeRangeVarFromNameList(relname), lockmode); reloid = RelationGetRelid(relation); /* Look up attribute and construct return value. */ address.classId = RelationRelationId; address.objectId = reloid; address.objectSubId = get_attnum(reloid, attname); if (address.objectSubId == InvalidAttrNumber) ereport(ERROR, (errcode(ERRCODE_UNDEFINED_COLUMN), errmsg("column \"%s\" of relation \"%s\" does not exist", attname, RelationGetRelationName(relation)))); *relp = relation; return address; }
/** * make full copy of image 'in' */ IMAGE *copyFITS(IMAGE *in){ IMAGE *out = similarFITS(in, in->dtype); memcpy(out->data, in->data, sizeof(Item)*in->width*in->height); out->keylist = list_copy(in->keylist); out->tables = table_copy(in->tables); return out; }
static inline void* eval(const unsigned char value, tuple_t tuple, const unsigned char **pc, Register *reg) { if (VAL_IS_HOST(value)) { return (void*)EVAL_HOST; } else if (VAL_IS_REG(value)) { return (void*)&(reg[VAL_REG(value)]); } else if (VAL_IS_TUPLE(value)) { return (void*)tuple; } else if (VAL_IS_FIELD(value)) { const unsigned char reg_index = VAL_FIELD_REG(*pc); const unsigned char field_num = VAL_FIELD_NUM(*pc); tuple_t tuple = (tuple_t)MELD_CONVERT_REG_TO_PTR(reg[reg_index]); (*pc) += 2; #ifdef DEBUG_INSTRS printf ("tuple = "); tuple_print(tuple, stdout); printf ("\n"); printf ("tuple[%d] = %lx\n", field_num, MELD_INT(GET_TUPLE_FIELD(tuple, field_num))); #endif return GET_TUPLE_FIELD(tuple, field_num); } else if (VAL_IS_INT(value)) { void *ret = (void *)(*pc); *pc = *pc + sizeof(meld_int); return ret; } else if (VAL_IS_FLOAT(value)) { void *ret = (void *)(*pc); *pc = *pc + sizeof(meld_float); return ret; } else if (VAL_IS_REVERSE(value)) { const int reg_index = VAL_FIELD_REG(*pc); const int field_num = VAL_FIELD_NUM(*pc); tuple_t tuple = (tuple_t)MELD_CONVERT_REG_TO_PTR(reg[reg_index]); (*pc) += 2; #ifdef PARALLEL_MACHINE List *route = MELD_LIST(GET_TUPLE_FIELD(tuple, field_num)); List *clone = list_copy(route); list_reverse_first(clone); thread_self()->reverse_list = clone; return (void *)&thread_self()->reverse_list; #else return GET_TUPLE_FIELD(tuple, field_num); #endif /* PARALLEL_MACHINE */ } else { assert(0 /* invalid value */ ); } assert(0); return NULL; }
/*------------------------------- random ----------------------------------*/ struct c_route_entry * c_rnd_lookup(const rimeaddr_t *dest, struct pipe* p) { LIST(temp_list); list_init(temp_list); struct c_route_entry *e; int num; list_copy(temp_list, p->route_table); for(e = list_head(temp_list); e != NULL; e = list_item_next(e)) { if(!rimeaddr_cmp(dest, &e->dest)) { list_remove(temp_list, e); } } /* Find a random route to destination. */ if (list_length(temp_list) > 0) { num = random_rand() % list_length(temp_list); printf("%d\n", num); int i = 0; for(e = list_head(temp_list); e != NULL && i != num; e = list_item_next(e)) { ++i; } if(e != NULL) { PRINTF("%d.%d: Forwarding packet to %d.%d (%d in list)\n", rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1], e->nexthop.u8[0], e->nexthop.u8[1], num); return e; } PRINTF("%d.%d: did not find a neighbor to foward to\n", rimeaddr_node_addr.u8[0], rimeaddr_node_addr.u8[1]); return NULL; } return e; }
/* * Find the struct objaddr for an attribute. */ static struct objaddr get_objaddr_attr( objtype_e objtype, struct list* objname, struct relation** relp, lockmode_t lockmode) { struct objaddr address; struct list* relname; oid_t reloid; struct relation* relation; const char *attname; /* Extract relation name and open relation. */ attname = str_value(lfirst(list_tail(objname))); relname = list_truncate(list_copy(objname), list_length(objname) - 1); relation = relation_openrv(nl_to_range_var(relname), lockmode); reloid = REL_ID(relation); /* Look up attribute and construct return value. */ address.classId = RelationRelationId; address.objectId = reloid; address.objectSubId = get_attnum(reloid, attname); if (address.objectSubId == INVALID_ATTR_NR) { ereport(ERROR, ( errcode(E_UNDEFINED_COLUMN), errmsg("column \"%s\" of relation \"%s\" does not exist", attname, REL_NAME(relation)))); } *relp = relation; return address; }
/* Look up the __TIMING_RULE__ variable on the given target, and if * non-empty, invoke the rule it names, passing the given * timing_info */ static void call_timing_rule(TARGET* target, timing_info* time) { LIST* timing_rule; pushsettings(target->settings); timing_rule = var_get( "__TIMING_RULE__" ); popsettings(target->settings); if (timing_rule) { /* We'll prepend $(__TIMING_RULE__[2-]) to the first argument */ LIST* initial_args = list_copy( L0, timing_rule->next ); /* Prepare the argument list */ FRAME frame[1]; frame_init( frame ); /* First argument is the name of the timed target */ lol_add( frame->args, list_new( initial_args, target->name ) ); append_double_string(frame->args, time->user); append_double_string(frame->args, time->system); if( lol_get( frame->args, 2 ) ) evaluate_rule( timing_rule->string, frame ); /* Clean up */ frame_free( frame ); } }
LIST * compile_set( PARSE *parse, LOL *args, int *jmp ) { LIST *nt = (*parse->left->func)( parse->left, args, jmp ); LIST *ns = (*parse->right->func)( parse->right, args, jmp ); LISTITEM *l; if( DEBUG_COMPILE ) { debug_compile( 0, "set" ); list_print( nt ); printf( " %s ", set_names[ parse->num ] ); list_print( ns ); printf( "\n" ); } /* Call var_set to set variable */ /* var_set keeps ns, so need to copy it */ for( l = list_first(nt); l; l = list_next( l ) ) var_set( list_value(l), list_copy( L0, ns ), parse->num ); list_free( nt ); return ns; }
BigInteger::BigInteger(const BigInteger& source) //copy constructor {head_ptr = NULL; node *tail_ptr = NULL; list_copy(source.head_ptr, head_ptr, tail_ptr); many_nodes = source.many_nodes; strnumber = source.strnumber; }
/* Use quite klugy approach: when we add order dependency from 'a' to 'b', just append 'b' to of value of variable 'a'. */ LIST *add_pair( FRAME *frame, int flags ) { LIST* arg = lol_get( frame->args, 0 ); var_set(arg->value, list_copy(0, arg->next), VAR_APPEND); return L0; }
/* Use quite klugy approach: when we add order dependency from 'a' to 'b', just append 'b' to of value of variable 'a'. */ LIST *add_pair( PARSE *parse, FRAME *frame ) { LIST* arg = lol_get( frame->args, 0 ); var_set(arg->string, list_copy(0, arg->next), VAR_APPEND); return L0; }
dict_t dict_copy(dict_t dict) { dict_t dict_copy = calloc(1, sizeof(struct _dict_t)); assert(dict_copy != NULL); dict_copy->length = dict->length; dict_copy->list = list_copy(dict->list); assert(dict_copy != NULL && dict_is_equal(dict_copy, dict)); return (dict_copy); }
smatrix::smatrix(const smatrix & source) { nrows = source.nrows; ncols = source.ncols; node * tail_ptr; list_copy(source.head_ptr, head_ptr, tail_ptr); }
SETTINGS * copysettings( SETTINGS * head ) { SETTINGS * copy = 0; SETTINGS * v; for ( v = head; v; v = v->next ) copy = addsettings( copy, VAR_SET, v->symbol, list_copy( 0, v->value ) ); return copy; }
static void test_list(void) { List *list = make_list(); assert_int(0, list_len(list)); list_push(list, (void *)1); assert_int(1, list_len(list)); list_push(list, (void *)2); assert_int(2, list_len(list)); Iter *iter = list_iter(list); assert_int(1, (long)iter_next(iter)); assert_int(false, iter_end(iter)); assert_int(2, (long)iter_next(iter)); assert_int(true, iter_end(iter)); assert_int(0, (long)iter_next(iter)); assert_int(true, iter_end(iter)); List *copy = list_copy(list); assert_int(2, list_len(copy)); assert_int(1, (long)list_get(copy, 0)); assert_int(2, (long)list_get(copy, 1)); List *rev = list_reverse(list); iter = list_iter(rev); assert_int(2, (long)iter_next(iter)); assert_int(1, (long)iter_next(iter)); assert_int(0, (long)iter_next(iter)); assert_int(2, list_len(rev)); assert_int(1, (long)list_pop(rev)); assert_int(1, list_len(rev)); assert_int(2, (long)list_pop(rev)); assert_int(0, list_len(rev)); assert_int(0, (long)list_pop(rev)); List *list2 = make_list(); list_push(list2, (void *)5); list_push(list2, (void *)6); assert_int(5, (long)list_shift(list2)); assert_int(6, (long)list_shift(list2)); assert_int(0, (long)list_shift(list2)); List *list3 = make_list(); assert_int(0, (long)list_head(list3)); assert_int(0, (long)list_tail(list3)); list_push(list3, (void *)1); assert_int(1, (long)list_head(list3)); assert_int(1, (long)list_tail(list3)); list_push(list3, (void *)2); assert_int(1, (long)list_head(list3)); assert_int(2, (long)list_tail(list3)); List *list4 = make_list(); list_push(list4, (void *)1); list_push(list4, (void *)2); assert_int(1, (long)list_get(list4, 0)); assert_int(2, (long)list_get(list4, 1)); assert_int(0, (long)list_get(list4, 2)); }
/* *********************************************** */ int set_header( call_t *c , packet_t * packet , destination_t * dst ) { struct nodedata *nodedata = get_node_private_data(c); struct protocoleData *entitydata =get_entity_private_data(c); packet_PROTOCOLE *data = (packet_PROTOCOLE *) (packet->data + nodedata->overhead); //augmenter le nbr d'evenement nodedata->nbr_evenement++; if(entitydata->debug) DBG("RBOP - %d SET HEADER \n",c->node); //Fixé le rayon if(nodedata->range<0) { listeNodes *tmp=nodedata->oneHopNeighbourhood; position_t pos1 = *get_node_position(c->node); double distMax = 0; while(tmp) { if(list_recherche(nodedata->RNG,tmp->values.node)) { position_t pos2= {tmp->values.x,tmp->values.y,tmp->values.z}; double dist=distance(&pos1,&pos2); if(distMax<dist) distMax=dist; } tmp=tmp->suiv; } set_range_Tr(c,distMax); nodedata->range=get_range_Tr(c); if(entitydata->debug) DBG("RBOP - %d FIXE RANGE TO %.2lf \n",c->node,get_range_Tr(c)); } //remplissage de data data->type=RBOP; data->src=c->node; data->src_pos=*get_node_position(c->node); data->seq=nodedata->nbr_evenement; data->redirected_by=c->node; data->destinations=Nullptr(list); list_copy(&data->destinations,nodedata->RNG); list_PACKET_insert_tout(&nodedata->paquets,data->src,data->seq,data->redirected_by); call_t c0 = {get_entity_bindings_down(c)->elts[0], c->node, c->entity}; destination_t destination = {BROADCAST_ADDR, {-1, -1, -1}}; return SET_HEADER(&c0, packet, &destination); }
void bag::operator +=(const bag& addend) { node *copy_head_ptr; node *copy_tail_ptr; if (addend.many_nodes > 0) { list_copy(addend.head_ptr, copy_head_ptr, copy_tail_ptr); copy_tail_ptr->set_link(head_ptr); head_ptr = copy_head_ptr; many_nodes += addend.many_nodes; } }
void bag::operator =(const bag& source) { node *tail_ptr; if (this == &source) { return; } list_clear(head_ptr); many_nodes = 0; list_copy(source.head_ptr, head_ptr, tail_ptr); many_nodes = source.many_nodes; }
LIST *builtin_listsort( PARSE *parse, LOL *args, int *jmp ) { LIST *l = list_copy( L0, lol_get( args, 0 ) ); LIST *caseSensitiveList = lol_get( args, 1 ); int caseSensitive = 1; if ( caseSensitiveList ) caseSensitive = atoi( caseSensitiveList->string ); l = list_sort( l, caseSensitive ); return l; }
static LakeVal *eval_special_form(LakeCtx *ctx, Env *env, LakeList *expr) { LakeSym *name = SYM(LIST_VAL(expr, 0)); special_form_handler handler = get_special_form_handler(ctx, name); if (handler) { return handler(ctx, env, list_copy(expr)); } ERR("unrecognized special form: %s", sym_repr(name)); return NULL; }
List* list_new_list(const List* list) { ListData data; assert(list_is_valid(list)); data.list = list_copy(list); return list_new(LIST_LIST, &data); }
void bag::operator -=(const bag& subend) { node *copy_head_ptr; node *copy_tail_ptr; if (subend.many_nodes > 0) { list_copy(subend.head_ptr, copy_head_ptr, copy_tail_ptr); size_type a = subend.many_nodes; for (node *cursor = copy_head_ptr; cursor != NULL; cursor = cursor->link()) { erase_one(cursor->data()); } } }
void smatrix::operator = (const smatrix & source) { if (this == &source) return; list_clear(head_ptr); nrows = source.nrows; ncols = source.ncols; node *tail_ptr; list_copy(source.head_ptr, head_ptr, tail_ptr); }
void list_add_list(List* list, const List* ll) { ListData data; assert(list_is_valid(list)); assert(list_is_valid(ll)); assert(list->type == LIST_LIST); data.list = list_copy(ll); list_add_data(list, &data); }
/* * twitterBegin * Query search API and setup result */ static void twitterBegin(ForeignScanState *node, int eflags) { CURL *curl; int ret; json_parser parser; json_parser_dom helper; ResultRoot *root; Relation rel; AttInMetadata *attinmeta; TwitterReply *reply; StringInfoData url; char *param_q = NULL; /* * Do nothing in EXPLAIN */ if (eflags & EXEC_FLAG_EXPLAIN_ONLY) return; initStringInfo(&url); appendStringInfoString(&url, "http://search.twitter.com/search.json"); if (node->ss.ps.plan->qual) { bool param_first = true; ListCell *lc; List *quals = list_copy(node->ss.ps.qual); foreach (lc, quals) { ExprState *state = lfirst(lc); char *param = twitter_param((Node *) state->expr, node->ss.ss_currentRelation->rd_att); if (param) { if (param_first) appendStringInfoChar(&url, '?'); else appendStringInfoChar(&url, '&'); appendStringInfoString(&url, param); if (param[0] == 'q' && param[1] == '=') param_q = ¶m[2]; /* take it from original qual */ node->ss.ps.qual = list_delete(node->ss.ps.qual, (void *) state); } // else // elog(ERROR, "Unknown qual"); }