void dij_note_rvalue( int later ) { /*variable number later is being used as an rvalue in this context, is this the first use? ie is this a parameter? if so make sure it has a slot. otherwise, we now know that it is not a return value, so move it out of that group.*/ if ( ! ( array_contains(write_code->parameters, write_code->num_parameters, later ) || array_contains(write_code->locals, write_code->num_locals, later ) ) ) { if( array_contains(write_code->returns, write_code->num_returns, later ) ) { write_code->returns = array_remove(write_code->returns, write_code->num_returns, later); write_code->locals = array_add(write_code->locals, write_code->num_locals, later); write_code->num_returns--; write_code->num_locals++; } else { write_code->parameters = array_add(write_code->parameters, write_code->num_parameters, later); write_code->num_parameters++; } } }
void dij_note_lvalue( int later ) { /*variable number later is being used as an lvalue in this context, is this the first use? ie is this possibly a return value? if so make sure it has a slot.*/ if ( ! ( array_contains ( write_code->parameters, write_code->num_parameters, later ) || array_contains ( write_code->locals, write_code->num_locals, later ) || array_contains ( write_code->returns, write_code->num_returns, later ) ) ) { write_code->returns = array_add(write_code->returns, write_code->num_returns, later); write_code->num_returns++; } }
/*** init_array: 배열변수를 초기화합니다. ***/ void init_array() { int i; time_t current_stamp = time(NULL); // 현재시간 // 랜덤머신 초기화 srand((unsigned int)current_stamp); if (selected_array_g == 1) for (i = 0; i < SIZE_OF_ARRAY; i++) array_direct[i] = i + 1; if (selected_array_g == 2) for (i = 0; i < SIZE_OF_ARRAY; i++) array_reverse[i] = SIZE_OF_ARRAY - i; if (selected_array_g == 3) for (i = 0; i < SIZE_OF_ARRAY; i++) { while (TRUE) { int rand_insidescope = rand() % (SIZE_OF_ARRAY + 1); if (not array_contains(array_random, rand_insidescope, i)) { array_random[i] = rand_insidescope; break; } } } if (selected_array_g == 4) for (i = 0; i < SIZE_OF_ARRAY; i++) array_overlap[i] = rand() % RAND_SECTION + RAND_MIN; }
gint tsplotPlottedColsGet(displayd *display, gint *cols, GGobiStage *d, GGobiSession *gg) { GList *l; splotd *s; gint ncols = 0; for (l=display->splots; l; l=l->next) { s = (splotd *) l->data; if (!array_contains (cols, ncols, s->xyvars.y)) cols[ncols++] = s->xyvars.y; } return(ncols); }
/** * Implementation of MUIM_DragDrop * * @param cl the class * @param obj the object * @param msg the parameter of the method * @return */ STATIC ULONG AddressGroupList_DragDrop(struct IClass *cl,Object *obj,struct MUIP_DragDrop *msg) { LONG pos; struct addressbook_entry_new *entry; struct addressbook_group *group; int need_refresh = 0; Object *address_list; if (!(address_list = msg->obj)) return 0; DoMethod(obj, MUIM_NList_GetEntry, xget(obj, MUIA_NList_DropMark), (ULONG)&group); if (!group) return 0; pos = MUIV_NList_NextSelected_Start; while (1) { DoMethod(address_list, MUIM_NList_NextSelected, (ULONG)&pos); if (pos == MUIV_NList_NextSelected_End) break; DoMethod(address_list, MUIM_NList_GetEntry, pos, (ULONG)&entry); if (entry && !array_contains(entry->group_array,group->name)) { char **newarray = array_add_string(entry->group_array,group->name); if (newarray) { entry->group_array = newarray; need_refresh = 1; } } } if (need_refresh) { DoMethod(address_list, MUIM_NList_Redraw, MUIV_NList_Redraw_All); /* TODO: Do this via a notify */ addressbook_clear(); addressbookwnd_store(); } return 1; }
/* Go through each unique source of the packets waiting on arp_req and send a ICMP host unreachable message. */ void notify_sources_badreq(struct sr_instance *sr, struct sr_arpreq *arp_req){ /*For each packet waiting on arp_req, determine unique sources and send them a ICMP. Have to read packet to find source*/ /*Go through each packet and for each unique source, send TCMP to say host unreachable*/ struct sr_packet *packet = arp_req->packets; Array sources; initArray(&a, 1); while (packet){ uint8_t source[ETHER_ADDR_LEN] = get_ether_source(packet); /*Check to make sure we haven't sent to this source yet*/ if (!array_contains(sources, source)){ send_host_runreachable(source, packet->buf); insertArray(&sources, source); } free(&source); packet = packet->next; } freeArray(&sources); }