static void copy_normalized_theory(Real *target) { int k, nQ; nQ = 0; for (k=0; k < MODELS; k++) { if (fit[k].datatype == FIT_POLARIZED) { copy_matching(fit[k].nQ,fit[k].fitQ,fit[k].fitA, fit[k].dataA.n,fit[k].dataA.Q,fit[k].dataA.dR, target+nQ); nQ += fit[k].dataA.n; copy_matching(fit[k].nQ,fit[k].fitQ,fit[k].fitB, fit[k].dataB.n,fit[k].dataB.Q,fit[k].dataB.dR, target+nQ); nQ += fit[k].dataB.n; copy_matching(fit[k].nQ,fit[k].fitQ,fit[k].fitC, fit[k].dataC.n,fit[k].dataC.Q,fit[k].dataC.dR, target+nQ); nQ += fit[k].dataC.n; copy_matching(fit[k].nQ,fit[k].fitQ,fit[k].fitD, fit[k].dataD.n,fit[k].dataD.Q,fit[k].dataD.dR, target+nQ); nQ += fit[k].dataD.n; } else { copy_all(fit[k].dataA.n,fit[k].fitA,fit[k].dataA.dR,target+nQ); nQ += fit[k].dataA.n; } } }
/** * The only process we are really guaranteed to have is this test process itself. * This test uses same one used in Process_Closer */ TEST( Process_List_Test, find_our_process_CI_generic ) { std::vector< PROCESSENTRY32W > v ; initialize_process_list( v, process_by_name_CI( mixedcase_exe_name ), copy_all() ) ; size_t size( v.size() ); EXPECT_EQ( 1u, size ); // Please, don't run multiple test executables simultaneously ASSERT_GE( 1u, size ); }
static void copy_normalized_data(Real *target) { int k, nQ; nQ = 0; for (k=0; k < MODELS; k++) { if (fit[k].datatype == FIT_POLARIZED) { copy_all(fit[k].dataA.n,fit[k].dataA.R,fit[k].dataA.dR,target+nQ); nQ += fit[k].dataA.n; copy_all(fit[k].dataB.n,fit[k].dataB.R,fit[k].dataB.dR,target+nQ); nQ += fit[k].dataB.n; copy_all(fit[k].dataC.n,fit[k].dataC.R,fit[k].dataC.dR,target+nQ); nQ += fit[k].dataC.n; copy_all(fit[k].dataD.n,fit[k].dataD.R,fit[k].dataD.dR,target+nQ); nQ += fit[k].dataD.n; } else { copy_all(fit[k].dataA.n,fit[k].dataA.R,fit[k].dataA.dR,target+nQ); nQ += fit[k].dataA.n; } } }
//copy constructor creates DLL and the dynamically allocated arrays of cards //input: Instance of the class Deck //ouput: copies all the data Deck::Deck(const Deck & deck_) { head = new node*[4]; //creates 4 DLLs //copies the data by calling copy_all function for(int i = 0; i < 4; ++i) { copy_all(head[i], deck_.head[i]); } //creates 52 instances of cards and copy all data card_ = new Card[52]; for(int i = 0; i < 52; ++i) { card_[i].set_num(deck_.card_[i].get_num()); card_[i].set_suit(deck_.card_[i].get_suit()); } }
static int msg_read(msg_t *m, void *buf, int len) { int r; switch (m->mode) { case M_FILL: if (m->filled + len > m->len) return -ENOENT; memcpy(buf, m->buf + m->filled, len); m->filled += len; return 0; case M_FD: r = copy_all(m->fd, read, buf, len); if (r < 0) return r; m->filled += len; return 0; case M_FAKE: m->filled += len; return 0; } return -EINVAL; }
static int msg_write(msg_t *m, void *buf, int len) { int r; switch (m->mode) { case M_FILL: if (m->filled + len > m->len) return -ENOENT; memcpy(m->buf + m->filled, buf, len); m->filled += len; return 0; case M_FD: r = copy_all(m->fd, (ssize_t (*)(int, void *, size_t))write, buf, len); if (r < 0) return r; m->filled += len; return 0; case M_FAKE: m->filled += len; return 0; } return -EINVAL; }
void redis_reshard::run() { if (get_masters_info() == false) return; show_nodes(); fflush(stdout); char buf[1024]; int nslots = 0; while (true) { printf("How many slots do you want to move (from 1 to 16384) ? "); fflush(stdout); int ret = acl_vstream_gets_nonl(ACL_VSTREAM_IN, buf, sizeof(buf)); if (ret == ACL_VSTREAM_EOF) exit(1); acl_mystr_trim(buf); nslots = atoi(buf); if (nslots > 0 && nslots < 16384) break; printf("invalid value: %d\r\n", ret); } acl::redis_node* target = NULL; while (true) { printf("What is the receiving node ID? "); fflush(stdout); int ret = acl_vstream_gets_nonl(ACL_VSTREAM_IN, buf, sizeof(buf)); if (ret == ACL_VSTREAM_EOF) exit(1); acl_mystr_trim(buf); target = find_node(buf); if (target != NULL) break; printf("...The specified node(%s) is not known or not " "a master, please try again.\r\n", buf); } assert(target != NULL); printf("Please input all the source node IDs.\r\n"); printf(" Type 'all' to use all the nodes as source nodes for the hash slots\r\n"); printf(" Type 'done' once you entered all the source node IDs.\r\n"); std::vector<acl::redis_node*> sources; while (true) { printf("Source node #%d: ", (int) sources.size() + 1); fflush(stdout); int ret = acl_vstream_gets_nonl(ACL_VSTREAM_IN, buf, sizeof(buf)); if (ret == ACL_VSTREAM_EOF) exit(1); acl_mystr_trim(buf); if (strcasecmp(buf, "done") == 0) break; if (strcasecmp(buf, "all") == 0) { copy_all(sources, target->get_id()); break; } acl::redis_node* source = find_node(buf); if (source == NULL) { printf("...The source node(%s) is not known\r\n", buf); continue; } if (strcmp(target->get_id(), buf) == 0) { printf("... It is not possible to use the target node as source node\r\n"); continue; } sources.push_back(source); } if (sources.empty()) { printf("*** No source nodes given, operation aborted\r\n"); exit(1); } redis_migrate migrate(masters_); migrate.move_slots(sources, *target, nslots); }
EDL& EDL::operator=(EDL &edl) { printf("EDL::operator= 1\n"); copy_all(&edl); return *this; }
/** * Construction test ensures that we don't throw and that at least one process shows up. */ TEST( Process_List_Test, construct_vector ) { std::vector< PROCESSENTRY32W > v ; initialize_process_list( v, every_process(), copy_all() ) ; ASSERT_GE( v.size(), 1u ); }