project
string | commit_id
string | target
int64 | func
string | cwe
string | big_vul_idx
string | idx
int64 | hash
string | size
float64 | message
string | dataset
string |
|---|---|---|---|---|---|---|---|---|---|---|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
void Graph::set_versions(const VersionDef& versions) { *versions_ = versions; }
| null | null | 220,206
|
246679989079001813886689761317132851962
| 1
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
void Node::Initialize(int id, int cost_id,
std::shared_ptr<NodeProperties> props,
Node::NodeClass node_class) {
DCHECK_EQ(id_, -1);
DCHECK(in_edges_.empty());
DCHECK(out_edges_.empty());
id_ = id;
cost_id_ = cost_id;
props_ = std::move(props);
class_ = node_class;
}
| null | null | 220,207
|
203556908936063558075263590974037492046
| 12
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
Node::Node()
: id_(-1),
cost_id_(-1),
class_(NC_UNINITIALIZED),
props_(nullptr),
assigned_device_name_index_(0),
while_ctx_(nullptr) {}
| null | null | 220,208
|
194235298668377148541760408581504272747
| 7
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
DataType Node::input_type(int32_t i) const { return props_->input_types[i]; }
| null | null | 220,209
|
257153408973255005311932207278504892735
| 1
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
Status Node::input_node(int idx, Node** n) const {
const Edge* e;
TF_RETURN_IF_ERROR(input_edge(idx, &e));
if (e == nullptr) {
*n = nullptr;
} else {
*n = e->src();
}
return Status::OK();
}
| null | null | 220,210
|
49220485176507413052360709421111817097
| 10
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
const std::string& Node::requested_device() const { return def().device(); }
| null | null | 220,211
|
153977176688327216531871803763788034317
| 1
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
gtl::iterator_range<NeighborIter> Node::in_nodes() const {
return gtl::make_range(NeighborIter(in_edges_.begin(), true),
NeighborIter(in_edges_.end(), true));
}
| null | null | 220,212
|
339470683087166155370417764365153328257
| 4
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
bool InputTensor::operator==(const InputTensor& other) const {
return node == other.node && index == other.index;
}
| null | null | 220,213
|
287167159545328695871037609481818431217
| 3
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
void Graph::ToGraphDef(GraphDef* graph_def) const {
ToGraphDefSubRange(graph_def, 0);
}
| null | null | 220,214
|
323577976625496497247308097013034316739
| 3
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
GraphDef Graph::ToGraphDefDebug() const {
GraphDef ret;
ToGraphDef(&ret);
return ret;
}
| null | null | 220,215
|
291059078071112070451691913750041477288
| 5
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
Status Graph::IsValidNode(const Node* node) const {
if (node == nullptr) {
return errors::InvalidArgument("Node is null");
}
const int id = node->id();
if (id < 0) {
return errors::InvalidArgument("node id ", id, " is less than zero");
}
if (static_cast<size_t>(id) >= nodes_.size()) {
return errors::InvalidArgument(
"node id ", id, " is >= than number of nodes in graph ", nodes_.size());
}
if (nodes_[id] != node) {
return errors::InvalidArgument("Node with id ", id,
" is different from the passed in node. "
"Does it belong to a different graph?");
}
return Status::OK();
}
| null | null | 220,216
|
143300731157496236697765102523230543885
| 19
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
int32 Node::num_outputs() const { return props_->output_types.size(); }
| null | null | 220,217
|
25056010561826327414933379731121307346
| 1
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
void Node::set_original_node_names(const std::vector<std::string>& names) {
MaybeCopyOnWrite();
props_->node_def.mutable_experimental_debug_info()
->clear_original_node_names();
if (!names.empty()) {
*props_->node_def.mutable_experimental_debug_info()
->mutable_original_node_names() = {names.begin(), names.end()};
}
}
| null | null | 220,218
|
312919349650771786931077233233063397255
| 9
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
Status Graph::UpdateEdge(Node* new_src, int new_src_index, Node* dst,
int dst_index) {
TF_RETURN_IF_ERROR(IsValidOutputTensor(new_src, new_src_index));
TF_RETURN_IF_ERROR(IsValidInputTensor(dst, dst_index));
const Edge* e = FindEdge(dst, dst_index);
if (e == nullptr) {
return errors::InvalidArgument("Couldn't find edge to ",
FormatNodeForError(*dst));
}
RemoveEdge(e);
AddEdge(new_src, new_src_index, dst, dst_index);
dst->MaybeCopyOnWrite();
(*dst->props_->node_def.mutable_input())[dst_index] =
strings::StrCat(new_src->name(), ":", new_src_index);
return Status::OK();
}
| null | null | 220,219
|
182431143859116624767672411849950849494
| 16
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
void Graph::RemoveNode(Node* node) {
TF_DCHECK_OK(IsValidNode(node)) << node->DebugString();
DCHECK(!node->IsSource());
DCHECK(!node->IsSink());
// Remove any edges involving this node.
for (const Edge* e : node->in_edges_) {
CHECK_EQ(e->src_->out_edges_.erase(e), size_t{1});
edges_[e->id_] = nullptr;
RecycleEdge(e);
--num_edges_;
}
node->in_edges_.clear();
for (const Edge* e : node->out_edges_) {
CHECK_EQ(e->dst_->in_edges_.erase(e), size_t{1});
edges_[e->id_] = nullptr;
RecycleEdge(e);
--num_edges_;
}
node->out_edges_.clear();
ReleaseNode(node);
}
| null | null | 220,220
|
44393823693341982219409084692947921782
| 22
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
AttrValue* Node::AddAttrHelper(const std::string& name) {
MaybeCopyOnWrite();
return &((*props_->node_def.mutable_attr())[name]);
}
| null | null | 220,221
|
296670438282768581266057966608664319818
| 4
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
const protobuf::RepeatedPtrField<std::string>& Node::requested_inputs() const {
return def().input();
}
| null | null | 220,222
|
221236896578154905731404502061926911595
| 3
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
int32 Node::num_inputs() const { return props_->input_types.size(); }
| null | null | 220,223
|
262936590786062235777158852221019069376
| 1
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
NodeDebugInfo::NodeDebugInfo(const Node& n) : NodeDebugInfo(n.def()) {}
| null | null | 220,224
|
50233414431284599023816715093905484777
| 1
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
NodeDebugInfo::NodeDebugInfo(
StringPiece node_name, bool has_experimental_debug_info,
const NodeDef_ExperimentalDebugInfo& experimental_debug_info)
: name(node_name) {
if (has_experimental_debug_info) {
const auto& node_names = experimental_debug_info.original_node_names();
original_node_names.assign(node_names.begin(), node_names.end());
const auto& func_names = experimental_debug_info.original_func_names();
original_func_names.assign(func_names.begin(), func_names.end());
}
}
| null | null | 220,225
|
114481772456125367922975084472849964627
| 11
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
Node* Graph::AddNode(NodeDef node_def, Status* status) {
const OpRegistrationData* op_reg_data;
status->Update(ops_.LookUp(node_def.op(), &op_reg_data));
if (!status->ok()) return nullptr;
DataTypeVector inputs;
DataTypeVector outputs;
status->Update(
InOutTypesForNode(node_def, op_reg_data->op_def, &inputs, &outputs));
if (!status->ok()) {
*status = AttachDef(*status, node_def);
return nullptr;
}
Node::NodeClass node_class = op_reg_data->is_function_op
? Node::NC_FUNCTION_OP
: Node::GetNodeClassForOp(node_def.op());
if (op_reg_data->type_ctor != nullptr) {
VLOG(3) << "AddNode: found type constructor for " << node_def.name();
const auto ctor_type =
full_type::SpecializeType(AttrSlice(node_def), op_reg_data->op_def);
if (!ctor_type.ok()) {
*status = errors::InvalidArgument("type error: ",
ctor_type.status().ToString());
return nullptr;
}
const FullTypeDef ctor_typedef = ctor_type.ValueOrDie();
if (ctor_typedef.type_id() != TFT_UNSET) {
*(node_def.mutable_experimental_type()) = ctor_typedef;
}
} else {
VLOG(3) << "AddNode: no type constructor for " << node_def.name();
}
Node* node = AllocateNode(std::make_shared<NodeProperties>(
&op_reg_data->op_def, std::move(node_def),
inputs, outputs, op_reg_data->fwd_type_fn),
nullptr, node_class);
return node;
}
| null | null | 220,226
|
131949883253677529452156943758238693934
| 41
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
Node* Graph::CopyNode(const Node* node) {
DCHECK(!node->IsSource());
DCHECK(!node->IsSink());
Node* copy = AllocateNode(node->props_, node, node->class_);
copy->set_assigned_device_name(node->assigned_device_name());
// Since the OpDef of a function may be owned by the Graph that owns 'node',
// relookup the OpDef in the target graph. If it differs, then clone the
// node properties with the updated OpDef.
const OpDef* op_def;
TF_CHECK_OK(ops_.LookUpOpDef(node->type_string(), &op_def));
if (op_def != node->props_->op_def) {
copy->MaybeCopyOnWrite();
copy->props_->op_def = op_def;
}
copy->SetStackTrace(node->GetStackTrace());
return copy;
}
| null | null | 220,227
|
93354748136517340622955040306559504819
| 19
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
const VersionDef& Graph::versions() const { return *versions_; }
| null | null | 220,228
|
5227392406786386383812019627217916035
| 1
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
const std::string& Node::type_string() const { return props_->node_def.op(); }
| null | null | 220,229
|
140132730628251352858768699729046695212
| 1
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
const NodeDef& Node::def() const { return props_->node_def; }
| null | null | 220,230
|
57186507853480293386367892746697840410
| 1
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
void Node::UpdateProperties() {
DataTypeVector inputs;
DataTypeVector outputs;
Status status =
InOutTypesForNode(props_->node_def, *(props_->op_def), &inputs, &outputs);
if (!status.ok()) {
LOG(ERROR) << "Failed at updating node: " << status;
return;
}
if (props_->input_types != inputs || props_->output_types != outputs) {
if (TF_PREDICT_TRUE(props_.use_count() == 1)) {
props_->input_types = inputs;
props_->input_types_slice = props_->input_types;
props_->output_types = outputs;
props_->output_types_slice = props_->output_types;
} else {
props_ = std::make_shared<NodeProperties>(
props_->op_def, std::move(props_->node_def), inputs, outputs);
}
}
}
| null | null | 220,231
|
29520340220445276302589971561339946886
| 21
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
AttrSlice Node::attrs() const { return AttrSlice(def()); }
| null | null | 220,232
|
118827566488754264805893880218024288472
| 1
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
NodeDef* Node::mutable_def() { return &props_->node_def; }
| null | null | 220,233
|
181211883383073108276568061383918482065
| 1
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
Graph::~Graph() {
// Manually call the destructors for all the Nodes we constructed using
// placement new.
for (Node* node : nodes_) {
if (node != nullptr) {
node->~Node();
}
}
for (Node* node : free_nodes_) {
node->~Node();
}
// Edges have no destructor, and we arena-allocated them, so no need to
// destroy them.
}
| null | null | 220,234
|
323714789386465748995624193026118764914
| 14
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
Graph::Graph(const FunctionLibraryDefinition& flib_def)
: Graph(flib_def.default_registry()) {
// Need a new-enough consumer to support the functions we add to the graph.
if (flib_def.num_functions() > 0 && versions_->min_consumer() < 12) {
versions_->set_min_consumer(12);
}
Status s = ops_.AddLibrary(flib_def);
CHECK(s.ok()) << s.error_message();
}
| null | null | 220,235
|
261299349855243558059732387453534905459
| 9
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
DataType Node::output_type(int32_t o) const { return props_->output_types[o]; }
| null | null | 220,236
|
75124942833520146713827252304197183336
| 1
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
Status Node::input_node(int idx, const Node** const_n) const {
Node* n;
TF_RETURN_IF_ERROR(input_node(idx, &n));
*const_n = n;
return Status::OK();
}
| null | null | 220,237
|
297591078281655076784863644978046023892
| 6
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
void Node::set_name(std::string name) {
MaybeCopyOnWrite();
props_->node_def.set_name(std::move(name));
}
| null | null | 220,238
|
333883922994978232962630265509612958500
| 4
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
Status Graph::IsValidOutputTensor(const Node* node, int idx) const {
TF_RETURN_IF_ERROR(IsValidNode(node));
if (idx >= node->num_outputs() || idx < 0) {
return errors::OutOfRange("Node '", node->name(), "' (type: '",
node->op_def().name(),
"', num of outputs: ", node->num_outputs(),
") does not have ", "output ", idx);
}
return Status::OK();
}
| null | null | 220,239
|
106507492932693111357281770601821808282
| 10
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
std::string Edge::DebugString() const {
return strings::Printf("[id=%d %s:%d -> %s:%d]", id_, src_->name().c_str(),
src_output_, dst_->name().c_str(), dst_input_);
}
| null | null | 220,240
|
31029794341434786574330640768628529951
| 4
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
Status Graph::AddWhileContext(StringPiece frame_name,
std::vector<Node*> enter_nodes,
std::vector<Node*> exit_nodes,
OutputTensor cond_output,
std::vector<OutputTensor> body_inputs,
std::vector<OutputTensor> body_outputs,
WhileContext** result) {
auto pair = while_ctxs_.insert(std::pair<std::string, WhileContext>(
std::string(frame_name),
WhileContext(frame_name, std::move(enter_nodes), std::move(exit_nodes),
cond_output, std::move(body_inputs),
std::move(body_outputs))));
if (!pair.second) {
*result = nullptr;
return errors::InvalidArgument("WhileContext with frame name '", frame_name,
"' already exists");
}
*result = &pair.first->second;
return Status::OK();
}
| null | null | 220,241
|
286923591469252398881716775514566862156
| 20
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
uint64 OutputTensor::Hash::operator()(OutputTensor const& s) const {
return Hash64Combine(std::hash<const Node*>()(s.node),
std::hash<int>()(s.index));
}
| null | null | 220,242
|
62260669746685521775556181022740241341
| 4
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
Node::NodeClass Node::GetNodeClassForOp(const std::string& ts) {
static const absl::flat_hash_map<std::string, Node::NodeClass>*
kNodeClassTable =
#define REF_CLASS(key, value) \
{key, value}, { "Ref" key, value }
new absl::flat_hash_map<std::string, Node::NodeClass>({
// Keep in same order as NodeClass values
REF_CLASS("Switch", NC_SWITCH),
REF_CLASS("_SwitchN", NC_SWITCH),
REF_CLASS("Merge", NC_MERGE),
REF_CLASS("Enter", NC_ENTER),
REF_CLASS("Exit", NC_EXIT),
REF_CLASS("NextIteration", NC_NEXT_ITERATION),
{"LoopCond", NC_LOOP_COND},
{"ControlTrigger", NC_CONTROL_TRIGGER},
{"_Send", NC_SEND},
{"_HostSend", NC_HOST_SEND},
{"_Recv", NC_RECV},
{"_HostRecv", NC_HOST_RECV},
{"Const", NC_CONSTANT},
{"HostConst", NC_CONSTANT},
{"Variable", NC_VARIABLE},
{"VariableV2", NC_VARIABLE},
REF_CLASS("Identity", NC_IDENTITY),
{"GetSessionHandle", NC_GET_SESSION_HANDLE},
{"GetSessionHandleV2", NC_GET_SESSION_HANDLE},
{"GetSessionTensor", NC_GET_SESSION_TENSOR},
{"DeleteSessionTensor", NC_DELETE_SESSION_TENSOR},
{"Size", NC_METADATA},
{"Shape", NC_METADATA},
{"Rank", NC_METADATA},
{"_ScopedAllocator", NC_SCOPED_ALLOCATOR},
{"CollectiveReduce", NC_COLLECTIVE},
{"CollectiveBcastSend", NC_COLLECTIVE},
{"CollectiveBcastRecv", NC_COLLECTIVE},
{"CollectiveGather", NC_COLLECTIVE},
{"FakeParam", NC_FAKE_PARAM},
{"PartitionedCall", NC_PARTITIONED_CALL},
{"StatefulPartitionedCall", NC_PARTITIONED_CALL},
{"SymbolicGradient", NC_SYMBOLIC_GRADIENT},
{"If", NC_IF},
{"StatelessIf", NC_IF},
{"While", NC_WHILE},
{"StatelessWhile", NC_WHILE},
{"Case", NC_CASE},
{"StatelessCase", NC_CASE},
// Not using the constants defined in FunctionLibraryDefinition
// for the
// 4 ops below because android inference library does not link
// tf.function related files.
{"_Arg", NC_ARG},
{"_DeviceArg", NC_ARG},
{"_Retval", NC_RETVAL},
{"_DeviceRetval", NC_RETVAL},
{"_XlaMerge", NC_MERGE},
});
#undef REF_CLASS
auto it = kNodeClassTable->find(ts);
if (it != kNodeClassTable->end()) {
return it->second;
} else {
return NC_OTHER;
}
}
| null | null | 220,243
|
30576608719650876601165659342378622558
| 65
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
const Edge* Graph::AddControlEdge(Node* source, Node* dest,
bool allow_duplicates) {
if (!allow_duplicates) {
for (const Edge* edge : dest->in_edges()) {
if (edge->IsControlEdge() && edge->src() == source) {
// The requested edge already exists.
return nullptr;
}
}
}
// Modify dest's NodeDef if necessary.
if (!source->IsSource() && !dest->IsSink() && !allow_duplicates) {
// Check if this input is already in dest's NodeDef.
const std::string new_input = strings::StrCat("^", source->name());
bool input_exists = false;
for (const std::string& input : dest->props_->node_def.input()) {
if (input == new_input) {
input_exists = true;
break;
}
}
if (!input_exists) {
dest->MaybeCopyOnWrite();
dest->props_->node_def.add_input(new_input);
}
}
return AddEdge(source, kControlSlot, dest, kControlSlot);
}
| null | null | 220,244
|
201649992068311064938381193018986564369
| 28
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
bool OutputTensor::operator==(const OutputTensor& other) const {
return node == other.node && index == other.index;
}
| null | null | 220,245
|
213732197676411874172700927251906361340
| 3
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
Status Graph::AddFunctionLibrary(const FunctionDefLibrary& fdef_lib) {
// Need a new-enough consumer to support the functions we add to the graph.
if (fdef_lib.function_size() > 0 && versions_->min_consumer() < 12) {
versions_->set_min_consumer(12);
}
return ops_.AddLibrary(fdef_lib);
}
| null | null | 220,246
|
194528431543865492608912556577072632861
| 7
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
tensorflow
|
c99d98cd189839dcf51aee94e7437b54b31f8abd
| 0
|
std::unique_ptr<Graph> Graph::Clone() {
std::unique_ptr<Graph> new_graph(new Graph(flib_def()));
new_graph->Copy(*this);
return new_graph;
}
| null | null | 220,247
|
331468854770703695806619709078379458218
| 5
|
Handle invalid inputs instead of crashing.
PiperOrigin-RevId: 409549744
Change-Id: I7f5935b34b53f7e426a5462fcc027bdbf5dcda24
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
array_copy(mrb_value *dst, const mrb_value *src, mrb_int size)
{
mrb_int i;
for (i = 0; i < size; i++) {
dst[i] = src[i];
}
}
| null | null | 220,388
|
182979075854352414587336468213685599373
| 8
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_clear(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
ary_modify(mrb, a);
if (ARY_SHARED_P(a)) {
mrb_ary_decref(mrb, a->as.heap.aux.shared);
ARY_UNSET_SHARED_FLAG(a);
}
else if (!ARY_EMBED_P(a)){
mrb_free(mrb, a->as.heap.ptr);
}
if (MRB_ARY_EMBED_LEN_MAX > 0) {
ARY_SET_EMBED_LEN(a, 0);
}
else {
a->as.heap.ptr = NULL;
a->as.heap.aux.capa = 0;
ARY_SET_LEN(a, 0);
}
return self;
}
| null | null | 220,389
|
290158225082948238904553781517914961518
| 22
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_push(mrb_state *mrb, mrb_value ary, mrb_value elem)
{
struct RArray *a = mrb_ary_ptr(ary);
mrb_int len = ARY_LEN(a);
ary_modify(mrb, a);
if (len == ARY_CAPA(a))
ary_expand_capa(mrb, a, len + 1);
ARY_PTR(a)[len] = elem;
ARY_SET_LEN(a, len+1);
mrb_field_write_barrier_value(mrb, (struct RBasic*)a, elem);
}
| null | null | 220,390
|
229475750227764633995431468913813032037
| 12
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_rindex_m(mrb_state *mrb, mrb_value self)
{
mrb_value obj = mrb_get_arg1(mrb);
mrb_int i, len;
for (i = RARRAY_LEN(self) - 1; i >= 0; i--) {
if (mrb_equal(mrb, RARRAY_PTR(self)[i], obj)) {
return mrb_int_value(mrb, i);
}
if (i > (len = RARRAY_LEN(self))) {
i = len;
}
}
return mrb_nil_value();
}
| null | null | 220,391
|
214952241037712876235182535411599040882
| 15
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_init_array(mrb_state *mrb)
{
struct RClass *a;
mrb->array_class = a = mrb_define_class(mrb, "Array", mrb->object_class); /* 15.2.12 */
MRB_SET_INSTANCE_TT(a, MRB_TT_ARRAY);
mrb_define_class_method(mrb, a, "[]", mrb_ary_s_create, MRB_ARGS_ANY()); /* 15.2.12.4.1 */
mrb_define_method(mrb, a, "+", mrb_ary_plus, MRB_ARGS_REQ(1)); /* 15.2.12.5.1 */
mrb_define_method(mrb, a, "*", mrb_ary_times, MRB_ARGS_REQ(1)); /* 15.2.12.5.2 */
mrb_define_method(mrb, a, "<<", mrb_ary_push_m, MRB_ARGS_REQ(1)); /* 15.2.12.5.3 */
mrb_define_method(mrb, a, "[]", mrb_ary_aget, MRB_ARGS_ARG(1,1)); /* 15.2.12.5.4 */
mrb_define_method(mrb, a, "[]=", mrb_ary_aset, MRB_ARGS_ARG(2,1)); /* 15.2.12.5.5 */
mrb_define_method(mrb, a, "clear", mrb_ary_clear_m, MRB_ARGS_NONE()); /* 15.2.12.5.6 */
mrb_define_method(mrb, a, "concat", mrb_ary_concat_m, MRB_ARGS_REQ(1)); /* 15.2.12.5.8 */
mrb_define_method(mrb, a, "delete_at", mrb_ary_delete_at, MRB_ARGS_REQ(1)); /* 15.2.12.5.9 */
mrb_define_method(mrb, a, "empty?", mrb_ary_empty_p, MRB_ARGS_NONE()); /* 15.2.12.5.12 */
mrb_define_method(mrb, a, "first", mrb_ary_first, MRB_ARGS_OPT(1)); /* 15.2.12.5.13 */
mrb_define_method(mrb, a, "index", mrb_ary_index_m, MRB_ARGS_REQ(1)); /* 15.2.12.5.14 */
mrb_define_method(mrb, a, "initialize_copy", mrb_ary_replace_m, MRB_ARGS_REQ(1)); /* 15.2.12.5.16 */
mrb_define_method(mrb, a, "join", mrb_ary_join_m, MRB_ARGS_OPT(1)); /* 15.2.12.5.17 */
mrb_define_method(mrb, a, "last", mrb_ary_last, MRB_ARGS_OPT(1)); /* 15.2.12.5.18 */
mrb_define_method(mrb, a, "length", mrb_ary_size, MRB_ARGS_NONE()); /* 15.2.12.5.19 */
mrb_define_method(mrb, a, "pop", mrb_ary_pop, MRB_ARGS_NONE()); /* 15.2.12.5.21 */
mrb_define_method(mrb, a, "push", mrb_ary_push_m, MRB_ARGS_ANY()); /* 15.2.12.5.22 */
mrb_define_method(mrb, a, "replace", mrb_ary_replace_m, MRB_ARGS_REQ(1)); /* 15.2.12.5.23 */
mrb_define_method(mrb, a, "reverse", mrb_ary_reverse, MRB_ARGS_NONE()); /* 15.2.12.5.24 */
mrb_define_method(mrb, a, "reverse!", mrb_ary_reverse_bang, MRB_ARGS_NONE()); /* 15.2.12.5.25 */
mrb_define_method(mrb, a, "rindex", mrb_ary_rindex_m, MRB_ARGS_REQ(1)); /* 15.2.12.5.26 */
mrb_define_method(mrb, a, "shift", mrb_ary_shift_m, MRB_ARGS_OPT(1)); /* 15.2.12.5.27 */
mrb_define_method(mrb, a, "size", mrb_ary_size, MRB_ARGS_NONE()); /* 15.2.12.5.28 */
mrb_define_method(mrb, a, "slice", mrb_ary_aget, MRB_ARGS_ARG(1,1)); /* 15.2.12.5.29 */
mrb_define_method(mrb, a, "unshift", mrb_ary_unshift_m, MRB_ARGS_ANY()); /* 15.2.12.5.30 */
mrb_define_method(mrb, a, "__ary_eq", mrb_ary_eq, MRB_ARGS_REQ(1));
mrb_define_method(mrb, a, "__ary_cmp", mrb_ary_cmp, MRB_ARGS_REQ(1));
mrb_define_method(mrb, a, "__ary_index", mrb_ary_index_m, MRB_ARGS_REQ(1)); /* kept for mruby-array-ext */
mrb_define_method(mrb, a, "__svalue", mrb_ary_svalue, MRB_ARGS_NONE());
}
| null | null | 220,392
|
283556898228574582856989207133036900698
| 40
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_plus(mrb_state *mrb, mrb_value self)
{
struct RArray *a1 = mrb_ary_ptr(self);
struct RArray *a2;
const mrb_value *ptr;
mrb_int blen, len1;
mrb_get_args(mrb, "a", &ptr, &blen);
if (ARY_MAX_SIZE - blen < ARY_LEN(a1)) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
}
len1 = ARY_LEN(a1);
a2 = ary_new_capa(mrb, len1 + blen);
array_copy(ARY_PTR(a2), ARY_PTR(a1), len1);
array_copy(ARY_PTR(a2) + len1, ptr, blen);
ARY_SET_LEN(a2, len1+blen);
return mrb_obj_value(a2);
}
| null | null | 220,393
|
65534246480514072787633239736186463982
| 19
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_replace_m(mrb_state *mrb, mrb_value self)
{
mrb_value other;
mrb_get_args(mrb, "A", &other);
mrb_ary_replace(mrb, self, other);
return self;
}
| null | null | 220,394
|
171738147248612382516244556592683984818
| 9
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
aget_index(mrb_state *mrb, mrb_value index)
{
if (mrb_integer_p(index)) {
return mrb_integer(index);
}
#ifndef MRB_NO_FLOAT
else if (mrb_float_p(index)) {
return (mrb_int)mrb_float(index);
}
#endif
else {
mrb_int i, argc;
const mrb_value *argv;
mrb_get_args(mrb, "i*!", &i, &argv, &argc);
return i;
}
}
| null | null | 220,395
|
176868318604794062400196218771802005760
| 18
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_aget(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
mrb_int i;
mrb_int len, alen;
mrb_value index;
if (mrb_get_argc(mrb) == 1) {
index = mrb_get_arg1(mrb);
switch (mrb_type(index)) {
/* a[n..m] */
case MRB_TT_RANGE:
if (mrb_range_beg_len(mrb, index, &i, &len, ARY_LEN(a), TRUE) == MRB_RANGE_OK) {
return ary_subseq(mrb, a, i, len);
}
else {
return mrb_nil_value();
}
case MRB_TT_INTEGER:
return mrb_ary_ref(mrb, self, mrb_integer(index));
default:
return mrb_ary_ref(mrb, self, aget_index(mrb, index));
}
}
mrb_get_args(mrb, "oi", &index, &len);
i = aget_index(mrb, index);
alen = ARY_LEN(a);
if (i < 0) i += alen;
if (i < 0 || alen < i) return mrb_nil_value();
if (len < 0) return mrb_nil_value();
if (alen == i) return mrb_ary_new(mrb);
if (len > alen - i) len = alen - i;
return ary_subseq(mrb, a, i, len);
}
| null | null | 220,396
|
159801651093092080458371998381992784828
| 36
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_pop(mrb_state *mrb, mrb_value ary)
{
struct RArray *a = mrb_ary_ptr(ary);
mrb_int len = ARY_LEN(a);
ary_modify_check(mrb, a);
if (len == 0) return mrb_nil_value();
ARY_SET_LEN(a, len-1);
return ARY_PTR(a)[len-1];
}
| null | null | 220,397
|
319664476435945432561541010124102947479
| 10
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
join_ary(mrb_state *mrb, mrb_value ary, mrb_value sep, mrb_value list)
{
mrb_int i;
mrb_value result, val, tmp;
/* check recursive */
for (i=0; i<RARRAY_LEN(list); i++) {
if (mrb_obj_equal(mrb, ary, RARRAY_PTR(list)[i])) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "recursive array join");
}
}
mrb_ary_push(mrb, list, ary);
result = mrb_str_new_capa(mrb, 64);
for (i=0; i<RARRAY_LEN(ary); i++) {
if (i > 0 && !mrb_nil_p(sep)) {
mrb_str_cat_str(mrb, result, sep);
}
val = RARRAY_PTR(ary)[i];
switch (mrb_type(val)) {
case MRB_TT_ARRAY:
ary_join:
val = join_ary(mrb, val, sep, list);
/* fall through */
case MRB_TT_STRING:
str_join:
mrb_str_cat_str(mrb, result, val);
break;
default:
if (!mrb_immediate_p(val)) {
tmp = mrb_check_string_type(mrb, val);
if (!mrb_nil_p(tmp)) {
val = tmp;
goto str_join;
}
tmp = mrb_check_array_type(mrb, val);
if (!mrb_nil_p(tmp)) {
val = tmp;
goto ary_join;
}
}
val = mrb_obj_as_string(mrb, val);
goto str_join;
}
}
mrb_ary_pop(mrb, list);
return result;
}
| null | null | 220,398
|
152225607295454349366616301155865019135
| 55
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
ary_replace(mrb_state *mrb, struct RArray *a, struct RArray *b)
{
mrb_int len = ARY_LEN(b);
ary_modify_check(mrb, a);
if (a == b) return;
if (ARY_SHARED_P(a)) {
mrb_ary_decref(mrb, a->as.heap.aux.shared);
a->as.heap.aux.capa = 0;
a->as.heap.len = 0;
a->as.heap.ptr = NULL;
ARY_UNSET_SHARED_FLAG(a);
}
if (ARY_SHARED_P(b)) {
shared_b:
if (ARY_EMBED_P(a)) {
ARY_UNSET_EMBED_FLAG(a);
}
else {
mrb_free(mrb, a->as.heap.ptr);
}
a->as.heap.ptr = b->as.heap.ptr;
a->as.heap.len = len;
a->as.heap.aux.shared = b->as.heap.aux.shared;
a->as.heap.aux.shared->refcnt++;
ARY_SET_SHARED_FLAG(a);
mrb_write_barrier(mrb, (struct RBasic*)a);
return;
}
if (!mrb_frozen_p(b) && len > ARY_REPLACE_SHARED_MIN) {
ary_make_shared(mrb, b);
goto shared_b;
}
if (ARY_CAPA(a) < len)
ary_expand_capa(mrb, a, len);
array_copy(ARY_PTR(a), ARY_PTR(b), len);
mrb_write_barrier(mrb, (struct RBasic*)a);
ARY_SET_LEN(a, len);
}
| null | null | 220,399
|
205412147462821822344888449400190554864
| 39
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
ary_subseq(mrb_state *mrb, struct RArray *a, mrb_int beg, mrb_int len)
{
struct RArray *b;
if (!ARY_SHARED_P(a) && len <= ARY_SHIFT_SHARED_MIN) {
return mrb_ary_new_from_values(mrb, len, ARY_PTR(a)+beg);
}
ary_make_shared(mrb, a);
b = MRB_OBJ_ALLOC(mrb, MRB_TT_ARRAY, mrb->array_class);
b->as.heap.ptr = a->as.heap.ptr + beg;
b->as.heap.len = len;
b->as.heap.aux.shared = a->as.heap.aux.shared;
b->as.heap.aux.shared->refcnt++;
ARY_SET_SHARED_FLAG(b);
return mrb_obj_value(b);
}
| null | null | 220,400
|
162649423477490317252565099877815745256
| 17
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_s_create(mrb_state *mrb, mrb_value klass)
{
mrb_value ary;
const mrb_value *vals;
mrb_int len;
struct RArray *a;
mrb_get_args(mrb, "*!", &vals, &len);
ary = mrb_ary_new_from_values(mrb, len, vals);
a = mrb_ary_ptr(ary);
a->c = mrb_class_ptr(klass);
return ary;
}
| null | null | 220,401
|
179069330256164148167699085308201110737
| 14
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_decref(mrb_state *mrb, mrb_shared_array *shared)
{
shared->refcnt--;
if (shared->refcnt == 0) {
mrb_free(mrb, shared->ptr);
mrb_free(mrb, shared);
}
}
| null | null | 220,402
|
335819206918727592457138298896263343219
| 8
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
ary_shrink_capa(mrb_state *mrb, struct RArray *a)
{
mrb_int capa;
if (ARY_EMBED_P(a)) return;
capa = a->as.heap.aux.capa;
if (capa < ARY_DEFAULT_LEN * 2) return;
if (capa <= a->as.heap.len * ARY_SHRINK_RATIO) return;
do {
capa /= 2;
if (capa < ARY_DEFAULT_LEN) {
capa = ARY_DEFAULT_LEN;
break;
}
} while (capa > a->as.heap.len * ARY_SHRINK_RATIO);
if (capa > a->as.heap.len && capa < a->as.heap.aux.capa) {
a->as.heap.aux.capa = capa;
a->as.heap.ptr = (mrb_value *)mrb_realloc(mrb, a->as.heap.ptr, sizeof(mrb_value)*capa);
}
}
| null | null | 220,403
|
178564294714391619166129836032262581263
| 24
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals)
{
struct RArray *a = ary_new_capa(mrb, size);
array_copy(ARY_PTR(a), vals, size);
ARY_SET_LEN(a, size);
return a;
}
| null | null | 220,404
|
197890844008520486288978990975789102650
| 9
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_new_capa(mrb_state *mrb, mrb_int capa)
{
struct RArray *a = ary_new_capa(mrb, capa);
return mrb_obj_value(a);
}
| null | null | 220,405
|
144775824120100166734218404428229827695
| 5
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_replace(mrb_state *mrb, mrb_value self, mrb_value other)
{
struct RArray *a1 = mrb_ary_ptr(self);
struct RArray *a2 = mrb_ary_ptr(other);
if (a1 != a2) {
ary_replace(mrb, a1, a2);
}
}
| null | null | 220,406
|
211498541890907890750736274738838813776
| 9
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_splat(mrb_state *mrb, mrb_value v)
{
mrb_value ary;
struct RArray *a;
if (mrb_array_p(v)) {
a = ary_dup(mrb, mrb_ary_ptr(v));
return mrb_obj_value(a);
}
if (!mrb_respond_to(mrb, v, MRB_SYM(to_a))) {
return mrb_ary_new_from_values(mrb, 1, &v);
}
ary = mrb_funcall_id(mrb, v, MRB_SYM(to_a), 0);
if (mrb_nil_p(ary)) {
return mrb_ary_new_from_values(mrb, 1, &v);
}
mrb_ensure_array_type(mrb, ary);
a = mrb_ary_ptr(ary);
a = ary_dup(mrb, a);
return mrb_obj_value(a);
}
| null | null | 220,407
|
172181304428003067547592369246399422957
| 23
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_svalue(mrb_state *mrb, mrb_value ary)
{
switch (RARRAY_LEN(ary)) {
case 0:
return mrb_nil_value();
case 1:
return RARRAY_PTR(ary)[0];
default:
return ary;
}
}
| null | null | 220,408
|
6927466950198086950524184963278864265
| 11
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_last(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
mrb_int n, size, alen;
n = mrb_get_args(mrb, "|i", &size);
alen = ARY_LEN(a);
if (n == 0) {
return (alen > 0) ? ARY_PTR(a)[alen - 1]: mrb_nil_value();
}
if (size < 0) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "negative array size");
}
if (size > alen) size = alen;
if (ARY_SHARED_P(a) || size > ARY_DEFAULT_LEN) {
return ary_subseq(mrb, a, alen - size, size);
}
return mrb_ary_new_from_values(mrb, size, ARY_PTR(a) + alen - size);
}
| null | null | 220,409
|
191906389278208917014915243020187404989
| 20
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_subseq(mrb_state *mrb, mrb_value ary, mrb_int beg, mrb_int len)
{
struct RArray *a = mrb_ary_ptr(ary);
return ary_subseq(mrb, a, beg, len);
}
| null | null | 220,410
|
100492130847017618858367341190316228909
| 5
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_resize(mrb_state *mrb, mrb_value ary, mrb_int new_len)
{
mrb_int old_len;
struct RArray *a = mrb_ary_ptr(ary);
ary_modify(mrb, a);
old_len = RARRAY_LEN(ary);
if (old_len != new_len) {
if (new_len < old_len) {
ary_shrink_capa(mrb, a);
}
else {
ary_expand_capa(mrb, a, new_len);
ary_fill_with_nil(ARY_PTR(a) + old_len, new_len - old_len);
}
ARY_SET_LEN(a, new_len);
}
return ary;
}
| null | null | 220,411
|
138926841833680401980124826320385009642
| 20
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_unshift_m(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
const mrb_value *vals;
mrb_value *ptr;
mrb_int alen, len;
mrb_get_args(mrb, "*!", &vals, &alen);
if (alen == 0) {
ary_modify_check(mrb, a);
return self;
}
len = ARY_LEN(a);
if (alen > ARY_MAX_SIZE - len) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
}
if (ARY_SHARED_P(a)
&& a->as.heap.aux.shared->refcnt == 1 /* shared only referenced from this array */
&& a->as.heap.ptr - a->as.heap.aux.shared->ptr >= alen) /* there's room for unshifted item */ {
ary_modify_check(mrb, a);
a->as.heap.ptr -= alen;
ptr = a->as.heap.ptr;
}
else {
mrb_bool same = vals == ARY_PTR(a);
ary_modify(mrb, a);
if (ARY_CAPA(a) < len + alen)
ary_expand_capa(mrb, a, len + alen);
ptr = ARY_PTR(a);
value_move(ptr + alen, ptr, len);
if (same) vals = ptr;
}
array_copy(ptr, vals, alen);
ARY_SET_LEN(a, len+alen);
while (alen--) {
mrb_field_write_barrier_value(mrb, (struct RBasic*)a, vals[alen]);
}
return self;
}
| null | null | 220,412
|
334315208091853107193012268378600927558
| 40
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_reverse(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self), *b = ary_new_capa(mrb, ARY_LEN(a));
mrb_int len = ARY_LEN(a);
if (len > 0) {
mrb_value *p1, *p2, *e;
p1 = ARY_PTR(a);
e = p1 + len;
p2 = ARY_PTR(b) + len - 1;
while (p1 < e) {
*p2-- = *p1++;
}
ARY_SET_LEN(b, len);
}
return mrb_obj_value(b);
}
| null | null | 220,413
|
84885243866055843742758879923055962939
| 18
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_empty_p(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
return mrb_bool_value(ARY_LEN(a) == 0);
}
| null | null | 220,414
|
230381522765676661876274077233685385029
| 6
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_new(mrb_state *mrb)
{
return mrb_ary_new_capa(mrb, 0);
}
| null | null | 220,415
|
132199299211522301528083088107915310404
| 4
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_eq(mrb_state *mrb, mrb_value ary1)
{
mrb_value ary2 = mrb_get_arg1(mrb);
mrb->c->ci->mid = 0;
if (mrb_obj_equal(mrb, ary1, ary2)) return mrb_true_value();
if (!mrb_array_p(ary2)) {
return mrb_false_value();
}
if (RARRAY_LEN(ary1) != RARRAY_LEN(ary2)) return mrb_false_value();
return ary2;
}
| null | null | 220,416
|
83975379673832047087985352439752618588
| 13
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_concat(mrb_state *mrb, mrb_value self, mrb_value other)
{
struct RArray *a2 = mrb_ary_ptr(other);
ary_concat(mrb, mrb_ary_ptr(self), a2);
}
| null | null | 220,417
|
194183578293957320448664420148493402699
| 6
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
ary_modify(mrb_state *mrb, struct RArray *a)
{
ary_modify_check(mrb, a);
if (ARY_SHARED_P(a)) {
mrb_shared_array *shared = a->as.heap.aux.shared;
if (shared->refcnt == 1 && a->as.heap.ptr == shared->ptr) {
a->as.heap.ptr = shared->ptr;
a->as.heap.aux.capa = a->as.heap.len;
mrb_free(mrb, shared);
}
else {
mrb_value *ptr, *p;
mrb_int len;
p = a->as.heap.ptr;
len = a->as.heap.len * sizeof(mrb_value);
ptr = (mrb_value *)mrb_malloc(mrb, len);
if (p) {
array_copy(ptr, p, a->as.heap.len);
}
a->as.heap.ptr = ptr;
a->as.heap.aux.capa = a->as.heap.len;
mrb_ary_decref(mrb, shared);
}
ARY_UNSET_SHARED_FLAG(a);
}
}
| null | null | 220,418
|
280352138228140300206158442331143566120
| 29
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_entry(mrb_value ary, mrb_int n)
{
struct RArray *a = mrb_ary_ptr(ary);
mrb_int len = ARY_LEN(a);
/* range check */
if (n < 0) n += len;
if (n < 0 || len <= n) return mrb_nil_value();
return ARY_PTR(a)[n];
}
| null | null | 220,419
|
335766727954014441008425668574059327839
| 11
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_assoc_new(mrb_state *mrb, mrb_value car, mrb_value cdr)
{
struct RArray *a;
a = ary_new_capa(mrb, 2);
ARY_PTR(a)[0] = car;
ARY_PTR(a)[1] = cdr;
ARY_SET_LEN(a, 2);
return mrb_obj_value(a);
}
| null | null | 220,420
|
127190349514189792202404353614494124923
| 10
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_splice(mrb_state *mrb, mrb_value ary, mrb_int head, mrb_int len, mrb_value rpl)
{
struct RArray *a = mrb_ary_ptr(ary);
mrb_int alen = ARY_LEN(a);
const mrb_value *argv;
mrb_int argc;
mrb_int tail;
ary_modify(mrb, a);
/* len check */
if (len < 0) mrb_raisef(mrb, E_INDEX_ERROR, "negative length (%i)", len);
/* range check */
if (head < 0) {
head += alen;
if (head < 0) goto out_of_range;
}
if (head > ARY_MAX_SIZE - len) {
out_of_range:
mrb_raisef(mrb, E_INDEX_ERROR, "index %i is out of array", head);
}
tail = head + len;
if (alen < len || alen < tail) {
len = alen - head;
tail = head + len;
}
/* size check */
if (mrb_array_p(rpl)) {
argc = RARRAY_LEN(rpl);
argv = RARRAY_PTR(rpl);
if (argv == ARY_PTR(a)) {
struct RArray *r;
if (argc > 32767) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "too big recursive splice");
}
r = ary_dup(mrb, a);
argv = ARY_PTR(r);
}
}
else if (mrb_undef_p(rpl)) {
argc = 0;
argv = NULL;
}
else {
argc = 1;
argv = &rpl;
}
if (head >= alen) {
if (head > ARY_MAX_SIZE - argc) goto out_of_range;
len = head + argc;
if (len > ARY_CAPA(a)) {
ary_expand_capa(mrb, a, len);
}
ary_fill_with_nil(ARY_PTR(a) + alen, head - alen);
if (argc > 0) {
array_copy(ARY_PTR(a) + head, argv, argc);
}
ARY_SET_LEN(a, len);
}
else {
mrb_int newlen;
if (alen - len > ARY_MAX_SIZE - argc) {
head = alen + argc - len;
goto out_of_range;
}
newlen = alen + argc - len;
if (newlen > ARY_CAPA(a)) {
ary_expand_capa(mrb, a, newlen);
}
if (len != argc) {
mrb_value *ptr = ARY_PTR(a);
value_move(ptr + head + argc, ptr + tail, alen - tail);
ARY_SET_LEN(a, newlen);
}
if (argc > 0) {
value_move(ARY_PTR(a) + head, argv, argc);
}
}
mrb_write_barrier(mrb, (struct RBasic*)a);
return ary;
}
| null | null | 220,421
|
25950020905157063465822081187109590579
| 86
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_clear_m(mrb_state *mrb, mrb_value self)
{
return mrb_ary_clear(mrb, self);
}
| null | null | 220,422
|
170697009280786314068716223120343318526
| 4
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_size(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
return mrb_int_value(mrb, ARY_LEN(a));
}
| null | null | 220,423
|
63243895453095942649072994734216922608
| 6
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
ary_new_capa(mrb_state *mrb, mrb_int capa)
{
struct RArray *a;
size_t blen;
if (capa > ARY_MAX_SIZE) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
}
blen = capa * sizeof(mrb_value);
a = MRB_OBJ_ALLOC(mrb, MRB_TT_ARRAY, mrb->array_class);
if (capa <= MRB_ARY_EMBED_LEN_MAX) {
ARY_SET_EMBED_LEN(a, 0);
}
else {
a->as.heap.ptr = (mrb_value *)mrb_malloc(mrb, blen);
a->as.heap.aux.capa = capa;
a->as.heap.len = 0;
}
return a;
}
| null | null | 220,424
|
177259796052009306962043695325436523896
| 22
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_join(mrb_state *mrb, mrb_value ary, mrb_value sep)
{
if (!mrb_nil_p(sep)) {
sep = mrb_obj_as_string(mrb, sep);
}
return join_ary(mrb, ary, sep, mrb_ary_new(mrb));
}
| null | null | 220,425
|
166963801508496817286925686924009602421
| 7
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
ary_modify_check(mrb_state *mrb, struct RArray *a)
{
mrb_check_frozen(mrb, a);
}
| null | null | 220,426
|
159853445898116804943019620148089445886
| 4
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_cmp(mrb_state *mrb, mrb_value ary1)
{
mrb_value ary2 = mrb_get_arg1(mrb);
mrb->c->ci->mid = 0;
if (mrb_obj_equal(mrb, ary1, ary2)) return mrb_fixnum_value(0);
if (!mrb_array_p(ary2)) {
return mrb_nil_value();
}
return ary2;
}
| null | null | 220,427
|
322494495423418078871284492979110381112
| 12
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
ary_expand_capa(mrb_state *mrb, struct RArray *a, mrb_int len)
{
mrb_int capa = ARY_CAPA(a);
if (len > ARY_MAX_SIZE || len < 0) {
size_error:
mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
}
if (capa < ARY_DEFAULT_LEN) {
capa = ARY_DEFAULT_LEN;
}
while (capa < len) {
if (capa <= ARY_MAX_SIZE / 2) {
capa *= 2;
}
else {
capa = len;
}
}
if (capa < len || capa > ARY_MAX_SIZE) {
goto size_error;
}
if (ARY_EMBED_P(a)) {
mrb_value *ptr = ARY_EMBED_PTR(a);
mrb_int len = ARY_EMBED_LEN(a);
mrb_value *expanded_ptr = (mrb_value *)mrb_malloc(mrb, sizeof(mrb_value)*capa);
ARY_UNSET_EMBED_FLAG(a);
array_copy(expanded_ptr, ptr, len);
a->as.heap.len = len;
a->as.heap.aux.capa = capa;
a->as.heap.ptr = expanded_ptr;
}
else if (capa > a->as.heap.aux.capa) {
mrb_value *expanded_ptr = (mrb_value *)mrb_realloc(mrb, a->as.heap.ptr, sizeof(mrb_value)*capa);
a->as.heap.aux.capa = capa;
a->as.heap.ptr = expanded_ptr;
}
}
| null | null | 220,428
|
130095157301728138413134171115098862627
| 42
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_index_m(mrb_state *mrb, mrb_value self)
{
mrb_value obj = mrb_get_arg1(mrb);
mrb_int i;
for (i = 0; i < RARRAY_LEN(self); i++) {
if (mrb_equal(mrb, RARRAY_PTR(self)[i], obj)) {
return mrb_int_value(mrb, i);
}
}
return mrb_nil_value();
}
| null | null | 220,429
|
338599107301653747232201130061420263392
| 12
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_unshift(mrb_state *mrb, mrb_value self, mrb_value item)
{
struct RArray *a = mrb_ary_ptr(self);
mrb_int len = ARY_LEN(a);
if (ARY_SHARED_P(a)
&& a->as.heap.aux.shared->refcnt == 1 /* shared only referenced from this array */
&& a->as.heap.ptr - a->as.heap.aux.shared->ptr >= 1) /* there's room for unshifted item */ {
a->as.heap.ptr--;
a->as.heap.ptr[0] = item;
}
else {
mrb_value *ptr;
ary_modify(mrb, a);
if (ARY_CAPA(a) < len + 1)
ary_expand_capa(mrb, a, len + 1);
ptr = ARY_PTR(a);
value_move(ptr + 1, ptr, len);
ptr[0] = item;
}
ARY_SET_LEN(a, len+1);
mrb_field_write_barrier_value(mrb, (struct RBasic*)a, item);
return self;
}
| null | null | 220,430
|
240743254862849014952706182273639063843
| 26
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_set(mrb_state *mrb, mrb_value ary, mrb_int n, mrb_value val)
{
struct RArray *a = mrb_ary_ptr(ary);
mrb_int len = ARY_LEN(a);
ary_modify(mrb, a);
/* range check */
if (n < 0) {
n += len;
if (n < 0) {
mrb_raisef(mrb, E_INDEX_ERROR, "index %i out of array", n - len);
}
}
if (len <= n) {
if (ARY_CAPA(a) <= n)
ary_expand_capa(mrb, a, n + 1);
ary_fill_with_nil(ARY_PTR(a) + len, n + 1 - len);
ARY_SET_LEN(a, n+1);
}
ARY_PTR(a)[n] = val;
mrb_field_write_barrier_value(mrb, (struct RBasic*)a, val);
}
| null | null | 220,431
|
117117913622888667971760653724727764375
| 23
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_concat_m(mrb_state *mrb, mrb_value self)
{
mrb_value ary;
mrb_get_args(mrb, "A", &ary);
mrb_ary_concat(mrb, self, ary);
return self;
}
| null | null | 220,432
|
168239782244727365863942493862828096927
| 8
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_join_m(mrb_state *mrb, mrb_value ary)
{
mrb_value sep = mrb_nil_value();
mrb_get_args(mrb, "|S!", &sep);
return mrb_ary_join(mrb, ary, sep);
}
| null | null | 220,433
|
220353674744268014548131041553355864705
| 7
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
ary_fill_with_nil(mrb_value *ptr, mrb_int size)
{
mrb_value nil = mrb_nil_value();
while (size--) {
*ptr++ = nil;
}
}
| null | null | 220,434
|
162016813516497702393149935445547807285
| 8
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_times(mrb_state *mrb, mrb_value self)
{
struct RArray *a1 = mrb_ary_ptr(self);
struct RArray *a2;
mrb_value *ptr;
mrb_int times, len1;
mrb_get_args(mrb, "i", ×);
if (times < 0) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "negative argument");
}
if (times == 0) return mrb_ary_new(mrb);
if (ARY_MAX_SIZE / times < ARY_LEN(a1)) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
}
len1 = ARY_LEN(a1);
a2 = ary_new_capa(mrb, len1 * times);
ARY_SET_LEN(a2, len1 * times);
ptr = ARY_PTR(a2);
while (times--) {
array_copy(ptr, ARY_PTR(a1), len1);
ptr += len1;
}
return mrb_obj_value(a2);
}
| null | null | 220,435
|
59973791336790087531172697748979687643
| 26
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_push_m(mrb_state *mrb, mrb_value self)
{
mrb_int argc;
const mrb_value *argv;
mrb_int len, len2;
struct RArray *a;
argc = mrb_get_argc(mrb);
argv = mrb_get_argv(mrb);
a = mrb_ary_ptr(self);
ary_modify(mrb, a);
len = ARY_LEN(a);
len2 = len + argc;
if (ARY_CAPA(a) < len2) {
ary_expand_capa(mrb, a, len2);
}
array_copy(ARY_PTR(a)+len, argv, argc);
ARY_SET_LEN(a, len2);
while (argc--) {
mrb_field_write_barrier_value(mrb, (struct RBasic*)a, *argv);
argv++;
}
return self;
}
| null | null | 220,436
|
197377563438203004717310267297135368275
| 24
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_aset(mrb_state *mrb, mrb_value self)
{
mrb_value v1, v2, v3;
mrb_int i, len;
ary_modify(mrb, mrb_ary_ptr(self));
if (mrb_get_argc(mrb) == 2) {
const mrb_value *vs = mrb_get_argv(mrb);
v1 = vs[0]; v2 = vs[1];
/* a[n..m] = v */
switch (mrb_range_beg_len(mrb, v1, &i, &len, RARRAY_LEN(self), FALSE)) {
case MRB_RANGE_TYPE_MISMATCH:
mrb_ary_set(mrb, self, aget_index(mrb, v1), v2);
break;
case MRB_RANGE_OK:
mrb_ary_splice(mrb, self, i, len, v2);
break;
case MRB_RANGE_OUT:
mrb_raisef(mrb, E_RANGE_ERROR, "%v out of range", v1);
break;
}
return v2;
}
mrb_get_args(mrb, "ooo", &v1, &v2, &v3);
/* a[n,m] = v */
mrb_ary_splice(mrb, self, aget_index(mrb, v1), aget_index(mrb, v2), v3);
return v3;
}
| null | null | 220,437
|
227437440724327067317016807225102425666
| 30
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_first(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
mrb_int size, alen;
if (mrb_get_argc(mrb) == 0) {
return (ARY_LEN(a) > 0)? ARY_PTR(a)[0]: mrb_nil_value();
}
mrb_get_args(mrb, "|i", &size);
if (size < 0) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "negative array size");
}
alen = ARY_LEN(a);
if (size > alen) size = alen;
if (ARY_SHARED_P(a)) {
return ary_subseq(mrb, a, 0, size);
}
return mrb_ary_new_from_values(mrb, size, ARY_PTR(a));
}
| null | null | 220,438
|
22738727453001422716952329239575849911
| 20
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
ary_make_shared(mrb_state *mrb, struct RArray *a)
{
if (!ARY_SHARED_P(a) && !ARY_EMBED_P(a)) {
mrb_shared_array *shared = (mrb_shared_array *)mrb_malloc(mrb, sizeof(mrb_shared_array));
mrb_value *ptr = a->as.heap.ptr;
mrb_int len = a->as.heap.len;
shared->refcnt = 1;
if (a->as.heap.aux.capa > len) {
a->as.heap.ptr = shared->ptr = (mrb_value *)mrb_realloc(mrb, ptr, sizeof(mrb_value)*len+1);
}
else {
shared->ptr = ptr;
}
shared->len = len;
a->as.heap.aux.shared = shared;
ARY_SET_SHARED_FLAG(a);
}
}
| null | null | 220,439
|
15955450162343325075017044055808484954
| 19
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_new_from_values(mrb_state *mrb, mrb_int size, const mrb_value *vals)
{
struct RArray *a = ary_new_from_values(mrb, size, vals);
return mrb_obj_value(a);
}
| null | null | 220,440
|
260771970141893475776764451168917237871
| 5
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_modify(mrb_state *mrb, struct RArray* a)
{
mrb_write_barrier(mrb, (struct RBasic*)a);
ary_modify(mrb, a);
}
| null | null | 220,441
|
237411611180493870936045593176479296485
| 5
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_shift_m(mrb_state *mrb, mrb_value self)
{
mrb_int n;
if (mrb_get_args(mrb, "|i", &n) == 0) {
return mrb_ary_shift(mrb, self);
}
struct RArray *a = mrb_ary_ptr(self);
mrb_int len = ARY_LEN(a);
mrb_value val;
ary_modify_check(mrb, a);
if (len == 0 || n == 0) return mrb_ary_new(mrb);
if (n < 0) mrb_raise(mrb, E_ARGUMENT_ERROR, "negative array shift");
if (n > len) n = len;
val = mrb_ary_new_from_values(mrb, n, ARY_PTR(a));
if (ARY_SHARED_P(a)) {
L_SHIFT:
a->as.heap.ptr+=n;
a->as.heap.len-=n;
return val;
}
if (len > ARY_SHIFT_SHARED_MIN) {
ary_make_shared(mrb, a);
goto L_SHIFT;
}
else if (len == n) {
ARY_SET_LEN(a, 0);
}
else {
mrb_value *ptr = ARY_PTR(a);
mrb_int size = len-n;
while (size--) {
*ptr = *(ptr+n);
++ptr;
}
ARY_SET_LEN(a, len-n);
}
return val;
}
| null | null | 220,442
|
218273634780972114764800997663884992078
| 42
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
ary_concat(mrb_state *mrb, struct RArray *a, struct RArray *a2)
{
mrb_int len;
if (ARY_LEN(a) == 0) {
ary_replace(mrb, a, a2);
return;
}
if (ARY_LEN(a2) > ARY_MAX_SIZE - ARY_LEN(a)) {
mrb_raise(mrb, E_ARGUMENT_ERROR, "array size too big");
}
len = ARY_LEN(a) + ARY_LEN(a2);
ary_modify(mrb, a);
if (ARY_CAPA(a) < len) {
ary_expand_capa(mrb, a, len);
}
array_copy(ARY_PTR(a)+ARY_LEN(a), ARY_PTR(a2), ARY_LEN(a2));
mrb_write_barrier(mrb, (struct RBasic*)a);
ARY_SET_LEN(a, len);
}
| null | null | 220,443
|
331484351250995621490153785157482797175
| 21
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_delete_at(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
mrb_int index;
mrb_value val;
mrb_value *ptr;
mrb_int len, alen;
mrb_get_args(mrb, "i", &index);
alen = ARY_LEN(a);
if (index < 0) index += alen;
if (index < 0 || alen <= index) return mrb_nil_value();
ary_modify(mrb, a);
ptr = ARY_PTR(a);
val = ptr[index];
ptr += index;
len = alen - index;
while (--len) {
*ptr = *(ptr+1);
++ptr;
}
ARY_SET_LEN(a, alen-1);
ary_shrink_capa(mrb, a);
return val;
}
| null | null | 220,444
|
224493729085090560568437285504944553139
| 29
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
mruby
|
27d1e0132a0804581dca28df042e7047fd27eaa8
| 0
|
mrb_ary_shift(mrb_state *mrb, mrb_value self)
{
struct RArray *a = mrb_ary_ptr(self);
mrb_int len = ARY_LEN(a);
mrb_value val;
ary_modify_check(mrb, a);
if (len == 0) return mrb_nil_value();
if (ARY_SHARED_P(a)) {
L_SHIFT:
val = a->as.heap.ptr[0];
a->as.heap.ptr++;
a->as.heap.len--;
return val;
}
if (len > ARY_SHIFT_SHARED_MIN) {
ary_make_shared(mrb, a);
goto L_SHIFT;
}
else {
mrb_value *ptr = ARY_PTR(a);
mrb_int size = len;
val = *ptr;
while (--size) {
*ptr = *(ptr+1);
++ptr;
}
ARY_SET_LEN(a, len-1);
}
return val;
}
| null | null | 220,445
|
311758108864036290854477370102254280596
| 32
|
array.c: fix `mrb_ary_shift_m` initialization bug.
The `ARY_PTR` and `ARY_LEN` may be modified in `mrb_get_args`.
|
other
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.