idx
int64
func
string
target
int64
353,235
void SplashOutputDev::setupScreenParams(double hDPI, double vDPI) { screenParams.size = -1; screenParams.dotRadius = -1; screenParams.gamma = (SplashCoord)1.0; screenParams.blackThreshold = (SplashCoord)0.0; screenParams.whiteThreshold = (SplashCoord)1.0; // use clustered dithering for resolution >= 300 dpi // (compare to 299.9 to avoid floating point issues) if (hDPI > 299.9 && vDPI > 299.9) { screenParams.type = splashScreenStochasticClustered; if (screenParams.size < 0) { screenParams.size = 64; } if (screenParams.dotRadius < 0) { screenParams.dotRadius = 2; } } else { screenParams.type = splashScreenDispersed; if (screenParams.size < 0) { screenParams.size = 4; } } }
0
430,369
struct list_head *seq_list_next(void *v, struct list_head *head, loff_t *ppos) { struct list_head *lh; lh = ((struct list_head *)v)->next; ++*ppos; return lh == head ? NULL : lh; }
0
432,164
getSortAndGroupStagesFromPipeline(const Pipeline::SourceContainer& sources) { boost::intrusive_ptr<DocumentSourceSort> sortStage = nullptr; boost::intrusive_ptr<DocumentSourceGroup> groupStage = nullptr; auto sourcesIt = sources.begin(); if (sourcesIt != sources.end()) { sortStage = dynamic_cast<DocumentSourceSort*>(sourcesIt->get()); if (sortStage) { if (!sortStage->hasLimit()) { ++sourcesIt; } else { // This $sort stage was previously followed by a $limit stage. sourcesIt = sources.end(); } } } if (sourcesIt != sources.end()) { groupStage = dynamic_cast<DocumentSourceGroup*>(sourcesIt->get()); } return std::make_pair(sortStage, groupStage); }
0
432,255
static int subpage_register(struct uc_struct *uc, subpage_t *mmio, uint32_t start, uint32_t end, uint16_t section) { int idx, eidx; if (start >= TARGET_PAGE_SIZE || end >= TARGET_PAGE_SIZE) return -1; idx = SUBPAGE_IDX(start); eidx = SUBPAGE_IDX(end); #if defined(DEBUG_SUBPAGE) printf("%s: %p start %08x end %08x idx %08x eidx %08x section %d\n", __func__, mmio, start, end, idx, eidx, section); #endif for (; idx <= eidx; idx++) { mmio->sub_section[idx] = section; } return 0; }
0
329,931
_cairo_image_spans_and_zero (void *abstract_renderer, int y, int height, const cairo_half_open_span_t *spans, unsigned num_spans) { cairo_image_span_renderer_t *r = abstract_renderer; uint8_t *mask; int len; mask = r->u.mask.data; if (y > r->u.mask.extents.y) { len = (y - r->u.mask.extents.y) * r->u.mask.stride; memset (mask, 0, len); mask += len; } r->u.mask.extents.y = y + height; r->u.mask.data = mask + height * r->u.mask.stride; if (num_spans == 0) { memset (mask, 0, height * r->u.mask.stride); } else { uint8_t *row = mask; if (spans[0].x != r->u.mask.extents.x) { len = spans[0].x - r->u.mask.extents.x; memset (row, 0, len); row += len; } do { len = spans[1].x - spans[0].x; *row++ = r->opacity * spans[0].coverage; if (len > 1) { memset (row, row[-1], --len); row += len; } spans++; } while (--num_spans > 1); if (spans[0].x != r->u.mask.extents.x + r->u.mask.extents.width) { len = r->u.mask.extents.x + r->u.mask.extents.width - spans[0].x; memset (row, 0, len); } row = mask; while (--height) { mask += r->u.mask.stride; memcpy (mask, row, r->u.mask.extents.width); } } return CAIRO_STATUS_SUCCESS; }
0
254,706
njs_typed_array_prototype_iterator_obj(njs_vm_t *vm, njs_value_t *args, njs_uint_t nargs, njs_index_t kind) { njs_value_t *this; njs_typed_array_t *array; this = njs_argument(args, 0); if (njs_slow_path(!njs_is_typed_array(this))) { njs_type_error(vm, "this is not a typed array"); return NJS_ERROR; } array = njs_typed_array(this); if (njs_slow_path(njs_is_detached_buffer(array->buffer))) { njs_type_error(vm, "detached buffer"); return NJS_ERROR; } return njs_array_iterator_create(vm, this, &vm->retval, kind); }
0
222,495
FunctionCallFrame::FunctionCallFrame(DataTypeSlice arg_types, DataTypeSlice ret_types) : arg_types_(arg_types.begin(), arg_types.end()), ret_types_(ret_types.begin(), ret_types.end()) { args_.resize(arg_types_.size()); rets_.resize(ret_types_.size()); }
0
310,054
extended_pair_content(int pair, int *f, int *b) { return NCURSES_SP_NAME(extended_pair_content) (CURRENT_SCREEN, pair, f, b); }
0
386,499
void DL_Dxf::addDictionaryEntry(DL_CreationInterface* creationInterface) { creationInterface->addDictionaryEntry(DL_DictionaryEntryData(getStringValue(3, ""), getStringValue(350, ""))); }
0
195,074
GF_AV1Config *gf_odf_av1_cfg_read_bs_size(GF_BitStream *bs, u32 size) { #ifndef GPAC_DISABLE_AV_PARSERS AV1State state; u8 reserved; GF_AV1Config *cfg; if (!size) size = (u32) gf_bs_available(bs); if (!size) return NULL; cfg = gf_odf_av1_cfg_new(); gf_av1_init_state(&state); state.config = cfg; cfg->marker = gf_bs_read_int(bs, 1); cfg->version = gf_bs_read_int(bs, 7); cfg->seq_profile = gf_bs_read_int(bs, 3); cfg->seq_level_idx_0 = gf_bs_read_int(bs, 5); cfg->seq_tier_0 = gf_bs_read_int(bs, 1); cfg->high_bitdepth = gf_bs_read_int(bs, 1); cfg->twelve_bit = gf_bs_read_int(bs, 1); cfg->monochrome = gf_bs_read_int(bs, 1); cfg->chroma_subsampling_x = gf_bs_read_int(bs, 1); cfg->chroma_subsampling_y = gf_bs_read_int(bs, 1); cfg->chroma_sample_position = gf_bs_read_int(bs, 2); reserved = gf_bs_read_int(bs, 3); if (reserved != 0 || cfg->marker != 1 || cfg->version != 1) { GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[AV1] wrong avcC reserved %d / marker %d / version %d expecting 0 1 1\n", reserved, cfg->marker, cfg->version)); gf_odf_av1_cfg_del(cfg); return NULL; } cfg->initial_presentation_delay_present = gf_bs_read_int(bs, 1); if (cfg->initial_presentation_delay_present) { cfg->initial_presentation_delay_minus_one = gf_bs_read_int(bs, 4); } else { /*reserved = */gf_bs_read_int(bs, 4); cfg->initial_presentation_delay_minus_one = 0; } size -= 4; while (size) { u64 pos, obu_size; ObuType obu_type; GF_AV1_OBUArrayEntry *a; pos = gf_bs_get_position(bs); obu_size = 0; if (gf_av1_parse_obu(bs, &obu_type, &obu_size, NULL, &state) != GF_OK) { GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[AV1] could not parse AV1 OBU at position "LLU". Leaving parsing.\n", pos)); break; } assert(obu_size == gf_bs_get_position(bs) - pos); GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[AV1] parsed AV1 OBU type=%u size="LLU" at position "LLU".\n", obu_type, obu_size, pos)); if (!av1_is_obu_header(obu_type)) { GF_LOG(GF_LOG_DEBUG, GF_LOG_CONTAINER, ("[AV1] AV1 unexpected OBU type=%u size="LLU" found at position "LLU". Forwarding.\n", pos)); } GF_SAFEALLOC(a, GF_AV1_OBUArrayEntry); if (!a) break; a->obu = gf_malloc((size_t)obu_size); if (!a->obu) { gf_free(a); break; } gf_bs_seek(bs, pos); gf_bs_read_data(bs, (char *) a->obu, (u32)obu_size); a->obu_length = obu_size; a->obu_type = obu_type; gf_list_add(cfg->obu_array, a); if (size<obu_size) { GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[AV1] AV1 config misses %d bytes to fit the entire OBU\n", obu_size - size)); break; } size -= (u32) obu_size; } gf_av1_reset_state(& state, GF_TRUE); return cfg; #else return NULL; #endif }
1
231,708
void recoverOrResetCongestionAndRttState( QuicServerConnectionState& conn, const folly::SocketAddress& peerAddress) { auto& lastState = conn.migrationState.lastCongestionAndRtt; if (lastState && lastState->peerAddress == peerAddress && (Clock::now() - lastState->recordTime <= kTimeToRetainLastCongestionAndRttState)) { // recover from matched non-stale state conn.congestionController = std::move(lastState->congestionController); conn.lossState.srtt = lastState->srtt; conn.lossState.lrtt = lastState->lrtt; conn.lossState.rttvar = lastState->rttvar; conn.lossState.mrtt = lastState->mrtt; conn.migrationState.lastCongestionAndRtt = folly::none; } else { resetCongestionAndRttState(conn); } }
0
231,785
void onServerReadDataFromClosed( QuicServerConnectionState& conn, ServerEvents::ReadData& readData) { CHECK_EQ(conn.state, ServerState::Closed); BufQueue udpData; udpData.append(std::move(readData.networkData.data)); auto packetSize = udpData.empty() ? 0 : udpData.chainLength(); if (!conn.readCodec) { // drop data. We closed before we even got the first packet. This is // normally not possible but might as well. if (conn.qLogger) { conn.qLogger->addPacketDrop( packetSize, QuicTransportStatsCallback::toString( PacketDropReason::SERVER_STATE_CLOSED)); } QUIC_STATS( conn.statsCallback, onPacketDropped, PacketDropReason::SERVER_STATE_CLOSED); return; } if (conn.peerConnectionError) { // We already got a peer error. We can ignore any futher peer errors. if (conn.qLogger) { conn.qLogger->addPacketDrop( packetSize, QuicTransportStatsCallback::toString( PacketDropReason::SERVER_STATE_CLOSED)); } QUIC_TRACE(packet_drop, conn, "ignoring peer close"); QUIC_STATS( conn.statsCallback, onPacketDropped, PacketDropReason::SERVER_STATE_CLOSED); return; } auto parsedPacket = conn.readCodec->parsePacket(udpData, conn.ackStates); switch (parsedPacket.type()) { case CodecResult::Type::CIPHER_UNAVAILABLE: { VLOG(10) << "drop cipher unavailable " << conn; if (conn.qLogger) { conn.qLogger->addPacketDrop(packetSize, kCipherUnavailable); } QUIC_TRACE(packet_drop, conn, "cipher_unavailable"); break; } case CodecResult::Type::RETRY: { VLOG(10) << "drop because the server is not supposed to " << "receive a retry " << conn; if (conn.qLogger) { conn.qLogger->addPacketDrop(packetSize, kRetry); } QUIC_TRACE(packet_drop, conn, "retry"); break; } case CodecResult::Type::STATELESS_RESET: { VLOG(10) << "drop because reset " << conn; if (conn.qLogger) { conn.qLogger->addPacketDrop(packetSize, kReset); } QUIC_TRACE(packet_drop, conn, "reset"); break; } case CodecResult::Type::NOTHING: { VLOG(10) << "drop cipher unavailable, no data " << conn; if (conn.qLogger) { conn.qLogger->addPacketDrop(packetSize, kCipherUnavailable); } QUIC_TRACE(packet_drop, conn, "cipher_unavailable"); break; } case CodecResult::Type::REGULAR_PACKET: break; } auto regularOptional = parsedPacket.regularPacket(); if (!regularOptional) { // We were unable to parse the packet, drop for now. VLOG(10) << "Not able to parse QUIC packet " << conn; if (conn.qLogger) { conn.qLogger->addPacketDrop( packetSize, QuicTransportStatsCallback::toString(PacketDropReason::PARSE_ERROR)); } QUIC_STATS( conn.statsCallback, onPacketDropped, PacketDropReason::PARSE_ERROR); return; } auto& regularPacket = *regularOptional; auto packetNum = regularPacket.header.getPacketSequenceNum(); auto pnSpace = regularPacket.header.getPacketNumberSpace(); if (conn.qLogger) { conn.qLogger->addPacket(regularPacket, packetSize); } // Only process the close frames in the packet for (auto& quicFrame : regularPacket.frames) { switch (quicFrame.type()) { case QuicFrame::Type::ConnectionCloseFrame: { ConnectionCloseFrame& connFrame = *quicFrame.asConnectionCloseFrame(); auto errMsg = folly::to<std::string>( "Server closed by peer reason=", connFrame.reasonPhrase); VLOG(4) << errMsg << " " << conn; if (conn.qLogger) { conn.qLogger->addTransportStateUpdate(getPeerClose(errMsg)); } // we want to deliver app callbacks with the peer supplied error, // but send a NO_ERROR to the peer. QUIC_TRACE(recvd_close, conn, errMsg.c_str()); conn.peerConnectionError = std::make_pair( QuicErrorCode(connFrame.errorCode), std::move(errMsg)); break; } default: break; } } // We only need to set the largest received packet number in order to // determine whether or not we need to send a new close. auto& largestReceivedPacketNum = getAckState(conn, pnSpace).largestReceivedPacketNum; largestReceivedPacketNum = std::max<PacketNum>( largestReceivedPacketNum.value_or(packetNum), packetNum); }
0
226,064
GF_Err stsg_box_write(GF_Box *s, GF_BitStream *bs) { GF_Err e; u32 i; GF_SubTrackSampleGroupBox *ptr = (GF_SubTrackSampleGroupBox *)s; e = gf_isom_full_box_write(s, bs); if (e) return e; gf_bs_write_u32(bs, ptr->grouping_type); gf_bs_write_u16(bs, ptr->nb_groups); for (i = 0; i < ptr->nb_groups; i++) { gf_bs_write_u32(bs, ptr->group_description_index[i]); } return GF_OK;
0
292,160
void LinkResolver::resolve_field_access(fieldDescriptor& fd, const constantPoolHandle& pool, int index, const methodHandle& method, Bytecodes::Code byte, TRAPS) { LinkInfo link_info(pool, index, method, CHECK); resolve_field(fd, link_info, byte, true, CHECK); }
0
224,195
codegen(codegen_scope *s, node *tree, int val) { int nt; int rlev = s->rlev; if (!tree) { if (val) { genop_1(s, OP_LOADNIL, cursp()); push(); } return; } s->rlev++; if (s->rlev > MRB_CODEGEN_LEVEL_MAX) { codegen_error(s, "too complex expression"); } if (s->irep && s->filename_index != tree->filename_index) { mrb_sym fname = mrb_parser_get_filename(s->parser, s->filename_index); const char *filename = mrb_sym_name_len(s->mrb, fname, NULL); mrb_debug_info_append_file(s->mrb, s->irep->debug_info, filename, s->lines, s->debug_start_pos, s->pc); s->debug_start_pos = s->pc; s->filename_index = tree->filename_index; s->filename_sym = mrb_parser_get_filename(s->parser, tree->filename_index); } nt = nint(tree->car); s->lineno = tree->lineno; tree = tree->cdr; switch (nt) { case NODE_BEGIN: if (val && !tree) { genop_1(s, OP_LOADNIL, cursp()); push(); } while (tree) { codegen(s, tree->car, tree->cdr ? NOVAL : val); tree = tree->cdr; } break; case NODE_RESCUE: { int noexc; uint32_t exend, pos1, pos2, tmp; struct loopinfo *lp; int catch_entry, begin, end; if (tree->car == NULL) goto exit; lp = loop_push(s, LOOP_BEGIN); lp->pc0 = new_label(s); catch_entry = catch_handler_new(s); begin = s->pc; codegen(s, tree->car, VAL); pop(); lp->type = LOOP_RESCUE; end = s->pc; noexc = genjmp_0(s, OP_JMP); catch_handler_set(s, catch_entry, MRB_CATCH_RESCUE, begin, end, s->pc); tree = tree->cdr; exend = JMPLINK_START; pos1 = JMPLINK_START; if (tree->car) { node *n2 = tree->car; int exc = cursp(); genop_1(s, OP_EXCEPT, exc); push(); while (n2) { node *n3 = n2->car; node *n4 = n3->car; dispatch(s, pos1); pos2 = JMPLINK_START; do { if (n4 && n4->car && nint(n4->car->car) == NODE_SPLAT) { codegen(s, n4->car, VAL); gen_move(s, cursp(), exc, 0); push_n(2); pop_n(2); /* space for one arg and a block */ pop(); genop_3(s, OP_SEND, cursp(), new_sym(s, MRB_SYM_2(s->mrb, __case_eqq)), 1); } else { if (n4) { codegen(s, n4->car, VAL); } else { genop_2(s, OP_GETCONST, cursp(), new_sym(s, MRB_SYM_2(s->mrb, StandardError))); push(); } pop(); genop_2(s, OP_RESCUE, exc, cursp()); } tmp = genjmp2(s, OP_JMPIF, cursp(), pos2, val); pos2 = tmp; if (n4) { n4 = n4->cdr; } } while (n4); pos1 = genjmp_0(s, OP_JMP); dispatch_linked(s, pos2); pop(); if (n3->cdr->car) { gen_assignment(s, n3->cdr->car, NULL, exc, NOVAL); } if (n3->cdr->cdr->car) { codegen(s, n3->cdr->cdr->car, val); if (val) pop(); } tmp = genjmp(s, OP_JMP, exend); exend = tmp; n2 = n2->cdr; push(); } if (pos1 != JMPLINK_START) { dispatch(s, pos1); genop_1(s, OP_RAISEIF, exc); } } pop(); tree = tree->cdr; dispatch(s, noexc); if (tree->car) { codegen(s, tree->car, val); } else if (val) { push(); } dispatch_linked(s, exend); loop_pop(s, NOVAL); } break; case NODE_ENSURE: if (!tree->cdr || !tree->cdr->cdr || (nint(tree->cdr->cdr->car) == NODE_BEGIN && tree->cdr->cdr->cdr)) { int catch_entry, begin, end, target; int idx; catch_entry = catch_handler_new(s); begin = s->pc; codegen(s, tree->car, val); end = target = s->pc; push(); idx = cursp(); genop_1(s, OP_EXCEPT, idx); push(); codegen(s, tree->cdr->cdr, NOVAL); pop(); genop_1(s, OP_RAISEIF, idx); pop(); catch_handler_set(s, catch_entry, MRB_CATCH_ENSURE, begin, end, target); } else { /* empty ensure ignored */ codegen(s, tree->car, val); } break; case NODE_LAMBDA: if (val) { int idx = lambda_body(s, tree, 1); genop_2(s, OP_LAMBDA, cursp(), idx); push(); } break; case NODE_BLOCK: if (val) { int idx = lambda_body(s, tree, 1); genop_2(s, OP_BLOCK, cursp(), idx); push(); } break; case NODE_IF: { uint32_t pos1, pos2; mrb_bool nil_p = FALSE; node *elsepart = tree->cdr->cdr->car; if (!tree->car) { codegen(s, elsepart, val); goto exit; } if (true_always(tree->car)) { codegen(s, tree->cdr->car, val); goto exit; } if (false_always(tree->car)) { codegen(s, elsepart, val); goto exit; } if (nint(tree->car->car) == NODE_CALL) { node *n = tree->car->cdr; mrb_sym mid = nsym(n->cdr->car); mrb_sym sym_nil_p = MRB_SYM_Q_2(s->mrb, nil); if (mid == sym_nil_p && n->cdr->cdr->car == NULL) { nil_p = TRUE; codegen(s, n->car, VAL); } } if (!nil_p) { codegen(s, tree->car, VAL); } pop(); if (val || tree->cdr->car) { if (nil_p) { pos2 = genjmp2_0(s, OP_JMPNIL, cursp(), val); pos1 = genjmp_0(s, OP_JMP); dispatch(s, pos2); } else { pos1 = genjmp2_0(s, OP_JMPNOT, cursp(), val); } codegen(s, tree->cdr->car, val); if (val) pop(); if (elsepart || val) { pos2 = genjmp_0(s, OP_JMP); dispatch(s, pos1); codegen(s, elsepart, val); dispatch(s, pos2); } else { dispatch(s, pos1); } } else { /* empty then-part */ if (elsepart) { if (nil_p) { pos1 = genjmp2_0(s, OP_JMPNIL, cursp(), val); } else { pos1 = genjmp2_0(s, OP_JMPIF, cursp(), val); } codegen(s, elsepart, val); dispatch(s, pos1); } else if (val && !nil_p) { genop_1(s, OP_LOADNIL, cursp()); push(); } } } break; case NODE_AND: { uint32_t pos; if (true_always(tree->car)) { codegen(s, tree->cdr, val); goto exit; } if (false_always(tree->car)) { codegen(s, tree->car, val); goto exit; } codegen(s, tree->car, VAL); pop(); pos = genjmp2_0(s, OP_JMPNOT, cursp(), val); codegen(s, tree->cdr, val); dispatch(s, pos); } break; case NODE_OR: { uint32_t pos; if (true_always(tree->car)) { codegen(s, tree->car, val); goto exit; } if (false_always(tree->car)) { codegen(s, tree->cdr, val); goto exit; } codegen(s, tree->car, VAL); pop(); pos = genjmp2_0(s, OP_JMPIF, cursp(), val); codegen(s, tree->cdr, val); dispatch(s, pos); } break; case NODE_WHILE: case NODE_UNTIL: { if (true_always(tree->car)) { if (nt == NODE_UNTIL) { if (val) { genop_1(s, OP_LOADNIL, cursp()); push(); } goto exit; } } else if (false_always(tree->car)) { if (nt == NODE_WHILE) { if (val) { genop_1(s, OP_LOADNIL, cursp()); push(); } goto exit; } } uint32_t pos = JMPLINK_START; struct loopinfo *lp = loop_push(s, LOOP_NORMAL); if (!val) lp->reg = -1; lp->pc0 = new_label(s); codegen(s, tree->car, VAL); pop(); if (nt == NODE_WHILE) { pos = genjmp2_0(s, OP_JMPNOT, cursp(), NOVAL); } else { pos = genjmp2_0(s, OP_JMPIF, cursp(), NOVAL); } lp->pc1 = new_label(s); codegen(s, tree->cdr, NOVAL); genjmp(s, OP_JMP, lp->pc0); dispatch(s, pos); loop_pop(s, val); } break; case NODE_FOR: for_body(s, tree); if (val) push(); break; case NODE_CASE: { int head = 0; uint32_t pos1, pos2, pos3, tmp; node *n; pos3 = JMPLINK_START; if (tree->car) { head = cursp(); codegen(s, tree->car, VAL); } tree = tree->cdr; while (tree) { n = tree->car->car; pos1 = pos2 = JMPLINK_START; while (n) { codegen(s, n->car, VAL); if (head) { gen_move(s, cursp(), head, 0); push(); push(); pop(); pop(); pop(); if (nint(n->car->car) == NODE_SPLAT) { genop_3(s, OP_SEND, cursp(), new_sym(s, MRB_SYM_2(s->mrb, __case_eqq)), 1); } else { genop_3(s, OP_SEND, cursp(), new_sym(s, MRB_OPSYM_2(s->mrb, eqq)), 1); } } else { pop(); } tmp = genjmp2(s, OP_JMPIF, cursp(), pos2, NOVAL); pos2 = tmp; n = n->cdr; } if (tree->car->car) { pos1 = genjmp_0(s, OP_JMP); dispatch_linked(s, pos2); } codegen(s, tree->car->cdr, val); if (val) pop(); tmp = genjmp(s, OP_JMP, pos3); pos3 = tmp; dispatch(s, pos1); tree = tree->cdr; } if (val) { uint32_t pos = cursp(); genop_1(s, OP_LOADNIL, cursp()); if (pos3 != JMPLINK_START) dispatch_linked(s, pos3); if (head) pop(); if (cursp() != pos) { gen_move(s, cursp(), pos, 0); } push(); } else { if (pos3 != JMPLINK_START) { dispatch_linked(s, pos3); } if (head) { pop(); } } } break; case NODE_SCOPE: scope_body(s, tree, NOVAL); break; case NODE_FCALL: case NODE_CALL: gen_call(s, tree, val, 0); break; case NODE_SCALL: gen_call(s, tree, val, 1); break; case NODE_DOT2: codegen(s, tree->car, val); codegen(s, tree->cdr, val); if (val) { pop(); pop(); genop_1(s, OP_RANGE_INC, cursp()); push(); } break; case NODE_DOT3: codegen(s, tree->car, val); codegen(s, tree->cdr, val); if (val) { pop(); pop(); genop_1(s, OP_RANGE_EXC, cursp()); push(); } break; case NODE_COLON2: { int sym = new_sym(s, nsym(tree->cdr)); codegen(s, tree->car, VAL); pop(); genop_2(s, OP_GETMCNST, cursp(), sym); if (val) push(); } break; case NODE_COLON3: { int sym = new_sym(s, nsym(tree)); genop_1(s, OP_OCLASS, cursp()); genop_2(s, OP_GETMCNST, cursp(), sym); if (val) push(); } break; case NODE_ARRAY: { int n; n = gen_values(s, tree, val, 0); if (val) { if (n >= 0) { pop_n(n); genop_2(s, OP_ARRAY, cursp(), n); } push(); } } break; case NODE_HASH: case NODE_KW_HASH: { int nk = gen_hash(s, tree, val, GEN_LIT_ARY_MAX); if (val && nk >= 0) { pop_n(nk*2); genop_2(s, OP_HASH, cursp(), nk); push(); } } break; case NODE_SPLAT: codegen(s, tree, val); break; case NODE_ASGN: gen_assignment(s, tree->car, tree->cdr, 0, val); break; case NODE_MASGN: { int len = 0, n = 0, post = 0; node *t = tree->cdr, *p; int rhs = cursp(); if (nint(t->car) == NODE_ARRAY && t->cdr && nosplat(t->cdr)) { /* fixed rhs */ t = t->cdr; while (t) { codegen(s, t->car, VAL); len++; t = t->cdr; } tree = tree->car; if (tree->car) { /* pre */ t = tree->car; n = 0; while (t) { if (n < len) { gen_assignment(s, t->car, NULL, rhs+n, NOVAL); n++; } else { genop_1(s, OP_LOADNIL, rhs+n); gen_assignment(s, t->car, NULL, rhs+n, NOVAL); } t = t->cdr; } } t = tree->cdr; if (t) { if (t->cdr) { /* post count */ p = t->cdr->car; while (p) { post++; p = p->cdr; } } if (t->car) { /* rest (len - pre - post) */ int rn; if (len < post + n) { rn = 0; } else { rn = len - post - n; } if (cursp() == rhs+n) { genop_2(s, OP_ARRAY, cursp(), rn); } else { genop_3(s, OP_ARRAY2, cursp(), rhs+n, rn); } gen_assignment(s, t->car, NULL, cursp(), NOVAL); n += rn; } if (t->cdr && t->cdr->car) { t = t->cdr->car; while (t) { if (n<len) { gen_assignment(s, t->car, NULL, rhs+n, NOVAL); } else { genop_1(s, OP_LOADNIL, cursp()); gen_assignment(s, t->car, NULL, cursp(), NOVAL); } t = t->cdr; n++; } } } pop_n(len); if (val) { genop_2(s, OP_ARRAY, rhs, len); push(); } } else { /* variable rhs */ codegen(s, t, VAL); gen_massignment(s, tree->car, rhs, val); if (!val) { pop(); } } } break; case NODE_OP_ASGN: { mrb_sym sym = nsym(tree->cdr->car); mrb_int len; const char *name = mrb_sym_name_len(s->mrb, sym, &len); int idx, callargs = -1, vsp = -1; if ((len == 2 && name[0] == '|' && name[1] == '|') && (nint(tree->car->car) == NODE_CONST || nint(tree->car->car) == NODE_CVAR)) { int catch_entry, begin, end; int noexc, exc; struct loopinfo *lp; lp = loop_push(s, LOOP_BEGIN); lp->pc0 = new_label(s); catch_entry = catch_handler_new(s); begin = s->pc; exc = cursp(); codegen(s, tree->car, VAL); end = s->pc; noexc = genjmp_0(s, OP_JMP); lp->type = LOOP_RESCUE; catch_handler_set(s, catch_entry, MRB_CATCH_RESCUE, begin, end, s->pc); genop_1(s, OP_EXCEPT, exc); genop_1(s, OP_LOADF, exc); dispatch(s, noexc); loop_pop(s, NOVAL); } else if (nint(tree->car->car) == NODE_CALL) { node *n = tree->car->cdr; int base, i, nargs = 0; callargs = 0; if (val) { vsp = cursp(); push(); } codegen(s, n->car, VAL); /* receiver */ idx = new_sym(s, nsym(n->cdr->car)); base = cursp()-1; if (n->cdr->cdr->car) { nargs = gen_values(s, n->cdr->cdr->car->car, VAL, 13); if (nargs >= 0) { callargs = nargs; } else { /* varargs */ push(); nargs = 1; callargs = CALL_MAXARGS; } } /* copy receiver and arguments */ gen_move(s, cursp(), base, 1); for (i=0; i<nargs; i++) { gen_move(s, cursp()+i+1, base+i+1, 1); } push_n(nargs+2);pop_n(nargs+2); /* space for receiver, arguments and a block */ genop_3(s, OP_SEND, cursp(), idx, callargs); push(); } else { codegen(s, tree->car, VAL); } if (len == 2 && ((name[0] == '|' && name[1] == '|') || (name[0] == '&' && name[1] == '&'))) { uint32_t pos; pop(); if (val) { if (vsp >= 0) { gen_move(s, vsp, cursp(), 1); } pos = genjmp2_0(s, name[0]=='|'?OP_JMPIF:OP_JMPNOT, cursp(), val); } else { pos = genjmp2_0(s, name[0]=='|'?OP_JMPIF:OP_JMPNOT, cursp(), val); } codegen(s, tree->cdr->cdr->car, VAL); pop(); if (val && vsp >= 0) { gen_move(s, vsp, cursp(), 1); } if (nint(tree->car->car) == NODE_CALL) { if (callargs == CALL_MAXARGS) { pop(); genop_2(s, OP_ARYPUSH, cursp(), 1); } else { pop_n(callargs); callargs++; } pop(); idx = new_sym(s, attrsym(s, nsym(tree->car->cdr->cdr->car))); genop_3(s, OP_SEND, cursp(), idx, callargs); } else { gen_assignment(s, tree->car, NULL, cursp(), val); } dispatch(s, pos); goto exit; } codegen(s, tree->cdr->cdr->car, VAL); push(); pop(); pop(); pop(); if (len == 1 && name[0] == '+') { gen_addsub(s, OP_ADD, cursp()); } else if (len == 1 && name[0] == '-') { gen_addsub(s, OP_SUB, cursp()); } else if (len == 1 && name[0] == '*') { genop_1(s, OP_MUL, cursp()); } else if (len == 1 && name[0] == '/') { genop_1(s, OP_DIV, cursp()); } else if (len == 1 && name[0] == '<') { genop_1(s, OP_LT, cursp()); } else if (len == 2 && name[0] == '<' && name[1] == '=') { genop_1(s, OP_LE, cursp()); } else if (len == 1 && name[0] == '>') { genop_1(s, OP_GT, cursp()); } else if (len == 2 && name[0] == '>' && name[1] == '=') { genop_1(s, OP_GE, cursp()); } else { idx = new_sym(s, sym); genop_3(s, OP_SEND, cursp(), idx, 1); } if (callargs < 0) { gen_assignment(s, tree->car, NULL, cursp(), val); } else { if (val && vsp >= 0) { gen_move(s, vsp, cursp(), 0); } if (callargs == CALL_MAXARGS) { pop(); genop_2(s, OP_ARYPUSH, cursp(), 1); } else { pop_n(callargs); callargs++; } pop(); idx = new_sym(s, attrsym(s,nsym(tree->car->cdr->cdr->car))); genop_3(s, OP_SEND, cursp(), idx, callargs); } } break; case NODE_SUPER: { codegen_scope *s2 = s; int lv = 0; int n = 0, nk = 0, st = 0; push(); while (!s2->mscope) { lv++; s2 = s2->prev; if (!s2) break; } if (tree) { node *args = tree->car; if (args) { st = n = gen_values(s, args, VAL, 14); if (n < 0) { st = 1; n = 15; push(); } } /* keyword arguments */ if (tree->cdr->car) { nk = gen_hash(s, tree->cdr->car->cdr, VAL, 14); if (nk < 0) {st++; nk = 15;} else st += nk*2; n |= nk<<4; } /* block arguments */ if (tree->cdr->cdr) { codegen(s, tree->cdr->cdr, VAL); } else if (s2) gen_blkmove(s, s2->ainfo, lv); else { genop_1(s, OP_LOADNIL, cursp()); push(); } } else { if (s2) gen_blkmove(s, s2->ainfo, lv); else { genop_1(s, OP_LOADNIL, cursp()); push(); } } st++; pop_n(st+1); genop_2(s, OP_SUPER, cursp(), n); if (val) push(); } break; case NODE_ZSUPER: { codegen_scope *s2 = s; int lv = 0; uint16_t ainfo = 0; int n = CALL_MAXARGS; int sp = cursp(); push(); /* room for receiver */ while (!s2->mscope) { lv++; s2 = s2->prev; if (!s2) break; } if (s2 && s2->ainfo > 0) { ainfo = s2->ainfo; } if (ainfo > 0) { genop_2S(s, OP_ARGARY, cursp(), (ainfo<<4)|(lv & 0xf)); push(); push(); push(); /* ARGARY pushes 3 values at most */ pop(); pop(); pop(); /* keyword arguments */ if (ainfo & 0x1) { n |= CALL_MAXARGS<<4; push(); } /* block argument */ if (tree && tree->cdr && tree->cdr->cdr) { push(); codegen(s, tree->cdr->cdr, VAL); } } else { /* block argument */ if (tree && tree->cdr && tree->cdr->cdr) { codegen(s, tree->cdr->cdr, VAL); } else { gen_blkmove(s, 0, lv); } n = 0; } s->sp = sp; genop_2(s, OP_SUPER, cursp(), n); if (val) push(); } break; case NODE_RETURN: if (tree) { gen_retval(s, tree); } else { genop_1(s, OP_LOADNIL, cursp()); } if (s->loop) { gen_return(s, OP_RETURN_BLK, cursp()); } else { gen_return(s, OP_RETURN, cursp()); } if (val) push(); break; case NODE_YIELD: { codegen_scope *s2 = s; int lv = 0, ainfo = -1; int n = 0, sendv = 0; while (!s2->mscope) { lv++; s2 = s2->prev; if (!s2) break; } if (s2) { ainfo = (int)s2->ainfo; } if (ainfo < 0) codegen_error(s, "invalid yield (SyntaxError)"); push(); if (tree) { n = gen_values(s, tree, VAL, 14); if (n < 0) { n = sendv = 1; push(); } } push();pop(); /* space for a block */ pop_n(n+1); genop_2S(s, OP_BLKPUSH, cursp(), (ainfo<<4)|(lv & 0xf)); if (sendv) n = CALL_MAXARGS; genop_3(s, OP_SEND, cursp(), new_sym(s, MRB_SYM_2(s->mrb, call)), n); if (val) push(); } break; case NODE_BREAK: loop_break(s, tree); if (val) push(); break; case NODE_NEXT: if (!s->loop) { raise_error(s, "unexpected next"); } else if (s->loop->type == LOOP_NORMAL) { codegen(s, tree, NOVAL); genjmp(s, OP_JMPUW, s->loop->pc0); } else { if (tree) { codegen(s, tree, VAL); pop(); } else { genop_1(s, OP_LOADNIL, cursp()); } gen_return(s, OP_RETURN, cursp()); } if (val) push(); break; case NODE_REDO: if (!s->loop || s->loop->type == LOOP_BEGIN || s->loop->type == LOOP_RESCUE) { raise_error(s, "unexpected redo"); } else { genjmp(s, OP_JMPUW, s->loop->pc1); } if (val) push(); break; case NODE_RETRY: { const char *msg = "unexpected retry"; const struct loopinfo *lp = s->loop; while (lp && lp->type != LOOP_RESCUE) { lp = lp->prev; } if (!lp) { raise_error(s, msg); } else { genjmp(s, OP_JMPUW, lp->pc0); } if (val) push(); } break; case NODE_LVAR: if (val) { int idx = lv_idx(s, nsym(tree)); if (idx > 0) { gen_move(s, cursp(), idx, val); } else { gen_getupvar(s, cursp(), nsym(tree)); } push(); } break; case NODE_NVAR: if (val) { int idx = nint(tree); gen_move(s, cursp(), idx, val); push(); } break; case NODE_GVAR: { int sym = new_sym(s, nsym(tree)); genop_2(s, OP_GETGV, cursp(), sym); if (val) push(); } break; case NODE_IVAR: { int sym = new_sym(s, nsym(tree)); genop_2(s, OP_GETIV, cursp(), sym); if (val) push(); } break; case NODE_CVAR: { int sym = new_sym(s, nsym(tree)); genop_2(s, OP_GETCV, cursp(), sym); if (val) push(); } break; case NODE_CONST: { int sym = new_sym(s, nsym(tree)); genop_2(s, OP_GETCONST, cursp(), sym); if (val) push(); } break; case NODE_BACK_REF: if (val) { char buf[] = {'$', nchar(tree)}; int sym = new_sym(s, mrb_intern(s->mrb, buf, sizeof(buf))); genop_2(s, OP_GETGV, cursp(), sym); push(); } break; case NODE_NTH_REF: if (val) { mrb_state *mrb = s->mrb; mrb_value str; int sym; str = mrb_format(mrb, "$%d", nint(tree)); sym = new_sym(s, mrb_intern_str(mrb, str)); genop_2(s, OP_GETGV, cursp(), sym); push(); } break; case NODE_ARG: /* should not happen */ break; case NODE_BLOCK_ARG: if (!tree) { int idx = lv_idx(s, MRB_OPSYM_2(s->mrb, and)); if (idx == 0) { codegen_error(s, "no anonymous block argument"); } gen_move(s, cursp(), idx, val); if (val) push(); } else { codegen(s, tree, val); } break; case NODE_INT: if (val) { char *p = (char*)tree->car; int base = nint(tree->cdr->car); mrb_int i; mrb_bool overflow; i = readint(s, p, base, FALSE, &overflow); if (overflow) { int off = new_litbn(s, p, base, FALSE); genop_2(s, OP_LOADL, cursp(), off); } else { gen_int(s, cursp(), i); } push(); } break; #ifndef MRB_NO_FLOAT case NODE_FLOAT: if (val) { char *p = (char*)tree; mrb_float f = mrb_float_read(p, NULL); int off = new_lit(s, mrb_float_value(s->mrb, f)); genop_2(s, OP_LOADL, cursp(), off); push(); } break; #endif case NODE_NEGATE: { nt = nint(tree->car); switch (nt) { #ifndef MRB_NO_FLOAT case NODE_FLOAT: if (val) { char *p = (char*)tree->cdr; mrb_float f = mrb_float_read(p, NULL); int off = new_lit(s, mrb_float_value(s->mrb, -f)); genop_2(s, OP_LOADL, cursp(), off); push(); } break; #endif case NODE_INT: if (val) { char *p = (char*)tree->cdr->car; int base = nint(tree->cdr->cdr->car); mrb_int i; mrb_bool overflow; i = readint(s, p, base, TRUE, &overflow); if (overflow) { int off = new_litbn(s, p, base, TRUE); genop_2(s, OP_LOADL, cursp(), off); } else { gen_int(s, cursp(), i); } push(); } break; default: if (val) { codegen(s, tree, VAL); pop(); push_n(2);pop_n(2); /* space for receiver&block */ mrb_sym minus = MRB_OPSYM_2(s->mrb, minus); if (!gen_uniop(s, minus, cursp())) { genop_3(s, OP_SEND, cursp(), new_sym(s, minus), 0); } push(); } else { codegen(s, tree, NOVAL); } break; } } break; case NODE_STR: if (val) { char *p = (char*)tree->car; mrb_int len = nint(tree->cdr); int ai = mrb_gc_arena_save(s->mrb); int off = new_lit(s, mrb_str_new(s->mrb, p, len)); mrb_gc_arena_restore(s->mrb, ai); genop_2(s, OP_STRING, cursp(), off); push(); } break; case NODE_HEREDOC: tree = ((struct mrb_parser_heredoc_info *)tree)->doc; /* fall through */ case NODE_DSTR: if (val) { node *n = tree; if (!n) { genop_1(s, OP_LOADNIL, cursp()); push(); break; } codegen(s, n->car, VAL); n = n->cdr; while (n) { codegen(s, n->car, VAL); pop(); pop(); genop_1(s, OP_STRCAT, cursp()); push(); n = n->cdr; } } else { node *n = tree; while (n) { if (nint(n->car->car) != NODE_STR) { codegen(s, n->car, NOVAL); } n = n->cdr; } } break; case NODE_WORDS: gen_literal_array(s, tree, FALSE, val); break; case NODE_SYMBOLS: gen_literal_array(s, tree, TRUE, val); break; case NODE_DXSTR: { node *n; int ai = mrb_gc_arena_save(s->mrb); int sym = new_sym(s, MRB_SYM_2(s->mrb, Kernel)); genop_1(s, OP_LOADSELF, cursp()); push(); codegen(s, tree->car, VAL); n = tree->cdr; while (n) { if (nint(n->car->car) == NODE_XSTR) { n->car->car = (struct mrb_ast_node*)(intptr_t)NODE_STR; mrb_assert(!n->cdr); /* must be the end */ } codegen(s, n->car, VAL); pop(); pop(); genop_1(s, OP_STRCAT, cursp()); push(); n = n->cdr; } push(); /* for block */ pop_n(3); sym = new_sym(s, MRB_OPSYM_2(s->mrb, tick)); /* ` */ genop_3(s, OP_SEND, cursp(), sym, 1); if (val) push(); mrb_gc_arena_restore(s->mrb, ai); } break; case NODE_XSTR: { char *p = (char*)tree->car; mrb_int len = nint(tree->cdr); int ai = mrb_gc_arena_save(s->mrb); int off = new_lit(s, mrb_str_new(s->mrb, p, len)); int sym; genop_1(s, OP_LOADSELF, cursp()); push(); genop_2(s, OP_STRING, cursp(), off); push(); push(); pop_n(3); sym = new_sym(s, MRB_OPSYM_2(s->mrb, tick)); /* ` */ genop_3(s, OP_SEND, cursp(), sym, 1); if (val) push(); mrb_gc_arena_restore(s->mrb, ai); } break; case NODE_REGX: if (val) { char *p1 = (char*)tree->car; char *p2 = (char*)tree->cdr->car; char *p3 = (char*)tree->cdr->cdr; int ai = mrb_gc_arena_save(s->mrb); int sym = new_sym(s, mrb_intern_lit(s->mrb, REGEXP_CLASS)); int off = new_lit(s, mrb_str_new_cstr(s->mrb, p1)); int argc = 1; genop_1(s, OP_OCLASS, cursp()); genop_2(s, OP_GETMCNST, cursp(), sym); push(); genop_2(s, OP_STRING, cursp(), off); push(); if (p2 || p3) { if (p2) { /* opt */ off = new_lit(s, mrb_str_new_cstr(s->mrb, p2)); genop_2(s, OP_STRING, cursp(), off); } else { genop_1(s, OP_LOADNIL, cursp()); } push(); argc++; if (p3) { /* enc */ off = new_lit(s, mrb_str_new(s->mrb, p3, 1)); genop_2(s, OP_STRING, cursp(), off); push(); argc++; } } push(); /* space for a block */ pop_n(argc+2); sym = new_sym(s, MRB_SYM_2(s->mrb, compile)); genop_3(s, OP_SEND, cursp(), sym, argc); mrb_gc_arena_restore(s->mrb, ai); push(); } break; case NODE_DREGX: if (val) { node *n = tree->car; int ai = mrb_gc_arena_save(s->mrb); int sym = new_sym(s, mrb_intern_lit(s->mrb, REGEXP_CLASS)); int argc = 1; int off; char *p; genop_1(s, OP_OCLASS, cursp()); genop_2(s, OP_GETMCNST, cursp(), sym); push(); codegen(s, n->car, VAL); n = n->cdr; while (n) { codegen(s, n->car, VAL); pop(); pop(); genop_1(s, OP_STRCAT, cursp()); push(); n = n->cdr; } n = tree->cdr->cdr; if (n->car) { /* tail */ p = (char*)n->car; off = new_lit(s, mrb_str_new_cstr(s->mrb, p)); codegen(s, tree->car, VAL); genop_2(s, OP_STRING, cursp(), off); pop(); genop_1(s, OP_STRCAT, cursp()); push(); } if (n->cdr->car) { /* opt */ char *p2 = (char*)n->cdr->car; off = new_lit(s, mrb_str_new_cstr(s->mrb, p2)); genop_2(s, OP_STRING, cursp(), off); push(); argc++; } if (n->cdr->cdr) { /* enc */ char *p2 = (char*)n->cdr->cdr; off = new_lit(s, mrb_str_new_cstr(s->mrb, p2)); genop_2(s, OP_STRING, cursp(), off); push(); argc++; } push(); /* space for a block */ pop_n(argc+2); sym = new_sym(s, MRB_SYM_2(s->mrb, compile)); genop_3(s, OP_SEND, cursp(), sym, argc); mrb_gc_arena_restore(s->mrb, ai); push(); } else { node *n = tree->car; while (n) { if (nint(n->car->car) != NODE_STR) { codegen(s, n->car, NOVAL); } n = n->cdr; } } break; case NODE_SYM: if (val) { int sym = new_sym(s, nsym(tree)); genop_2(s, OP_LOADSYM, cursp(), sym); push(); } break; case NODE_DSYM: codegen(s, tree, val); if (val) { gen_intern(s); } break; case NODE_SELF: if (val) { genop_1(s, OP_LOADSELF, cursp()); push(); } break; case NODE_NIL: if (val) { genop_1(s, OP_LOADNIL, cursp()); push(); } break; case NODE_TRUE: if (val) { genop_1(s, OP_LOADT, cursp()); push(); } break; case NODE_FALSE: if (val) { genop_1(s, OP_LOADF, cursp()); push(); } break; case NODE_ALIAS: { int a = new_sym(s, nsym(tree->car)); int b = new_sym(s, nsym(tree->cdr)); genop_2(s, OP_ALIAS, a, b); if (val) { genop_1(s, OP_LOADNIL, cursp()); push(); } } break; case NODE_UNDEF: { node *t = tree; while (t) { int symbol = new_sym(s, nsym(t->car)); genop_1(s, OP_UNDEF, symbol); t = t->cdr; } if (val) { genop_1(s, OP_LOADNIL, cursp()); push(); } } break; case NODE_CLASS: { int idx; node *body; if (tree->car->car == (node*)0) { genop_1(s, OP_LOADNIL, cursp()); push(); } else if (tree->car->car == (node*)1) { genop_1(s, OP_OCLASS, cursp()); push(); } else { codegen(s, tree->car->car, VAL); } if (tree->cdr->car) { codegen(s, tree->cdr->car, VAL); } else { genop_1(s, OP_LOADNIL, cursp()); push(); } pop(); pop(); idx = new_sym(s, nsym(tree->car->cdr)); genop_2(s, OP_CLASS, cursp(), idx); body = tree->cdr->cdr->car; if (nint(body->cdr->car) == NODE_BEGIN && body->cdr->cdr == NULL) { genop_1(s, OP_LOADNIL, cursp()); } else { idx = scope_body(s, body, val); genop_2(s, OP_EXEC, cursp(), idx); } if (val) { push(); } } break; case NODE_MODULE: { int idx; if (tree->car->car == (node*)0) { genop_1(s, OP_LOADNIL, cursp()); push(); } else if (tree->car->car == (node*)1) { genop_1(s, OP_OCLASS, cursp()); push(); } else { codegen(s, tree->car->car, VAL); } pop(); idx = new_sym(s, nsym(tree->car->cdr)); genop_2(s, OP_MODULE, cursp(), idx); if (nint(tree->cdr->car->cdr->car) == NODE_BEGIN && tree->cdr->car->cdr->cdr == NULL) { genop_1(s, OP_LOADNIL, cursp()); } else { idx = scope_body(s, tree->cdr->car, val); genop_2(s, OP_EXEC, cursp(), idx); } if (val) { push(); } } break; case NODE_SCLASS: { int idx; codegen(s, tree->car, VAL); pop(); genop_1(s, OP_SCLASS, cursp()); if (nint(tree->cdr->car->cdr->car) == NODE_BEGIN && tree->cdr->car->cdr->cdr == NULL) { genop_1(s, OP_LOADNIL, cursp()); } else { idx = scope_body(s, tree->cdr->car, val); genop_2(s, OP_EXEC, cursp(), idx); } if (val) { push(); } } break; case NODE_DEF: { int sym = new_sym(s, nsym(tree->car)); int idx = lambda_body(s, tree->cdr, 0); genop_1(s, OP_TCLASS, cursp()); push(); genop_2(s, OP_METHOD, cursp(), idx); push(); pop(); pop(); genop_2(s, OP_DEF, cursp(), sym); if (val) push(); } break; case NODE_SDEF: { node *recv = tree->car; int sym = new_sym(s, nsym(tree->cdr->car)); int idx = lambda_body(s, tree->cdr->cdr, 0); codegen(s, recv, VAL); pop(); genop_1(s, OP_SCLASS, cursp()); push(); genop_2(s, OP_METHOD, cursp(), idx); pop(); genop_2(s, OP_DEF, cursp(), sym); if (val) push(); } break; case NODE_POSTEXE: codegen(s, tree, NOVAL); break; default: break; } exit: s->rlev = rlev; }
0
210,161
gdImagePtr gdImageRotateInterpolated(const gdImagePtr src, const float angle, int bgcolor) { const int angle_rounded = (int)floor(angle * 100); if (bgcolor < 0 || bgcolor >= gdMaxColors) { return NULL; } /* impact perf a bit, but not that much. Implementation for palette images can be done at a later point. */ if (src->trueColor == 0) { if (bgcolor >= 0) { bgcolor = gdTrueColorAlpha(src->red[bgcolor], src->green[bgcolor], src->blue[bgcolor], src->alpha[bgcolor]); } gdImagePaletteToTrueColor(src); } /* no interpolation needed here */ switch (angle_rounded) { case 9000: return gdImageRotate90(src, 0); case 18000: return gdImageRotate180(src, 0); case 27000: return gdImageRotate270(src, 0); } if (src == NULL || src->interpolation_id < 1 || src->interpolation_id > GD_METHOD_COUNT) { return NULL; } switch (src->interpolation_id) { case GD_NEAREST_NEIGHBOUR: return gdImageRotateNearestNeighbour(src, angle, bgcolor); break; case GD_BILINEAR_FIXED: return gdImageRotateBilinear(src, angle, bgcolor); break; case GD_BICUBIC_FIXED: return gdImageRotateBicubicFixed(src, angle, bgcolor); break; default: return gdImageRotateGeneric(src, angle, bgcolor); } return NULL; }
1
386,593
void DL_Dxf::addTrace(DL_CreationInterface* creationInterface) { DL_TraceData td; for (int k = 0; k < 4; k++) { td.x[k] = getRealValue(10 + k, 0.0); td.y[k] = getRealValue(20 + k, 0.0); td.z[k] = getRealValue(30 + k, 0.0); } creationInterface->addTrace(td); }
0
272,354
digest_get_digest_oid(cms_context *cms) { int i = cms->selected_digest; return digest_params[i].digest_tag; }
0
359,436
DEFUN (clear_ip_bgp_peer_group_in_prefix_filter, clear_ip_bgp_peer_group_in_prefix_filter_cmd, "clear ip bgp peer-group WORD in prefix-filter", CLEAR_STR IP_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Soft reconfig inbound update\n" "Push out prefix-list ORF and do inbound soft reconfig\n") { return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_group, BGP_CLEAR_SOFT_IN_ORF_PREFIX, argv[0]); }
0
412,335
static RzList *relocs(RzBinFile *bf) { rz_return_val_if_fail(bf && bf->o, NULL); QnxObj *qo = bf->o->bin_obj; RzBinReloc *reloc = NULL; RzListIter *it = NULL; RzList *relocs = rz_list_newf(free); if (!relocs) { return NULL; } rz_list_foreach (qo->fixups, it, reloc) { RzBinReloc *copy = RZ_NEW0(RzBinReloc); if (!copy) { break; } copy->vaddr = reloc->vaddr; copy->paddr = reloc->paddr; copy->type = reloc->type; rz_list_append(relocs, copy); } return relocs; }
0
223,398
static void * pcre2_jit_malloc(size_t size, void *allocator_data) { pcre2_memctl *allocator = ((pcre2_memctl*)allocator_data); return allocator->malloc(size, allocator->memory_data); }
0
247,642
TEST_P(SslSocketTest, OverrideRequestedServerName) { envoy::config::listener::v3::Listener listener; envoy::config::listener::v3::FilterChain* filter_chain = listener.add_filter_chains(); envoy::extensions::transport_sockets::tls::v3::DownstreamTlsContext tls_context; envoy::extensions::transport_sockets::tls::v3::TlsCertificate* server_cert = tls_context.mutable_common_tls_context()->add_tls_certificates(); server_cert->mutable_certificate_chain()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns_cert.pem")); server_cert->mutable_private_key()->set_filename(TestEnvironment::substitute( "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns_key.pem")); updateFilterChain(tls_context, *filter_chain); envoy::extensions::transport_sockets::tls::v3::UpstreamTlsContext client; client.set_sni("lyft.com"); Network::TransportSocketOptionsConstSharedPtr transport_socket_options( new Network::TransportSocketOptionsImpl("example.com")); TestUtilOptionsV2 test_options(listener, client, true, GetParam()); testUtilV2(test_options.setExpectedRequestedServerName("example.com") .setTransportSocketOptions(transport_socket_options)); }
0
267,848
vm_op_set_value (ecma_value_t base, /**< base object */ ecma_value_t property, /**< property name */ ecma_value_t value, /**< ecma value */ bool is_strict) /**< strict mode */ { ecma_value_t result = ECMA_VALUE_EMPTY; ecma_object_t *object_p; ecma_string_t *property_p; if (JERRY_UNLIKELY (!ecma_is_value_object (base))) { if (JERRY_UNLIKELY (ecma_is_value_null (base) || ecma_is_value_undefined (base))) { #if JERRY_ERROR_MESSAGES result = ecma_raise_standard_error_with_format (JERRY_ERROR_TYPE, "Cannot set property '%' of %", property, base); #else /* !JERRY_ERROR_MESSAGES */ result = ecma_raise_type_error (NULL); #endif /* JERRY_ERROR_MESSAGES */ ecma_free_value (property); return result; } if (JERRY_UNLIKELY (!ecma_is_value_prop_name (property))) { property_p = ecma_op_to_string (property); ecma_fast_free_value (property); if (JERRY_UNLIKELY (property_p == NULL)) { ecma_free_value (base); return ECMA_VALUE_ERROR; } } else { property_p = ecma_get_prop_name_from_value (property); } ecma_value_t object = ecma_op_to_object (base); JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (object)); object_p = ecma_get_object_from_value (object); ecma_op_ordinary_object_prevent_extensions (object_p); result = ecma_op_object_put_with_receiver (object_p, property_p, value, base, is_strict); ecma_free_value (base); } else { object_p = ecma_get_object_from_value (base); if (JERRY_UNLIKELY (!ecma_is_value_prop_name (property))) { property_p = ecma_op_to_string (property); ecma_fast_free_value (property); if (JERRY_UNLIKELY (property_p == NULL)) { ecma_deref_object (object_p); return ECMA_VALUE_ERROR; } } else { property_p = ecma_get_prop_name_from_value (property); } if (!ecma_is_lexical_environment (object_p)) { result = ecma_op_object_put_with_receiver (object_p, property_p, value, base, is_strict); } else { result = ecma_op_set_mutable_binding (object_p, property_p, value, is_strict); } } ecma_deref_object (object_p); ecma_deref_ecma_string (property_p); return result; } /* vm_op_set_value */
0
448,562
static int bgp_capability_msg_parse(struct peer *peer, uint8_t *pnt, bgp_size_t length) { uint8_t *end; struct capability_mp_data mpc; struct capability_header *hdr; uint8_t action; iana_afi_t pkt_afi; afi_t afi; iana_safi_t pkt_safi; safi_t safi; end = pnt + length; while (pnt < end) { /* We need at least action, capability code and capability * length. */ if (pnt + 3 > end) { zlog_info("%s Capability length error", peer->host); bgp_notify_send(peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_SUBCODE_UNSPECIFIC); return BGP_Stop; } action = *pnt; hdr = (struct capability_header *)(pnt + 1); /* Action value check. */ if (action != CAPABILITY_ACTION_SET && action != CAPABILITY_ACTION_UNSET) { zlog_info("%s Capability Action Value error %d", peer->host, action); bgp_notify_send(peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_SUBCODE_UNSPECIFIC); return BGP_Stop; } if (bgp_debug_neighbor_events(peer)) zlog_debug( "%s CAPABILITY has action: %d, code: %u, length %u", peer->host, action, hdr->code, hdr->length); if (hdr->length < sizeof(struct capability_mp_data)) { zlog_info( "%pBP Capability structure is not properly filled out, expected at least %zu bytes but header length specified is %d", peer, sizeof(struct capability_mp_data), hdr->length); return BGP_Stop; } /* Capability length check. */ if ((pnt + hdr->length + 3) > end) { zlog_info("%s Capability length error", peer->host); bgp_notify_send(peer, BGP_NOTIFY_CEASE, BGP_NOTIFY_SUBCODE_UNSPECIFIC); return BGP_Stop; } /* Fetch structure to the byte stream. */ memcpy(&mpc, pnt + 3, sizeof(struct capability_mp_data)); pnt += hdr->length + 3; /* We know MP Capability Code. */ if (hdr->code == CAPABILITY_CODE_MP) { pkt_afi = ntohs(mpc.afi); pkt_safi = mpc.safi; /* Ignore capability when override-capability is set. */ if (CHECK_FLAG(peer->flags, PEER_FLAG_OVERRIDE_CAPABILITY)) continue; /* Convert AFI, SAFI to internal values. */ if (bgp_map_afi_safi_iana2int(pkt_afi, pkt_safi, &afi, &safi)) { if (bgp_debug_neighbor_events(peer)) zlog_debug( "%s Dynamic Capability MP_EXT afi/safi invalid (%s/%s)", peer->host, iana_afi2str(pkt_afi), iana_safi2str(pkt_safi)); continue; } /* Address family check. */ if (bgp_debug_neighbor_events(peer)) zlog_debug( "%s CAPABILITY has %s MP_EXT CAP for afi/safi: %s/%s", peer->host, action == CAPABILITY_ACTION_SET ? "Advertising" : "Removing", iana_afi2str(pkt_afi), iana_safi2str(pkt_safi)); if (action == CAPABILITY_ACTION_SET) { peer->afc_recv[afi][safi] = 1; if (peer->afc[afi][safi]) { peer->afc_nego[afi][safi] = 1; bgp_announce_route(peer, afi, safi, false); } } else { peer->afc_recv[afi][safi] = 0; peer->afc_nego[afi][safi] = 0; if (peer_active_nego(peer)) bgp_clear_route(peer, afi, safi); else return BGP_Stop; } } else { flog_warn( EC_BGP_UNRECOGNIZED_CAPABILITY, "%s unrecognized capability code: %d - ignored", peer->host, hdr->code); } } /* No FSM action necessary */ return BGP_PACKET_NOOP; }
0
238,811
find_mps_values( int *initc, int *findc, int *backwards, int switchit) { char_u *ptr; ptr = curbuf->b_p_mps; while (*ptr != NUL) { if (has_mbyte) { char_u *prev; if (mb_ptr2char(ptr) == *initc) { if (switchit) { *findc = *initc; *initc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); *backwards = TRUE; } else { *findc = mb_ptr2char(ptr + mb_ptr2len(ptr) + 1); *backwards = FALSE; } return; } prev = ptr; ptr += mb_ptr2len(ptr) + 1; if (mb_ptr2char(ptr) == *initc) { if (switchit) { *findc = *initc; *initc = mb_ptr2char(prev); *backwards = FALSE; } else { *findc = mb_ptr2char(prev); *backwards = TRUE; } return; } ptr += mb_ptr2len(ptr); } else { if (*ptr == *initc) { if (switchit) { *backwards = TRUE; *findc = *initc; *initc = ptr[2]; } else { *backwards = FALSE; *findc = ptr[2]; } return; } ptr += 2; if (*ptr == *initc) { if (switchit) { *backwards = FALSE; *findc = *initc; *initc = ptr[-2]; } else { *backwards = TRUE; *findc = ptr[-2]; } return; } ++ptr; } if (*ptr == ',') ++ptr; } }
0
508,761
int _ma_initialize_data_file(MARIA_SHARE *share, File dfile) { if (share->data_file_type == BLOCK_RECORD) { share->bitmap.block_size= share->base.block_size; share->bitmap.file.file = dfile; return _ma_bitmap_create_first(share); } return 0; }
0
261,216
int MqttClient_Auth(MqttClient *client, MqttAuth* auth) { int rc, len; /* Validate required arguments */ if (client == NULL) { return MQTT_CODE_ERROR_BAD_ARG; } if (auth->stat == MQTT_MSG_BEGIN) { #ifdef WOLFMQTT_MULTITHREAD /* Lock send socket mutex */ rc = wm_SemLock(&client->lockSend); if (rc != 0) { return rc; } #endif /* Encode the authentication packet */ rc = MqttEncode_Auth(client->tx_buf, client->tx_buf_len, auth); #ifdef WOLFMQTT_DEBUG_CLIENT PRINTF("MqttClient_EncodePacket: Len %d, Type %s (%d), ID %d, QoS %d", rc, MqttPacket_TypeDesc(MQTT_PACKET_TYPE_AUTH), MQTT_PACKET_TYPE_AUTH, 0, 0); #endif if (rc <= 0) { #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif return rc; } len = rc; #ifdef WOLFMQTT_MULTITHREAD rc = wm_SemLock(&client->lockClient); if (rc == 0) { /* inform other threads of expected response */ rc = MqttClient_RespList_Add(client, MQTT_PACKET_TYPE_AUTH, 0, &auth->pendResp, auth); wm_SemUnlock(&client->lockClient); } if (rc != 0) { wm_SemUnlock(&client->lockSend); return rc; /* Error locking client */ } #endif /* Send authentication packet */ rc = MqttPacket_Write(client, client->tx_buf, len); #ifdef WOLFMQTT_MULTITHREAD wm_SemUnlock(&client->lockSend); #endif if (rc != len) { #ifdef WOLFMQTT_MULTITHREAD if (wm_SemLock(&client->lockClient) == 0) { MqttClient_RespList_Remove(client, &auth->pendResp); wm_SemUnlock(&client->lockClient); } #endif return rc; } auth->stat = MQTT_MSG_WAIT; } /* Wait for auth packet */ rc = MqttClient_WaitType(client, auth, MQTT_PACKET_TYPE_AUTH, 0, client->cmd_timeout_ms); #ifdef WOLFMQTT_NONBLOCK if (rc == MQTT_CODE_CONTINUE) return rc; #endif #ifdef WOLFMQTT_MULTITHREAD if (wm_SemLock(&client->lockClient) == 0) { MqttClient_RespList_Remove(client, &auth->pendResp); wm_SemUnlock(&client->lockClient); } #endif /* reset state */ auth->stat = MQTT_MSG_BEGIN; return rc; }
0
292,178
int LinkResolver::resolve_virtual_vtable_index(Klass* receiver_klass, const LinkInfo& link_info) { EXCEPTION_MARK; CallInfo info; resolve_virtual_call(info, Handle(), receiver_klass, link_info, /*check_null_or_abstract*/false, THREAD); if (HAS_PENDING_EXCEPTION) { CLEAR_PENDING_EXCEPTION; return Method::invalid_vtable_index; } return info.vtable_index(); }
0
300,774
static void tipc_sk_check_probing_state(struct sock *sk, struct sk_buff_head *list) { struct tipc_sock *tsk = tipc_sk(sk); u32 pnode = tsk_peer_node(tsk); u32 pport = tsk_peer_port(tsk); u32 self = tsk_own_node(tsk); u32 oport = tsk->portid; struct sk_buff *skb; if (tsk->probe_unacked) { tipc_set_sk_state(sk, TIPC_DISCONNECTING); sk->sk_err = ECONNABORTED; tipc_node_remove_conn(sock_net(sk), pnode, pport); sk->sk_state_change(sk); return; } /* Prepare new probe */ skb = tipc_msg_create(CONN_MANAGER, CONN_PROBE, INT_H_SIZE, 0, pnode, self, pport, oport, TIPC_OK); if (skb) __skb_queue_tail(list, skb); tsk->probe_unacked = true; sk_reset_timer(sk, &sk->sk_timer, jiffies + CONN_PROBING_INTV); }
0
442,961
redraw_after_callback(int call_update_screen, int do_message) { ++redrawing_for_callback; if (State == HITRETURN || State == ASKMORE || State == SETWSIZE || State == EXTERNCMD || State == CONFIRM || exmode_active) { if (do_message) repeat_message(); } else if (State & CMDLINE) { // Don't redraw when in prompt_for_number(). if (cmdline_row > 0) { // Redrawing only works when the screen didn't scroll. Don't clear // wildmenu entries. if (msg_scrolled == 0 #ifdef FEAT_WILDMENU && wild_menu_showing == 0 #endif && call_update_screen) update_screen(0); // Redraw in the same position, so that the user can continue // editing the command. redrawcmdline_ex(FALSE); } } else if (State & (NORMAL | INSERT | TERMINAL)) { // keep the command line if possible update_screen(VALID_NO_UPDATE); setcursor(); if (msg_scrolled == 0) { // don't want a hit-enter prompt when something else is displayed msg_didany = FALSE; need_wait_return = FALSE; } } cursor_on(); #ifdef FEAT_GUI if (gui.in_use && !gui_mch_is_blink_off()) // Don't update the cursor when it is blinking and off to avoid // flicker. out_flush_cursor(FALSE, FALSE); else #endif out_flush(); --redrawing_for_callback; }
0
252,407
int mz_compress(unsigned char *pDest, mz_ulong *pDest_len, const unsigned char *pSource, mz_ulong source_len) { return mz_compress2(pDest, pDest_len, pSource, source_len, MZ_DEFAULT_COMPRESSION); }
0
430,439
static void ovs_nla_free_set_action(const struct nlattr *a) { const struct nlattr *ovs_key = nla_data(a); struct ovs_tunnel_info *ovs_tun; switch (nla_type(ovs_key)) { case OVS_KEY_ATTR_TUNNEL_INFO: ovs_tun = nla_data(ovs_key); dst_release((struct dst_entry *)ovs_tun->tun_dst); break; } }
0
481,272
static int mlx5_fpga_conn_create_mkey(struct mlx5_core_dev *mdev, u32 pdn, struct mlx5_core_mkey *mkey) { int inlen = MLX5_ST_SZ_BYTES(create_mkey_in); void *mkc; u32 *in; int err; in = kvzalloc(inlen, GFP_KERNEL); if (!in) return -ENOMEM; mkc = MLX5_ADDR_OF(create_mkey_in, in, memory_key_mkey_entry); MLX5_SET(mkc, mkc, access_mode_1_0, MLX5_MKC_ACCESS_MODE_PA); MLX5_SET(mkc, mkc, lw, 1); MLX5_SET(mkc, mkc, lr, 1); MLX5_SET(mkc, mkc, pd, pdn); MLX5_SET(mkc, mkc, length64, 1); MLX5_SET(mkc, mkc, qpn, 0xffffff); err = mlx5_core_create_mkey(mdev, mkey, in, inlen); kvfree(in); return err; }
0
502,694
long SSL_CTX_get_timeout(const SSL_CTX *s) { if (s == NULL) return (0); return (s->session_timeout); }
0
445,897
ecryption_copy_ready_cb (GObject *source_object, GAsyncResult *result, gpointer user_data) { EncryptData *edata = user_data; FrWindow *window = edata->window; GError *error = NULL; _fr_window_stop_activity_mode (window); close_progress_dialog (window, FALSE); if (! g_file_copy_finish (G_FILE (source_object), result, &error)) { _handle_archive_operation_error (window, edata->new_archive, FR_ACTION_CREATING_NEW_ARCHIVE, error, NULL, NULL); fr_window_stop_batch (window); g_error_free (error); return; } fr_window_set_password (window, edata->password); fr_window_set_encrypt_header (window, edata->encrypt_header); window->priv->reload_archive = TRUE; fr_window_exec_next_batch_action (window); }
0
257,006
static void *route4_get(struct tcf_proto *tp, u32 handle) { struct route4_head *head = rtnl_dereference(tp->root); struct route4_bucket *b; struct route4_filter *f; unsigned int h1, h2; h1 = to_hash(handle); if (h1 > 256) return NULL; h2 = from_hash(handle >> 16); if (h2 > 32) return NULL; b = rtnl_dereference(head->table[h1]); if (b) { for (f = rtnl_dereference(b->ht[h2]); f; f = rtnl_dereference(f->next)) if (f->handle == handle) return f; } return NULL; }
0
229,221
cql_server::connection::process_batch(uint16_t stream, request_reader in, service::client_state& client_state, service_permit permit, tracing::trace_state_ptr trace_state) { ++_server._stats.batch_requests; return process(stream, in, client_state, permit, std::move(trace_state), process_batch_internal); }
0
513,154
static SHOW_COMP_OPTION plugin_status(const LEX_STRING *name, int type) { SHOW_COMP_OPTION rc= SHOW_OPTION_NO; struct st_plugin_int *plugin; DBUG_ENTER("plugin_is_ready"); mysql_mutex_lock(&LOCK_plugin); if ((plugin= plugin_find_internal(name, type))) { rc= SHOW_OPTION_DISABLED; if (plugin->state == PLUGIN_IS_READY) rc= SHOW_OPTION_YES; } mysql_mutex_unlock(&LOCK_plugin); DBUG_RETURN(rc); }
0
256,389
int blk_rq_map_user_iov(struct request_queue *q, struct request *rq, struct rq_map_data *map_data, const struct iov_iter *iter, gfp_t gfp_mask) { bool copy = false; unsigned long align = q->dma_pad_mask | queue_dma_alignment(q); struct bio *bio = NULL; struct iov_iter i; int ret = -EINVAL; if (!iter_is_iovec(iter)) goto fail; if (map_data) copy = true; else if (blk_queue_may_bounce(q)) copy = true; else if (iov_iter_alignment(iter) & align) copy = true; else if (queue_virt_boundary(q)) copy = queue_virt_boundary(q) & iov_iter_gap_alignment(iter); i = *iter; do { if (copy) ret = bio_copy_user_iov(rq, map_data, &i, gfp_mask); else ret = bio_map_user_iov(rq, &i, gfp_mask); if (ret) goto unmap_rq; if (!bio) bio = rq->bio; } while (iov_iter_count(&i)); return 0; unmap_rq: blk_rq_unmap_user(bio); fail: rq->bio = NULL; return ret; }
0
328,981
R_API RBinJavaAttrInfo *r_bin_java_read_next_attr(RBinJavaObj *bin, const ut64 offset, const ut8 *buf, const ut64 buf_len) { const ut8 *a_buf = offset + buf; ut8 attr_idx_len = 6; if (offset + 6 > buf_len) { eprintf ("[X] r_bin_java: Error unable to parse remainder of classfile in Attribute offset " "(0x%"PFMT64x ") > len of remaining bytes (0x%"PFMT64x ").\n", offset, buf_len); return NULL; } // ut16 attr_idx, ut32 length of attr. ut32 sz = R_BIN_JAVA_UINT (a_buf, 2) + attr_idx_len; // r_bin_java_read_int (bin, buf_offset+2) + attr_idx_len; if (sz + offset > buf_len) { eprintf ("[X] r_bin_java: Error unable to parse remainder of classfile in Attribute len " "(0x%x) + offset (0x%"PFMT64x ") exceeds length of buffer (0x%"PFMT64x ").\n", sz, offset, buf_len); return NULL; } // when reading the attr bytes, need to also // include the initial 6 bytes, which // are not included in the attribute length // , // sz, buf_offset, buf_offset+sz); ut8 *buffer = r_bin_java_get_attr_buf (bin, sz, offset, buf, buf_len); RBinJavaAttrInfo *attr = NULL; // printf ("%d %d %d\n", sz, buf_len, offset); if (offset < buf_len) { attr = r_bin_java_read_next_attr_from_buffer (bin, buffer, buf_len - offset, offset); free (buffer); if (!attr) { return NULL; } attr->size = sz; } else { free (buffer); eprintf ("IS OOB\n"); } return attr; }
0
463,184
static int find_desc_store(annotate_state_t *state, const char *name, const annotate_entrydesc_t **descp) { int scope = state->which; const ptrarray_t *descs; const annotate_entrydesc_t *db_entry; annotate_entrydesc_t *desc; int i; if (scope == ANNOTATION_SCOPE_SERVER) { descs = &server_entries; db_entry = &server_db_entry; } else if (scope == ANNOTATION_SCOPE_MAILBOX) { descs = &mailbox_entries; db_entry = &mailbox_db_entry; } else if (scope == ANNOTATION_SCOPE_MESSAGE) { descs = &message_entries; db_entry = &message_db_entry; } else { syslog(LOG_ERR, "IOERROR: unknown scope in find_desc_store %d", scope); return IMAP_INTERNAL; } /* check for DAV annotations */ if (state->mailbox && (state->mailbox->mbtype & MBTYPES_DAV) && !strncmp(name, DAV_ANNOT_NS, strlen(DAV_ANNOT_NS))) { *descp = db_entry; return 0; } /* check known IMAP annotations */ for (i = 0 ; i < descs->count ; i++) { desc = descs->data[i]; if (strcmp(name, desc->name)) continue; if (!desc->set) { /* read-only annotation */ return IMAP_PERMISSION_DENIED; } *descp = desc; return 0; } /* unknown annotation */ if (!config_getswitch(IMAPOPT_ANNOTATION_ALLOW_UNDEFINED)) return IMAP_PERMISSION_DENIED; /* check for /flags and /vendor/cmu */ if (scope == ANNOTATION_SCOPE_MESSAGE && !strncmp(name, "/flags/", 7)) return IMAP_PERMISSION_DENIED; if (!strncmp(name, IMAP_ANNOT_NS, strlen(IMAP_ANNOT_NS))) return IMAP_PERMISSION_DENIED; *descp = db_entry; return 0; }
0
512,302
Item_date_literal(THD *thd, const Date *ltime) :Item_temporal_literal(thd), cached_time(*ltime) { DBUG_ASSERT(cached_time.is_valid_date()); max_length= MAX_DATE_WIDTH; /* If date has zero month or day, it can return NULL in case of NO_ZERO_DATE or NO_ZERO_IN_DATE. If date is `February 30`, it can return NULL in case if no ALLOW_INVALID_DATES is set. We can't set null_value using the current sql_mode here in constructor, because sql_mode can change in case of prepared statements between PREPARE and EXECUTE. Here we only set maybe_null to true if the value has such anomalies. Later (during execution time), if maybe_null is true, then the value will be checked per row, according to the execution time sql_mode. The check_date() below call should cover all cases mentioned. */ maybe_null= cached_time.check_date(TIME_NO_ZERO_DATE | TIME_NO_ZERO_IN_DATE); }
0
437,334
print_indent_tree(FILE* f, Node* node, int indent) { int i; NodeType type; UChar* p; int add = 3; Indent(f, indent); if (IS_NULL(node)) { fprintf(f, "ERROR: null node!!!\n"); exit (0); } type = NODE_TYPE(node); switch (type) { case NODE_LIST: case NODE_ALT: if (type == NODE_LIST) fprintf(f, "<list:%p>\n", node); else fprintf(f, "<alt:%p>\n", node); print_indent_tree(f, NODE_CAR(node), indent + add); while (IS_NOT_NULL(node = NODE_CDR(node))) { if (NODE_TYPE(node) != type) { fprintf(f, "ERROR: list/alt right is not a cons. %d\n", NODE_TYPE(node)); exit(0); } print_indent_tree(f, NODE_CAR(node), indent + add); } break; case NODE_STRING: fprintf(f, "<string%s:%p>", (NODE_STRING_IS_RAW(node) ? "-raw" : ""), node); for (p = STR_(node)->s; p < STR_(node)->end; p++) { if (*p >= 0x20 && *p < 0x7f) fputc(*p, f); else { fprintf(f, " 0x%02x", *p); } } break; case NODE_CCLASS: fprintf(f, "<cclass:%p>", node); if (IS_NCCLASS_NOT(CCLASS_(node))) fputs(" not", f); if (CCLASS_(node)->mbuf) { BBuf* bbuf = CCLASS_(node)->mbuf; for (i = 0; i < bbuf->used; i++) { if (i > 0) fprintf(f, ","); fprintf(f, "%0x", bbuf->p[i]); } } break; case NODE_CTYPE: fprintf(f, "<ctype:%p> ", node); switch (CTYPE_(node)->ctype) { case CTYPE_ANYCHAR: fprintf(f, "<anychar:%p>", node); break; case ONIGENC_CTYPE_WORD: if (CTYPE_(node)->not != 0) fputs("not word", f); else fputs("word", f); if (CTYPE_(node)->ascii_mode != 0) fputs(" (ascii)", f); break; default: fprintf(f, "ERROR: undefined ctype.\n"); exit(0); } break; case NODE_ANCHOR: fprintf(f, "<anchor:%p> ", node); switch (ANCHOR_(node)->type) { case ANCHOR_BEGIN_BUF: fputs("begin buf", f); break; case ANCHOR_END_BUF: fputs("end buf", f); break; case ANCHOR_BEGIN_LINE: fputs("begin line", f); break; case ANCHOR_END_LINE: fputs("end line", f); break; case ANCHOR_SEMI_END_BUF: fputs("semi end buf", f); break; case ANCHOR_BEGIN_POSITION: fputs("begin position", f); break; case ANCHOR_WORD_BOUNDARY: fputs("word boundary", f); break; case ANCHOR_NO_WORD_BOUNDARY: fputs("not word boundary", f); break; #ifdef USE_WORD_BEGIN_END case ANCHOR_WORD_BEGIN: fputs("word begin", f); break; case ANCHOR_WORD_END: fputs("word end", f); break; #endif case ANCHOR_EXTENDED_GRAPHEME_CLUSTER_BOUNDARY: fputs("extended-grapheme-cluster boundary", f); break; case ANCHOR_NO_EXTENDED_GRAPHEME_CLUSTER_BOUNDARY: fputs("no-extended-grapheme-cluster boundary", f); break; case ANCHOR_PREC_READ: fprintf(f, "prec read\n"); print_indent_tree(f, NODE_BODY(node), indent + add); break; case ANCHOR_PREC_READ_NOT: fprintf(f, "prec read not\n"); print_indent_tree(f, NODE_BODY(node), indent + add); break; case ANCHOR_LOOK_BEHIND: fprintf(f, "look behind\n"); print_indent_tree(f, NODE_BODY(node), indent + add); break; case ANCHOR_LOOK_BEHIND_NOT: fprintf(f, "look behind not\n"); print_indent_tree(f, NODE_BODY(node), indent + add); break; default: fprintf(f, "ERROR: undefined anchor type.\n"); break; } break; case NODE_BACKREF: { int* p; BackRefNode* br = BACKREF_(node); p = BACKREFS_P(br); fprintf(f, "<backref%s:%p>", NODE_IS_CHECKER(node) ? "-checker" : "", node); for (i = 0; i < br->back_num; i++) { if (i > 0) fputs(", ", f); fprintf(f, "%d", p[i]); } } break; #ifdef USE_CALL case NODE_CALL: { CallNode* cn = CALL_(node); fprintf(f, "<call:%p>", node); p_string(f, cn->name_end - cn->name, cn->name); } break; #endif case NODE_QUANT: fprintf(f, "<quantifier:%p>{%d,%d}%s\n", node, QUANT_(node)->lower, QUANT_(node)->upper, (QUANT_(node)->greedy ? "" : "?")); print_indent_tree(f, NODE_BODY(node), indent + add); break; case NODE_ENCLOSURE: fprintf(f, "<enclosure:%p> ", node); switch (ENCLOSURE_(node)->type) { case ENCLOSURE_OPTION: fprintf(f, "option:%d", ENCLOSURE_(node)->o.options); break; case ENCLOSURE_MEMORY: fprintf(f, "memory:%d", ENCLOSURE_(node)->m.regnum); break; case ENCLOSURE_STOP_BACKTRACK: fprintf(f, "stop-bt"); break; default: break; } fprintf(f, "\n"); print_indent_tree(f, NODE_BODY(node), indent + add); break; case NODE_GIMMICK: fprintf(f, "<gimmick:%p> ", node); switch (GIMMICK_(node)->type) { case GIMMICK_FAIL: fprintf(f, "fail"); break; case GIMMICK_KEEP: fprintf(f, "keep:%d", GIMMICK_(node)->id); break; case GIMMICK_SAVE: fprintf(f, "save:%d:%d", GIMMICK_(node)->detail_type, GIMMICK_(node)->id); break; case GIMMICK_UPDATE_VAR: fprintf(f, "update_var:%d:%d", GIMMICK_(node)->detail_type, GIMMICK_(node)->id); break; #ifdef USE_CALLOUT case GIMMICK_CALLOUT: switch (GIMMICK_(node)->detail_type) { case ONIG_CALLOUT_OF_CONTENTS: fprintf(f, "callout:contents:%d", GIMMICK_(node)->num); break; case ONIG_CALLOUT_OF_NAME: fprintf(f, "callout:name:%d:%d", GIMMICK_(node)->id, GIMMICK_(node)->num); break; } #endif } break; default: fprintf(f, "print_indent_tree: undefined node type %d\n", NODE_TYPE(node)); break; } if (type != NODE_LIST && type != NODE_ALT && type != NODE_QUANT && type != NODE_ENCLOSURE) fprintf(f, "\n"); fflush(f); }
0
233,826
int fmtutil_find_zip_eocd(deark *c, dbuf *f, i64 *foundpos) { u32 sig; u8 *buf = NULL; int retval = 0; i64 buf_offset; i64 buf_size; i64 i; *foundpos = 0; if(f->len < 22) goto done; // End-of-central-dir record usually starts 22 bytes from EOF. Try that first. sig = (u32)dbuf_getu32le(f, f->len - 22); if(sig == 0x06054b50U) { *foundpos = f->len - 22; retval = 1; goto done; } // Search for the signature. // The end-of-central-directory record could theoretically appear anywhere // in the file. We'll follow Info-Zip/UnZip's lead and search the last 66000 // bytes. #define MAX_ZIP_EOCD_SEARCH 66000 buf_size = f->len; if(buf_size > MAX_ZIP_EOCD_SEARCH) buf_size = MAX_ZIP_EOCD_SEARCH; buf = de_malloc(c, buf_size); buf_offset = f->len - buf_size; dbuf_read(f, buf, buf_offset, buf_size); for(i=buf_size-22; i>=0; i--) { if(buf[i]=='P' && buf[i+1]=='K' && buf[i+2]==5 && buf[i+3]==6) { *foundpos = buf_offset + i; retval = 1; goto done; } } done: de_free(c, buf); return retval; }
0
274,696
callbacks_show_sidepane_toggled (GtkMenuItem *menuitem, gpointer user_data) { gtk_widget_set_visible (user_data, GTK_CHECK_MENU_ITEM(menuitem)->active); }
0
244,291
GF_Err prft_box_read(GF_Box *s,GF_BitStream *bs) { GF_ProducerReferenceTimeBox *ptr = (GF_ProducerReferenceTimeBox *) s; ISOM_DECREASE_SIZE(ptr, 12); ptr->refTrackID = gf_bs_read_u32(bs); ptr->ntp = gf_bs_read_u64(bs); if (ptr->version==0) { ISOM_DECREASE_SIZE(ptr, 4); ptr->timestamp = gf_bs_read_u32(bs); } else { ISOM_DECREASE_SIZE(ptr, 8); ptr->timestamp = gf_bs_read_u64(bs); } return GF_OK; }
0
293,945
ins_try_si(int c) { pos_T *pos, old_pos; char_u *ptr; int i; int temp; // do some very smart indenting when entering '{' or '}' if (((did_si || can_si_back) && c == '{') || (can_si && c == '}')) { // for '}' set indent equal to indent of line containing matching '{' if (c == '}' && (pos = findmatch(NULL, '{')) != NULL) { old_pos = curwin->w_cursor; // If the matching '{' has a ')' immediately before it (ignoring // white-space), then line up with the start of the line // containing the matching '(' if there is one. This handles the // case where an "if (..\n..) {" statement continues over multiple // lines -- webb ptr = ml_get(pos->lnum); i = pos->col; if (i > 0) // skip blanks before '{' while (--i > 0 && VIM_ISWHITE(ptr[i])) ; curwin->w_cursor.lnum = pos->lnum; curwin->w_cursor.col = i; if (ptr[i] == ')' && (pos = findmatch(NULL, '(')) != NULL) curwin->w_cursor = *pos; i = get_indent(); curwin->w_cursor = old_pos; if (State & VREPLACE_FLAG) change_indent(INDENT_SET, i, FALSE, NUL, TRUE); else (void)set_indent(i, SIN_CHANGED); } else if (curwin->w_cursor.col > 0) { // when inserting '{' after "O" reduce indent, but not // more than indent of previous line temp = TRUE; if (c == '{' && can_si_back && curwin->w_cursor.lnum > 1) { old_pos = curwin->w_cursor; i = get_indent(); while (curwin->w_cursor.lnum > 1) { ptr = skipwhite(ml_get(--(curwin->w_cursor.lnum))); // ignore empty lines and lines starting with '#'. if (*ptr != '#' && *ptr != NUL) break; } if (get_indent() >= i) temp = FALSE; curwin->w_cursor = old_pos; } if (temp) shift_line(TRUE, FALSE, 1, TRUE); } } // set indent of '#' always to 0 if (curwin->w_cursor.col > 0 && can_si && c == '#') { // remember current indent for next line old_indent = get_indent(); (void)set_indent(0, SIN_CHANGED); } // Adjust ai_col, the char at this position can be deleted. if (ai_col > curwin->w_cursor.col) ai_col = curwin->w_cursor.col; }
0
225,899
GF_Box *sdtp_box_new() { ISOM_DECL_BOX_ALLOC(GF_SampleDependencyTypeBox, GF_ISOM_BOX_TYPE_SDTP); return (GF_Box *)tmp;
0
221,640
CstrBroadcastableOpLowering::CstrBroadcastableOpLowering(MLIRContext* ctx) : Base(ctx) {}
0
301,358
static ssize_t vfswrap_listxattr(struct vfs_handle_struct *handle, const char *path, char *list, size_t size) { return listxattr(path, list, size); }
0
513,319
fix_inner_refs(THD *thd, List<Item> &all_fields, SELECT_LEX *select, Ref_ptr_array ref_pointer_array) { Item_outer_ref *ref; /* Mark the references from the inner_refs_list that are occurred in the group by expressions. Those references will contain direct references to the referred fields. The markers are set in the found_in_group_by field of the references from the list. */ List_iterator_fast <Item_outer_ref> ref_it(select->inner_refs_list); for (ORDER *group= select->join->group_list; group; group= group->next) { (*group->item)->walk(&Item::check_inner_refs_processor, TRUE, &ref_it); } while ((ref= ref_it++)) { bool direct_ref= false; Item *item= ref->outer_ref; Item **item_ref= ref->ref; Item_ref *new_ref; /* TODO: this field item already might be present in the select list. In this case instead of adding new field item we could use an existing one. The change will lead to less operations for copying fields, smaller temporary tables and less data passed through filesort. */ if (!ref_pointer_array.is_null() && !ref->found_in_select_list) { int el= all_fields.elements; ref_pointer_array[el]= item; /* Add the field item to the select list of the current select. */ all_fields.push_front(item, thd->mem_root); /* If it's needed reset each Item_ref item that refers this field with a new reference taken from ref_pointer_array. */ item_ref= &ref_pointer_array[el]; } if (ref->in_sum_func) { Item_sum *sum_func; if (ref->in_sum_func->nest_level > select->nest_level) direct_ref= TRUE; else { for (sum_func= ref->in_sum_func; sum_func && sum_func->aggr_level >= select->nest_level; sum_func= sum_func->in_sum_func) { if (sum_func->aggr_level == select->nest_level) { direct_ref= TRUE; break; } } } } else if (ref->found_in_group_by) direct_ref= TRUE; new_ref= direct_ref ? new (thd->mem_root) Item_direct_ref(thd, ref->context, item_ref, ref->table_name, ref->field_name, ref->alias_name_used) : new (thd->mem_root) Item_ref(thd, ref->context, item_ref, ref->table_name, ref->field_name, ref->alias_name_used); if (!new_ref) return TRUE; ref->outer_ref= new_ref; ref->ref= &ref->outer_ref; if (!ref->fixed && ref->fix_fields(thd, 0)) return TRUE; thd->lex->used_tables|= item->used_tables(); thd->lex->current_select->select_list_tables|= item->used_tables(); } return false; }
0
376,318
camel_gpg_context_get_always_trust (CamelGpgContext *context) { g_return_val_if_fail (CAMEL_IS_GPG_CONTEXT (context), FALSE); return context->priv->always_trust; }
0
253,548
static loff_t smb3_llseek(struct file *file, struct cifs_tcon *tcon, loff_t offset, int whence) { struct cifsFileInfo *wrcfile, *cfile = file->private_data; struct cifsInodeInfo *cifsi; struct inode *inode; int rc = 0; struct file_allocated_range_buffer in_data, *out_data = NULL; u32 out_data_len; unsigned int xid; if (whence != SEEK_HOLE && whence != SEEK_DATA) return generic_file_llseek(file, offset, whence); inode = d_inode(cfile->dentry); cifsi = CIFS_I(inode); if (offset < 0 || offset >= i_size_read(inode)) return -ENXIO; xid = get_xid(); /* * We need to be sure that all dirty pages are written as they * might fill holes on the server. * Note that we also MUST flush any written pages since at least * some servers (Windows2016) will not reflect recent writes in * QUERY_ALLOCATED_RANGES until SMB2_flush is called. */ wrcfile = find_writable_file(cifsi, FIND_WR_ANY); if (wrcfile) { filemap_write_and_wait(inode->i_mapping); smb2_flush_file(xid, tcon, &wrcfile->fid); cifsFileInfo_put(wrcfile); } if (!(cifsi->cifsAttrs & FILE_ATTRIBUTE_SPARSE_FILE)) { if (whence == SEEK_HOLE) offset = i_size_read(inode); goto lseek_exit; } in_data.file_offset = cpu_to_le64(offset); in_data.length = cpu_to_le64(i_size_read(inode)); rc = SMB2_ioctl(xid, tcon, cfile->fid.persistent_fid, cfile->fid.volatile_fid, FSCTL_QUERY_ALLOCATED_RANGES, true, (char *)&in_data, sizeof(in_data), sizeof(struct file_allocated_range_buffer), (char **)&out_data, &out_data_len); if (rc == -E2BIG) rc = 0; if (rc) goto lseek_exit; if (whence == SEEK_HOLE && out_data_len == 0) goto lseek_exit; if (whence == SEEK_DATA && out_data_len == 0) { rc = -ENXIO; goto lseek_exit; } if (out_data_len < sizeof(struct file_allocated_range_buffer)) { rc = -EINVAL; goto lseek_exit; } if (whence == SEEK_DATA) { offset = le64_to_cpu(out_data->file_offset); goto lseek_exit; } if (offset < le64_to_cpu(out_data->file_offset)) goto lseek_exit; offset = le64_to_cpu(out_data->file_offset) + le64_to_cpu(out_data->length); lseek_exit: free_xid(xid); kfree(out_data); if (!rc) return vfs_setpos(file, offset, inode->i_sb->s_maxbytes); else return rc; }
0
247,738
TEST_P(SslSocketTest, RevokedIntermediateCertificateCRLInTrustedCA) { // This should succeed, since the crl chain is complete. // // Trust chain contains: // - Root authority certificate (i.e., ca_cert.pem) // - Root authority certificate revocation list (i.e., ca_cert.crl) // - Intermediate authority certificate (i.e., intermediate_ca_cert.pem) // - Intermediate authority certificate revocation list (i.e., intermediate_ca_cert.crl) const std::string complete_server_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_key.pem" validation_context: trusted_ca: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/intermediate_ca_cert_chain_with_crl_chain.pem" )EOF"; // This should fail, since the crl chain is incomplete. // // Trust chain contains: // - Root authority certificate (i.e., ca_cert.pem) // - Intermediate authority certificate (i.e., intermediate_ca_cert.pem) // - Intermediate authority certificate revocation list (i.e., intermediate_ca_cert.crl) // // Trust chain omits: // - Root authority certificate revocation list (i.e., ca_cert.crl) const std::string incomplete_server_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/unittest_key.pem" validation_context: trusted_ca: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/intermediate_ca_cert_chain_with_crl.pem" )EOF"; // This should fail, since the certificate has been revoked. const std::string revoked_client_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns3_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns3_key.pem" )EOF"; // This should succeed, since the certificate has not been revoked. const std::string unrevoked_client_ctx_yaml = R"EOF( common_tls_context: tls_certificates: certificate_chain: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns4_cert.pem" private_key: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/san_dns4_key.pem" )EOF"; // Ensure that incomplete crl chains fail with revoked certificates. TestUtilOptions incomplete_revoked_test_options(revoked_client_ctx_yaml, incomplete_server_ctx_yaml, false, GetParam()); testUtil(incomplete_revoked_test_options.setExpectedServerStats("ssl.fail_verify_error") .setExpectedVerifyErrorCode(X509_V_ERR_CERT_REVOKED)); // Ensure that incomplete crl chains fail with unrevoked certificates. TestUtilOptions incomplete_unrevoked_test_options(unrevoked_client_ctx_yaml, incomplete_server_ctx_yaml, false, GetParam()); testUtil(incomplete_unrevoked_test_options.setExpectedServerStats("ssl.fail_verify_error") .setExpectedVerifyErrorCode(X509_V_ERR_UNABLE_TO_GET_CRL)); // Ensure that complete crl chains fail with revoked certificates. TestUtilOptions complete_revoked_test_options(revoked_client_ctx_yaml, complete_server_ctx_yaml, false, GetParam()); testUtil(complete_revoked_test_options.setExpectedServerStats("ssl.fail_verify_error") .setExpectedVerifyErrorCode(X509_V_ERR_CERT_REVOKED)); // Ensure that complete crl chains succeed with unrevoked certificates. TestUtilOptions complete_unrevoked_test_options(unrevoked_client_ctx_yaml, complete_server_ctx_yaml, true, GetParam()); testUtil(complete_unrevoked_test_options.setExpectedSerialNumber(TEST_SAN_DNS4_CERT_SERIAL)); }
0
369,126
static void io_req_map_rw(struct io_kiocb *req, const struct iovec *iovec, const struct iovec *fast_iov, struct iov_iter *iter) { struct io_async_rw *rw = req->async_data; memcpy(&rw->s.iter, iter, sizeof(*iter)); rw->free_iovec = iovec; rw->bytes_done = 0; /* can only be fixed buffers, no need to do anything */ if (iov_iter_is_bvec(iter)) return; if (!iovec) { unsigned iov_off = 0; rw->s.iter.iov = rw->s.fast_iov; if (iter->iov != fast_iov) { iov_off = iter->iov - fast_iov; rw->s.iter.iov += iov_off; } if (rw->s.fast_iov != fast_iov) memcpy(rw->s.fast_iov + iov_off, fast_iov + iov_off, sizeof(struct iovec) * iter->nr_segs); } else { req->flags |= REQ_F_NEED_CLEANUP; } }
0
359,630
DEFUN (clear_bgp_peer_group_soft_out, clear_bgp_peer_group_soft_out_cmd, "clear bgp peer-group WORD soft out", CLEAR_STR BGP_STR "Clear all members of peer-group\n" "BGP peer-group name\n" "Soft reconfig\n" "Soft reconfig outbound update\n") { return bgp_clear_vty (vty, NULL, AFI_IP6, SAFI_UNICAST, clear_group, BGP_CLEAR_SOFT_OUT, argv[0]); }
0
309,887
drv_getsize(TERMINAL_CONTROL_BLOCK * TCB, int *l, int *c) { AssertTCB(); assert(l != 0 && c != 0); *l = lines; *c = columns; return OK; }
0
309,983
_nc_mouse_wrap(SCREEN *sp) /* release mouse -- called by endwin() before shellout/exit */ { TR(MY_TRACE, ("_nc_mouse_wrap() called")); switch (sp->_mouse_type) { case M_XTERM: if (sp->_mouse_mask) mouse_activate(sp, FALSE); break; #if USE_GPM_SUPPORT /* GPM: pass all mouse events to next client */ case M_GPM: if (sp->_mouse_mask) mouse_activate(sp, FALSE); break; #endif #if USE_SYSMOUSE case M_SYSMOUSE: mouse_activate(sp, FALSE); break; #endif #ifdef USE_TERM_DRIVER case M_TERM_DRIVER: mouse_activate(sp, FALSE); break; #endif case M_NONE: break; } }
0
398,520
static int init_die(RzBinDwarfDie *die, ut64 abbr_code, ut64 attr_count) { if (!die) { return -1; } if (attr_count) { die->attr_values = calloc(sizeof(RzBinDwarfAttrValue), attr_count); if (!die->attr_values) { return -1; } } else { die->attr_values = NULL; } die->abbrev_code = abbr_code; die->capacity = attr_count; die->count = 0; return 0; }
0
261,986
static int bundle_remove_conn(struct connectbundle *bundle, struct connectdata *conn) { struct Curl_llist_element *curr; curr = bundle->conn_list.head; while(curr) { if(curr->ptr == conn) { Curl_llist_remove(&bundle->conn_list, curr, NULL); bundle->num_connections--; conn->bundle = NULL; return 1; /* we removed a handle */ } curr = curr->next; } DEBUGASSERT(0); return 0; }
0
253,723
static void ccp_prepare_data(struct ccp_data *src, struct ccp_data *dst, struct ccp_op *op, unsigned int block_size, bool blocksize_op) { unsigned int sg_src_len, sg_dst_len, op_len; /* The CCP can only DMA from/to one address each per operation. This * requires that we find the smallest DMA area between the source * and destination. The resulting len values will always be <= UINT_MAX * because the dma length is an unsigned int. */ sg_src_len = sg_dma_len(src->sg_wa.dma_sg) - src->sg_wa.sg_used; sg_src_len = min_t(u64, src->sg_wa.bytes_left, sg_src_len); if (dst) { sg_dst_len = sg_dma_len(dst->sg_wa.dma_sg) - dst->sg_wa.sg_used; sg_dst_len = min_t(u64, src->sg_wa.bytes_left, sg_dst_len); op_len = min(sg_src_len, sg_dst_len); } else { op_len = sg_src_len; } /* The data operation length will be at least block_size in length * or the smaller of available sg room remaining for the source or * the destination */ op_len = max(op_len, block_size); /* Unless we have to buffer data, there's no reason to wait */ op->soc = 0; if (sg_src_len < block_size) { /* Not enough data in the sg element, so it * needs to be buffered into a blocksize chunk */ int cp_len = ccp_fill_queue_buf(src); op->soc = 1; op->src.u.dma.address = src->dm_wa.dma.address; op->src.u.dma.offset = 0; op->src.u.dma.length = (blocksize_op) ? block_size : cp_len; } else { /* Enough data in the sg element, but we need to * adjust for any previously copied data */ op->src.u.dma.address = sg_dma_address(src->sg_wa.dma_sg); op->src.u.dma.offset = src->sg_wa.sg_used; op->src.u.dma.length = op_len & ~(block_size - 1); ccp_update_sg_workarea(&src->sg_wa, op->src.u.dma.length); } if (dst) { if (sg_dst_len < block_size) { /* Not enough room in the sg element or we're on the * last piece of data (when using padding), so the * output needs to be buffered into a blocksize chunk */ op->soc = 1; op->dst.u.dma.address = dst->dm_wa.dma.address; op->dst.u.dma.offset = 0; op->dst.u.dma.length = op->src.u.dma.length; } else { /* Enough room in the sg element, but we need to * adjust for any previously used area */ op->dst.u.dma.address = sg_dma_address(dst->sg_wa.dma_sg); op->dst.u.dma.offset = dst->sg_wa.sg_used; op->dst.u.dma.length = op->src.u.dma.length; } } }
0
309,991
_nc_captoinfo_leaks(void) { if (my_string != 0) { FreeAndNull(my_string); } my_length = 0; }
0
238,449
static void mark_pkt_end(struct bpf_verifier_state *vstate, int regn, bool range_open) { struct bpf_func_state *state = vstate->frame[vstate->curframe]; struct bpf_reg_state *reg = &state->regs[regn]; if (reg->type != PTR_TO_PACKET) /* PTR_TO_PACKET_META is not supported yet */ return; /* The 'reg' is pkt > pkt_end or pkt >= pkt_end. * How far beyond pkt_end it goes is unknown. * if (!range_open) it's the case of pkt >= pkt_end * if (range_open) it's the case of pkt > pkt_end * hence this pointer is at least 1 byte bigger than pkt_end */ if (range_open) reg->range = BEYOND_PKT_END; else reg->range = AT_PKT_END; }
0
267,922
void ogs_nas_5gs_imsi_to_bcd( ogs_nas_5gs_mobile_identity_t *mobile_identity, char *imsi_bcd) { ogs_nas_5gs_mobile_identity_suci_t *mobile_identity_suci = NULL; ogs_plmn_id_t plmn_id; char tmp[OGS_MAX_IMSI_BCD_LEN+1]; char *p, *last; ogs_assert(mobile_identity); ogs_assert(imsi_bcd); p = imsi_bcd; last = imsi_bcd + OGS_MAX_IMSI_BCD_LEN + 1; mobile_identity_suci = (ogs_nas_5gs_mobile_identity_suci_t *)mobile_identity->buffer; ogs_assert(mobile_identity_suci); ogs_nas_to_plmn_id(&plmn_id, &mobile_identity_suci->nas_plmn_id); if (ogs_plmn_id_mnc_len(&plmn_id) == 2) p = ogs_slprintf(p, last, "%03d%02d", ogs_plmn_id_mcc(&plmn_id), ogs_plmn_id_mnc(&plmn_id)); else p = ogs_slprintf(p, last, "%03d%03d", ogs_plmn_id_mcc(&plmn_id), ogs_plmn_id_mnc(&plmn_id)); ogs_assert(mobile_identity->length > 8); ogs_buffer_to_bcd(mobile_identity_suci->scheme_output, mobile_identity->length - 8, tmp); p = ogs_slprintf(p, last, "%s", tmp); }
0
317,335
static int selinux_sem_semctl(struct kern_ipc_perm *sma, int cmd) { int err; u32 perms; switch (cmd) { case IPC_INFO: case SEM_INFO: /* No specific object, just general system-wide information. */ return avc_has_perm(&selinux_state, current_sid(), SECINITSID_KERNEL, SECCLASS_SYSTEM, SYSTEM__IPC_INFO, NULL); case GETPID: case GETNCNT: case GETZCNT: perms = SEM__GETATTR; break; case GETVAL: case GETALL: perms = SEM__READ; break; case SETVAL: case SETALL: perms = SEM__WRITE; break; case IPC_RMID: perms = SEM__DESTROY; break; case IPC_SET: perms = SEM__SETATTR; break; case IPC_STAT: case SEM_STAT: case SEM_STAT_ANY: perms = SEM__GETATTR | SEM__ASSOCIATE; break; default: return 0; } err = ipc_has_perm(sma, perms); return err; }
0
328,856
R_API void r_bin_java_print_enclosing_methods_attr_summary(RBinJavaAttrInfo *attr) { if (!attr) { eprintf ("Attempting to print an invalid RBinJavaAttrInfo *Deperecated.\n"); return; } printf ("Enclosing Method Attribute Information:\n"); printf (" Attribute Offset: 0x%08"PFMT64x "\n", attr->file_offset); printf (" Attribute Name Index: %d (%s)\n", attr->name_idx, attr->name); printf (" Attribute Length: %d\n", attr->length); printf (" Class Info Index : 0x%02x\n", attr->info.enclosing_method_attr.class_idx); printf (" Method Name and Type Index : 0x%02x\n", attr->info.enclosing_method_attr.method_idx); printf (" Class Name : %s\n", attr->info.enclosing_method_attr.class_name); printf (" Method Name and Desc : %s %s\n", attr->info.enclosing_method_attr.method_name, attr->info.enclosing_method_attr.method_descriptor); }
0
359,672
DEFUN (neighbor_remote_as, neighbor_remote_as_cmd, NEIGHBOR_CMD2 "remote-as <1-65535>", NEIGHBOR_STR NEIGHBOR_ADDR_STR2 "Specify a BGP neighbor\n" AS_STR) { return peer_remote_as_vty (vty, argv[0], argv[1], AFI_IP, SAFI_UNICAST); }
0
231,740
bool validateAndUpdateSourceToken( QuicServerConnectionState& conn, std::vector<folly::IPAddress> sourceAddresses) { DCHECK(conn.peerAddress.isInitialized()); bool foundMatch = false; for (int ii = sourceAddresses.size() - 1; ii >= 0; --ii) { // TODO T33014230 subnet matching if (conn.peerAddress.getIPAddress() == sourceAddresses[ii]) { foundMatch = true; // If peer address is found in the token, move the element to the end // of vector to increase its favorability. sourceAddresses.erase(sourceAddresses.begin() + ii); sourceAddresses.push_back(conn.peerAddress.getIPAddress()); } } conn.sourceTokenMatching = foundMatch; bool acceptZeroRtt = foundMatch; if (!foundMatch) { // Add peer address to token for next resumption if (sourceAddresses.size() >= kMaxNumTokenSourceAddresses) { sourceAddresses.erase(sourceAddresses.begin()); } sourceAddresses.push_back(conn.peerAddress.getIPAddress()); switch (conn.transportSettings.zeroRttSourceTokenMatchingPolicy) { case ZeroRttSourceTokenMatchingPolicy::REJECT_IF_NO_EXACT_MATCH: acceptZeroRtt = false; break; case ZeroRttSourceTokenMatchingPolicy::LIMIT_IF_NO_EXACT_MATCH: acceptZeroRtt = true; conn.writableBytesLimit = conn.transportSettings.limitedCwndInMss * conn.udpSendPacketLen; break; } } // Save the source token so that it can be written to client via NST later conn.tokenSourceAddresses = std::move(sourceAddresses); return acceptZeroRtt; }
0
359,333
DEFUN (clear_ip_bgp_all_soft_out, clear_ip_bgp_all_soft_out_cmd, "clear ip bgp * soft out", CLEAR_STR IP_STR BGP_STR "Clear all peers\n" "Soft reconfig\n" "Soft reconfig outbound update\n") { if (argc == 1) return bgp_clear_vty (vty, argv[0], AFI_IP, SAFI_UNICAST, clear_all, BGP_CLEAR_SOFT_OUT, NULL); return bgp_clear_vty (vty, NULL, AFI_IP, SAFI_UNICAST, clear_all, BGP_CLEAR_SOFT_OUT, NULL); }
0
482,496
lou_free(void) { TranslationTableChainEntry *currentEntry; TranslationTableChainEntry *previousEntry; lou_logEnd(); if (translationTableChain != NULL) { currentEntry = translationTableChain; while (currentEntry) { freeTranslationTable(currentEntry->table); previousEntry = currentEntry; currentEntry = currentEntry->next; free(previousEntry); } translationTableChain = NULL; } if (typebuf != NULL) free(typebuf); typebuf = NULL; if (wordBuffer != NULL) free(wordBuffer); wordBuffer = NULL; if (emphasisBuffer != NULL) free(emphasisBuffer); emphasisBuffer = NULL; sizeTypebuf = 0; if (destSpacing != NULL) free(destSpacing); destSpacing = NULL; sizeDestSpacing = 0; { int k; for (k = 0; k < MAXPASSBUF; k++) { if (passbuf[k] != NULL) free(passbuf[k]); passbuf[k] = NULL; sizePassbuf[k] = 0; } } if (posMapping1 != NULL) free(posMapping1); posMapping1 = NULL; sizePosMapping1 = 0; if (posMapping2 != NULL) free(posMapping2); posMapping2 = NULL; sizePosMapping2 = 0; if (posMapping3 != NULL) free(posMapping3); posMapping3 = NULL; sizePosMapping3 = 0; opcodeLengths[0] = 0; }
0
256,454
JANET_CORE_FN(cfun_array_pop, "(array/pop arr)", "Remove the last element of the array and return it. If the array is empty, will return nil. Modifies " "the input array.") { janet_fixarity(argc, 1); JanetArray *array = janet_getarray(argv, 0); return janet_array_pop(array); }
0
204,534
stl_remove_degenerate(stl_file *stl, int facet) { int edge1; int edge2; int edge3; int neighbor1; int neighbor2; int neighbor3; int vnot1; int vnot2; int vnot3; if (stl->error) return; if( !memcmp(&stl->facet_start[facet].vertex[0], &stl->facet_start[facet].vertex[1], sizeof(stl_vertex)) && !memcmp(&stl->facet_start[facet].vertex[1], &stl->facet_start[facet].vertex[2], sizeof(stl_vertex))) { /* all 3 vertices are equal. Just remove the facet. I don't think*/ /* this is really possible, but just in case... */ printf("removing a facet in stl_remove_degenerate\n"); stl_remove_facet(stl, facet); return; } if(!memcmp(&stl->facet_start[facet].vertex[0], &stl->facet_start[facet].vertex[1], sizeof(stl_vertex))) { edge1 = 1; edge2 = 2; edge3 = 0; } else if(!memcmp(&stl->facet_start[facet].vertex[1], &stl->facet_start[facet].vertex[2], sizeof(stl_vertex))) { edge1 = 0; edge2 = 2; edge3 = 1; } else if(!memcmp(&stl->facet_start[facet].vertex[2], &stl->facet_start[facet].vertex[0], sizeof(stl_vertex))) { edge1 = 0; edge2 = 1; edge3 = 2; } else { /* No degenerate. Function shouldn't have been called. */ return; } neighbor1 = stl->neighbors_start[facet].neighbor[edge1]; neighbor2 = stl->neighbors_start[facet].neighbor[edge2]; if(neighbor1 == -1) { stl_update_connects_remove_1(stl, neighbor2); } if(neighbor2 == -1) { stl_update_connects_remove_1(stl, neighbor1); } neighbor3 = stl->neighbors_start[facet].neighbor[edge3]; vnot1 = stl->neighbors_start[facet].which_vertex_not[edge1]; vnot2 = stl->neighbors_start[facet].which_vertex_not[edge2]; vnot3 = stl->neighbors_start[facet].which_vertex_not[edge3]; if(neighbor1 != -1){ stl->neighbors_start[neighbor1].neighbor[(vnot1 + 1) % 3] = neighbor2; stl->neighbors_start[neighbor1].which_vertex_not[(vnot1 + 1) % 3] = vnot2; } if(neighbor2 != -1){ stl->neighbors_start[neighbor2].neighbor[(vnot2 + 1) % 3] = neighbor1; stl->neighbors_start[neighbor2].which_vertex_not[(vnot2 + 1) % 3] = vnot1; } stl_remove_facet(stl, facet); if(neighbor3 != -1) { stl_update_connects_remove_1(stl, neighbor3); stl->neighbors_start[neighbor3].neighbor[(vnot3 + 1) % 3] = -1; } }
1
241,070
static int format_peers(char **pdata, unsigned int *len) { struct booth_site *s; char *data, *cp; char time_str[64]; int i, alloc; *pdata = NULL; *len = 0; alloc = booth_conf->site_count * (BOOTH_NAME_LEN + 256); data = malloc(alloc); if (!data) return -ENOMEM; cp = data; foreach_node(i, s) { if (s == local) continue; strftime(time_str, sizeof(time_str), "%F %T", localtime(&s->last_recv)); cp += snprintf(cp, alloc - (cp - data), "%-12s %s, last recv: %s\n", type_to_string(s->type), s->addr_string, time_str); cp += snprintf(cp, alloc - (cp - data), "\tSent pkts:%u error:%u resends:%u\n", s->sent_cnt, s->sent_err_cnt, s->resend_cnt); cp += snprintf(cp, alloc - (cp - data), "\tRecv pkts:%u error:%u authfail:%u invalid:%u\n\n", s->recv_cnt, s->recv_err_cnt, s->sec_cnt, s->invalid_cnt); if (alloc - (cp - data) <= 0) { free(data); return -ENOMEM; } } *pdata = data; *len = cp - data; return 0; }
0
231,670
TEST_F(QuicServerTransportTest, IdleTimeoutExpired) { server->idleTimeout().timeoutExpired(); EXPECT_FALSE(server->idleTimeout().isScheduled()); EXPECT_TRUE(server->isDraining()); EXPECT_TRUE(server->isClosed()); auto serverReadCodec = makeClientEncryptedCodec(); EXPECT_FALSE(verifyFramePresent( serverWrites, *serverReadCodec, QuicFrame::Type::ConnectionCloseFrame)); EXPECT_FALSE(verifyFramePresent( serverWrites, *serverReadCodec, QuicFrame::Type::ConnectionCloseFrame)); }
0
436,068
static void __io_commit_cqring_flush(struct io_ring_ctx *ctx) { if (ctx->off_timeout_used) io_flush_timeouts(ctx); if (ctx->drain_active) io_queue_deferred(ctx); }
0
259,532
CURLUcode curl_url_get(CURLU *u, CURLUPart what, char **part, unsigned int flags) { char *ptr; CURLUcode ifmissing = CURLUE_UNKNOWN_PART; char portbuf[7]; bool urldecode = (flags & CURLU_URLDECODE)?1:0; bool urlencode = (flags & CURLU_URLENCODE)?1:0; bool plusdecode = FALSE; (void)flags; if(!u) return CURLUE_BAD_HANDLE; if(!part) return CURLUE_BAD_PARTPOINTER; *part = NULL; switch(what) { case CURLUPART_SCHEME: ptr = u->scheme; ifmissing = CURLUE_NO_SCHEME; urldecode = FALSE; /* never for schemes */ break; case CURLUPART_USER: ptr = u->user; ifmissing = CURLUE_NO_USER; break; case CURLUPART_PASSWORD: ptr = u->password; ifmissing = CURLUE_NO_PASSWORD; break; case CURLUPART_OPTIONS: ptr = u->options; ifmissing = CURLUE_NO_OPTIONS; break; case CURLUPART_HOST: ptr = u->host; ifmissing = CURLUE_NO_HOST; break; case CURLUPART_ZONEID: ptr = u->zoneid; ifmissing = CURLUE_NO_ZONEID; break; case CURLUPART_PORT: ptr = u->port; ifmissing = CURLUE_NO_PORT; urldecode = FALSE; /* never for port */ if(!ptr && (flags & CURLU_DEFAULT_PORT) && u->scheme) { /* there's no stored port number, but asked to deliver a default one for the scheme */ const struct Curl_handler *h = Curl_builtin_scheme(u->scheme); if(h) { msnprintf(portbuf, sizeof(portbuf), "%u", h->defport); ptr = portbuf; } } else if(ptr && u->scheme) { /* there is a stored port number, but ask to inhibit if it matches the default one for the scheme */ const struct Curl_handler *h = Curl_builtin_scheme(u->scheme); if(h && (h->defport == u->portnum) && (flags & CURLU_NO_DEFAULT_PORT)) ptr = NULL; } break; case CURLUPART_PATH: ptr = u->path; if(!ptr) { ptr = u->path = strdup("/"); if(!u->path) return CURLUE_OUT_OF_MEMORY; } break; case CURLUPART_QUERY: ptr = u->query; ifmissing = CURLUE_NO_QUERY; plusdecode = urldecode; break; case CURLUPART_FRAGMENT: ptr = u->fragment; ifmissing = CURLUE_NO_FRAGMENT; break; case CURLUPART_URL: { char *url; char *scheme; char *options = u->options; char *port = u->port; char *allochost = NULL; if(u->scheme && strcasecompare("file", u->scheme)) { url = aprintf("file://%s%s%s", u->path, u->fragment? "#": "", u->fragment? u->fragment : ""); } else if(!u->host) return CURLUE_NO_HOST; else { const struct Curl_handler *h = NULL; if(u->scheme) scheme = u->scheme; else if(flags & CURLU_DEFAULT_SCHEME) scheme = (char *) DEFAULT_SCHEME; else return CURLUE_NO_SCHEME; h = Curl_builtin_scheme(scheme); if(!port && (flags & CURLU_DEFAULT_PORT)) { /* there's no stored port number, but asked to deliver a default one for the scheme */ if(h) { msnprintf(portbuf, sizeof(portbuf), "%u", h->defport); port = portbuf; } } else if(port) { /* there is a stored port number, but asked to inhibit if it matches the default one for the scheme */ if(h && (h->defport == u->portnum) && (flags & CURLU_NO_DEFAULT_PORT)) port = NULL; } if(h && !(h->flags & PROTOPT_URLOPTIONS)) options = NULL; if(u->host[0] == '[') { if(u->zoneid) { /* make it '[ host %25 zoneid ]' */ size_t hostlen = strlen(u->host); size_t alen = hostlen + 3 + strlen(u->zoneid) + 1; allochost = malloc(alen); if(!allochost) return CURLUE_OUT_OF_MEMORY; memcpy(allochost, u->host, hostlen - 1); msnprintf(&allochost[hostlen - 1], alen - hostlen + 1, "%%25%s]", u->zoneid); } } else if(urlencode) { allochost = curl_easy_escape(NULL, u->host, 0); if(!allochost) return CURLUE_OUT_OF_MEMORY; } else { /* only encode '%' in output host name */ char *host = u->host; size_t pcount = 0; /* first, count number of percents present in the name */ while(*host) { if(*host == '%') pcount++; host++; } /* if there were percents, encode the host name */ if(pcount) { size_t hostlen = strlen(u->host); size_t alen = hostlen + 2 * pcount + 1; char *o = allochost = malloc(alen); if(!allochost) return CURLUE_OUT_OF_MEMORY; host = u->host; while(*host) { if(*host == '%') { memcpy(o, "%25", 3); o += 3; host++; continue; } *o++ = *host++; } *o = '\0'; } } url = aprintf("%s://%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", scheme, u->user ? u->user : "", u->password ? ":": "", u->password ? u->password : "", options ? ";" : "", options ? options : "", (u->user || u->password || options) ? "@": "", allochost ? allochost : u->host, port ? ":": "", port ? port : "", (u->path && (u->path[0] != '/')) ? "/": "", u->path ? u->path : "/", (u->query && u->query[0]) ? "?": "", (u->query && u->query[0]) ? u->query : "", u->fragment? "#": "", u->fragment? u->fragment : ""); free(allochost); } if(!url) return CURLUE_OUT_OF_MEMORY; *part = url; return CURLUE_OK; } default: ptr = NULL; break; } if(ptr) { *part = strdup(ptr); if(!*part) return CURLUE_OUT_OF_MEMORY; if(plusdecode) { /* convert + to space */ char *plus; for(plus = *part; *plus; ++plus) { if(*plus == '+') *plus = ' '; } } if(urldecode) { char *decoded; size_t dlen; /* this unconditional rejection of control bytes is documented API behavior */ CURLcode res = Curl_urldecode(*part, 0, &decoded, &dlen, REJECT_CTRL); free(*part); if(res) { *part = NULL; return CURLUE_URLDECODE; } *part = decoded; } return CURLUE_OK; } else return ifmissing; }
0
463,180
EXPORTED int annotate_state_set_mailbox_mbe(annotate_state_t *state, const mbentry_t *mbentry) { return annotate_state_set_scope(state, mbentry, NULL, 0); }
0
508,353
close_mysql_tables(THD *thd) { if (! thd->in_sub_stmt) trans_commit_stmt(thd); close_thread_tables(thd); thd->release_transactional_locks(); }
0
498,128
static void site_url(const char *page, const char *search, const char *sort, int ofs, int always_root) { char *delim = "?"; if (always_root || page) html_attr(cgit_rooturl()); else { char *currenturl = cgit_currenturl(); html_attr(currenturl); free(currenturl); } if (page) { htmlf("?p=%s", page); delim = "&amp;"; } if (search) { html(delim); html("q="); html_attr(search); delim = "&amp;"; } if (sort) { html(delim); html("s="); html_attr(sort); delim = "&amp;"; } if (ofs) { html(delim); htmlf("ofs=%d", ofs); } }
0
417,105
mp_sint32 PlayerGeneric::getSampleShift() const { if (mixer) return mixer->getSampleShift(); return sampleShift; }
0
333,075
has_state_with_pos( nfa_list_T *l, // runtime state list nfa_state_T *state, // state to update regsubs_T *subs, // pointers to subexpressions nfa_pim_T *pim) // postponed match or NULL { nfa_thread_T *thread; int i; for (i = 0; i < l->n; ++i) { thread = &l->t[i]; if (thread->state->id == state->id && sub_equal(&thread->subs.norm, &subs->norm) #ifdef FEAT_SYN_HL && (!rex.nfa_has_zsubexpr || sub_equal(&thread->subs.synt, &subs->synt)) #endif && pim_equal(&thread->pim, pim)) return TRUE; } return FALSE; }
0
413,677
static int fcn_print_legacy(RCore *core, RAnalFunction *fcn) { RListIter *iter; RAnalRef *refi; RList *refs, *xrefs; int ebbs = 0; char *name = r_core_anal_fcn_name (core, fcn); r_cons_printf ("#\noffset: 0x%08"PFMT64x"\nname: %s\nsize: %"PFMT64u, fcn->addr, name, r_anal_function_linear_size (fcn)); r_cons_printf ("\nis-pure: %s", r_str_bool (r_anal_function_purity (fcn))); r_cons_printf ("\nrealsz: %" PFMT64d, r_anal_function_realsize (fcn)); r_cons_printf ("\nstackframe: %d", fcn->maxstack); if (fcn->cc) { r_cons_printf ("\ncall-convention: %s", fcn->cc); } r_cons_printf ("\ncyclomatic-cost: %d", r_anal_function_cost (fcn)); r_cons_printf ("\ncyclomatic-complexity: %d", r_anal_function_complexity (fcn)); r_cons_printf ("\nbits: %d", fcn->bits); r_cons_printf ("\ntype: %s", r_anal_functiontype_tostring (fcn->type)); if (fcn->type == R_ANAL_FCN_TYPE_FCN || fcn->type == R_ANAL_FCN_TYPE_SYM) { r_cons_printf (" [%s]", fcn->diff->type == R_ANAL_DIFF_TYPE_MATCH?"MATCH": fcn->diff->type == R_ANAL_DIFF_TYPE_UNMATCH?"UNMATCH":"NEW"); } r_cons_printf ("\nnum-bbs: %d", r_list_length (fcn->bbs)); r_cons_printf ("\nedges: %d", r_anal_function_count_edges (fcn, &ebbs)); r_cons_printf ("\nend-bbs: %d", ebbs); r_cons_printf ("\ncall-refs:"); int outdegree = 0; refs = r_anal_function_get_refs (fcn); r_list_foreach (refs, iter, refi) { if (refi->type == R_ANAL_REF_TYPE_CALL) { outdegree++; } if (refi->type == R_ANAL_REF_TYPE_CODE || refi->type == R_ANAL_REF_TYPE_CALL) { r_cons_printf (" 0x%08"PFMT64x" %c", refi->addr, refi->type == R_ANAL_REF_TYPE_CALL?'C':'J'); } } r_cons_printf ("\ndata-refs:"); r_list_foreach (refs, iter, refi) { // global or local? if (refi->type == R_ANAL_REF_TYPE_DATA) { r_cons_printf (" 0x%08"PFMT64x, refi->addr); } } r_list_free (refs); int indegree = 0; r_cons_printf ("\ncode-xrefs:"); xrefs = r_anal_function_get_xrefs (fcn); r_list_foreach (xrefs, iter, refi) { if (refi->type == R_ANAL_REF_TYPE_CODE || refi->type == R_ANAL_REF_TYPE_CALL) { indegree++; r_cons_printf (" 0x%08"PFMT64x" %c", refi->addr, refi->type == R_ANAL_REF_TYPE_CALL?'C':'J'); } } r_cons_printf ("\nnoreturn: %s", r_str_bool (fcn->is_noreturn)); r_cons_printf ("\nin-degree: %d", indegree); r_cons_printf ("\nout-degree: %d", outdegree); r_cons_printf ("\ndata-xrefs:"); r_list_foreach (xrefs, iter, refi) { if (refi->type == R_ANAL_REF_TYPE_DATA) { r_cons_printf (" 0x%08"PFMT64x, refi->addr); } } r_list_free (xrefs); if (fcn->type == R_ANAL_FCN_TYPE_FCN || fcn->type == R_ANAL_FCN_TYPE_SYM) { int args_count = r_anal_var_count_args (fcn); int var_count = r_anal_var_count_locals (fcn); r_cons_printf ("\nlocals: %d\nargs: %d\n", var_count, args_count); r_anal_var_list_show (core->anal, fcn, 'b', 0, NULL); r_anal_var_list_show (core->anal, fcn, 's', 0, NULL); r_anal_var_list_show (core->anal, fcn, 'r', 0, NULL); r_cons_printf ("diff: type: %s", fcn->diff->type == R_ANAL_DIFF_TYPE_MATCH?"match": fcn->diff->type == R_ANAL_DIFF_TYPE_UNMATCH?"unmatch":"new"); if (fcn->diff->addr != -1) { r_cons_printf ("addr: 0x%"PFMT64x, fcn->diff->addr); } if (fcn->diff->name) { r_cons_printf ("function: %s", fcn->diff->name); } } free (name); // traced if (core->dbg->trace->enabled) { is_fcn_traced (core->dbg->trace, fcn); } return 0; }
0
333,551
gdImagePtr gdImageRotateBicubicFixed(gdImagePtr src, const float degrees, const int bgColor) { const float _angle = (float)((- degrees / 180.0f) * M_PI); const int src_w = gdImageSX(src); const int src_h = gdImageSY(src); const unsigned int new_width = abs((int)(src_w*cos(_angle))) + abs((int)(src_h*sin(_angle) + 0.5f)); const unsigned int new_height = abs((int)(src_w*sin(_angle))) + abs((int)(src_h*cos(_angle) + 0.5f)); const gdFixed f_0_5 = gd_ftofx(0.5f); const gdFixed f_H = gd_itofx(src_h/2); const gdFixed f_W = gd_itofx(src_w/2); const gdFixed f_cos = gd_ftofx(cos(-_angle)); const gdFixed f_sin = gd_ftofx(sin(-_angle)); const gdFixed f_1 = gd_itofx(1); const gdFixed f_2 = gd_itofx(2); const gdFixed f_4 = gd_itofx(4); const gdFixed f_6 = gd_itofx(6); const gdFixed f_gama = gd_ftofx(1.04f); unsigned int dst_offset_x; unsigned int dst_offset_y = 0; unsigned int i; gdImagePtr dst; dst = gdImageCreateTrueColor(new_width, new_height); if (dst == NULL) { return NULL; } dst->saveAlphaFlag = 1; for (i=0; i < new_height; i++) { unsigned int j; dst_offset_x = 0; for (j=0; j < new_width; j++) { const gdFixed f_i = gd_itofx((int)i - (int)new_height/2); const gdFixed f_j = gd_itofx((int)j - (int)new_width/2); const gdFixed f_m = gd_mulfx(f_j,f_sin) + gd_mulfx(f_i,f_cos) + f_0_5 + f_H; const gdFixed f_n = gd_mulfx(f_j,f_cos) - gd_mulfx(f_i,f_sin) + f_0_5 + f_W; const int m = gd_fxtoi(f_m); const int n = gd_fxtoi(f_n); if ((m > 0) && (m < src_h - 1) && (n > 0) && (n < src_w-1)) { const gdFixed f_f = f_m - gd_itofx(m); const gdFixed f_g = f_n - gd_itofx(n); unsigned int src_offset_x[16], src_offset_y[16]; unsigned char red, green, blue, alpha; gdFixed f_red=0, f_green=0, f_blue=0, f_alpha=0; int k; if ((m < 1) || (n < 1)) { src_offset_x[0] = n; src_offset_y[0] = m; } else { src_offset_x[0] = n - 1; src_offset_y[0] = m; } if (m < 1) { src_offset_x[1] = n; src_offset_y[1] = m; } else { src_offset_x[1] = n; src_offset_y[1] = m ; } if ((m < 1) || (n >= src_w-1)) { src_offset_x[2] = - 1; src_offset_y[2] = - 1; } else { src_offset_x[2] = n + 1; src_offset_y[2] = m ; } if ((m < 1) || (n >= src_w-2)) { src_offset_x[3] = - 1; src_offset_y[3] = - 1; } else { src_offset_x[3] = n + 1 + 1; src_offset_y[3] = m ; } if (n < 1) { src_offset_x[4] = - 1; src_offset_y[4] = - 1; } else { src_offset_x[4] = n - 1; src_offset_y[4] = m; } src_offset_x[5] = n; src_offset_y[5] = m; if (n >= src_w-1) { src_offset_x[6] = - 1; src_offset_y[6] = - 1; } else { src_offset_x[6] = n + 1; src_offset_y[6] = m; } if (n >= src_w-2) { src_offset_x[7] = - 1; src_offset_y[7] = - 1; } else { src_offset_x[7] = n + 1 + 1; src_offset_y[7] = m; } if ((m >= src_h-1) || (n < 1)) { src_offset_x[8] = - 1; src_offset_y[8] = - 1; } else { src_offset_x[8] = n - 1; src_offset_y[8] = m; } if (m >= src_h-1) { src_offset_x[8] = - 1; src_offset_y[8] = - 1; } else { src_offset_x[9] = n; src_offset_y[9] = m; } if ((m >= src_h-1) || (n >= src_w-1)) { src_offset_x[10] = - 1; src_offset_y[10] = - 1; } else { src_offset_x[10] = n + 1; src_offset_y[10] = m; } if ((m >= src_h-1) || (n >= src_w-2)) { src_offset_x[11] = - 1; src_offset_y[11] = - 1; } else { src_offset_x[11] = n + 1 + 1; src_offset_y[11] = m; } if ((m >= src_h-2) || (n < 1)) { src_offset_x[12] = - 1; src_offset_y[12] = - 1; } else { src_offset_x[12] = n - 1; src_offset_y[12] = m; } if (m >= src_h-2) { src_offset_x[13] = - 1; src_offset_y[13] = - 1; } else { src_offset_x[13] = n; src_offset_y[13] = m; } if ((m >= src_h-2) || (n >= src_w - 1)) { src_offset_x[14] = - 1; src_offset_y[14] = - 1; } else { src_offset_x[14] = n + 1; src_offset_y[14] = m; } if ((m >= src_h-2) || (n >= src_w-2)) { src_offset_x[15] = - 1; src_offset_y[15] = - 1; } else { src_offset_x[15] = n + 1 + 1; src_offset_y[15] = m; } for (k=-1; k<3; k++) { const gdFixed f = gd_itofx(k)-f_f; const gdFixed f_fm1 = f - f_1; const gdFixed f_fp1 = f + f_1; const gdFixed f_fp2 = f + f_2; gdFixed f_a = 0, f_b = 0,f_c = 0, f_d = 0; gdFixed f_RY; int l; if (f_fp2 > 0) { f_a = gd_mulfx(f_fp2,gd_mulfx(f_fp2,f_fp2)); } if (f_fp1 > 0) { f_b = gd_mulfx(f_fp1,gd_mulfx(f_fp1,f_fp1)); } if (f > 0) { f_c = gd_mulfx(f,gd_mulfx(f,f)); } if (f_fm1 > 0) { f_d = gd_mulfx(f_fm1,gd_mulfx(f_fm1,f_fm1)); } f_RY = gd_divfx((f_a-gd_mulfx(f_4,f_b)+gd_mulfx(f_6,f_c)-gd_mulfx(f_4,f_d)),f_6); for (l=-1; l< 3; l++) { const gdFixed f = gd_itofx(l) - f_g; const gdFixed f_fm1 = f - f_1; const gdFixed f_fp1 = f + f_1; const gdFixed f_fp2 = f + f_2; gdFixed f_a = 0, f_b = 0, f_c = 0, f_d = 0; gdFixed f_RX, f_R; const int _k = ((k + 1) * 4) + (l + 1); register gdFixed f_rs, f_gs, f_bs, f_as; register int c; if (f_fp2 > 0) { f_a = gd_mulfx(f_fp2,gd_mulfx(f_fp2,f_fp2)); } if (f_fp1 > 0) { f_b = gd_mulfx(f_fp1,gd_mulfx(f_fp1,f_fp1)); } if (f > 0) { f_c = gd_mulfx(f,gd_mulfx(f,f)); } if (f_fm1 > 0) { f_d = gd_mulfx(f_fm1,gd_mulfx(f_fm1,f_fm1)); } f_RX = gd_divfx((f_a - gd_mulfx(f_4, f_b) + gd_mulfx(f_6, f_c) - gd_mulfx(f_4, f_d)), f_6); f_R = gd_mulfx(f_RY, f_RX); if ((src_offset_x[_k] <= 0) || (src_offset_y[_k] <= 0) || (src_offset_y[_k] >= src_h) || (src_offset_x[_k] >= src_w)) { c = bgColor; } else if ((src_offset_x[_k] <= 1) || (src_offset_y[_k] <= 1) || (src_offset_y[_k] >= (int)src_h - 1) || (src_offset_x[_k] >= (int)src_w - 1)) { gdFixed f_127 = gd_itofx(127); c = src->tpixels[src_offset_y[_k]][src_offset_x[_k]]; c = c | (( (int) (gd_fxtof(gd_mulfx(f_R, f_127)) + 50.5f)) << 24); c = _color_blend(bgColor, c); } else { c = src->tpixels[src_offset_y[_k]][src_offset_x[_k]]; } f_rs = gd_itofx(gdTrueColorGetRed(c)); f_gs = gd_itofx(gdTrueColorGetGreen(c)); f_bs = gd_itofx(gdTrueColorGetBlue(c)); f_as = gd_itofx(gdTrueColorGetAlpha(c)); f_red += gd_mulfx(f_rs, f_R); f_green += gd_mulfx(f_gs, f_R); f_blue += gd_mulfx(f_bs, f_R); f_alpha += gd_mulfx(f_as, f_R); } } red = (unsigned char) CLAMP(gd_fxtoi(gd_mulfx(f_red, f_gama)), 0, 255); green = (unsigned char) CLAMP(gd_fxtoi(gd_mulfx(f_green, f_gama)), 0, 255); blue = (unsigned char) CLAMP(gd_fxtoi(gd_mulfx(f_blue, f_gama)), 0, 255); alpha = (unsigned char) CLAMP(gd_fxtoi(gd_mulfx(f_alpha, f_gama)), 0, 127); dst->tpixels[dst_offset_y][dst_offset_x] = gdTrueColorAlpha(red, green, blue, alpha); } else { dst->tpixels[dst_offset_y][dst_offset_x] = bgColor; } dst_offset_x++; } dst_offset_y++; } return dst; }
0
204,814
static void sixpack_close(struct tty_struct *tty) { struct sixpack *sp; write_lock_irq(&disc_data_lock); sp = tty->disc_data; tty->disc_data = NULL; write_unlock_irq(&disc_data_lock); if (!sp) return; /* * We have now ensured that nobody can start using ap from now on, but * we have to wait for all existing users to finish. */ if (!refcount_dec_and_test(&sp->refcnt)) wait_for_completion(&sp->dead); /* We must stop the queue to avoid potentially scribbling * on the free buffers. The sp->dead completion is not sufficient * to protect us from sp->xbuff access. */ netif_stop_queue(sp->dev); del_timer_sync(&sp->tx_t); del_timer_sync(&sp->resync_t); unregister_netdev(sp->dev); /* Free all 6pack frame buffers after unreg. */ kfree(sp->rbuff); kfree(sp->xbuff); free_netdev(sp->dev); }
1
233,814
const char *fmtutil_get_windows_charset_name(u8 cs) { struct csname_struct { u8 id; const char *name; }; static const struct csname_struct csname_arr[] = { {0x00, "ANSI"}, {0x01, "default"}, {0x02, "symbol"}, {0x4d, "Mac"}, {0x80, "Shift-JIS"}, {0x81, "Hangul"}, {0x82, "Johab"}, {0x86, "GB2312"}, {0x88, "BIG5"}, {0xa1, "Greek"}, {0xa2, "Turkish"}, {0xa3, "Vietnamese"}, {0xb1, "Hebrew"}, {0xb2, "Arabic"}, {0xba, "Baltic"}, {0xcc, "Russian"}, {0xde, "Thai"}, {0xee, "Eastern Europe"}, {0xff, "OEM"} }; size_t i; for(i=0; i<DE_ARRAYCOUNT(csname_arr); i++) { if(cs==csname_arr[i].id) return csname_arr[i].name; } return "?"; }
0
233,894
Serializes given variables and adds them to packet given by packet_id */ PHP_FUNCTION(wddx_add_vars) { int num_args, i; zval *args = NULL; zval *packet_id; wddx_packet *packet = NULL; if (zend_parse_parameters(ZEND_NUM_ARGS(), "r+", &packet_id, &args, &num_args) == FAILURE) { return; } if ((packet = (wddx_packet *)zend_fetch_resource(Z_RES_P(packet_id), "WDDX packet ID", le_wddx)) == NULL) { RETURN_FALSE; } for (i=0; i<num_args; i++) { zval *arg; if (!Z_ISREF(args[i])) { arg = &args[i]; } else { arg = Z_REFVAL(args[i]); } if (Z_TYPE_P(arg) != IS_ARRAY && Z_TYPE_P(arg) != IS_OBJECT) { convert_to_string_ex(arg); } php_wddx_add_var(packet, arg); } RETURN_TRUE;
0
384,131
raptor_xml_writer_comment_counted(raptor_xml_writer* xml_writer, const unsigned char *s, unsigned int len) { XML_WRITER_FLUSH_CLOSE_BRACKET(xml_writer); raptor_xml_writer_raw_counted(xml_writer, (const unsigned char*)"<!-- ", 5); raptor_xml_writer_cdata_counted(xml_writer, s, len); raptor_xml_writer_raw_counted(xml_writer, (const unsigned char*)" -->", 4); }
0
198,013
void Compute(OpKernelContext* context) override { // Checks what we're remapping and inverts the relevant remapping Tensors to // be maps with key = old ID, value = new ID. std::unordered_map<int64_t, int64_t> old_row_to_new_row_map; std::vector<bool> row_id_present; const Tensor* row_remapping_t; OP_REQUIRES_OK(context, context->input("row_remapping", &row_remapping_t)); const auto row_remapping = row_remapping_t->vec<int64_t>(); OP_REQUIRES(context, row_remapping.size() == num_rows_, errors::InvalidArgument(strings::StrCat( "Size of row_remapping is ", row_remapping.size(), " instead of being equal to num_rows=", num_rows_))); OP_REQUIRES_OK(context, RemapVectorToMap(row_remapping, &row_id_present, &old_row_to_new_row_map)); // Calculates the min/max old row ID that we need to read, to save us from // reading some unnecessary slices of the old tensor. int64_t min_old_row = -1; int64_t max_old_row = -1; for (int i = 0; i < row_remapping.size(); ++i) { if (min_old_row < 0 || (row_remapping(i) >= 0 && row_remapping(i) < min_old_row)) { min_old_row = row_remapping(i); } if (max_old_row < 0 || (row_remapping(i) >= 0 && row_remapping(i) > max_old_row)) { max_old_row = row_remapping(i); } } // Processes the remapping for columns. std::unordered_map<int64_t, int64_t> old_col_to_new_col_map; std::vector<bool> col_id_present; const Tensor* col_remapping_t; OP_REQUIRES_OK(context, context->input("col_remapping", &col_remapping_t)); const auto col_remapping = col_remapping_t->vec<int64_t>(); // Note that we always "remap rows", even when the row vocabulary does // not change, because partitioning requires a mapping from partitioned // Variables to the full checkpoints we load. const bool remap_cols = col_remapping.size() > 0; if (remap_cols) { OP_REQUIRES( context, col_remapping.size() == num_cols_, errors::InvalidArgument(strings::StrCat( "Provided col_remapping, but its size is ", col_remapping.size(), " instead of being equal to num_cols=", num_cols_))); OP_REQUIRES_OK(context, RemapVectorToMap(col_remapping, &col_id_present, &old_col_to_new_col_map)); } else { col_id_present.clear(); col_id_present.resize(num_cols_, true); } // Processes the checkpoint source and the provided Tensor name. const Tensor* ckpt_path_t; OP_REQUIRES_OK(context, context->input("ckpt_path", &ckpt_path_t)); OP_REQUIRES( context, ckpt_path_t->NumElements() == 1, errors::InvalidArgument("The `ckpt_path` tensor must have exactly one " "element, got tensor of shape ", ckpt_path_t->shape().DebugString())); const string& ckpt_path = ckpt_path_t->scalar<tstring>()(); const Tensor* old_tensor_name_t; OP_REQUIRES_OK(context, context->input("old_tensor_name", &old_tensor_name_t)); const string& old_tensor_name = old_tensor_name_t->scalar<tstring>()(); LOG(INFO) << "Processing checkpoint : " << ckpt_path; BundleReader reader(context->env(), ckpt_path); OP_REQUIRES_OK(context, reader.status()); DataType tensor_type; TensorShape tensor_shape; OP_REQUIRES_OK(context, reader.LookupDtypeAndShape( old_tensor_name, &tensor_type, &tensor_shape)); OP_REQUIRES(context, tensor_type == DT_FLOAT, errors::InvalidArgument(strings::StrCat( "Tensor ", old_tensor_name, " has invalid type ", DataTypeString(tensor_type), " instead of expected type ", DataTypeString(DT_FLOAT)))); // This op is limited to loading Tensors of rank 2 (matrices). OP_REQUIRES( context, tensor_shape.dims() == 2, errors::InvalidArgument(strings::StrCat( "Tensor ", old_tensor_name, " has shape ", tensor_shape.DebugString(), " of invalid rank ", tensor_shape.dims(), " instead of expected shape of rank 2."))); if (!remap_cols) { // TODO(weiho): Consider relaxing this restriction to allow partial column // loading (even when no column remapping is specified) if there turns out // to be a use case for it. OP_REQUIRES(context, num_cols_ == tensor_shape.dim_size(1), errors::InvalidArgument(strings::StrCat( "Tensor ", old_tensor_name, " has shape ", tensor_shape.DebugString(), ", where the size of its 2nd dimension is ", tensor_shape.dim_size(1), " instead of being equal to num_cols=", num_cols_))); } // Uses TensorSlice to potentially load the old tensor in chunks in case // memory usage is a concern. std::vector<TensorSlice> tensor_slices; TensorSlice slice(tensor_shape.dims()); if (min_old_row >= 0 && max_old_row >= 0) { int64_t row_start = min_old_row; // TODO(weiho): Given the list of old row IDs of interest (the keys of // old_row_to_new_row_map), we could also try something smarter to // find some minimal set of covering ranges for the list of old row IDs // such that the size of each range is less than max_rows_in_memory_. while (row_start <= max_old_row) { const int64_t slice_length = max_rows_in_memory_ <= 0 // If max_rows_in_memory_ <= 0, we just load the entire chunk. ? max_old_row - row_start + 1 : std::min(max_rows_in_memory_, max_old_row - row_start + 1); slice.set_start(0, row_start); slice.set_length(0, slice_length); tensor_slices.push_back(slice); row_start += slice_length; } } // Allocates the output matrix. Tensor* output_matrix_t = nullptr; OP_REQUIRES_OK(context, context->allocate_output("output_matrix", TensorShape({num_rows_, num_cols_}), &output_matrix_t)); auto output_matrix = output_matrix_t->matrix<float>(); // Iterates through tensor slices and copies over values from the old tensor // to the output matrix. int64_t row_index = min_old_row; int64_t rows_copied = 0; Tensor loaded_tensor_t; for (const TensorSlice& tensor_slice : tensor_slices) { LOG(INFO) << "Loading slice " << tensor_slice.DebugString(); TensorShape slice_shape; OP_REQUIRES_OK(context, tensor_slice.SliceTensorShape(tensor_shape, &slice_shape)); // Potentially re-allocates the tensor buffer since the last slice may // have fewer rows than the other slices. if (loaded_tensor_t.shape() != slice_shape) { loaded_tensor_t = Tensor(DT_FLOAT, slice_shape); } OP_REQUIRES_OK(context, reader.LookupSlice(old_tensor_name, tensor_slice, &loaded_tensor_t)); // Iterates through the old loaded tensor slice row-by-row. for (int row = 0; row < loaded_tensor_t.dim_size(0); ++row, ++row_index) { if (row_index % 500000 == min_old_row) { LOG(INFO) << "Processing old row " << row_index; } // If the old row ID is not found in old_row_to_new_row_map, continue // to the next row; otherwise, copy it to the output matrix. const int64_t* new_row_ptr = gtl::FindOrNull(old_row_to_new_row_map, row_index); if (new_row_ptr == nullptr) { continue; } ++rows_copied; const int64_t new_row = *new_row_ptr; // Copies over the row element-by-element, in case remapping is needed // along the column axis. const auto& loaded_tensor = loaded_tensor_t.matrix<float>(); for (int old_col = 0; old_col < loaded_tensor_t.dim_size(1); ++old_col) { int64_t new_col = old_col; if (remap_cols) { const int64_t* new_col_ptr = gtl::FindOrNull(old_col_to_new_col_map, old_col); if (new_col_ptr == nullptr) { // Column remapping is specified, but this column is not found in // old_col_to_new_col_map, so we leave it uninitialized, to be // filled in with initializing_values later. continue; } new_col = *new_col_ptr; } OP_REQUIRES(context, new_row < num_rows_ && new_col < num_cols_ && new_row >= 0 && new_col >= 0, errors::Internal(strings::StrCat( "new_row=", new_row, " and new_col=", new_col, " should have been less than num_rows_=", num_rows_, " and num_cols_=", num_cols_, " and non-negative. This should never have happened " "if the code were correct. Please file a bug."))); output_matrix(new_row, new_col) = loaded_tensor(row, old_col); } } } LOG(INFO) << "Copied " << rows_copied << " rows from old matrix (with " << tensor_shape.dim_size(0) << " rows) to new matrix (with " << num_rows_ << " rows)."; // At this point, there are potentially whole rows/columns uninitialized // (corresponding to the indices where row_id_present/col_id_present are // false). We fill this in cell-by-cell using row_id_present and // col_id_present while dequeuing from the initializing_values vector. const Tensor* initializing_values_t; OP_REQUIRES_OK( context, context->input("initializing_values", &initializing_values_t)); const auto initializing_values = initializing_values_t->flat<float>(); int64_t initializing_values_index = 0; for (int i = 0; i < num_rows_; ++i) { for (int j = 0; j < num_cols_; ++j) { if (row_id_present[i] && col_id_present[j]) continue; OP_REQUIRES( context, initializing_values_index < initializing_values.size(), errors::InvalidArgument( "initializing_values contained ", initializing_values.size(), " elements, but more missing values remain.")); output_matrix(i, j) = initializing_values(initializing_values_index); ++initializing_values_index; } } // Checks that we used all the given initializing values. OP_REQUIRES( context, initializing_values_index == initializing_values.size(), errors::InvalidArgument( "initializing_values contained ", initializing_values.size(), " elements, but only ", initializing_values_index, " elements were used to fill in missing values.")); }
1
204,016
static struct dir *squashfs_opendir(unsigned int block_start, unsigned int offset, struct inode **i) { squashfs_dir_header_2 dirh; char buffer[sizeof(squashfs_dir_entry_2) + SQUASHFS_NAME_LEN + 1] __attribute__((aligned)); squashfs_dir_entry_2 *dire = (squashfs_dir_entry_2 *) buffer; long long start; int bytes = 0; int dir_count, size, res; struct dir_ent *ent, *cur_ent = NULL; struct dir *dir; TRACE("squashfs_opendir: inode start block %d, offset %d\n", block_start, offset); *i = read_inode(block_start, offset); dir = malloc(sizeof(struct dir)); if(dir == NULL) MEM_ERROR(); dir->dir_count = 0; dir->cur_entry = NULL; dir->mode = (*i)->mode; dir->uid = (*i)->uid; dir->guid = (*i)->gid; dir->mtime = (*i)->time; dir->xattr = (*i)->xattr; dir->dirs = NULL; if ((*i)->data == 0) /* * if the directory is empty, skip the unnecessary * lookup_entry, this fixes the corner case with * completely empty filesystems where lookup_entry correctly * returning -1 is incorrectly treated as an error */ return dir; start = sBlk.s.directory_table_start + (*i)->start; offset = (*i)->offset; size = (*i)->data + bytes; while(bytes < size) { if(swap) { squashfs_dir_header_2 sdirh; res = read_directory_data(&sdirh, &start, &offset, sizeof(sdirh)); if(res) SQUASHFS_SWAP_DIR_HEADER_2(&dirh, &sdirh); } else res = read_directory_data(&dirh, &start, &offset, sizeof(dirh)); if(res == FALSE) goto corrupted; dir_count = dirh.count + 1; TRACE("squashfs_opendir: Read directory header @ byte position " "%d, %d directory entries\n", bytes, dir_count); bytes += sizeof(dirh); /* dir_count should never be larger than SQUASHFS_DIR_COUNT */ if(dir_count > SQUASHFS_DIR_COUNT) { ERROR("File system corrupted: too many entries in directory\n"); goto corrupted; } while(dir_count--) { if(swap) { squashfs_dir_entry_2 sdire; res = read_directory_data(&sdire, &start, &offset, sizeof(sdire)); if(res) SQUASHFS_SWAP_DIR_ENTRY_2(dire, &sdire); } else res = read_directory_data(dire, &start, &offset, sizeof(*dire)); if(res == FALSE) goto corrupted; bytes += sizeof(*dire); /* size should never be SQUASHFS_NAME_LEN or larger */ if(dire->size >= SQUASHFS_NAME_LEN) { ERROR("File system corrupted: filename too long\n"); goto corrupted; } res = read_directory_data(dire->name, &start, &offset, dire->size + 1); if(res == FALSE) goto corrupted; dire->name[dire->size + 1] = '\0'; /* check name for invalid characters (i.e /, ., ..) */ if(check_name(dire->name, dire->size + 1) == FALSE) { ERROR("File system corrupted: invalid characters in name\n"); goto corrupted; } TRACE("squashfs_opendir: directory entry %s, inode " "%d:%d, type %d\n", dire->name, dirh.start_block, dire->offset, dire->type); ent = malloc(sizeof(struct dir_ent)); if(ent == NULL) MEM_ERROR(); ent->name = strdup(dire->name); ent->start_block = dirh.start_block; ent->offset = dire->offset; ent->type = dire->type; ent->next = NULL; if(cur_ent == NULL) dir->dirs = ent; else cur_ent->next = ent; cur_ent = ent; dir->dir_count ++; bytes += dire->size + 1; } } return dir; corrupted: squashfs_closedir(dir); return NULL; }
1
472,370
void ciEnv::cache_dtrace_flags() { // Need lock? _dtrace_extended_probes = ExtendedDTraceProbes; if (_dtrace_extended_probes) { _dtrace_method_probes = true; _dtrace_alloc_probes = true; } else { _dtrace_method_probes = DTraceMethodProbes; _dtrace_alloc_probes = DTraceAllocProbes; } }
0
274,733
callbacks_render_type_changed () { static gboolean isChanging = FALSE; if (isChanging) return; isChanging = TRUE; gerbv_render_types_t type = screenRenderInfo.renderType; GtkCheckMenuItem *check_item = screen.win.menu_view_render_group[type]; dprintf ("%s(): type = %d, check_item = %p\n", __FUNCTION__, type, check_item); gtk_check_menu_item_set_active (check_item, TRUE); gtk_combo_box_set_active (screen.win.sidepaneRenderComboBox, type); render_refresh_rendered_image_on_screen(); isChanging = FALSE; }
0
236,179
GF_Box *text_box_new() { ISOM_DECL_BOX_ALLOC(GF_TextSampleEntryBox, GF_ISOM_BOX_TYPE_TEXT); gf_isom_sample_entry_init((GF_SampleEntryBox *)tmp); return (GF_Box *) tmp; }
0
483,486
bool efi_is_table_address(unsigned long phys_addr) { unsigned int i; if (phys_addr == EFI_INVALID_TABLE_ADDR) return false; for (i = 0; i < ARRAY_SIZE(efi_tables); i++) if (*(efi_tables[i]) == phys_addr) return true; return false; }
0
206,665
static void parse_relocation_info(struct MACH0_(obj_t) *bin, RSkipList *relocs, ut32 offset, ut32 num) { if (!num || !offset || (st32)num < 0) { return; } ut64 total_size = num * sizeof (struct relocation_info); if (offset > bin->size) { return; } if (total_size > bin->size) { total_size = bin->size - offset; num = total_size /= sizeof (struct relocation_info); } struct relocation_info *info = calloc (num, sizeof (struct relocation_info)); if (!info) { return; } if (r_buf_read_at (bin->b, offset, (ut8 *) info, total_size) < total_size) { free (info); return; } size_t i; for (i = 0; i < num; i++) { struct relocation_info a_info = info[i]; ut32 sym_num = a_info.r_symbolnum; if (sym_num > bin->nsymtab) { continue; } ut32 stridx = bin->symtab[sym_num].n_strx; char *sym_name = get_name (bin, stridx, false); if (!sym_name) { continue; } struct reloc_t *reloc = R_NEW0 (struct reloc_t); if (!reloc) { free (info); free (sym_name); return; } reloc->addr = offset_to_vaddr (bin, a_info.r_address); reloc->offset = a_info.r_address; reloc->ord = sym_num; reloc->type = a_info.r_type; // enum RelocationInfoType reloc->external = a_info.r_extern; reloc->pc_relative = a_info.r_pcrel; reloc->size = a_info.r_length; r_str_ncpy (reloc->name, sym_name, sizeof (reloc->name) - 1); r_skiplist_insert (relocs, reloc); free (sym_name); } free (info); }
1
364,240
void rds_inc_info_copy(struct rds_incoming *inc, struct rds_info_iterator *iter, __be32 saddr, __be32 daddr, int flip) { struct rds_info_message minfo; minfo.seq = be64_to_cpu(inc->i_hdr.h_sequence); minfo.len = be32_to_cpu(inc->i_hdr.h_len); if (flip) { minfo.laddr = daddr; minfo.faddr = saddr; minfo.lport = inc->i_hdr.h_dport; minfo.fport = inc->i_hdr.h_sport; } else { minfo.laddr = saddr; minfo.faddr = daddr; minfo.lport = inc->i_hdr.h_sport; minfo.fport = inc->i_hdr.h_dport; } minfo.flags = 0; rds_info_copy(iter, &minfo, sizeof(minfo)); }
0
353,110
T3FontCache::~T3FontCache() { gfree(cacheData); gfree(cacheTags); }
0
514,317
bool unsafe_key_update(List<TABLE_LIST> leaves, table_map tables_for_update) { List_iterator_fast<TABLE_LIST> it(leaves), it2(leaves); TABLE_LIST *tl, *tl2; while ((tl= it++)) { if (!tl->is_jtbm() && (tl->table->map & tables_for_update)) { TABLE *table1= tl->table; bool primkey_clustered= (table1->file->primary_key_is_clustered() && table1->s->primary_key != MAX_KEY); bool table_partitioned= false; #ifdef WITH_PARTITION_STORAGE_ENGINE table_partitioned= (table1->part_info != NULL); #endif if (!table_partitioned && !primkey_clustered) continue; it2.rewind(); while ((tl2= it2++)) { if (tl2->is_jtbm()) continue; /* Look at "next" tables only since all previous tables have already been checked */ TABLE *table2= tl2->table; if (tl2 != tl && table2->map & tables_for_update && table1->s == table2->s) { // A table is updated through two aliases if (table_partitioned && (partition_key_modified(table1, table1->write_set) || partition_key_modified(table2, table2->write_set))) { // Partitioned key is updated my_error(ER_MULTI_UPDATE_KEY_CONFLICT, MYF(0), tl->top_table()->alias.str, tl2->top_table()->alias.str); return true; } if (primkey_clustered) { // The primary key can cover multiple columns KEY key_info= table1->key_info[table1->s->primary_key]; KEY_PART_INFO *key_part= key_info.key_part; KEY_PART_INFO *key_part_end= key_part + key_info.user_defined_key_parts; for (;key_part != key_part_end; ++key_part) { if (bitmap_is_set(table1->write_set, key_part->fieldnr-1) || bitmap_is_set(table2->write_set, key_part->fieldnr-1)) { // Clustered primary key is updated my_error(ER_MULTI_UPDATE_KEY_CONFLICT, MYF(0), tl->top_table()->alias.str, tl2->top_table()->alias.str); return true; } } } } } } } return false; }
0
202,256
void QPaintEngineEx::stroke(const QVectorPath &path, const QPen &inPen) { #ifdef QT_DEBUG_DRAW qDebug() << "QPaintEngineEx::stroke()" << pen; #endif Q_D(QPaintEngineEx); if (path.isEmpty()) return; if (!d->strokeHandler) { d->strokeHandler = new StrokeHandler(path.elementCount()+4); d->stroker.setMoveToHook(qpaintengineex_moveTo); d->stroker.setLineToHook(qpaintengineex_lineTo); d->stroker.setCubicToHook(qpaintengineex_cubicTo); } QRectF clipRect; QPen pen = inPen; if (pen.style() > Qt::SolidLine) { QRectF cpRect = path.controlPointRect(); const QTransform &xf = state()->matrix; if (pen.isCosmetic()) { clipRect = d->exDeviceRect; cpRect.translate(xf.dx(), xf.dy()); } else { clipRect = xf.inverted().mapRect(QRectF(d->exDeviceRect)); } // Check to avoid generating unwieldy amount of dashes that will not be visible anyway QRectF extentRect = cpRect & clipRect; qreal extent = qMax(extentRect.width(), extentRect.height()); qreal patternLength = 0; const QList<qreal> pattern = pen.dashPattern(); const int patternSize = qMin(pattern.size(), 32); for (int i = 0; i < patternSize; i++) patternLength += qMax(pattern.at(i), qreal(0)); if (pen.widthF()) patternLength *= pen.widthF(); if (qFuzzyIsNull(patternLength)) { pen.setStyle(Qt::NoPen); } else if (extent / patternLength > 10000) { // approximate stream of tiny dashes with semi-transparent solid line pen.setStyle(Qt::SolidLine); QColor color(pen.color()); color.setAlpha(color.alpha() / 2); pen.setColor(color); } } if (!qpen_fast_equals(pen, d->strokerPen)) { d->strokerPen = pen; d->stroker.setJoinStyle(pen.joinStyle()); d->stroker.setCapStyle(pen.capStyle()); d->stroker.setMiterLimit(pen.miterLimit()); qreal penWidth = pen.widthF(); if (penWidth == 0) d->stroker.setStrokeWidth(1); else d->stroker.setStrokeWidth(penWidth); Qt::PenStyle style = pen.style(); if (style == Qt::SolidLine) { d->activeStroker = &d->stroker; } else if (style == Qt::NoPen) { d->activeStroker = nullptr; } else { d->dasher.setDashPattern(pen.dashPattern()); d->dasher.setDashOffset(pen.dashOffset()); d->activeStroker = &d->dasher; } } if (!d->activeStroker) { return; } if (!clipRect.isNull()) d->activeStroker->setClipRect(clipRect); if (d->activeStroker == &d->stroker) d->stroker.setForceOpen(path.hasExplicitOpen()); const QPainterPath::ElementType *types = path.elements(); const qreal *points = path.points(); int pointCount = path.elementCount(); const qreal *lastPoint = points + (pointCount<<1); d->strokeHandler->types.reset(); d->strokeHandler->pts.reset(); // Some engines might decide to optimize for the non-shape hint later on... uint flags = QVectorPath::WindingFill; if (path.elementCount() > 2) flags |= QVectorPath::NonConvexShapeMask; if (d->stroker.capStyle() == Qt::RoundCap || d->stroker.joinStyle() == Qt::RoundJoin) flags |= QVectorPath::CurvedShapeMask; // ### Perspective Xforms are currently not supported... if (!pen.isCosmetic()) { // We include cosmetic pens in this case to avoid having to // change the current transform. Normal transformed, // non-cosmetic pens will be transformed as part of fill // later, so they are also covered here.. d->activeStroker->setCurveThresholdFromTransform(state()->matrix); d->activeStroker->begin(d->strokeHandler); if (types) { while (points < lastPoint) { switch (*types) { case QPainterPath::MoveToElement: d->activeStroker->moveTo(points[0], points[1]); points += 2; ++types; break; case QPainterPath::LineToElement: d->activeStroker->lineTo(points[0], points[1]); points += 2; ++types; break; case QPainterPath::CurveToElement: d->activeStroker->cubicTo(points[0], points[1], points[2], points[3], points[4], points[5]); points += 6; types += 3; flags |= QVectorPath::CurvedShapeMask; break; default: break; } } if (path.hasImplicitClose()) d->activeStroker->lineTo(path.points()[0], path.points()[1]); } else { d->activeStroker->moveTo(points[0], points[1]); points += 2; while (points < lastPoint) { d->activeStroker->lineTo(points[0], points[1]); points += 2; } if (path.hasImplicitClose()) d->activeStroker->lineTo(path.points()[0], path.points()[1]); } d->activeStroker->end(); if (!d->strokeHandler->types.size()) // an empty path... return; QVectorPath strokePath(d->strokeHandler->pts.data(), d->strokeHandler->types.size(), d->strokeHandler->types.data(), flags); fill(strokePath, pen.brush()); } else { // For cosmetic pens we need a bit of trickery... We to process xform the input points if (state()->matrix.type() >= QTransform::TxProject) { QPainterPath painterPath = state()->matrix.map(path.convertToPainterPath()); d->activeStroker->strokePath(painterPath, d->strokeHandler, QTransform()); } else { d->activeStroker->setCurveThresholdFromTransform(QTransform()); d->activeStroker->begin(d->strokeHandler); if (types) { while (points < lastPoint) { switch (*types) { case QPainterPath::MoveToElement: { QPointF pt = (*(const QPointF *) points) * state()->matrix; d->activeStroker->moveTo(pt.x(), pt.y()); points += 2; ++types; break; } case QPainterPath::LineToElement: { QPointF pt = (*(const QPointF *) points) * state()->matrix; d->activeStroker->lineTo(pt.x(), pt.y()); points += 2; ++types; break; } case QPainterPath::CurveToElement: { QPointF c1 = ((const QPointF *) points)[0] * state()->matrix; QPointF c2 = ((const QPointF *) points)[1] * state()->matrix; QPointF e = ((const QPointF *) points)[2] * state()->matrix; d->activeStroker->cubicTo(c1.x(), c1.y(), c2.x(), c2.y(), e.x(), e.y()); points += 6; types += 3; flags |= QVectorPath::CurvedShapeMask; break; } default: break; } } if (path.hasImplicitClose()) { QPointF pt = * ((const QPointF *) path.points()) * state()->matrix; d->activeStroker->lineTo(pt.x(), pt.y()); } } else { QPointF p = ((const QPointF *)points)[0] * state()->matrix; d->activeStroker->moveTo(p.x(), p.y()); points += 2; while (points < lastPoint) { QPointF p = ((const QPointF *)points)[0] * state()->matrix; d->activeStroker->lineTo(p.x(), p.y()); points += 2; } if (path.hasImplicitClose()) d->activeStroker->lineTo(p.x(), p.y()); } d->activeStroker->end(); } QVectorPath strokePath(d->strokeHandler->pts.data(), d->strokeHandler->types.size(), d->strokeHandler->types.data(), flags); QTransform xform = state()->matrix; state()->matrix = QTransform(); transformChanged(); QBrush brush = pen.brush(); if (qbrush_style(brush) != Qt::SolidPattern) brush.setTransform(brush.transform() * xform); fill(strokePath, brush); state()->matrix = xform; transformChanged(); } }
1
202,688
lprn_is_black(gx_device_printer * pdev, int r, int h, int bx) { gx_device_lprn *const lprn = (gx_device_lprn *) pdev; int bh = lprn->nBh; int bpl = gdev_mem_bytes_per_scan_line(pdev); int x, y, y0; byte *p; int maxY = lprn->BlockLine / lprn->nBh * lprn->nBh; y0 = (r + h - bh) % maxY; for (y = 0; y < bh; y++) { p = &lprn->ImageBuf[(y0 + y) * bpl + bx * lprn->nBw]; for (x = 0; x < lprn->nBw; x++) if (p[x] != 0) return 1; } return 0; }
1
498,619
read_line (FILE *fp, guchar *row, guchar *buf, tga_info *info, gint bpp, const guchar *convert_cmap) { if (info->imageCompression == TGA_COMP_RLE) { rle_read (fp, buf, info); } else { fread (buf, info->bytes, info->width, fp); } if (info->flipHoriz) { flip_line (buf, info); } if (info->imageType == TGA_TYPE_COLOR) { if (info->bpp == 16 || info->bpp == 15) { upsample (row, buf, info->width, info->bytes, info->alphaBits); } else { bgr2rgb (row, buf, info->width, info->bytes, info->alphaBits); } } else if (convert_cmap) { gboolean has_alpha = (info->alphaBits > 0); apply_colormap (row, buf, info->width, convert_cmap, has_alpha, info->colorMapIndex); } else if (info->imageType == TGA_TYPE_MAPPED) { g_assert(bpp == 1); apply_index (row, buf, info->width, info->colorMapIndex); } else { memcpy (row, buf, info->width * bpp); } }
0