idx
int64 | func
string | target
int64 |
|---|---|---|
432,311
|
AddressSpace *cpu_get_address_space(CPUState *cpu, int asidx)
{
/* only one AddressSpace. */
return cpu->cpu_ases[0].as;
}
| 0
|
432,159
|
Timestamp PipelineD::getLatestOplogTimestamp(const Pipeline* pipeline) {
if (auto docSourceCursor =
dynamic_cast<DocumentSourceCursor*>(pipeline->_sources.front().get())) {
return docSourceCursor->getLatestOplogTimestamp();
}
return Timestamp();
}
| 0
|
477,364
|
R_API RBinJavaAttrInfo *r_bin_java_signature_attr_new(RBinJavaObj *bin, ut8 *buffer, ut64 sz, ut64 buf_offset) {
ut64 offset = 6;
RBinJavaAttrInfo *attr = r_bin_java_default_attr_new (bin, buffer, sz, buf_offset);
if (!attr) {
return NULL;
}
attr->type = R_BIN_JAVA_ATTR_TYPE_SIGNATURE_ATTR;
// attr->info.source_file_attr.sourcefile_idx = R_BIN_JAVA_USHORT (buffer, offset);
// offset += 2;
attr->info.signature_attr.signature_idx = R_BIN_JAVA_USHORT (buffer, offset);
offset += 2;
attr->info.signature_attr.signature = r_bin_java_get_utf8_from_bin_cp_list (
R_BIN_JAVA_GLOBAL_BIN, attr->info.signature_attr.signature_idx);
if (!attr->info.signature_attr.signature) {
eprintf ("r_bin_java_signature_attr_new: Unable to resolve the "
"Signature UTF8 String Index: 0x%02x\n", attr->info.signature_attr.signature_idx);
}
attr->size = offset;
// IFDBG r_bin_java_print_source_code_file_attr_summary(attr);
return attr;
}
| 0
|
230,395
|
PJ_DEF(pj_xml_attr*) pj_xml_attr_new( pj_pool_t *pool, const pj_str_t *name,
const pj_str_t *value)
{
pj_xml_attr *attr = alloc_attr(pool);
pj_strdup( pool, &attr->name, name);
pj_strdup( pool, &attr->value, value);
return attr;
}
| 0
|
336,492
|
SPICE_GNUC_VISIBLE SpiceImageCompression spice_server_get_image_compression(SpiceServer *s)
{
return s->config->image_compression;
}
| 0
|
477,295
|
static void tipc_crypto_key_synch(struct tipc_crypto *rx, struct sk_buff *skb)
{
struct tipc_ehdr *ehdr = (struct tipc_ehdr *)skb_network_header(skb);
struct tipc_crypto *tx = tipc_net(rx->net)->crypto_tx;
struct tipc_msg *hdr = buf_msg(skb);
u32 self = tipc_own_addr(rx->net);
u8 cur, new;
unsigned long delay;
/* Update RX 'key_master' flag according to peer, also mark "legacy" if
* a peer has no master key.
*/
rx->key_master = ehdr->master_key;
if (!rx->key_master)
tx->legacy_user = 1;
/* For later cases, apply only if message is destined to this node */
if (!ehdr->destined || msg_short(hdr) || msg_destnode(hdr) != self)
return;
/* Case 1: Peer has no keys, let's make master key take over */
if (ehdr->rx_nokey) {
/* Set or extend grace period */
tx->timer2 = jiffies;
/* Schedule key distributing for the peer if not yet */
if (tx->key.keys &&
!atomic_cmpxchg(&rx->key_distr, 0, KEY_DISTR_SCHED)) {
get_random_bytes(&delay, 2);
delay %= 5;
delay = msecs_to_jiffies(500 * ++delay);
if (queue_delayed_work(tx->wq, &rx->work, delay))
tipc_node_get(rx->node);
}
} else {
/* Cancel a pending key distributing if any */
atomic_xchg(&rx->key_distr, 0);
}
/* Case 2: Peer RX active key has changed, let's update own TX users */
cur = atomic_read(&rx->peer_rx_active);
new = ehdr->rx_key_active;
if (tx->key.keys &&
cur != new &&
atomic_cmpxchg(&rx->peer_rx_active, cur, new) == cur) {
if (new)
tipc_aead_users_inc(tx->aead[new], INT_MAX);
if (cur)
tipc_aead_users_dec(tx->aead[cur], 0);
atomic64_set(&rx->sndnxt, 0);
/* Mark the point TX key users changed */
tx->timer1 = jiffies;
pr_debug("%s: key users changed %d-- %d++, peer %s\n",
tx->name, cur, new, rx->name);
}
}
| 0
|
329,937
|
draw (cairo_t *cr, int width, int height)
{
cairo_set_source_rgb (cr, 0., 0., 0.);
cairo_paint (cr);
cairo_set_source_rgb (cr, 1., 1., 1.);
cairo_set_line_width (cr, 1.);
cairo_pattern_t *p = cairo_pattern_create_linear (0, 0, width, height);
cairo_pattern_add_color_stop_rgb (p, 0, 0.99, 1, 1);
cairo_pattern_add_color_stop_rgb (p, 1, 1, 1, 1);
cairo_set_source (cr, p);
cairo_move_to (cr, 0.5, -1);
for (int i = 0; i < width; i+=3) {
cairo_rel_line_to (cr, 2, 2);
cairo_rel_line_to (cr, 1, -2);
}
cairo_set_operator (cr, CAIRO_OPERATOR_SOURCE);
cairo_stroke (cr);
cairo_pattern_destroy(p);
return CAIRO_TEST_SUCCESS;
}
| 0
|
373,546
|
ipf_expiry_list_remove(struct ipf_list *ipf_list)
/* OVS_REQUIRES(ipf_lock) */
{
ovs_list_remove(&ipf_list->list_node);
}
| 0
|
244,293
|
GF_Err sdtp_box_write(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
GF_SampleDependencyTypeBox *ptr = (GF_SampleDependencyTypeBox *)s;
e = gf_isom_full_box_write(s, bs);
if (e) return e;
gf_bs_write_data(bs, (char*)ptr->sample_info, ptr->sampleCount);
return GF_OK;
}
| 0
|
415,186
|
cmd_readkey (assuan_context_t ctx, char *line)
{
ctrl_t ctrl = assuan_get_pointer (ctx);
int rc;
unsigned char *cert = NULL;
size_t ncert, n;
ksba_cert_t kc = NULL;
ksba_sexp_t p;
unsigned char *pk;
size_t pklen;
if ((rc = open_card (ctrl, NULL)))
return rc;
line = xstrdup (line); /* Need a copy of the line. */
/* If the application supports the READKEY function we use that.
Otherwise we use the old way by extracting it from the
certificate. */
rc = app_readkey (ctrl->app_ctx, line, &pk, &pklen);
if (!rc)
{ /* Yeah, got that key - send it back. */
rc = assuan_send_data (ctx, pk, pklen);
xfree (pk);
xfree (line);
line = NULL;
goto leave;
}
if (gpg_err_code (rc) != GPG_ERR_UNSUPPORTED_OPERATION)
log_error ("app_readkey failed: %s\n", gpg_strerror (rc));
else
{
rc = app_readcert (ctrl->app_ctx, line, &cert, &ncert);
if (rc)
log_error ("app_readcert failed: %s\n", gpg_strerror (rc));
}
xfree (line);
line = NULL;
if (rc)
goto leave;
rc = ksba_cert_new (&kc);
if (rc)
goto leave;
rc = ksba_cert_init_from_mem (kc, cert, ncert);
if (rc)
{
log_error ("failed to parse the certificate: %s\n", gpg_strerror (rc));
goto leave;
}
p = ksba_cert_get_public_key (kc);
if (!p)
{
rc = gpg_error (GPG_ERR_NO_PUBKEY);
goto leave;
}
n = gcry_sexp_canon_len (p, 0, NULL, NULL);
rc = assuan_send_data (ctx, p, n);
xfree (p);
leave:
ksba_cert_release (kc);
xfree (cert);
TEST_CARD_REMOVAL (ctrl, rc);
return rc;
}
| 0
|
390,586
|
SetKeyBehaviors( XkbSrvInfoPtr xkbi,
xkbSetMapReq *req,
xkbBehaviorWireDesc *wire,
XkbChangesPtr changes)
{
register unsigned i;
int maxRG = -1;
XkbDescPtr xkb = xkbi->desc;
XkbServerMapPtr server = xkb->server;
unsigned first,last;
first= req->firstKeyBehavior;
last= req->firstKeyBehavior+req->nKeyBehaviors-1;
bzero(&server->behaviors[first],req->nKeyBehaviors*sizeof(XkbBehavior));
for (i=0;i<req->totalKeyBehaviors;i++) {
if ((server->behaviors[wire->key].type&XkbKB_Permanent)==0) {
server->behaviors[wire->key].type= wire->type;
server->behaviors[wire->key].data= wire->data;
if ((wire->type==XkbKB_RadioGroup)&&(((int)wire->data)>maxRG))
maxRG= wire->data + 1;
}
wire++;
}
if (maxRG>(int)xkbi->nRadioGroups) {
int sz = maxRG*sizeof(XkbRadioGroupRec);
if (xkbi->radioGroups)
xkbi->radioGroups=(XkbRadioGroupPtr)_XkbRealloc(xkbi->radioGroups,sz);
else xkbi->radioGroups= (XkbRadioGroupPtr)_XkbCalloc(1, sz);
if (xkbi->radioGroups) {
if (xkbi->nRadioGroups)
bzero(&xkbi->radioGroups[xkbi->nRadioGroups],
(maxRG-xkbi->nRadioGroups)*sizeof(XkbRadioGroupRec));
xkbi->nRadioGroups= maxRG;
}
else xkbi->nRadioGroups= 0;
/* should compute members here */
}
if (changes->map.changed&XkbKeyBehaviorsMask) {
unsigned oldLast;
oldLast= changes->map.first_key_behavior+
changes->map.num_key_behaviors-1;
if (changes->map.first_key_behavior<req->firstKeyBehavior)
first= changes->map.first_key_behavior;
if (oldLast>last)
last= oldLast;
}
changes->map.changed|= XkbKeyBehaviorsMask;
changes->map.first_key_behavior = first;
changes->map.num_key_behaviors = (last-first+1);
return (char *)wire;
}
| 0
|
238,535
|
static void adjust_insn_aux_data(struct bpf_verifier_env *env,
struct bpf_insn_aux_data *new_data,
struct bpf_prog *new_prog, u32 off, u32 cnt)
{
struct bpf_insn_aux_data *old_data = env->insn_aux_data;
struct bpf_insn *insn = new_prog->insnsi;
u32 old_seen = old_data[off].seen;
u32 prog_len;
int i;
/* aux info at OFF always needs adjustment, no matter fast path
* (cnt == 1) is taken or not. There is no guarantee INSN at OFF is the
* original insn at old prog.
*/
old_data[off].zext_dst = insn_has_def32(env, insn + off + cnt - 1);
if (cnt == 1)
return;
prog_len = new_prog->len;
memcpy(new_data, old_data, sizeof(struct bpf_insn_aux_data) * off);
memcpy(new_data + off + cnt - 1, old_data + off,
sizeof(struct bpf_insn_aux_data) * (prog_len - off - cnt + 1));
for (i = off; i < off + cnt - 1; i++) {
/* Expand insni[off]'s seen count to the patched range. */
new_data[i].seen = old_seen;
new_data[i].zext_dst = insn_has_def32(env, insn + i);
}
env->insn_aux_data = new_data;
vfree(old_data);
}
| 0
|
401,590
|
static int proc_do_entropy(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
struct ctl_table fake_table;
int entropy_count;
entropy_count = *(int *)table->data >> ENTROPY_SHIFT;
fake_table.data = &entropy_count;
fake_table.maxlen = sizeof(entropy_count);
return proc_dointvec(&fake_table, write, buffer, lenp, ppos);
}
| 0
|
244,289
|
void strk_box_del(GF_Box *s)
{
gf_free(s);
}
| 0
|
412,147
|
respip_set_apply_cfg(struct respip_set* set, char* const* tagname, int num_tags,
struct config_strbytelist* respip_tags,
struct config_str2list* respip_actions,
struct config_str2list* respip_data)
{
struct config_strbytelist* p;
struct config_str2list* pa;
struct config_str2list* pd;
set->tagname = tagname;
set->num_tags = num_tags;
p = respip_tags;
while(p) {
struct config_strbytelist* np = p->next;
log_assert(p->str && p->str2);
if(!respip_tag_cfg(set, p->str, p->str2, p->str2len)) {
config_del_strbytelist(p);
return 0;
}
free(p->str);
free(p->str2);
free(p);
p = np;
}
pa = respip_actions;
while(pa) {
struct config_str2list* np = pa->next;
log_assert(pa->str && pa->str2);
if(!respip_action_cfg(set, pa->str, pa->str2)) {
config_deldblstrlist(pa);
return 0;
}
free(pa->str);
free(pa->str2);
free(pa);
pa = np;
}
pd = respip_data;
while(pd) {
struct config_str2list* np = pd->next;
log_assert(pd->str && pd->str2);
if(!respip_data_cfg(set, pd->str, pd->str2)) {
config_deldblstrlist(pd);
return 0;
}
free(pd->str);
free(pd->str2);
free(pd);
pd = np;
}
addr_tree_init_parents(&set->ip_tree);
return 1;
}
| 0
|
224,178
|
std::size_t incomplete_size() {
tensorflow::mutex_lock lock(mu_);
return incomplete_.size();
}
| 0
|
245,723
|
static void relay_connection (struct conn_s *connptr)
{
int ret;
ssize_t bytes_received;
for (;;) {
pollfd_struct fds[2] = {0};
fds[0].fd = connptr->client_fd;
fds[1].fd = connptr->server_fd;
if (buffer_size (connptr->sbuffer) > 0)
fds[0].events |= MYPOLL_WRITE;
if (buffer_size (connptr->cbuffer) > 0)
fds[1].events |= MYPOLL_WRITE;
if (buffer_size (connptr->sbuffer) < MAXBUFFSIZE)
fds[1].events |= MYPOLL_READ;
if (buffer_size (connptr->cbuffer) < MAXBUFFSIZE)
fds[0].events |= MYPOLL_READ;
ret = mypoll(fds, 2, config->idletimeout);
if (ret == 0) {
log_message (LOG_INFO,
"Idle Timeout (after " SELECT_OR_POLL ")");
return;
} else if (ret < 0) {
log_message (LOG_ERR,
"relay_connection: " SELECT_OR_POLL "() error \"%s\". "
"Closing connection (client_fd:%d, server_fd:%d)",
strerror (errno), connptr->client_fd,
connptr->server_fd);
return;
}
if (fds[1].revents & MYPOLL_READ) {
bytes_received =
read_buffer (connptr->server_fd, connptr->sbuffer);
if (bytes_received < 0)
break;
connptr->content_length.server -= bytes_received;
if (connptr->content_length.server == 0)
break;
}
if ((fds[0].revents & MYPOLL_READ)
&& read_buffer (connptr->client_fd, connptr->cbuffer) < 0) {
break;
}
if ((fds[1].revents & MYPOLL_WRITE)
&& write_buffer (connptr->server_fd, connptr->cbuffer) < 0) {
break;
}
if ((fds[0].revents & MYPOLL_WRITE)
&& write_buffer (connptr->client_fd, connptr->sbuffer) < 0) {
break;
}
}
while (buffer_size (connptr->sbuffer) > 0) {
if (write_buffer (connptr->client_fd, connptr->sbuffer) < 0)
break;
}
shutdown (connptr->client_fd, SHUT_WR);
/*
* Try to send any remaining data to the server if we can.
*/
ret = socket_blocking (connptr->server_fd);
if (ret != 0) {
log_message(LOG_ERR,
"Failed to set server socket to blocking: %s",
strerror(errno));
return;
}
while (buffer_size (connptr->cbuffer) > 0) {
if (write_buffer (connptr->server_fd, connptr->cbuffer) < 0)
break;
}
return;
}
| 0
|
522,341
|
int APIF77(gmfsetkwd)( int64_t *MshIdx, int *KwdIdx, int *NmbLin,
int *NmbTyp, int *TypTab, int *deg, int *NmbNod)
{
if(!strcmp(GmfKwdFmt[ *KwdIdx ][2], "hr"))
return(GmfSetKwd(*MshIdx, *KwdIdx, *NmbLin, *NmbTyp, TypTab, *deg, *NmbNod));
else if(!strcmp(GmfKwdFmt[ *KwdIdx ][2], "sr"))
return(GmfSetKwd(*MshIdx, *KwdIdx, *NmbLin, *NmbTyp, TypTab));
else
return(GmfSetKwd(*MshIdx, *KwdIdx, *NmbLin));
}
| 0
|
338,079
|
void WasmBinaryWriter::writeLegacyDylinkSection() {
if (!wasm->dylinkSection) {
return;
}
auto start = startSection(BinaryConsts::User);
writeInlineString(BinaryConsts::UserSections::Dylink);
o << U32LEB(wasm->dylinkSection->memorySize);
o << U32LEB(wasm->dylinkSection->memoryAlignment);
o << U32LEB(wasm->dylinkSection->tableSize);
o << U32LEB(wasm->dylinkSection->tableAlignment);
o << U32LEB(wasm->dylinkSection->neededDynlibs.size());
for (auto& neededDynlib : wasm->dylinkSection->neededDynlibs) {
writeInlineString(neededDynlib.c_str());
}
finishSection(start);
}
| 0
|
359,352
|
DEFUN (bgp_redistribute_ipv4_rmap_metric,
bgp_redistribute_ipv4_rmap_metric_cmd,
"redistribute (connected|kernel|ospf|rip|static) route-map WORD metric <0-4294967295>",
"Redistribute information from another routing protocol\n"
"Connected\n"
"Kernel routes\n"
"Open Shurtest Path First (OSPF)\n"
"Routing Information Protocol (RIP)\n"
"Static routes\n"
"Route map reference\n"
"Pointer to route-map entries\n"
"Metric for redistributed routes\n"
"Default metric\n")
{
int type;
u_int32_t metric;
type = bgp_str2route_type (AFI_IP, argv[0]);
if (! type)
{
vty_out (vty, "%% Invalid route type%s", VTY_NEWLINE);
return CMD_WARNING;
}
VTY_GET_INTEGER ("metric", metric, argv[2]);
bgp_redistribute_rmap_set (vty->index, AFI_IP, type, argv[1]);
bgp_redistribute_metric_set (vty->index, AFI_IP, type, metric);
return bgp_redistribute_set (vty->index, AFI_IP, type);
}
| 0
|
345,139
|
static inline struct pxa3xx_gcu_priv *to_pxa3xx_gcu_priv(struct file *file)
{
struct miscdevice *dev = file->private_data;
return container_of(dev, struct pxa3xx_gcu_priv, misc_dev);
}
| 0
|
244,159
|
void ihdr_box_del(GF_Box *s)
{
gf_free(s);
}
| 0
|
512,282
|
my_decimal *val_decimal(my_decimal *to)
{
return has_value() ? Date(this).to_decimal(to) : NULL;
}
| 0
|
269,311
|
static av_always_inline void predict_plane(SnowContext *s, IDWTELEM *buf, int plane_index, int add){
const int mb_h= s->b_height << s->block_max_depth;
int mb_y;
for(mb_y=0; mb_y<=mb_h; mb_y++)
predict_slice(s, buf, plane_index, add, mb_y);
}
| 0
|
242,984
|
static int ssl_buffer_make_space( mbedtls_ssl_context *ssl,
size_t desired )
{
int offset;
mbedtls_ssl_handshake_params * const hs = ssl->handshake;
MBEDTLS_SSL_DEBUG_MSG( 2, ( "Attempt to free buffered messages to have %u bytes available",
(unsigned) desired ) );
/* Get rid of future records epoch first, if such exist. */
ssl_free_buffered_record( ssl );
/* Check if we have enough space available now. */
if( desired <= ( MBEDTLS_SSL_DTLS_MAX_BUFFERING -
hs->buffering.total_bytes_buffered ) )
{
MBEDTLS_SSL_DEBUG_MSG( 2, ( "Enough space available after freeing future epoch record" ) );
return( 0 );
}
/* We don't have enough space to buffer the next expected handshake
* message. Remove buffers used for future messages to gain space,
* starting with the most distant one. */
for( offset = MBEDTLS_SSL_MAX_BUFFERED_HS - 1;
offset >= 0; offset-- )
{
MBEDTLS_SSL_DEBUG_MSG( 2, ( "Free buffering slot %d to make space for reassembly of next handshake message",
offset ) );
ssl_buffering_free_slot( ssl, (uint8_t) offset );
/* Check if we have enough space available now. */
if( desired <= ( MBEDTLS_SSL_DTLS_MAX_BUFFERING -
hs->buffering.total_bytes_buffered ) )
{
MBEDTLS_SSL_DEBUG_MSG( 2, ( "Enough space available after freeing buffered HS messages" ) );
return( 0 );
}
}
return( -1 );
}
| 0
|
299,976
|
static int elo_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
struct elo_priv *priv;
int ret;
struct usb_device *udev;
if (!hid_is_usb(hdev))
return -EINVAL;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
INIT_DELAYED_WORK(&priv->work, elo_work);
udev = interface_to_usbdev(to_usb_interface(hdev->dev.parent));
priv->usbdev = usb_get_dev(udev);
hid_set_drvdata(hdev, priv);
ret = hid_parse(hdev);
if (ret) {
hid_err(hdev, "parse failed\n");
goto err_free;
}
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
if (ret) {
hid_err(hdev, "hw start failed\n");
goto err_free;
}
if (elo_broken_firmware(priv->usbdev)) {
hid_info(hdev, "broken firmware found, installing workaround\n");
queue_delayed_work(wq, &priv->work, ELO_PERIODIC_READ_INTERVAL);
}
return 0;
err_free:
usb_put_dev(udev);
kfree(priv);
return ret;
}
| 0
|
294,641
|
date_s__valid_jd_p(int argc, VALUE *argv, VALUE klass)
{
VALUE vjd, vsg;
VALUE argv2[2];
rb_scan_args(argc, argv, "11", &vjd, &vsg);
argv2[0] = vjd;
if (argc < 2)
argv2[1] = DBL2NUM(GREGORIAN);
else
argv2[1] = vsg;
return valid_jd_sub(2, argv2, klass, 1);
}
| 0
|
202,810
|
_gcry_ecc_ecdsa_sign (gcry_mpi_t input, ECC_secret_key *skey,
gcry_mpi_t r, gcry_mpi_t s,
int flags, int hashalgo)
{
gpg_err_code_t rc = 0;
int extraloops = 0;
gcry_mpi_t k, dr, sum, k_1, x;
mpi_point_struct I;
gcry_mpi_t hash;
const void *abuf;
unsigned int abits, qbits;
mpi_ec_t ctx;
if (DBG_CIPHER)
log_mpidump ("ecdsa sign hash ", input );
qbits = mpi_get_nbits (skey->E.n);
/* Convert the INPUT into an MPI if needed. */
rc = _gcry_dsa_normalize_hash (input, &hash, qbits);
if (rc)
return rc;
k = NULL;
dr = mpi_alloc (0);
sum = mpi_alloc (0);
k_1 = mpi_alloc (0);
x = mpi_alloc (0);
point_init (&I);
ctx = _gcry_mpi_ec_p_internal_new (skey->E.model, skey->E.dialect, 0,
skey->E.p, skey->E.a, skey->E.b);
/* Two loops to avoid R or S are zero. This is more of a joke than
a real demand because the probability of them being zero is less
than any hardware failure. Some specs however require it. */
do
{
do
{
mpi_free (k);
k = NULL;
if ((flags & PUBKEY_FLAG_RFC6979) && hashalgo)
{
/* Use Pornin's method for deterministic DSA. If this
flag is set, it is expected that HASH is an opaque
MPI with the to be signed hash. That hash is also
used as h1 from 3.2.a. */
if (!mpi_is_opaque (input))
{
rc = GPG_ERR_CONFLICT;
goto leave;
}
abuf = mpi_get_opaque (input, &abits);
rc = _gcry_dsa_gen_rfc6979_k (&k, skey->E.n, skey->d,
abuf, (abits+7)/8,
hashalgo, extraloops);
if (rc)
goto leave;
extraloops++;
}
else
k = _gcry_dsa_gen_k (skey->E.n, GCRY_STRONG_RANDOM);
_gcry_mpi_ec_mul_point (&I, k, &skey->E.G, ctx);
if (_gcry_mpi_ec_get_affine (x, NULL, &I, ctx))
{
if (DBG_CIPHER)
log_debug ("ecc sign: Failed to get affine coordinates\n");
rc = GPG_ERR_BAD_SIGNATURE;
goto leave;
}
mpi_mod (r, x, skey->E.n); /* r = x mod n */
}
while (!mpi_cmp_ui (r, 0));
mpi_mulm (dr, skey->d, r, skey->E.n); /* dr = d*r mod n */
mpi_addm (sum, hash, dr, skey->E.n); /* sum = hash + (d*r) mod n */
mpi_invm (k_1, k, skey->E.n); /* k_1 = k^(-1) mod n */
mpi_mulm (s, k_1, sum, skey->E.n); /* s = k^(-1)*(hash+(d*r)) mod n */
}
while (!mpi_cmp_ui (s, 0));
if (DBG_CIPHER)
{
log_mpidump ("ecdsa sign result r ", r);
log_mpidump ("ecdsa sign result s ", s);
}
leave:
_gcry_mpi_ec_free (ctx);
point_free (&I);
mpi_free (x);
mpi_free (k_1);
mpi_free (sum);
mpi_free (dr);
mpi_free (k);
if (hash != input)
mpi_free (hash);
return rc;
}
| 1
|
445,902
|
archive_is_encrypted (FrWindow *window,
GList *file_list)
{
gboolean encrypted = FALSE;
if (file_list == NULL) {
int i;
for (i = 0; ! encrypted && i < window->archive->files->len; i++) {
FileData *fdata = g_ptr_array_index (window->archive->files, i);
if (fdata->encrypted)
encrypted = TRUE;
}
}
else {
GList *scan;
for (scan = file_list; ! encrypted && scan; scan = scan->next) {
char *filename = scan->data;
FileData *fdata;
fdata = g_hash_table_lookup (window->archive->files_hash, filename);
g_return_val_if_fail (fdata != NULL, FALSE);
if (fdata->encrypted)
encrypted = TRUE;
}
}
return encrypted;
}
| 0
|
448,554
|
bool bgp_notify_send_hard_reset(struct peer *peer, uint8_t code,
uint8_t subcode)
{
/* When the "N" bit has been exchanged, a Hard Reset message is used to
* indicate to the peer that the session is to be fully terminated.
*/
if (!bgp_has_graceful_restart_notification(peer))
return false;
/*
* https://datatracker.ietf.org/doc/html/rfc8538#section-5.1
*/
if (code == BGP_NOTIFY_CEASE) {
switch (subcode) {
case BGP_NOTIFY_CEASE_MAX_PREFIX:
case BGP_NOTIFY_CEASE_ADMIN_SHUTDOWN:
case BGP_NOTIFY_CEASE_PEER_UNCONFIG:
case BGP_NOTIFY_CEASE_HARD_RESET:
case BGP_NOTIFY_CEASE_BFD_DOWN:
return true;
case BGP_NOTIFY_CEASE_ADMIN_RESET:
/* Provide user control:
* `bgp hard-adminstrative-reset`
*/
if (CHECK_FLAG(peer->bgp->flags,
BGP_FLAG_HARD_ADMIN_RESET))
return true;
else
return false;
default:
break;
}
}
return false;
}
| 0
|
513,269
|
bool JOIN::rollup_init()
{
uint i,j;
Item **ref_array;
tmp_table_param.quick_group= 0; // Can't create groups in tmp table
rollup.state= ROLLUP::STATE_INITED;
/*
Create pointers to the different sum function groups
These are updated by rollup_make_fields()
*/
tmp_table_param.group_parts= send_group_parts;
Item_null_result **null_items=
static_cast<Item_null_result**>(thd->alloc(sizeof(Item*)*send_group_parts));
rollup.null_items= Item_null_array(null_items, send_group_parts);
rollup.ref_pointer_arrays=
static_cast<Ref_ptr_array*>
(thd->alloc((sizeof(Ref_ptr_array) +
all_fields.elements * sizeof(Item*)) * send_group_parts));
rollup.fields=
static_cast<List<Item>*>(thd->alloc(sizeof(List<Item>) * send_group_parts));
if (!null_items || !rollup.ref_pointer_arrays || !rollup.fields)
return true;
ref_array= (Item**) (rollup.ref_pointer_arrays+send_group_parts);
/*
Prepare space for field list for the different levels
These will be filled up in rollup_make_fields()
*/
for (i= 0 ; i < send_group_parts ; i++)
{
rollup.null_items[i]= new (thd->mem_root) Item_null_result(thd);
List<Item> *rollup_fields= &rollup.fields[i];
rollup_fields->empty();
rollup.ref_pointer_arrays[i]= Ref_ptr_array(ref_array, all_fields.elements);
ref_array+= all_fields.elements;
}
for (i= 0 ; i < send_group_parts; i++)
{
for (j=0 ; j < fields_list.elements ; j++)
rollup.fields[i].push_back(rollup.null_items[i], thd->mem_root);
}
List_iterator<Item> it(all_fields);
Item *item;
while ((item= it++))
{
ORDER *group_tmp;
bool found_in_group= 0;
for (group_tmp= group_list; group_tmp; group_tmp= group_tmp->next)
{
if (*group_tmp->item == item)
{
item->maybe_null= 1;
item->in_rollup= 1;
found_in_group= 1;
break;
}
}
if (item->type() == Item::FUNC_ITEM && !found_in_group)
{
bool changed= FALSE;
if (change_group_ref(thd, (Item_func *) item, group_list, &changed))
return 1;
/*
We have to prevent creation of a field in a temporary table for
an expression that contains GROUP BY attributes.
Marking the expression item as 'with_sum_func' will ensure this.
*/
if (changed)
item->with_sum_func= 1;
}
}
return 0;
}
| 0
|
369,100
|
static int io_poll_update_prep(struct io_kiocb *req,
const struct io_uring_sqe *sqe)
{
struct io_poll_update *upd = &req->poll_update;
u32 flags;
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
if (sqe->ioprio || sqe->buf_index || sqe->splice_fd_in)
return -EINVAL;
flags = READ_ONCE(sqe->len);
if (flags & ~(IORING_POLL_UPDATE_EVENTS | IORING_POLL_UPDATE_USER_DATA |
IORING_POLL_ADD_MULTI))
return -EINVAL;
/* meaningless without update */
if (flags == IORING_POLL_ADD_MULTI)
return -EINVAL;
upd->old_user_data = READ_ONCE(sqe->addr);
upd->update_events = flags & IORING_POLL_UPDATE_EVENTS;
upd->update_user_data = flags & IORING_POLL_UPDATE_USER_DATA;
upd->new_user_data = READ_ONCE(sqe->off);
if (!upd->update_user_data && upd->new_user_data)
return -EINVAL;
if (upd->update_events)
upd->events = io_poll_parse_events(sqe, flags);
else if (sqe->poll32_events)
return -EINVAL;
return 0;
| 0
|
439,056
|
static Image *ReadHEICImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
heif_item_id
exif_id;
Image
*image;
int
count,
stride_y,
stride_cb,
stride_cr;
MagickBooleanType
status;
MagickSizeType
length;
ssize_t
y;
struct heif_context
*heif_context;
struct heif_error
error;
struct heif_image
*heif_image;
struct heif_image_handle
*image_handle;
uint8_t
*p_y,
*p_cb,
*p_cr;
void
*file_data;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
return(DestroyImageList(image));
length=GetBlobSize(image);
file_data=AcquireMagickMemory(length);
if (file_data == (void *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if (ReadBlob(image,length,file_data) != (ssize_t) length)
{
file_data=RelinquishMagickMemory(file_data);
ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
}
/*
Decode HEIF file
*/
heif_context=heif_context_alloc();
error=heif_context_read_from_memory(heif_context,file_data,length,NULL);
file_data=RelinquishMagickMemory(file_data);
if (IsHeifSuccess(&error,image) == MagickFalse)
{
heif_context_free(heif_context);
return(DestroyImageList(image));
}
image_handle=(struct heif_image_handle *) NULL;
error=heif_context_get_primary_image_handle(heif_context,&image_handle);
if (IsHeifSuccess(&error,image) == MagickFalse)
{
heif_context_free(heif_context);
return(DestroyImageList(image));
}
/*
Read Exif data from HEIC file
*/
count=heif_image_handle_get_list_of_metadata_block_IDs(image_handle,"Exif",
&exif_id,1);
if (count > 0)
{
size_t
exif_size;
void
*exif_buffer;
exif_size=heif_image_handle_get_metadata_size(image_handle,exif_id);
if (exif_size > GetBlobSize(image))
{
heif_image_handle_release(image_handle);
heif_context_free(heif_context);
ThrowReaderException(CorruptImageError,
"InsufficientImageDataInFile");
}
exif_buffer=AcquireMagickMemory(exif_size);
error=heif_image_handle_get_metadata(image_handle,exif_id,exif_buffer);
if (error.code == 0)
{
StringInfo
*profile;
profile=BlobToStringInfo(exif_buffer,exif_size);
SetImageProfile(image,"exif",profile);
profile=DestroyStringInfo(profile);
}
exif_buffer=RelinquishMagickMemory(exif_buffer);
}
/*
Set image size
*/
image->depth=8;
image->columns=(size_t) heif_image_handle_get_width(image_handle);
image->rows=(size_t) heif_image_handle_get_height(image_handle);
if (image_info->ping != MagickFalse)
{
image->colorspace=YCbCrColorspace;
heif_image_handle_release(image_handle);
heif_context_free(heif_context);
return(GetFirstImageInList(image));
}
status=SetImageExtent(image,image->columns,image->rows);
if (status == MagickFalse)
{
heif_image_handle_release(image_handle);
heif_context_free(heif_context);
return(DestroyImageList(image));
}
/*
Copy HEIF image into ImageMagick data structures
*/
(void) SetImageColorspace(image,YCbCrColorspace);
error=heif_decode_image(image_handle,&heif_image,heif_colorspace_YCbCr,
heif_chroma_420,NULL);
if (IsHeifSuccess(&error,image) == MagickFalse)
{
heif_image_handle_release(image_handle);
heif_context_free(heif_context);
return(DestroyImageList(image));
}
p_y=heif_image_get_plane(heif_image,heif_channel_Y,&stride_y);
p_cb=heif_image_get_plane(heif_image,heif_channel_Cb,&stride_cb);
p_cr=heif_image_get_plane(heif_image,heif_channel_Cr,&stride_cr);
for (y=0; y < (ssize_t) image->rows; y++)
{
PixelPacket
*q;
register ssize_t
x;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
for (x=0; x < (long) image->columns; x++)
{
SetPixelRed(q,ScaleCharToQuantum(p_y[y*stride_y + x]));
SetPixelGreen(q,ScaleCharToQuantum(p_cb[(y/2)*stride_cb + x/2]));
SetPixelBlue(q,ScaleCharToQuantum(p_cr[(y/2)*stride_cr + x/2]));
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
heif_image_release(heif_image);
heif_image_handle_release(image_handle);
heif_context_free(heif_context);
return(GetFirstImageInList(image));
}
| 0
|
387,818
|
void InstanceKlass::adjust_default_methods(InstanceKlass* holder, bool* trace_name_printed) {
// search the default_methods for uses of either obsolete or EMCP methods
if (default_methods() != NULL) {
for (int index = 0; index < default_methods()->length(); index ++) {
Method* old_method = default_methods()->at(index);
if (old_method == NULL || old_method->method_holder() != holder || !old_method->is_old()) {
continue; // skip uninteresting entries
}
assert(!old_method->is_deleted(), "default methods may not be deleted");
Method* new_method = holder->method_with_idnum(old_method->orig_method_idnum());
assert(new_method != NULL, "method_with_idnum() should not be NULL");
assert(old_method != new_method, "sanity check");
default_methods()->at_put(index, new_method);
if (log_is_enabled(Info, redefine, class, update)) {
ResourceMark rm;
if (!(*trace_name_printed)) {
log_info(redefine, class, update)
("adjust: klassname=%s default methods from name=%s",
external_name(), old_method->method_holder()->external_name());
*trace_name_printed = true;
}
log_debug(redefine, class, update, vtables)
("default method update: %s(%s) ",
new_method->name()->as_C_string(), new_method->signature()->as_C_string());
}
}
}
}
| 0
|
215,073
|
static ssize_t cgroup_release_agent_write(struct kernfs_open_file *of,
char *buf, size_t nbytes, loff_t off)
{
struct cgroup *cgrp;
BUILD_BUG_ON(sizeof(cgrp->root->release_agent_path) < PATH_MAX);
cgrp = cgroup_kn_lock_live(of->kn, false);
if (!cgrp)
return -ENODEV;
spin_lock(&release_agent_path_lock);
strlcpy(cgrp->root->release_agent_path, strstrip(buf),
sizeof(cgrp->root->release_agent_path));
spin_unlock(&release_agent_path_lock);
cgroup_kn_unlock(of->kn);
return nbytes;
}
| 1
|
359,308
|
DEFUN (show_ip_community_list_arg,
show_ip_community_list_arg_cmd,
"show ip community-list (<1-500>|WORD)",
SHOW_STR
IP_STR
"List community-list\n"
"Community-list number\n"
"Community-list name\n")
{
struct community_list *list;
list = community_list_lookup (bgp_clist, argv[0], COMMUNITY_LIST_MASTER);
if (! list)
{
vty_out (vty, "%% Can't find communit-list%s", VTY_NEWLINE);
return CMD_WARNING;
}
community_list_show (vty, list);
return CMD_SUCCESS;
}
| 0
|
253,519
|
smb3_handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid)
{
char *buf = server->large_buf ? server->bigbuf : server->smallbuf;
return handle_read_data(server, mid, buf, server->pdu_size,
NULL, 0, 0, false);
}
| 0
|
221,145
|
GF_Err gf_odf_avc_cfg_write(GF_AVCConfig *cfg, u8 **outData, u32 *outSize)
{
GF_BitStream *bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);
gf_odf_avc_cfg_write_bs(cfg, bs);
*outSize = 0;
*outData = NULL;
gf_bs_get_content(bs, outData, outSize);
gf_bs_del(bs);
return GF_OK;
}
| 0
|
486,784
|
static inline unsigned tx_desc_get_length(uint32_t *desc)
{
return desc[1] & DESC_1_LENGTH;
}
| 0
|
220,004
|
int callback_glewlwyd_get_module_type_list (const struct _u_request * request, struct _u_response * response, void * user_data) {
UNUSED(request);
struct config_elements * config = (struct config_elements *)user_data;
json_t * j_module_type;
j_module_type = get_module_type_list(config);
if (check_result_value(j_module_type, G_OK)) {
ulfius_set_json_body_response(response, 200, json_object_get(j_module_type, "module"));
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_get_module_type_list - Error get_module_type_list");
response->status = 500;
}
json_decref(j_module_type);
return U_CALLBACK_CONTINUE;
}
| 0
|
437,316
|
set_optimize_info_from_tree(Node* node, regex_t* reg, ScanEnv* scan_env)
{
int r;
NodeOpt opt;
OptEnv env;
env.enc = reg->enc;
env.options = reg->options;
env.case_fold_flag = reg->case_fold_flag;
env.scan_env = scan_env;
clear_mml(&env.mmd);
r = optimize_nodes(node, &opt, &env);
if (r != 0) return r;
reg->anchor = opt.anc.left & (ANCHOR_BEGIN_BUF |
ANCHOR_BEGIN_POSITION | ANCHOR_ANYCHAR_INF | ANCHOR_ANYCHAR_INF_ML |
ANCHOR_LOOK_BEHIND);
if ((opt.anc.left & (ANCHOR_LOOK_BEHIND | ANCHOR_PREC_READ_NOT)) != 0)
reg->anchor &= ~ANCHOR_ANYCHAR_INF_ML;
reg->anchor |= opt.anc.right & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF |
ANCHOR_PREC_READ_NOT);
if (reg->anchor & (ANCHOR_END_BUF | ANCHOR_SEMI_END_BUF)) {
reg->anchor_dmin = opt.len.min;
reg->anchor_dmax = opt.len.max;
}
if (opt.exb.len > 0 || opt.exm.len > 0) {
select_opt_exact(reg->enc, &opt.exb, &opt.exm);
if (opt.map.value > 0 && comp_opt_exact_or_map(&opt.exb, &opt.map) > 0) {
goto set_map;
}
else {
r = set_optimize_exact(reg, &opt.exb);
set_sub_anchor(reg, &opt.exb.anc);
}
}
else if (opt.map.value > 0) {
set_map:
set_optimize_map(reg, &opt.map);
set_sub_anchor(reg, &opt.map.anc);
}
else {
reg->sub_anchor |= opt.anc.left & ANCHOR_BEGIN_LINE;
if (opt.len.max == 0)
reg->sub_anchor |= opt.anc.right & ANCHOR_END_LINE;
}
#if defined(ONIG_DEBUG_COMPILE) || defined(ONIG_DEBUG_MATCH)
print_optimize_info(stderr, reg);
#endif
return r;
}
| 0
|
310,150
|
cleanup(void)
{
outs(t_me);
if (!outs(t_oc))
outs(t_op);
outs(t_cl);
outs(t_ve);
fflush(stdout);
fprintf(stderr, "\n\n%ld total cells, rate %.2f/sec\n",
total_chars,
((double) (total_chars) / (double) (time((time_t *) 0) - started)));
}
| 0
|
209,801
|
void jsP_dumpsyntax(js_State *J, js_Ast *prog, int dominify)
{
minify = dominify;
if (prog->type == AST_LIST)
pstmlist(-1, prog);
else {
pstm(0, prog);
nl();
}
if (minify > 1)
putchar('\n');
}
| 1
|
242,927
|
void Compute(OpKernelContext *ctx) override {
const Tensor *a_indices_t, *a_values_t, *a_shape_t, *b;
OP_REQUIRES_OK(ctx, ctx->input("a_indices", &a_indices_t));
OP_REQUIRES_OK(ctx, ctx->input("a_values", &a_values_t));
OP_REQUIRES_OK(ctx, ctx->input("a_shape", &a_shape_t));
OP_REQUIRES_OK(ctx, ctx->input("b", &b));
OP_REQUIRES_OK(
ctx, ValidateInputs<Index>(a_indices_t, a_values_t, a_shape_t, b));
Tensor *out_t;
OP_REQUIRES_OK(ctx, ctx->allocate_output(0, b->shape(), &out_t));
const int ndims = static_cast<int>(a_indices_t->dim_size(1));
const auto a_indices_mat = a_indices_t->flat_inner_dims<Index>();
const auto a_values_flat = a_values_t->flat<T>();
switch (ndims) {
#define NDIMS_CASE(N) \
case N: { \
auto out_tensor = out_t->tensor<T, N>(); \
out_tensor.device(ctx->eigen_device<Device>()) = b->tensor<T, N>(); \
const Index result = \
functor::ScatterNdFunctor<Device, T, Index, N, \
scatter_op::UpdateOp::ADD>()( \
ctx->eigen_device<Device>(), a_indices_mat, a_values_flat, \
out_tensor); \
OP_REQUIRES( \
ctx, result == -1, \
errors::InvalidArgument( \
"Sparse tensor has some invalid index on dimension ", result, \
"; dense tensor shape: ", b->shape().DebugString())); \
} break;
NDIMS_CASE(1);
NDIMS_CASE(2);
NDIMS_CASE(3);
NDIMS_CASE(4);
NDIMS_CASE(5);
default:
OP_REQUIRES(
ctx, false,
errors::InvalidArgument("Only tensors with ranks between 1 and 5 "
"are currently supported. Tensor rank: ",
ndims));
#undef NDIMS_CASE
}
}
| 0
|
245,148
|
Status Examples::SampleAdaptiveProbabilities(
const int num_loss_partitions, const Regularizations& regularization,
const ModelWeights& model_weights,
const TTypes<float>::Matrix example_state_data,
const std::unique_ptr<DualLossUpdater>& loss_updater,
const int num_weight_vectors) {
if (num_weight_vectors != 1) {
return errors::InvalidArgument(
"Adaptive SDCA only works with binary SDCA, "
"where num_weight_vectors should be 1.");
}
// Compute the probabilities
for (int example_id = 0; example_id < num_examples(); ++example_id) {
const Example& example = examples_[example_id];
const double example_weight = example.example_weight();
float label = example.example_label();
const Status conversion_status = loss_updater->ConvertLabel(&label);
const ExampleStatistics example_statistics =
example.ComputeWxAndWeightedExampleNorm(num_loss_partitions,
model_weights, regularization,
num_weight_vectors);
const double kappa = example_state_data(example_id, 0) +
loss_updater->PrimalLossDerivative(
example_statistics.wx[0], label, 1.0);
probabilities_[example_id] = example_weight *
sqrt(examples_[example_id].squared_norm_ +
regularization.symmetric_l2() *
loss_updater->SmoothnessConstant()) *
std::abs(kappa);
}
// Sample the index
random::DistributionSampler sampler(probabilities_);
GuardedPhiloxRandom generator;
generator.Init(0, 0);
auto local_gen = generator.ReserveSamples32(num_examples());
random::SimplePhilox random(&local_gen);
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_real_distribution<> dis(0, 1);
// We use a decay of 10: the probability of an example is divided by 10
// once that example is picked. A good approximation of that is to only
// keep a picked example with probability (1 / 10) ^ k where k is the
// number of times we already picked that example. We add a num_retries
// to avoid taking too long to sample. We then fill the sampled_index with
// unseen examples sorted by probabilities.
int id = 0;
int num_retries = 0;
while (id < num_examples() && num_retries < num_examples()) {
int picked_id = sampler.Sample(&random);
if (dis(gen) > MathUtil::IPow(0.1, sampled_count_[picked_id])) {
num_retries++;
continue;
}
sampled_count_[picked_id]++;
sampled_index_[id++] = picked_id;
}
std::vector<std::pair<int, float>> examples_not_seen;
examples_not_seen.reserve(num_examples());
for (int i = 0; i < num_examples(); ++i) {
if (sampled_count_[i] == 0)
examples_not_seen.emplace_back(sampled_index_[i], probabilities_[i]);
}
std::sort(
examples_not_seen.begin(), examples_not_seen.end(),
[](const std::pair<int, float>& lhs, const std::pair<int, float>& rhs) {
return lhs.second > rhs.second;
});
for (int i = id; i < num_examples(); ++i) {
sampled_count_[i] = examples_not_seen[i - id].first;
}
return Status::OK();
}
| 0
|
463,178
|
EXPORTED void annotate_state_set_auth(annotate_state_t *state,
int isadmin, const char *userid,
const struct auth_state *auth_state)
{
/* Note: lmtpd sometimes calls through the append code with
* auth_state=NULL, so we cannot rely on it being non-NULL */
state->userid = userid;
state->isadmin = isadmin;
state->auth_state = auth_state;
}
| 0
|
344,264
|
int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) {
const TValue *tm;
if (ttypetag(t1) != ttypetag(t2)) { /* not the same variant? */
if (ttype(t1) != ttype(t2) || ttype(t1) != LUA_TNUMBER)
return 0; /* only numbers can be equal with different variants */
else { /* two numbers with different variants */
/* One of them is an integer. If the other does not have an
integer value, they cannot be equal; otherwise, compare their
integer values. */
lua_Integer i1, i2;
return (luaV_tointegerns(t1, &i1, F2Ieq) &&
luaV_tointegerns(t2, &i2, F2Ieq) &&
i1 == i2);
}
}
/* values have same type and same variant */
switch (ttypetag(t1)) {
case LUA_VNIL: case LUA_VFALSE: case LUA_VTRUE: return 1;
case LUA_VNUMINT: return (ivalue(t1) == ivalue(t2));
case LUA_VNUMFLT: return luai_numeq(fltvalue(t1), fltvalue(t2));
case LUA_VLIGHTUSERDATA: return pvalue(t1) == pvalue(t2);
case LUA_VLCF: return fvalue(t1) == fvalue(t2);
case LUA_VSHRSTR: return eqshrstr(tsvalue(t1), tsvalue(t2));
case LUA_VLNGSTR: return luaS_eqlngstr(tsvalue(t1), tsvalue(t2));
case LUA_VUSERDATA: {
if (uvalue(t1) == uvalue(t2)) return 1;
else if (L == NULL) return 0;
tm = fasttm(L, uvalue(t1)->metatable, TM_EQ);
if (tm == NULL)
tm = fasttm(L, uvalue(t2)->metatable, TM_EQ);
break; /* will try TM */
}
case LUA_VTABLE: {
if (hvalue(t1) == hvalue(t2)) return 1;
else if (L == NULL) return 0;
tm = fasttm(L, hvalue(t1)->metatable, TM_EQ);
if (tm == NULL)
tm = fasttm(L, hvalue(t2)->metatable, TM_EQ);
break; /* will try TM */
}
default:
return gcvalue(t1) == gcvalue(t2);
}
if (tm == NULL) /* no TM? */
return 0; /* objects are different */
else {
luaT_callTMres(L, tm, t1, t2, L->top); /* call TM */
return !l_isfalse(s2v(L->top));
}
}
| 0
|
387,877
|
void InstanceKlass::deallocate_methods(ClassLoaderData* loader_data,
Array<Method*>* methods) {
if (methods != NULL && methods != Universe::the_empty_method_array() &&
!methods->is_shared()) {
for (int i = 0; i < methods->length(); i++) {
Method* method = methods->at(i);
if (method == NULL) continue; // maybe null if error processing
// Only want to delete methods that are not executing for RedefineClasses.
// The previous version will point to them so they're not totally dangling
assert (!method->on_stack(), "shouldn't be called with methods on stack");
MetadataFactory::free_metadata(loader_data, method);
}
MetadataFactory::free_array<Method*>(loader_data, methods);
}
}
| 0
|
294,484
|
test_nth_kday(int from, int to, double sg)
{
int j;
fprintf(stderr, "test_nth_kday: %d...%d (%d) - %.0f\n",
from, to, to - from, sg);
for (j = from; j <= to; j++) {
int y, m, n, k, rj, ns;
c_jd_to_nth_kday(j, sg, &y, &m, &n, &k);
c_nth_kday_to_jd(y, m, n, k, sg, &rj, &ns);
if (j != rj) {
fprintf(stderr, "%d != %d\n", j, rj);
return 0;
}
}
return 1;
}
| 0
|
421,375
|
static void pargs(int d, js_Ast *list)
{
while (list) {
assert(list->type == AST_LIST);
pexpi(d, COMMA, list->a);
list = list->b;
if (list)
comma();
}
}
| 0
|
282,879
|
static int rsi_send_common_dev_params(struct rsi_common *common)
{
struct sk_buff *skb;
u16 frame_len;
struct rsi_config_vals *dev_cfgs;
frame_len = sizeof(struct rsi_config_vals);
rsi_dbg(MGMT_TX_ZONE, "Sending common device config params\n");
skb = dev_alloc_skb(frame_len);
if (!skb) {
rsi_dbg(ERR_ZONE, "%s: Unable to allocate skb\n", __func__);
return -ENOMEM;
}
memset(skb->data, 0, frame_len);
dev_cfgs = (struct rsi_config_vals *)skb->data;
memset(dev_cfgs, 0, (sizeof(struct rsi_config_vals)));
rsi_set_len_qno(&dev_cfgs->len_qno, (frame_len - FRAME_DESC_SZ),
RSI_COEX_Q);
dev_cfgs->pkt_type = COMMON_DEV_CONFIG;
dev_cfgs->lp_ps_handshake = common->lp_ps_handshake_mode;
dev_cfgs->ulp_ps_handshake = common->ulp_ps_handshake_mode;
dev_cfgs->unused_ulp_gpio = RSI_UNUSED_ULP_GPIO_BITMAP;
dev_cfgs->unused_soc_gpio_bitmap =
cpu_to_le32(RSI_UNUSED_SOC_GPIO_BITMAP);
dev_cfgs->opermode = common->oper_mode;
dev_cfgs->wlan_rf_pwr_mode = common->wlan_rf_power_mode;
dev_cfgs->driver_mode = common->driver_mode;
dev_cfgs->region_code = NL80211_DFS_FCC;
dev_cfgs->antenna_sel_val = common->obm_ant_sel_val;
skb_put(skb, frame_len);
return rsi_send_internal_mgmt_frame(common, skb);
}
| 0
|
225,507
|
void SwapRegularFanoutsAndMaxPortValues(FanoutsMap* fanouts,
MaxOutputPortsMap* max_output_ports,
NodeDef* from_node, NodeDef* to_node) {
auto from_max_port = max_output_ports->find(from_node);
auto to_max_port = max_output_ports->find(to_node);
bool from_exists = from_max_port != max_output_ports->end();
bool to_exists = to_max_port != max_output_ports->end();
auto forward_fanouts = [fanouts](NodeDef* from, NodeDef* to, int start,
int end) {
for (int i = start; i <= end; ++i) {
MutableGraphView::OutputPort from_port(from, i);
auto from_fanouts = fanouts->find(from_port);
if (from_fanouts != fanouts->end()) {
MutableGraphView::OutputPort to_port(to, i);
fanouts->emplace(to_port, std::move(from_fanouts->second));
fanouts->erase(from_port);
}
}
};
if (from_exists && to_exists) {
const int from = from_max_port->second;
const int to = to_max_port->second;
const int shared = std::min(from, to);
for (int i = 0; i <= shared; ++i) {
MutableGraphView::OutputPort from_port(from_node, i);
auto from_fanouts = fanouts->find(from_port);
MutableGraphView::OutputPort to_port(to_node, i);
auto to_fanouts = fanouts->find(to_port);
SwapFanoutsMapValues(fanouts, from_port, from_fanouts, to_port,
to_fanouts);
}
if (to > from) {
forward_fanouts(to_node, from_node, shared + 1, to);
} else if (from > to) {
forward_fanouts(from_node, to_node, shared + 1, from);
}
std::swap(from_max_port->second, to_max_port->second);
} else if (from_exists) {
forward_fanouts(from_node, to_node, 0, from_max_port->second);
max_output_ports->emplace(to_node, from_max_port->second);
max_output_ports->erase(from_node);
} else if (to_exists) {
forward_fanouts(to_node, from_node, 0, to_max_port->second);
max_output_ports->emplace(from_node, to_max_port->second);
max_output_ports->erase(to_node);
}
}
| 0
|
310,254
|
_compare_routerinfo_by_ip_and_bw(const void **a, const void **b)
{
routerinfo_t *first = *(routerinfo_t **)a, *second = *(routerinfo_t **)b;
int first_is_auth, second_is_auth;
uint32_t bw_first, bw_second;
/* we return -1 if first should appear before second... that is,
* if first is a better router. */
if (first->addr < second->addr)
return -1;
else if (first->addr > second->addr)
return 1;
/* Potentially, this next bit could cause k n lg n memcmp calls. But in
* reality, we will almost never get here, since addresses will usually be
* different. */
first_is_auth =
router_digest_is_trusted_dir(first->cache_info.identity_digest);
second_is_auth =
router_digest_is_trusted_dir(second->cache_info.identity_digest);
if (first_is_auth && !second_is_auth)
return -1;
else if (!first_is_auth && second_is_auth)
return 1;
else if (first->is_running && !second->is_running)
return -1;
else if (!first->is_running && second->is_running)
return 1;
bw_first = router_get_advertised_bandwidth(first);
bw_second = router_get_advertised_bandwidth(second);
if (bw_first > bw_second)
return -1;
else if (bw_first < bw_second)
return 1;
/* They're equal! Compare by identity digest, so there's a
* deterministic order and we avoid flapping. */
return fast_memcmp(first->cache_info.identity_digest,
second->cache_info.identity_digest,
DIGEST_LEN);
}
| 0
|
247,567
|
TEST_P(SslSocketTest, FailedClientAuthCaVerification) {
const std::string client_ctx_yaml = R"EOF(
common_tls_context:
tls_certificates:
certificate_chain:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/selfsigned_cert.pem"
private_key:
filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/selfsigned_key.pem"
)EOF";
const std::string 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/ca_cert.pem"
)EOF";
TestUtilOptions test_options(client_ctx_yaml, server_ctx_yaml, false, GetParam());
testUtil(test_options.setExpectedServerStats("ssl.fail_verify_error")
.setExpectedVerifyErrorCode(X509_V_ERR_UNABLE_TO_GET_ISSUER_CERT_LOCALLY));
}
| 0
|
391,636
|
static bool share_conflict(struct share_mode_entry *entry,
uint32 access_mask,
uint32 share_access)
{
DEBUG(10,("share_conflict: entry->access_mask = 0x%x, "
"entry->share_access = 0x%x, "
"entry->private_options = 0x%x\n",
(unsigned int)entry->access_mask,
(unsigned int)entry->share_access,
(unsigned int)entry->private_options));
if (server_id_is_disconnected(&entry->pid)) {
/*
* note: cleanup should have been done by
* delay_for_batch_oplocks()
*/
return false;
}
DEBUG(10,("share_conflict: access_mask = 0x%x, share_access = 0x%x\n",
(unsigned int)access_mask, (unsigned int)share_access));
if ((entry->access_mask & (FILE_WRITE_DATA|
FILE_APPEND_DATA|
FILE_READ_DATA|
FILE_EXECUTE|
DELETE_ACCESS)) == 0) {
DEBUG(10,("share_conflict: No conflict due to "
"entry->access_mask = 0x%x\n",
(unsigned int)entry->access_mask ));
return False;
}
if ((access_mask & (FILE_WRITE_DATA|
FILE_APPEND_DATA|
FILE_READ_DATA|
FILE_EXECUTE|
DELETE_ACCESS)) == 0) {
DEBUG(10,("share_conflict: No conflict due to "
"access_mask = 0x%x\n",
(unsigned int)access_mask ));
return False;
}
#if 1 /* JRA TEST - Superdebug. */
#define CHECK_MASK(num, am, right, sa, share) \
DEBUG(10,("share_conflict: [%d] am (0x%x) & right (0x%x) = 0x%x\n", \
(unsigned int)(num), (unsigned int)(am), \
(unsigned int)(right), (unsigned int)(am)&(right) )); \
DEBUG(10,("share_conflict: [%d] sa (0x%x) & share (0x%x) = 0x%x\n", \
(unsigned int)(num), (unsigned int)(sa), \
(unsigned int)(share), (unsigned int)(sa)&(share) )); \
if (((am) & (right)) && !((sa) & (share))) { \
DEBUG(10,("share_conflict: check %d conflict am = 0x%x, right = 0x%x, \
sa = 0x%x, share = 0x%x\n", (num), (unsigned int)(am), (unsigned int)(right), (unsigned int)(sa), \
(unsigned int)(share) )); \
return True; \
}
#else
#define CHECK_MASK(num, am, right, sa, share) \
if (((am) & (right)) && !((sa) & (share))) { \
DEBUG(10,("share_conflict: check %d conflict am = 0x%x, right = 0x%x, \
sa = 0x%x, share = 0x%x\n", (num), (unsigned int)(am), (unsigned int)(right), (unsigned int)(sa), \
(unsigned int)(share) )); \
return True; \
}
#endif
CHECK_MASK(1, entry->access_mask, FILE_WRITE_DATA | FILE_APPEND_DATA,
share_access, FILE_SHARE_WRITE);
CHECK_MASK(2, access_mask, FILE_WRITE_DATA | FILE_APPEND_DATA,
entry->share_access, FILE_SHARE_WRITE);
CHECK_MASK(3, entry->access_mask, FILE_READ_DATA | FILE_EXECUTE,
share_access, FILE_SHARE_READ);
CHECK_MASK(4, access_mask, FILE_READ_DATA | FILE_EXECUTE,
entry->share_access, FILE_SHARE_READ);
CHECK_MASK(5, entry->access_mask, DELETE_ACCESS,
share_access, FILE_SHARE_DELETE);
CHECK_MASK(6, access_mask, DELETE_ACCESS,
entry->share_access, FILE_SHARE_DELETE);
DEBUG(10,("share_conflict: No conflict.\n"));
return False;
}
| 0
|
474,051
|
rehash(register st_table *table)
{
register st_table_entry *ptr, **new_bins;
st_index_t i, new_num_bins, hash_val;
new_num_bins = new_size(table->num_bins+1);
new_bins = (st_table_entry**)
xrealloc(table->bins, new_num_bins * sizeof(st_table_entry*));
for (i = 0; i < new_num_bins; ++i) new_bins[i] = 0;
table->num_bins = new_num_bins;
table->bins = new_bins;
if ((ptr = table->head) != 0) {
do {
hash_val = ptr->hash % new_num_bins;
ptr->next = new_bins[hash_val];
new_bins[hash_val] = ptr;
} while ((ptr = ptr->fore) != 0);
}
}
| 0
|
233,844
|
void fmtutil_macbitmap_read_baseaddr(deark *c, dbuf *f, struct fmtutil_macbitmap_info *bi, i64 pos)
{
i64 n;
de_dbg(c, "baseAddr part of PixMap, at %d", (int)pos);
de_dbg_indent(c, 1);
n = dbuf_getu32be(f, pos);
de_dbg(c, "baseAddr: 0x%08x", (unsigned int)n);
de_dbg_indent(c, -1);
}
| 0
|
483,512
|
static int register_update_efi_random_seed(void)
{
if (efi.rng_seed == EFI_INVALID_TABLE_ADDR)
return 0;
return register_reboot_notifier(&efi_random_seed_nb);
}
| 0
|
462,411
|
createInstance(instanceConf_t **pinst)
{
instanceConf_t *inst;
DEFiRet;
CHKmalloc(inst = MALLOC(sizeof(instanceConf_t)));
inst->next = NULL;
inst->pszBindPort = NULL;
inst->pszBindAddr = NULL;
inst->pszBindPath = NULL;
inst->fileUID = -1;
inst->fileGID = -1;
inst->fCreateMode = 0644;
inst->bFailOnPerms = 1;
inst->bUnlink = 0;
inst->pszBindRuleset = NULL;
inst->pszInputName = NULL;
inst->bSuppOctetFram = 1;
inst->bSPFramingFix = 0;
inst->bKeepAlive = 0;
inst->iKeepAliveIntvl = 0;
inst->iKeepAliveProbes = 0;
inst->iKeepAliveTime = 0;
inst->bEmitMsgOnClose = 0;
inst->dfltTZ = NULL;
inst->iAddtlFrameDelim = TCPSRV_NO_ADDTL_DELIMITER;
inst->pBindRuleset = NULL;
inst->ratelimitBurst = 10000; /* arbitrary high limit */
inst->ratelimitInterval = 0; /* off */
inst->compressionMode = COMPRESS_SINGLE_MSG;
/* node created, let's add to config */
if(loadModConf->tail == NULL) {
loadModConf->tail = loadModConf->root = inst;
} else {
loadModConf->tail->next = inst;
loadModConf->tail = inst;
}
*pinst = inst;
finalize_it:
RETiRet;
}
| 0
|
234,236
|
load_debug_section_with_follow (enum dwarf_section_display_enum sec_enum,
void * handle)
{
if (load_debug_section (sec_enum, handle))
{
if (debug_displays[sec_enum].section.filename == NULL)
{
/* See if we can associate a filename with this section. */
separate_info * i;
for (i = first_separate_info; i != NULL; i = i->next)
if (i->handle == handle)
{
debug_displays[sec_enum].section.filename = i->filename;
break;
}
}
return true;
}
if (do_follow_links)
{
separate_info * i;
for (i = first_separate_info; i != NULL; i = i->next)
{
if (load_debug_section (sec_enum, i->handle))
{
debug_displays[sec_enum].section.filename = i->filename;
/* FIXME: We should check to see if any of the remaining debug info
files also contain this section, and, umm, do something about it. */
return true;
}
}
}
return false;
}
| 0
|
219,949
|
int callback_glewlwyd_user_update_password (const struct _u_request * request, struct _u_response * response, void * user_data) {
struct config_elements * config = (struct config_elements *)user_data;
json_t * j_session, * j_password, * j_element = NULL;
char * session_uid = get_session_id(config, request);
const char ** passwords = NULL;
int res;
struct _user_module_instance * user_module;
size_t index = 0;
if (session_uid != NULL && o_strlen(session_uid)) {
j_session = get_current_user_for_session(config, session_uid);
if (check_result_value(j_session, G_OK)) {
j_password = ulfius_get_json_body_request(request, NULL);
user_module = get_user_module_instance(config, json_string_value(json_object_get(json_object_get(j_session, "user"), "source")));
if (user_module && user_module->multiple_passwords) {
if (json_string_length(json_object_get(j_password, "old_password")) && json_is_array(json_object_get(j_password, "password"))) {
if ((passwords = o_malloc(json_array_size(json_object_get(j_password, "password")) * sizeof(char *))) != NULL) {
json_array_foreach(json_object_get(j_password, "password"), index, j_element) {
passwords[index] = json_string_value(j_element);
}
if ((res = user_update_password(config, json_string_value(json_object_get(json_object_get(j_session, "user"), "username")), json_string_value(json_object_get(j_password, "old_password")), passwords, json_array_size(json_object_get(j_password, "password")))) == G_ERROR_PARAM) {
response->status = 400;
} else if (res != G_OK) {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error user_update_password (1)");
response->status = 500;
}
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error allocating resources for passwords (1)");
response->status = 500;
}
o_free(passwords);
} else {
response->status = 400;
}
} else {
if (json_string_length(json_object_get(j_password, "old_password")) && json_string_length(json_object_get(j_password, "password"))) {
if ((passwords = o_malloc(sizeof(char *))) != NULL) {
passwords[0] = json_string_value(json_object_get(j_password, "password"));
if ((res = user_update_password(config, json_string_value(json_object_get(json_object_get(j_session, "user"), "username")), json_string_value(json_object_get(j_password, "old_password")), passwords, 1)) == G_ERROR_PARAM) {
response->status = 400;
} else if (res != G_OK) {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error user_update_password (2)");
response->status = 500;
}
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error allocating resources for passwords (2)");
response->status = 500;
}
o_free(passwords);
} else {
response->status = 400;
}
}
json_decref(j_password);
} else if (check_result_value(j_session, G_ERROR_NOT_FOUND)) {
response->status = 401;
} else {
y_log_message(Y_LOG_LEVEL_ERROR, "callback_glewlwyd_user_update_password - Error get_current_user_for_session");
response->status = 500;
}
json_decref(j_session);
} else {
response->status = 401;
}
o_free(session_uid);
return U_CALLBACK_CONTINUE;
}
| 0
|
221,408
|
static int svm_check_nested_events(struct kvm_vcpu *vcpu)
{
struct vcpu_svm *svm = to_svm(vcpu);
bool block_nested_events =
kvm_event_needs_reinjection(vcpu) || svm->nested.nested_run_pending;
struct kvm_lapic *apic = vcpu->arch.apic;
if (lapic_in_kernel(vcpu) &&
test_bit(KVM_APIC_INIT, &apic->pending_events)) {
if (block_nested_events)
return -EBUSY;
if (!nested_exit_on_init(svm))
return 0;
nested_svm_simple_vmexit(svm, SVM_EXIT_INIT);
return 0;
}
if (vcpu->arch.exception.pending) {
/*
* Only a pending nested run can block a pending exception.
* Otherwise an injected NMI/interrupt should either be
* lost or delivered to the nested hypervisor in the EXITINTINFO
* vmcb field, while delivering the pending exception.
*/
if (svm->nested.nested_run_pending)
return -EBUSY;
if (!nested_exit_on_exception(svm))
return 0;
nested_svm_inject_exception_vmexit(svm);
return 0;
}
if (vcpu->arch.smi_pending && !svm_smi_blocked(vcpu)) {
if (block_nested_events)
return -EBUSY;
if (!nested_exit_on_smi(svm))
return 0;
nested_svm_simple_vmexit(svm, SVM_EXIT_SMI);
return 0;
}
if (vcpu->arch.nmi_pending && !svm_nmi_blocked(vcpu)) {
if (block_nested_events)
return -EBUSY;
if (!nested_exit_on_nmi(svm))
return 0;
nested_svm_simple_vmexit(svm, SVM_EXIT_NMI);
return 0;
}
if (kvm_cpu_has_interrupt(vcpu) && !svm_interrupt_blocked(vcpu)) {
if (block_nested_events)
return -EBUSY;
if (!nested_exit_on_intr(svm))
return 0;
trace_kvm_nested_intr_vmexit(svm->vmcb->save.rip);
nested_svm_simple_vmexit(svm, SVM_EXIT_INTR);
return 0;
}
return 0;
}
| 0
|
369,307
|
static int io_files_update(struct io_kiocb *req, unsigned int issue_flags)
{
struct io_ring_ctx *ctx = req->ctx;
bool needs_lock = issue_flags & IO_URING_F_UNLOCKED;
struct io_uring_rsrc_update2 up;
int ret;
up.offset = req->rsrc_update.offset;
up.data = req->rsrc_update.arg;
up.nr = 0;
up.tags = 0;
up.resv = 0;
up.resv2 = 0;
io_ring_submit_lock(ctx, needs_lock);
ret = __io_register_rsrc_update(ctx, IORING_RSRC_FILE,
&up, req->rsrc_update.nr_args);
io_ring_submit_unlock(ctx, needs_lock);
if (ret < 0)
req_set_fail(req);
__io_req_complete(req, issue_flags, ret, 0);
return 0;
| 0
|
463,064
|
static bool sungem_rx_full(SunGEMState *s, uint32_t kick, uint32_t done)
{
return kick == ((done + 1) & s->rx_mask);
}
| 0
|
313,861
|
may_clear_cmdline(void)
{
if (mode_displayed)
clear_cmdline = TRUE; // unshow visual mode later
#ifdef FEAT_CMDL_INFO
else
clear_showcmd();
#endif
}
| 0
|
275,953
|
uECC_VLI_API void uECC_vli_modSub(uECC_word_t *result,
const uECC_word_t *left,
const uECC_word_t *right,
const uECC_word_t *mod,
wordcount_t num_words) {
uECC_word_t l_borrow = uECC_vli_sub(result, left, right, num_words);
if (l_borrow) {
/* In this case, result == -diff == (max int) - diff. Since -x % d == d - x,
we can get the correct result from result + mod (with overflow). */
uECC_vli_add(result, result, mod, num_words);
}
}
| 0
|
498,620
|
save_image (const gchar *filename,
gint32 image_ID,
gint32 drawable_ID,
GError **error)
{
GeglBuffer *buffer;
const Babl *format = NULL;
GimpImageType dtype;
gint width;
gint height;
FILE *fp;
gint out_bpp = 0;
gboolean status = TRUE;
gint i, row;
guchar header[18];
guchar footer[26];
guchar *pixels;
guchar *data;
gint num_colors;
guchar *gimp_cmap = NULL;
buffer = gimp_drawable_get_buffer (drawable_ID);
dtype = gimp_drawable_type (drawable_ID);
width = gegl_buffer_get_width (buffer);
height = gegl_buffer_get_height (buffer);
gimp_progress_init_printf (_("Exporting '%s'"),
gimp_filename_to_utf8 (filename));
if ((fp = g_fopen (filename, "wb")) == NULL)
{
g_set_error (error, G_FILE_ERROR, g_file_error_from_errno (errno),
_("Could not open '%s' for writing: %s"),
gimp_filename_to_utf8 (filename), g_strerror (errno));
return FALSE;
}
header[0] = 0; /* No image identifier / description */
if (dtype == GIMP_INDEXED_IMAGE)
{
gimp_cmap = gimp_image_get_colormap (image_ID, &num_colors);
header[1] = 1; /* cmap type */
header[2] = (tsvals.rle) ? 9 : 1;
header[3] = header[4] = 0; /* no offset */
header[5] = num_colors % 256;
header[6] = num_colors / 256;
header[7] = 24; /* cmap size / bits */
}
else if (dtype == GIMP_INDEXEDA_IMAGE)
{
gimp_cmap = gimp_image_get_colormap (image_ID, &num_colors);
header[1] = 1; /* cmap type */
header[2] = (tsvals.rle) ? 9 : 1;
header[3] = header[4] = 0; /* no offset */
header[5] = (num_colors + 1) % 256;
header[6] = (num_colors + 1) / 256;
header[7] = 32; /* cmap size / bits */
}
else
{
header[1]= 0;
if (dtype == GIMP_RGB_IMAGE || dtype == GIMP_RGBA_IMAGE)
{
header[2]= (tsvals.rle) ? 10 : 2;
}
else
{
header[2]= (tsvals.rle) ? 11 : 3;
}
header[3] = header[4] = header[5] = header[6] = header[7] = 0;
}
header[8] = header[9] = 0; /* xorigin */
header[10] = tsvals.origin ? 0 : (height % 256); /* yorigin */
header[11] = tsvals.origin ? 0 : (height / 256); /* yorigin */
header[12] = width % 256;
header[13] = width / 256;
header[14] = height % 256;
header[15] = height / 256;
switch (dtype)
{
case GIMP_INDEXED_IMAGE:
case GIMP_INDEXEDA_IMAGE:
format = NULL;
out_bpp = 1;
header[16] = 8; /* bpp */
header[17] = tsvals.origin ? 0 : 0x20; /* alpha + orientation */
break;
case GIMP_GRAY_IMAGE:
format = babl_format ("Y' u8");
out_bpp = 1;
header[16] = 8; /* bpp */
header[17] = tsvals.origin ? 0 : 0x20; /* alpha + orientation */
break;
case GIMP_GRAYA_IMAGE:
format = babl_format ("Y'A u8");
out_bpp = 2;
header[16] = 16; /* bpp */
header[17] = tsvals.origin ? 8 : 0x28; /* alpha + orientation */
break;
case GIMP_RGB_IMAGE:
format = babl_format ("R'G'B' u8");
out_bpp = 3;
header[16] = 24; /* bpp */
header[17] = tsvals.origin ? 0 : 0x20; /* alpha + orientation */
break;
case GIMP_RGBA_IMAGE:
format = babl_format ("R'G'B'A u8");
out_bpp = 4;
header[16] = 32; /* bpp */
header[17] = tsvals.origin ? 8 : 0x28; /* alpha + orientation */
break;
}
/* write header to front of file */
fwrite (header, sizeof (header), 1, fp);
if (dtype == GIMP_INDEXED_IMAGE)
{
/* write out palette */
for (i = 0; i < num_colors; ++i)
{
fputc (gimp_cmap[(i * 3) + 2], fp);
fputc (gimp_cmap[(i * 3) + 1], fp);
fputc (gimp_cmap[(i * 3) + 0], fp);
}
}
else if (dtype == GIMP_INDEXEDA_IMAGE)
{
/* write out palette */
for (i = 0; i < num_colors; ++i)
{
fputc (gimp_cmap[(i * 3) + 2], fp);
fputc (gimp_cmap[(i * 3) + 1], fp);
fputc (gimp_cmap[(i * 3) + 0], fp);
fputc (255, fp);
}
fputc (0, fp);
fputc (0, fp);
fputc (0, fp);
fputc (0, fp);
}
pixels = g_new (guchar, width * out_bpp);
data = g_new (guchar, width * out_bpp);
for (row = 0; row < height; ++row)
{
if (tsvals.origin)
{
gegl_buffer_get (buffer,
GEGL_RECTANGLE (0, height - (row + 1), width, 1), 1.0,
format, pixels,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
}
else
{
gegl_buffer_get (buffer,
GEGL_RECTANGLE (0, row, width, 1), 1.0,
format, pixels,
GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
}
if (dtype == GIMP_RGB_IMAGE)
{
bgr2rgb (data, pixels, width, out_bpp, 0);
}
else if (dtype == GIMP_RGBA_IMAGE)
{
bgr2rgb (data, pixels, width, out_bpp, 1);
}
else if (dtype == GIMP_INDEXEDA_IMAGE)
{
for (i = 0; i < width; ++i)
{
if (pixels[i * 2 + 1] > 127)
data[i] = pixels[i * 2];
else
data[i] = num_colors;
}
}
else
{
memcpy (data, pixels, width * out_bpp);
}
if (tsvals.rle)
{
rle_write (fp, data, width, out_bpp);
}
else
{
fwrite (data, width * out_bpp, 1, fp);
}
if (row % 16 == 0)
gimp_progress_update ((gdouble) row / (gdouble) height);
}
g_object_unref (buffer);
g_free (data);
g_free (pixels);
/* footer must be the last thing written to file */
memset (footer, 0, 8); /* No extensions, no developer directory */
memcpy (footer + 8, magic, sizeof (magic)); /* magic signature */
fwrite (footer, sizeof (footer), 1, fp);
fclose (fp);
gimp_progress_update (1.0);
return status;
}
| 0
|
244,247
|
void moof_box_del(GF_Box *s)
{
GF_MovieFragmentBox *ptr = (GF_MovieFragmentBox *)s;
if (ptr == NULL) return;
gf_list_del(ptr->TrackList);
if (ptr->PSSHs) gf_list_del(ptr->PSSHs);
if (ptr->mdat) gf_free(ptr->mdat);
//happens if error while fragmenting, the emsg boxes are not part of the moof hierarchy !
if (ptr->emsgs) {
while (1) {
GF_Box *emsg = gf_list_pop_front(ptr->emsgs);
if (!emsg) break;
gf_isom_box_del(emsg);
}
gf_list_del(ptr->emsgs);
}
gf_free(ptr);
}
| 0
|
273,089
|
net_address_get(char *addr, size_t addr_len, union net_sockaddr *naddr)
{
const char *s;
memset(addr, 0, addr_len); // Just in case caller doesn't check for errors
if (naddr->sa.sa_family == AF_INET6)
s = inet_ntop(AF_INET6, &naddr->sin6.sin6_addr, addr, addr_len);
else
s = inet_ntop(AF_INET, &naddr->sin.sin_addr, addr, addr_len);
if (!s)
return -1;
return 0;
}
| 0
|
231,802
|
TEST_F(QuicServerTransportTest, TestAckStopSending) {
auto streamId = server->createBidirectionalStream().value();
server->getNonConstConn().streamManager->getStream(streamId);
server->stopSending(streamId, GenericApplicationErrorCode::UNKNOWN);
loopForWrites();
auto match = findFrameInPacketFunc<QuicSimpleFrame::Type::StopSendingFrame>();
auto op = findOutstandingPacket(server->getNonConstConn(), match);
ASSERT_TRUE(op != nullptr);
PacketNum packetNum = op->packet.header.getPacketSequenceNum();
AckBlocks acks = {{packetNum, packetNum}};
auto packet1 = createAckPacket(
server->getNonConstConn(),
++clientNextAppDataPacketNum,
acks,
PacketNumberSpace::AppData);
deliverData(packetToBuf(packet1));
op = findOutstandingPacket(server->getNonConstConn(), match);
EXPECT_TRUE(op == nullptr);
}
| 0
|
244,062
|
GF_Box *sidx_box_new()
{
ISOM_DECL_BOX_ALLOC(GF_SegmentIndexBox, GF_ISOM_BOX_TYPE_SIDX);
return (GF_Box *)tmp;
}
| 0
|
294,680
|
rt__valid_date_frags_p(VALUE hash, VALUE sg)
{
{
VALUE vjd;
if (!NIL_P(vjd = ref_hash("jd"))) {
VALUE jd = rt__valid_jd_p(vjd, sg);
if (!NIL_P(jd))
return jd;
}
}
{
VALUE year, yday;
if (!NIL_P(yday = ref_hash("yday")) &&
!NIL_P(year = ref_hash("year"))) {
VALUE jd = rt__valid_ordinal_p(year, yday, sg);
if (!NIL_P(jd))
return jd;
}
}
{
VALUE year, mon, mday;
if (!NIL_P(mday = ref_hash("mday")) &&
!NIL_P(mon = ref_hash("mon")) &&
!NIL_P(year = ref_hash("year"))) {
VALUE jd = rt__valid_civil_p(year, mon, mday, sg);
if (!NIL_P(jd))
return jd;
}
}
{
VALUE year, week, wday;
wday = ref_hash("cwday");
if (NIL_P(wday)) {
wday = ref_hash("wday");
if (!NIL_P(wday))
if (f_zero_p(wday))
wday = INT2FIX(7);
}
if (!NIL_P(wday) &&
!NIL_P(week = ref_hash("cweek")) &&
!NIL_P(year = ref_hash("cwyear"))) {
VALUE jd = rt__valid_commercial_p(year, week, wday, sg);
if (!NIL_P(jd))
return jd;
}
}
{
VALUE year, week, wday;
wday = ref_hash("wday");
if (NIL_P(wday)) {
wday = ref_hash("cwday");
if (!NIL_P(wday))
if (f_eqeq_p(wday, INT2FIX(7)))
wday = INT2FIX(0);
}
if (!NIL_P(wday) &&
!NIL_P(week = ref_hash("wnum0")) &&
!NIL_P(year = ref_hash("year"))) {
VALUE jd = rt__valid_weeknum_p(year, week, wday, INT2FIX(0), sg);
if (!NIL_P(jd))
return jd;
}
}
{
VALUE year, week, wday;
wday = ref_hash("wday");
if (NIL_P(wday))
wday = ref_hash("cwday");
if (!NIL_P(wday))
wday = f_mod(f_sub(wday, INT2FIX(1)),
INT2FIX(7));
if (!NIL_P(wday) &&
!NIL_P(week = ref_hash("wnum1")) &&
!NIL_P(year = ref_hash("year"))) {
VALUE jd = rt__valid_weeknum_p(year, week, wday, INT2FIX(1), sg);
if (!NIL_P(jd))
return jd;
}
}
return Qnil;
}
| 0
|
273,926
|
static void do_STOR(uev_t *w, void *arg, int events)
{
ctrl_t *ctrl = (ctrl_t *)arg;
struct timeval tv;
ssize_t bytes;
size_t num;
char buf[BUFFER_SIZE];
if (UEV_ERROR == events || UEV_HUP == events) {
DBG("error on data_sd ...");
uev_io_start(w);
return;
}
if (!ctrl->fp) {
DBG("no fp for STOR, bailing.");
return;
}
/* Reset inactivity timer. */
uev_timer_set(&ctrl->timeout_watcher, INACTIVITY_TIMER, 0);
bytes = recv(ctrl->data_sd, buf, sizeof(buf), 0);
if (bytes < 0) {
if (ECONNRESET == errno)
DBG("Connection reset by client.");
else
ERR(errno, "Failed receiving file %s from client", ctrl->file);
do_abort(ctrl);
send_msg(ctrl->sd, "426 TCP connection was established but then broken!\r\n");
return;
}
if (bytes == 0) {
INFO("User %s at %s uploaded file %s", ctrl->name, ctrl->clientaddr, ctrl->file);
do_abort(ctrl);
send_msg(ctrl->sd, "226 Transfer complete.\r\n");
return;
}
gettimeofday(&tv, NULL);
if (tv.tv_sec - ctrl->tv.tv_sec > 3) {
DBG("Receiving %zd bytes of %s from %s ...", bytes, ctrl->file, ctrl->clientaddr);
ctrl->tv.tv_sec = tv.tv_sec;
}
num = fwrite(buf, 1, bytes, ctrl->fp);
if ((size_t)bytes != num)
ERR(errno, "552 Disk full.");
}
| 0
|
353,021
|
bitStringValidate(
Syntax *syntax,
struct berval *in )
{
ber_len_t i;
/* very unforgiving validation, requires no normalization
* before simplistic matching
*/
if( in->bv_len < 3 ) {
return LDAP_INVALID_SYNTAX;
}
/* RFC 4517 Section 3.3.2 Bit String:
* BitString = SQUOTE *binary-digit SQUOTE "B"
* binary-digit = "0" / "1"
*
* where SQUOTE [RFC4512] is
* SQUOTE = %x27 ; single quote ("'")
*
* Example: '0101111101'B
*/
if( in->bv_val[0] != '\'' ||
in->bv_val[in->bv_len - 2] != '\'' ||
in->bv_val[in->bv_len - 1] != 'B' )
{
return LDAP_INVALID_SYNTAX;
}
for( i = in->bv_len - 3; i > 0; i-- ) {
if( in->bv_val[i] != '0' && in->bv_val[i] != '1' ) {
return LDAP_INVALID_SYNTAX;
}
}
return LDAP_SUCCESS;
}
| 0
|
226,186
|
void tpyl_box_del(GF_Box *s)
{
gf_free((GF_NTYLBox *)s);
}
| 0
|
482,489
|
compileGrouping(FileInfo *file, int noback, int nofor, TranslationTableHeader **table,
DisplayTableHeader **displayTable) {
int k;
CharsString name;
CharsString groupChars;
CharsString groupDots;
CharsString dotsParsed;
if (!getToken(file, &name, "name operand")) return 0;
if (!getRuleCharsText(file, &groupChars)) return 0;
if (!getToken(file, &groupDots, "dots operand")) return 0;
for (k = 0; k < groupDots.length && groupDots.chars[k] != ','; k++)
;
if (k == groupDots.length) {
compileError(file, "Dots operand must consist of two cells separated by a comma");
return 0;
}
groupDots.chars[k] = '-';
if (!parseDots(file, &dotsParsed, &groupDots)) return 0;
if (groupChars.length != 2 || dotsParsed.length != 2) {
compileError(file,
"two Unicode characters and two cells separated by a comma are needed.");
return 0;
}
if (table) {
TranslationTableOffset ruleOffset;
TranslationTableCharacter *charsDotsPtr;
charsDotsPtr = putChar(file, groupChars.chars[0], table, NULL);
charsDotsPtr->attributes |= CTC_Math;
charsDotsPtr = putChar(file, groupChars.chars[1], table, NULL);
charsDotsPtr->attributes |= CTC_Math;
charsDotsPtr = putDots(file, dotsParsed.chars[0], table);
charsDotsPtr->attributes |= CTC_Math;
charsDotsPtr = putDots(file, dotsParsed.chars[1], table);
charsDotsPtr->attributes |= CTC_Math;
if (!addRule(file, CTO_Grouping, &groupChars, &dotsParsed, 0, 0, &ruleOffset,
NULL, noback, nofor, table))
return 0;
if (!addRuleName(file, &name, ruleOffset, *table)) return 0;
}
if (displayTable) {
putCharDotsMapping(file, groupChars.chars[0], dotsParsed.chars[0], displayTable);
putCharDotsMapping(file, groupChars.chars[1], dotsParsed.chars[1], displayTable);
}
if (table) {
widechar endChar;
widechar endDots;
endChar = groupChars.chars[1];
endDots = dotsParsed.chars[1];
groupChars.length = dotsParsed.length = 1;
if (!addRule(file, CTO_Math, &groupChars, &dotsParsed, 0, 0, NULL, NULL, noback,
nofor, table))
return 0;
groupChars.chars[0] = endChar;
dotsParsed.chars[0] = endDots;
if (!addRule(file, CTO_Math, &groupChars, &dotsParsed, 0, 0, NULL, NULL, noback,
nofor, table))
return 0;
}
return 1;
}
| 0
|
401,559
|
static inline void timer_base_lock_expiry(struct timer_base *base)
{
spin_lock(&base->expiry_lock);
}
| 0
|
195,670
|
static pj_xml_node *xml_parse_node( pj_pool_t *pool, pj_scanner *scanner)
{
pj_xml_node *node;
pj_str_t end_name;
PJ_CHECK_STACK();
if (*scanner->curptr != '<')
on_syntax_error(scanner);
/* Handle Processing Instructino (PI) construct (i.e. "<?") */
if (*scanner->curptr == '<' && *(scanner->curptr+1) == '?') {
pj_scan_advance_n(scanner, 2, PJ_FALSE);
for (;;) {
pj_str_t dummy;
pj_scan_get_until_ch(scanner, '?', &dummy);
if (*scanner->curptr=='?' && *(scanner->curptr+1)=='>') {
pj_scan_advance_n(scanner, 2, PJ_TRUE);
break;
} else {
pj_scan_advance_n(scanner, 1, PJ_FALSE);
}
}
return xml_parse_node(pool, scanner);
}
/* Handle comments construct (i.e. "<!") */
if (pj_scan_strcmp(scanner, "<!", 2) == 0) {
pj_scan_advance_n(scanner, 2, PJ_FALSE);
for (;;) {
pj_str_t dummy;
pj_scan_get_until_ch(scanner, '>', &dummy);
if (pj_scan_strcmp(scanner, ">", 1) == 0) {
pj_scan_advance_n(scanner, 1, PJ_TRUE);
break;
} else {
pj_scan_advance_n(scanner, 1, PJ_FALSE);
}
}
return xml_parse_node(pool, scanner);
}
/* Alloc node. */
node = alloc_node(pool);
/* Get '<' */
pj_scan_get_char(scanner);
/* Get node name. */
pj_scan_get_until_chr( scanner, " />\t\r\n", &node->name);
/* Get attributes. */
while (*scanner->curptr != '>' && *scanner->curptr != '/') {
pj_xml_attr *attr = alloc_attr(pool);
pj_scan_get_until_chr( scanner, "=> \t\r\n", &attr->name);
if (*scanner->curptr == '=') {
pj_scan_get_char( scanner );
pj_scan_get_quotes(scanner, "\"'", "\"'", 2, &attr->value);
/* remove quote characters */
++attr->value.ptr;
attr->value.slen -= 2;
}
pj_list_push_back( &node->attr_head, attr );
}
if (*scanner->curptr == '/') {
pj_scan_get_char(scanner);
if (pj_scan_get_char(scanner) != '>')
on_syntax_error(scanner);
return node;
}
/* Enclosing bracket. */
if (pj_scan_get_char(scanner) != '>')
on_syntax_error(scanner);
/* Sub nodes. */
while (*scanner->curptr == '<' && *(scanner->curptr+1) != '/'
&& *(scanner->curptr+1) != '!')
{
pj_xml_node *sub_node = xml_parse_node(pool, scanner);
pj_list_push_back( &node->node_head, sub_node );
}
/* Content. */
if (!pj_scan_is_eof(scanner) && *scanner->curptr != '<') {
pj_scan_get_until_ch(scanner, '<', &node->content);
}
/* CDATA content. */
if (*scanner->curptr == '<' && *(scanner->curptr+1) == '!' &&
pj_scan_strcmp(scanner, "<![CDATA[", 9) == 0)
{
pj_scan_advance_n(scanner, 9, PJ_FALSE);
pj_scan_get_until_ch(scanner, ']', &node->content);
while (pj_scan_strcmp(scanner, "]]>", 3)) {
pj_str_t dummy;
pj_scan_get_until_ch(scanner, ']', &dummy);
}
node->content.slen = scanner->curptr - node->content.ptr;
pj_scan_advance_n(scanner, 3, PJ_TRUE);
}
/* Enclosing node. */
if (pj_scan_get_char(scanner) != '<' || pj_scan_get_char(scanner) != '/')
on_syntax_error(scanner);
pj_scan_get_until_chr(scanner, " \t>", &end_name);
/* Compare name. */
if (pj_stricmp(&node->name, &end_name) != 0)
on_syntax_error(scanner);
/* Enclosing '>' */
if (pj_scan_get_char(scanner) != '>')
on_syntax_error(scanner);
return node;
}
| 1
|
225,423
|
static void init_capture_param(struct v4l2_captureparm *capture_param)
{
MARK();
capture_param->capability = 0;
capture_param->capturemode = 0;
capture_param->extendedmode = 0;
capture_param->readbuffers = max_buffers;
capture_param->timeperframe.numerator = 1;
capture_param->timeperframe.denominator = 30;
}
| 0
|
244,314
|
GF_Err csgp_box_size(GF_Box *s)
{
u32 i, bits;
GF_CompactSampleGroupBox *ptr = (GF_CompactSampleGroupBox*)s;
u32 pattern_size = get_size_by_code( ((ptr->flags>>4) & 0x3) );
u32 scount_size = get_size_by_code( ((ptr->flags>>2) & 0x3) );
u32 index_size = get_size_by_code( (ptr->flags & 0x3) );
ptr->size += 12; //v, flags , grouping_type, pattern_length
if (ptr->flags & (1<<6))
ptr->size+=4;
ptr->size += ptr->pattern_count * (pattern_size + scount_size) / 8;
bits=0;
for (i=0; i<ptr->pattern_count; i++)
bits += ptr->patterns[i].length * index_size;
ptr->size += bits/8;
if (bits % 8) ptr->size++;
return GF_OK;
}
| 0
|
221,488
|
flatpak_run_add_a11y_dbus_args (FlatpakBwrap *app_bwrap,
FlatpakBwrap *proxy_arg_bwrap,
FlatpakContext *context,
FlatpakRunFlags flags)
{
static const char sandbox_socket_path[] = "/run/flatpak/at-spi-bus";
static const char sandbox_dbus_address[] = "unix:path=/run/flatpak/at-spi-bus";
g_autoptr(GDBusConnection) session_bus = NULL;
g_autofree char *a11y_address = NULL;
g_autoptr(GError) local_error = NULL;
g_autoptr(GDBusMessage) reply = NULL;
g_autoptr(GDBusMessage) msg = NULL;
g_autofree char *proxy_socket = NULL;
if ((flags & FLATPAK_RUN_FLAG_NO_A11Y_BUS_PROXY) != 0)
return FALSE;
session_bus = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
if (session_bus == NULL)
return FALSE;
msg = g_dbus_message_new_method_call ("org.a11y.Bus", "/org/a11y/bus", "org.a11y.Bus", "GetAddress");
g_dbus_message_set_body (msg, g_variant_new ("()"));
reply =
g_dbus_connection_send_message_with_reply_sync (session_bus, msg,
G_DBUS_SEND_MESSAGE_FLAGS_NONE,
30000,
NULL,
NULL,
NULL);
if (reply)
{
if (g_dbus_message_to_gerror (reply, &local_error))
{
if (!g_error_matches (local_error, G_DBUS_ERROR, G_DBUS_ERROR_SERVICE_UNKNOWN))
g_message ("Can't find a11y bus: %s", local_error->message);
}
else
{
g_variant_get (g_dbus_message_get_body (reply),
"(s)", &a11y_address);
}
}
if (!a11y_address)
return FALSE;
proxy_socket = create_proxy_socket ("a11y-bus-proxy-XXXXXX");
if (proxy_socket == NULL)
return FALSE;
flatpak_bwrap_add_args (proxy_arg_bwrap,
a11y_address,
proxy_socket, "--filter", "--sloppy-names",
"--call=org.a11y.atspi.Registry=org.a11y.atspi.Socket.Embed@/org/a11y/atspi/accessible/root",
"--call=org.a11y.atspi.Registry=org.a11y.atspi.Socket.Unembed@/org/a11y/atspi/accessible/root",
"--call=org.a11y.atspi.Registry=org.a11y.atspi.Registry.GetRegisteredEvents@/org/a11y/atspi/registry",
"--call=org.a11y.atspi.Registry=org.a11y.atspi.DeviceEventController.GetKeystrokeListeners@/org/a11y/atspi/registry/deviceeventcontroller",
"--call=org.a11y.atspi.Registry=org.a11y.atspi.DeviceEventController.GetDeviceEventListeners@/org/a11y/atspi/registry/deviceeventcontroller",
"--call=org.a11y.atspi.Registry=org.a11y.atspi.DeviceEventController.NotifyListenersSync@/org/a11y/atspi/registry/deviceeventcontroller",
"--call=org.a11y.atspi.Registry=org.a11y.atspi.DeviceEventController.NotifyListenersAsync@/org/a11y/atspi/registry/deviceeventcontroller",
NULL);
if ((flags & FLATPAK_RUN_FLAG_LOG_A11Y_BUS) != 0)
flatpak_bwrap_add_args (proxy_arg_bwrap, "--log", NULL);
flatpak_bwrap_add_args (app_bwrap,
"--ro-bind", proxy_socket, sandbox_socket_path,
NULL);
flatpak_bwrap_set_env (app_bwrap, "AT_SPI_BUS_ADDRESS", sandbox_dbus_address, TRUE);
return TRUE;
}
| 0
|
238,761
|
findmatchlimit(
oparg_T *oap,
int initc,
int flags,
int maxtravel)
{
static pos_T pos; // current search position
int findc = 0; // matching brace
int c;
int count = 0; // cumulative number of braces
int backwards = FALSE; // init for gcc
int raw_string = FALSE; // search for raw string
int inquote = FALSE; // TRUE when inside quotes
char_u *linep; // pointer to current line
char_u *ptr;
int do_quotes; // check for quotes in current line
int at_start; // do_quotes value at start position
int hash_dir = 0; // Direction searched for # things
int comment_dir = 0; // Direction searched for comments
pos_T match_pos; // Where last slash-star was found
int start_in_quotes; // start position is in quotes
int traveled = 0; // how far we've searched so far
int ignore_cend = FALSE; // ignore comment end
int cpo_match; // vi compatible matching
int cpo_bsl; // don't recognize backslashes
int match_escaped = 0; // search for escaped match
int dir; // Direction to search
int comment_col = MAXCOL; // start of / / comment
int lispcomm = FALSE; // inside of Lisp-style comment
int lisp = curbuf->b_p_lisp; // engage Lisp-specific hacks ;)
pos = curwin->w_cursor;
pos.coladd = 0;
linep = ml_get(pos.lnum);
cpo_match = (vim_strchr(p_cpo, CPO_MATCH) != NULL);
cpo_bsl = (vim_strchr(p_cpo, CPO_MATCHBSL) != NULL);
// Direction to search when initc is '/', '*' or '#'
if (flags & FM_BACKWARD)
dir = BACKWARD;
else if (flags & FM_FORWARD)
dir = FORWARD;
else
dir = 0;
/*
* if initc given, look in the table for the matching character
* '/' and '*' are special cases: look for start or end of comment.
* When '/' is used, we ignore running backwards into an star-slash, for
* "[*" command, we just want to find any comment.
*/
if (initc == '/' || initc == '*' || initc == 'R')
{
comment_dir = dir;
if (initc == '/')
ignore_cend = TRUE;
backwards = (dir == FORWARD) ? FALSE : TRUE;
raw_string = (initc == 'R');
initc = NUL;
}
else if (initc != '#' && initc != NUL)
{
find_mps_values(&initc, &findc, &backwards, TRUE);
if (dir)
backwards = (dir == FORWARD) ? FALSE : TRUE;
if (findc == NUL)
return NULL;
}
else
{
/*
* Either initc is '#', or no initc was given and we need to look
* under the cursor.
*/
if (initc == '#')
{
hash_dir = dir;
}
else
{
/*
* initc was not given, must look for something to match under
* or near the cursor.
* Only check for special things when 'cpo' doesn't have '%'.
*/
if (!cpo_match)
{
// Are we before or at #if, #else etc.?
ptr = skipwhite(linep);
if (*ptr == '#' && pos.col <= (colnr_T)(ptr - linep))
{
ptr = skipwhite(ptr + 1);
if ( STRNCMP(ptr, "if", 2) == 0
|| STRNCMP(ptr, "endif", 5) == 0
|| STRNCMP(ptr, "el", 2) == 0)
hash_dir = 1;
}
// Are we on a comment?
else if (linep[pos.col] == '/')
{
if (linep[pos.col + 1] == '*')
{
comment_dir = FORWARD;
backwards = FALSE;
pos.col++;
}
else if (pos.col > 0 && linep[pos.col - 1] == '*')
{
comment_dir = BACKWARD;
backwards = TRUE;
pos.col--;
}
}
else if (linep[pos.col] == '*')
{
if (linep[pos.col + 1] == '/')
{
comment_dir = BACKWARD;
backwards = TRUE;
}
else if (pos.col > 0 && linep[pos.col - 1] == '/')
{
comment_dir = FORWARD;
backwards = FALSE;
}
}
}
/*
* If we are not on a comment or the # at the start of a line, then
* look for brace anywhere on this line after the cursor.
*/
if (!hash_dir && !comment_dir)
{
/*
* Find the brace under or after the cursor.
* If beyond the end of the line, use the last character in
* the line.
*/
if (linep[pos.col] == NUL && pos.col)
--pos.col;
for (;;)
{
initc = PTR2CHAR(linep + pos.col);
if (initc == NUL)
break;
find_mps_values(&initc, &findc, &backwards, FALSE);
if (findc)
break;
pos.col += mb_ptr2len(linep + pos.col);
}
if (!findc)
{
// no brace in the line, maybe use " #if" then
if (!cpo_match && *skipwhite(linep) == '#')
hash_dir = 1;
else
return NULL;
}
else if (!cpo_bsl)
{
int col, bslcnt = 0;
// Set "match_escaped" if there are an odd number of
// backslashes.
for (col = pos.col; check_prevcol(linep, col, '\\', &col);)
bslcnt++;
match_escaped = (bslcnt & 1);
}
}
}
if (hash_dir)
{
/*
* Look for matching #if, #else, #elif, or #endif
*/
if (oap != NULL)
oap->motion_type = MLINE; // Linewise for this case only
if (initc != '#')
{
ptr = skipwhite(skipwhite(linep) + 1);
if (STRNCMP(ptr, "if", 2) == 0 || STRNCMP(ptr, "el", 2) == 0)
hash_dir = 1;
else if (STRNCMP(ptr, "endif", 5) == 0)
hash_dir = -1;
else
return NULL;
}
pos.col = 0;
while (!got_int)
{
if (hash_dir > 0)
{
if (pos.lnum == curbuf->b_ml.ml_line_count)
break;
}
else if (pos.lnum == 1)
break;
pos.lnum += hash_dir;
linep = ml_get(pos.lnum);
line_breakcheck(); // check for CTRL-C typed
ptr = skipwhite(linep);
if (*ptr != '#')
continue;
pos.col = (colnr_T) (ptr - linep);
ptr = skipwhite(ptr + 1);
if (hash_dir > 0)
{
if (STRNCMP(ptr, "if", 2) == 0)
count++;
else if (STRNCMP(ptr, "el", 2) == 0)
{
if (count == 0)
return &pos;
}
else if (STRNCMP(ptr, "endif", 5) == 0)
{
if (count == 0)
return &pos;
count--;
}
}
else
{
if (STRNCMP(ptr, "if", 2) == 0)
{
if (count == 0)
return &pos;
count--;
}
else if (initc == '#' && STRNCMP(ptr, "el", 2) == 0)
{
if (count == 0)
return &pos;
}
else if (STRNCMP(ptr, "endif", 5) == 0)
count++;
}
}
return NULL;
}
}
#ifdef FEAT_RIGHTLEFT
// This is just guessing: when 'rightleft' is set, search for a matching
// paren/brace in the other direction.
if (curwin->w_p_rl && vim_strchr((char_u *)"()[]{}<>", initc) != NULL)
backwards = !backwards;
#endif
do_quotes = -1;
start_in_quotes = MAYBE;
CLEAR_POS(&match_pos);
// backward search: Check if this line contains a single-line comment
if ((backwards && comment_dir) || lisp)
comment_col = check_linecomment(linep);
if (lisp && comment_col != MAXCOL && pos.col > (colnr_T)comment_col)
lispcomm = TRUE; // find match inside this comment
while (!got_int)
{
/*
* Go to the next position, forward or backward. We could use
* inc() and dec() here, but that is much slower
*/
if (backwards)
{
// char to match is inside of comment, don't search outside
if (lispcomm && pos.col < (colnr_T)comment_col)
break;
if (pos.col == 0) // at start of line, go to prev. one
{
if (pos.lnum == 1) // start of file
break;
--pos.lnum;
if (maxtravel > 0 && ++traveled > maxtravel)
break;
linep = ml_get(pos.lnum);
pos.col = (colnr_T)STRLEN(linep); // pos.col on trailing NUL
do_quotes = -1;
line_breakcheck();
// Check if this line contains a single-line comment
if (comment_dir || lisp)
comment_col = check_linecomment(linep);
// skip comment
if (lisp && comment_col != MAXCOL)
pos.col = comment_col;
}
else
{
--pos.col;
if (has_mbyte)
pos.col -= (*mb_head_off)(linep, linep + pos.col);
}
}
else // forward search
{
if (linep[pos.col] == NUL
// at end of line, go to next one
// For lisp don't search for match in comment
|| (lisp && comment_col != MAXCOL
&& pos.col == (colnr_T)comment_col))
{
if (pos.lnum == curbuf->b_ml.ml_line_count // end of file
// line is exhausted and comment with it,
// don't search for match in code
|| lispcomm)
break;
++pos.lnum;
if (maxtravel && traveled++ > maxtravel)
break;
linep = ml_get(pos.lnum);
pos.col = 0;
do_quotes = -1;
line_breakcheck();
if (lisp) // find comment pos in new line
comment_col = check_linecomment(linep);
}
else
{
if (has_mbyte)
pos.col += (*mb_ptr2len)(linep + pos.col);
else
++pos.col;
}
}
/*
* If FM_BLOCKSTOP given, stop at a '{' or '}' in column 0.
*/
if (pos.col == 0 && (flags & FM_BLOCKSTOP)
&& (linep[0] == '{' || linep[0] == '}'))
{
if (linep[0] == findc && count == 0) // match!
return &pos;
break; // out of scope
}
if (comment_dir)
{
// Note: comments do not nest, and we ignore quotes in them
// TODO: ignore comment brackets inside strings
if (comment_dir == FORWARD)
{
if (linep[pos.col] == '*' && linep[pos.col + 1] == '/')
{
pos.col++;
return &pos;
}
}
else // Searching backwards
{
/*
* A comment may contain / * or / /, it may also start or end
* with / * /. Ignore a / * after / / and after *.
*/
if (pos.col == 0)
continue;
else if (raw_string)
{
if (linep[pos.col - 1] == 'R'
&& linep[pos.col] == '"'
&& vim_strchr(linep + pos.col + 1, '(') != NULL)
{
// Possible start of raw string. Now that we have the
// delimiter we can check if it ends before where we
// started searching, or before the previously found
// raw string start.
if (!find_rawstring_end(linep, &pos,
count > 0 ? &match_pos : &curwin->w_cursor))
{
count++;
match_pos = pos;
match_pos.col--;
}
linep = ml_get(pos.lnum); // may have been released
}
}
else if ( linep[pos.col - 1] == '/'
&& linep[pos.col] == '*'
&& (pos.col == 1 || linep[pos.col - 2] != '*')
&& (int)pos.col < comment_col)
{
count++;
match_pos = pos;
match_pos.col--;
}
else if (linep[pos.col - 1] == '*' && linep[pos.col] == '/')
{
if (count > 0)
pos = match_pos;
else if (pos.col > 1 && linep[pos.col - 2] == '/'
&& (int)pos.col <= comment_col)
pos.col -= 2;
else if (ignore_cend)
continue;
else
return NULL;
return &pos;
}
}
continue;
}
/*
* If smart matching ('cpoptions' does not contain '%'), braces inside
* of quotes are ignored, but only if there is an even number of
* quotes in the line.
*/
if (cpo_match)
do_quotes = 0;
else if (do_quotes == -1)
{
/*
* Count the number of quotes in the line, skipping \" and '"'.
* Watch out for "\\".
*/
at_start = do_quotes;
for (ptr = linep; *ptr; ++ptr)
{
if (ptr == linep + pos.col + backwards)
at_start = (do_quotes & 1);
if (*ptr == '"'
&& (ptr == linep || ptr[-1] != '\'' || ptr[1] != '\''))
++do_quotes;
if (*ptr == '\\' && ptr[1] != NUL)
++ptr;
}
do_quotes &= 1; // result is 1 with even number of quotes
/*
* If we find an uneven count, check current line and previous
* one for a '\' at the end.
*/
if (!do_quotes)
{
inquote = FALSE;
if (ptr[-1] == '\\')
{
do_quotes = 1;
if (start_in_quotes == MAYBE)
{
// Do we need to use at_start here?
inquote = TRUE;
start_in_quotes = TRUE;
}
else if (backwards)
inquote = TRUE;
}
if (pos.lnum > 1)
{
ptr = ml_get(pos.lnum - 1);
if (*ptr && *(ptr + STRLEN(ptr) - 1) == '\\')
{
do_quotes = 1;
if (start_in_quotes == MAYBE)
{
inquote = at_start;
if (inquote)
start_in_quotes = TRUE;
}
else if (!backwards)
inquote = TRUE;
}
// ml_get() only keeps one line, need to get linep again
linep = ml_get(pos.lnum);
}
}
}
if (start_in_quotes == MAYBE)
start_in_quotes = FALSE;
/*
* If 'smartmatch' is set:
* Things inside quotes are ignored by setting 'inquote'. If we
* find a quote without a preceding '\' invert 'inquote'. At the
* end of a line not ending in '\' we reset 'inquote'.
*
* In lines with an uneven number of quotes (without preceding '\')
* we do not know which part to ignore. Therefore we only set
* inquote if the number of quotes in a line is even, unless this
* line or the previous one ends in a '\'. Complicated, isn't it?
*/
c = PTR2CHAR(linep + pos.col);
switch (c)
{
case NUL:
// at end of line without trailing backslash, reset inquote
if (pos.col == 0 || linep[pos.col - 1] != '\\')
{
inquote = FALSE;
start_in_quotes = FALSE;
}
break;
case '"':
// a quote that is preceded with an odd number of backslashes is
// ignored
if (do_quotes)
{
int col;
for (col = pos.col - 1; col >= 0; --col)
if (linep[col] != '\\')
break;
if ((((int)pos.col - 1 - col) & 1) == 0)
{
inquote = !inquote;
start_in_quotes = FALSE;
}
}
break;
/*
* If smart matching ('cpoptions' does not contain '%'):
* Skip things in single quotes: 'x' or '\x'. Be careful for single
* single quotes, eg jon's. Things like '\233' or '\x3f' are not
* skipped, there is never a brace in them.
* Ignore this when finding matches for `'.
*/
case '\'':
if (!cpo_match && initc != '\'' && findc != '\'')
{
if (backwards)
{
if (pos.col > 1)
{
if (linep[pos.col - 2] == '\'')
{
pos.col -= 2;
break;
}
else if (linep[pos.col - 2] == '\\'
&& pos.col > 2 && linep[pos.col - 3] == '\'')
{
pos.col -= 3;
break;
}
}
}
else if (linep[pos.col + 1]) // forward search
{
if (linep[pos.col + 1] == '\\'
&& linep[pos.col + 2] && linep[pos.col + 3] == '\'')
{
pos.col += 3;
break;
}
else if (linep[pos.col + 2] == '\'')
{
pos.col += 2;
break;
}
}
}
// FALLTHROUGH
default:
/*
* For Lisp skip over backslashed (), {} and [].
* (actually, we skip #\( et al)
*/
if (curbuf->b_p_lisp
&& vim_strchr((char_u *)"(){}[]", c) != NULL
&& pos.col > 1
&& check_prevcol(linep, pos.col, '\\', NULL)
&& check_prevcol(linep, pos.col - 1, '#', NULL))
break;
// Check for match outside of quotes, and inside of
// quotes when the start is also inside of quotes.
if ((!inquote || start_in_quotes == TRUE)
&& (c == initc || c == findc))
{
int col, bslcnt = 0;
if (!cpo_bsl)
{
for (col = pos.col; check_prevcol(linep, col, '\\', &col);)
bslcnt++;
}
// Only accept a match when 'M' is in 'cpo' or when escaping
// is what we expect.
if (cpo_bsl || (bslcnt & 1) == match_escaped)
{
if (c == initc)
count++;
else
{
if (count == 0)
return &pos;
count--;
}
}
}
}
}
if (comment_dir == BACKWARD && count > 0)
{
pos = match_pos;
return &pos;
}
return (pos_T *)NULL; // never found it
}
| 0
|
226,980
|
IRC_PROTOCOL_CALLBACK(368)
{
char *pos_args;
struct t_irc_channel *ptr_channel;
struct t_gui_buffer *ptr_buffer;
struct t_irc_modelist *ptr_modelist;
IRC_PROTOCOL_MIN_ARGS(4);
pos_args = (argc > 4) ?
((argv_eol[4][0] == ':') ? argv_eol[4] + 1 : argv_eol[4]) : NULL;
ptr_channel = irc_channel_search (server, argv[3]);
ptr_buffer = (ptr_channel && ptr_channel->nicks) ?
ptr_channel->buffer : server->buffer;
ptr_modelist = irc_modelist_search (ptr_channel, 'b');
if (ptr_modelist)
{
if (ptr_modelist->state != IRC_MODELIST_STATE_RECEIVING)
{
/*
* remove all items if no ban was received before
* the end of ban list
*/
irc_modelist_item_free_all (ptr_modelist);
}
ptr_modelist->state = IRC_MODELIST_STATE_RECEIVED;
}
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, "banlist", ptr_buffer),
date,
irc_protocol_tags (command, "irc_numeric", NULL, NULL),
"%s%s[%s%s%s]%s%s%s",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(pos_args) ? " " : "",
(pos_args) ? pos_args : "");
return WEECHAT_RC_OK;
}
| 0
|
232,332
|
Bool gf_box_valid_in_parent(GF_Box *a, const char *parent_4cc)
{
if (!a || !a->registry || !a->registry->parents_4cc) return GF_FALSE;
if (strstr(a->registry->parents_4cc, parent_4cc) != NULL) return GF_TRUE;
return GF_FALSE;
| 0
|
233,821
|
void fmtutil_handle_exif(deark *c, i64 pos, i64 len)
{
fmtutil_handle_exif2(c, pos, len, NULL, NULL, NULL);
}
| 0
|
473,931
|
mbc_case_fold(OnigCaseFoldType flag,
const UChar** pp, const UChar* end ARG_UNUSED, UChar* lower,
OnigEncoding enc ARG_UNUSED)
{
const UChar* p = *pp;
if (*p == 0xdf && (flag & INTERNAL_ONIGENC_CASE_FOLD_MULTI_CHAR) != 0) {
*lower++ = 's';
*lower = 's';
(*pp)++;
return 2;
}
*lower = ENC_ISO_8859_9_TO_LOWER_CASE(*p);
(*pp)++;
return 1;
}
| 0
|
225,482
|
Status MutableGraphView::AddRegularFaninByPort(absl::string_view node_name,
int port,
const TensorId& fanin) {
auto error_status = [node_name, port, fanin](absl::string_view msg) {
string params = absl::Substitute("node_name='$0', port=$1, fanin='$2'",
node_name, port, fanin.ToString());
return MutationError("AddRegularFaninByPort", params, msg);
};
TF_RETURN_IF_ERROR(CheckFaninIsRegular(fanin, error_status));
TF_RETURN_IF_ERROR(CheckAddingFaninToSelf(node_name, fanin, error_status));
NodeDef* node = GetNode(node_name);
TF_RETURN_IF_ERROR(CheckNodeExists(node_name, node, error_status));
const int num_regular_fanins =
NumFanins(*node, /*include_controlling_nodes=*/false);
TF_RETURN_IF_ERROR(
CheckPortRange(port, /*min=*/0, num_regular_fanins, error_status));
NodeDef* fanin_node = GetNode(fanin.node());
TF_RETURN_IF_ERROR(CheckNodeExists(fanin.node(), fanin_node, error_status));
const int last_node_input = node->input_size();
node->add_input(TensorIdToString(fanin));
node->mutable_input()->SwapElements(num_regular_fanins, last_node_input);
for (int i = num_regular_fanins - 1; i >= port; --i) {
TensorId tensor_id = ParseTensorName(node->input(i));
OutputPort fanin_port(nodes()[tensor_id.node()], tensor_id.index());
absl::flat_hash_set<InputPort>* fanouts_set = &fanouts()[fanin_port];
fanouts_set->erase({node, i});
fanouts_set->insert({node, i + 1});
node->mutable_input()->SwapElements(i, i + 1);
}
OutputPort fanin_port(fanin_node, fanin.index());
fanouts()[fanin_port].insert({node, port});
UpdateMaxRegularOutputPortForAddedFanin(fanin_port);
max_regular_input_port()[node] = num_regular_fanins;
if (CanDedupControlWithRegularInput(*this, *fanin_node)) {
RemoveControllingFaninInternal(node, fanin_node);
}
return Status::OK();
}
| 0
|
244,202
|
void clap_box_del(GF_Box *s)
{
GF_CleanApertureBox *ptr = (GF_CleanApertureBox*)s;
if (ptr == NULL) return;
gf_free(ptr);
}
| 0
|
307,834
|
bool ciEnv::system_dictionary_modification_counter_changed() {
return _system_dictionary_modification_counter != SystemDictionary::number_of_modifications();
}
| 0
|
211,700
|
int st21nfca_connectivity_event_received(struct nfc_hci_dev *hdev, u8 host,
u8 event, struct sk_buff *skb)
{
int r = 0;
struct device *dev = &hdev->ndev->dev;
struct nfc_evt_transaction *transaction;
pr_debug("connectivity gate event: %x\n", event);
switch (event) {
case ST21NFCA_EVT_CONNECTIVITY:
r = nfc_se_connectivity(hdev->ndev, host);
break;
case ST21NFCA_EVT_TRANSACTION:
/*
* According to specification etsi 102 622
* 11.2.2.4 EVT_TRANSACTION Table 52
* Description Tag Length
* AID 81 5 to 16
* PARAMETERS 82 0 to 255
*/
if (skb->len < NFC_MIN_AID_LENGTH + 2 &&
skb->data[0] != NFC_EVT_TRANSACTION_AID_TAG)
return -EPROTO;
transaction = devm_kzalloc(dev, skb->len - 2, GFP_KERNEL);
if (!transaction)
return -ENOMEM;
transaction->aid_len = skb->data[1];
memcpy(transaction->aid, &skb->data[2],
transaction->aid_len);
/* Check next byte is PARAMETERS tag (82) */
if (skb->data[transaction->aid_len + 2] !=
NFC_EVT_TRANSACTION_PARAMS_TAG)
return -EPROTO;
transaction->params_len = skb->data[transaction->aid_len + 3];
memcpy(transaction->params, skb->data +
transaction->aid_len + 4, transaction->params_len);
r = nfc_se_transaction(hdev->ndev, host, transaction);
break;
default:
nfc_err(&hdev->ndev->dev, "Unexpected event on connectivity gate\n");
return 1;
}
kfree_skb(skb);
return r;
}
| 1
|
468,357
|
g_socket_client_enumerator_callback (GObject *object,
GAsyncResult *result,
gpointer user_data)
{
GSocketClientAsyncConnectData *data = user_data;
GSocketAddress *address = NULL;
GSocket *socket;
ConnectionAttempt *attempt;
GError *error = NULL;
if (task_completed_or_cancelled (data->task))
{
g_object_unref (data->task);
return;
}
address = g_socket_address_enumerator_next_finish (data->enumerator,
result, &error);
if (address == NULL)
{
if (data->connection_attempts)
{
g_object_unref (data->task);
return;
}
g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_COMPLETE, data->connectable, NULL);
if (!error)
{
if (data->last_error)
{
error = data->last_error;
data->last_error = NULL;
}
else
{
g_set_error_literal (&error, G_IO_ERROR, G_IO_ERROR_FAILED,
_("Unknown error on connect"));
}
}
g_task_return_error (data->task, error);
g_object_unref (data->task);
return;
}
g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_RESOLVED,
data->connectable, NULL);
if (G_IS_PROXY_ADDRESS (address) &&
data->client->priv->enable_proxy)
data->proxy_addr = g_object_ref (G_PROXY_ADDRESS (address));
g_clear_error (&data->last_error);
socket = create_socket (data->client, address, &data->last_error);
if (socket == NULL)
{
g_object_unref (address);
enumerator_next_async (data, FALSE);
return;
}
attempt = connection_attempt_new ();
attempt->data = data;
attempt->socket = socket;
attempt->address = address;
attempt->cancellable = g_cancellable_new ();
attempt->connection = (GIOStream *)g_socket_connection_factory_create_connection (socket);
attempt->timeout_source = g_timeout_source_new (HAPPY_EYEBALLS_CONNECTION_ATTEMPT_TIMEOUT_MS);
g_source_set_callback (attempt->timeout_source, on_connection_attempt_timeout, attempt, NULL);
g_source_attach (attempt->timeout_source, g_main_context_get_thread_default ());
data->connection_attempts = g_slist_append (data->connection_attempts, attempt);
if (g_task_get_cancellable (data->task))
g_cancellable_connect (g_task_get_cancellable (data->task), G_CALLBACK (on_connection_cancelled),
g_object_ref (attempt->cancellable), g_object_unref);
g_socket_connection_set_cached_remote_address ((GSocketConnection *)attempt->connection, address);
g_socket_client_emit_event (data->client, G_SOCKET_CLIENT_CONNECTING, data->connectable, attempt->connection);
g_socket_connection_connect_async (G_SOCKET_CONNECTION (attempt->connection),
address,
attempt->cancellable,
g_socket_client_connected_callback, connection_attempt_ref (attempt));
}
| 0
|
498,153
|
void cgit_print_docend(void)
{
html("</div> <!-- class=content -->\n");
if (ctx.cfg.embedded) {
html("</div> <!-- id=cgit -->\n");
if (ctx.cfg.footer)
html_include(ctx.cfg.footer);
return;
}
if (ctx.cfg.footer)
html_include(ctx.cfg.footer);
else {
htmlf("<div class='footer'>generated by <a href='http://git.zx2c4.com/cgit/about/'>cgit %s</a> at ",
cgit_version);
cgit_print_date(time(NULL), FMT_LONGDATE, ctx.cfg.local_time);
html("</div>\n");
}
html("</div> <!-- id=cgit -->\n");
html("</body>\n</html>\n");
}
| 0
|
237,878
|
qeh_in_on_new (void *stream_if_ctx, struct lsquic_stream *stream)
{
struct qpack_enc_hdl *const qeh = stream_if_ctx;
qeh->qeh_dec_sm_in = stream;
if (qeh->qeh_flags & QEH_INITIALIZED)
lsquic_stream_wantread(qeh->qeh_dec_sm_in, 1);
else
qeh->qeh_conn = lsquic_stream_conn(stream); /* Or NULL deref in log */
LSQ_DEBUG("initialized incoming decoder stream");
return (void *) qeh;
}
| 0
|
249,516
|
inline unsigned int read_chunk(Reader* r, CHUNK* pChunk) {
unsigned char len[4];
pChunk->size = 0;
pChunk->p = 0;
if (r->Read(&len, 4)) {
const auto size = png_get_uint_32(len);
// Check first, to avoid overflow.
if (size > kMaxPNGChunkSize) {
JXL_WARNING("APNG chunk size is too big");
return 0;
}
pChunk->size = size + 12;
pChunk->p = new unsigned char[pChunk->size];
memcpy(pChunk->p, len, 4);
if (r->Read(pChunk->p + 4, pChunk->size - 4)) {
return *(unsigned int*)(pChunk->p + 4);
}
}
return 0;
}
| 0
|
337,819
|
static struct sctp_chunk *sctp_make_asconf_ack(const struct sctp_association *asoc,
__u32 serial, int vparam_len)
{
struct sctp_addiphdr asconf;
struct sctp_chunk *retval;
int length = sizeof(asconf) + vparam_len;
/* Create the chunk. */
retval = sctp_make_control(asoc, SCTP_CID_ASCONF_ACK, 0, length,
GFP_ATOMIC);
if (!retval)
return NULL;
asconf.serial = htonl(serial);
retval->subh.addip_hdr =
sctp_addto_chunk(retval, sizeof(asconf), &asconf);
return retval;
}
| 0
|
390,625
|
CheckSetDeviceIndicators( char * wire,
DeviceIntPtr dev,
int num,
int * status_rtrn,
ClientPtr client)
{
xkbDeviceLedsWireDesc * ledWire;
int i;
XkbSrvLedInfoPtr sli;
ledWire= (xkbDeviceLedsWireDesc *)wire;
for (i=0;i<num;i++) {
if (client->swapped) {
register int n;
swaps(&ledWire->ledClass,n);
swaps(&ledWire->ledID,n);
swapl(&ledWire->namesPresent,n);
swapl(&ledWire->mapsPresent,n);
swapl(&ledWire->physIndicators,n);
}
sli= XkbFindSrvLedInfo(dev,ledWire->ledClass,ledWire->ledID,
XkbXI_IndicatorsMask);
if (sli!=NULL) {
register int n;
register unsigned bit;
int nMaps,nNames;
CARD32 *atomWire;
xkbIndicatorMapWireDesc *mapWire;
nMaps= nNames= 0;
for (n=0,bit=1;n<XkbNumIndicators;n++,bit<<=1) {
if (ledWire->namesPresent&bit)
nNames++;
if (ledWire->mapsPresent&bit)
nMaps++;
}
atomWire= (CARD32 *)&ledWire[1];
if (nNames>0) {
for (n=0;n<nNames;n++) {
if (client->swapped) {
register int t;
swapl(atomWire,t);
}
CHK_ATOM_OR_NONE3(((Atom)(*atomWire)),client->errorValue,
*status_rtrn,NULL);
atomWire++;
}
}
mapWire= (xkbIndicatorMapWireDesc *)atomWire;
if (nMaps>0) {
for (n=0;n<nMaps;n++) {
if (client->swapped) {
register int t;
swaps(&mapWire->virtualMods,t);
swapl(&mapWire->ctrls,t);
}
CHK_MASK_LEGAL3(0x21,mapWire->whichGroups,
XkbIM_UseAnyGroup,
client->errorValue,
*status_rtrn,NULL);
CHK_MASK_LEGAL3(0x22,mapWire->whichMods,XkbIM_UseAnyMods,
client->errorValue,
*status_rtrn,NULL);
mapWire++;
}
}
ledWire= (xkbDeviceLedsWireDesc *)mapWire;
}
else {
/* SHOULD NEVER HAPPEN */
return (char *)ledWire;
}
}
return (char *)ledWire;
}
| 0
|
227,019
|
IRC_PROTOCOL_CALLBACK(341)
{
char *pos_channel;
IRC_PROTOCOL_MIN_ARGS(5);
pos_channel = (argv[4][0] == ':') ? argv[4] + 1 : argv[4];
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (server, argv[2], command, NULL, NULL),
date,
irc_protocol_tags (command, "irc_numeric", argv[2], address),
_("%s%s%s%s has invited %s%s%s to %s%s%s"),
weechat_prefix ("network"),
irc_nick_color_for_msg (server, 1, NULL, argv[2]),
argv[2],
IRC_COLOR_RESET,
irc_nick_color_for_msg (server, 1, NULL, argv[3]),
argv[3],
IRC_COLOR_RESET,
IRC_COLOR_CHAT_CHANNEL,
pos_channel,
IRC_COLOR_RESET);
return WEECHAT_RC_OK;
}
| 0
|
195,404
|
void Compute(OpKernelContext* context) override {
typedef Eigen::Map<const Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>
ConstEigenMatrixMap;
typedef Eigen::Map<Eigen::Matrix<T, Eigen::Dynamic, Eigen::Dynamic>>
EigenMatrixMap;
constexpr int tensor_in_and_out_dims = 4;
const Tensor& tensor_in = context->input(0);
OP_REQUIRES(context, tensor_in.dims() == tensor_in_and_out_dims,
errors::InvalidArgument("tensor_in must be 4-dimensional"));
std::vector<int> input_size(tensor_in_and_out_dims);
std::vector<int> output_size(tensor_in_and_out_dims);
for (int i = 0; i < tensor_in_and_out_dims; ++i) {
input_size[i] = tensor_in.dim_size(i);
}
// Output size.
for (int i = 0; i < tensor_in_and_out_dims; ++i) {
// This must match the same logic in the shape function in
// core/ops/nn_ops.cc.
output_size[i] =
static_cast<int>(std::floor(input_size[i] / pooling_ratio_[i]));
DCHECK_GT(output_size[i], 0);
}
// Generate pooling sequence.
std::vector<int64_t> height_cum_seq;
std::vector<int64_t> width_cum_seq;
GuardedPhiloxRandom generator;
generator.Init(seed_, seed2_);
height_cum_seq = GeneratePoolingSequence(input_size[1], output_size[1],
&generator, pseudo_random_);
width_cum_seq = GeneratePoolingSequence(input_size[2], output_size[2],
&generator, pseudo_random_);
// Prepare output.
Tensor* output_tensor = nullptr;
OP_REQUIRES_OK(context, context->allocate_output(
0,
TensorShape({output_size[0], output_size[1],
output_size[2], output_size[3]}),
&output_tensor));
Tensor* output_height_seq_tensor = nullptr;
OP_REQUIRES_OK(
context,
context->allocate_output(
1, TensorShape({static_cast<int64_t>(height_cum_seq.size())}),
&output_height_seq_tensor));
Tensor* output_width_seq_tensor = nullptr;
OP_REQUIRES_OK(
context,
context->allocate_output(
2, TensorShape({static_cast<int64_t>(width_cum_seq.size())}),
&output_width_seq_tensor));
ConstEigenMatrixMap in_mat(tensor_in.flat<T>().data(), input_size[3],
input_size[2] * input_size[1] * input_size[0]);
EigenMatrixMap out_mat(output_tensor->flat<T>().data(), output_size[3],
output_size[2] * output_size[1] * output_size[0]);
// Initializes the output tensor with MIN<T>.
output_tensor->flat<T>().setConstant(Eigen::NumTraits<T>::lowest());
auto output_height_seq_flat = output_height_seq_tensor->flat<int64_t>();
auto output_width_seq_flat = output_width_seq_tensor->flat<int64_t>();
// Set output tensors.
for (int i = 0; i < height_cum_seq.size(); ++i) {
output_height_seq_flat(i) = height_cum_seq[i];
}
for (int i = 0; i < width_cum_seq.size(); ++i) {
output_width_seq_flat(i) = width_cum_seq[i];
}
// For both input and output,
// 0: batch
// 1: height / row
// 2: width / col
// 3: depth / channel
const int64_t height_max = input_size[1] - 1;
const int64_t width_max = input_size[2] - 1;
for (int64_t b = 0; b < input_size[0]; ++b) {
// height sequence.
for (int64_t hs = 0; hs < height_cum_seq.size() - 1; ++hs) {
// height start and end.
const int64_t height_start = height_cum_seq[hs];
int64_t height_end =
overlapping_ ? height_cum_seq[hs + 1] : height_cum_seq[hs + 1] - 1;
height_end = std::min(height_end, height_max);
// width sequence.
for (int64_t ws = 0; ws < width_cum_seq.size() - 1; ++ws) {
const int64_t out_offset =
(b * output_size[1] + hs) * output_size[2] + ws;
// width start and end.
const int64_t width_start = width_cum_seq[ws];
int64_t width_end =
overlapping_ ? width_cum_seq[ws + 1] : width_cum_seq[ws + 1] - 1;
width_end = std::min(width_end, width_max);
for (int64_t h = height_start; h <= height_end; ++h) {
for (int64_t w = width_start; w <= width_end; ++w) {
const int64_t in_offset =
(b * input_size[1] + h) * input_size[2] + w;
out_mat.col(out_offset) =
out_mat.col(out_offset).cwiseMax(in_mat.col(in_offset));
}
}
}
}
}
}
| 1
|
313,844
|
nv_dollar(cmdarg_T *cap)
{
cap->oap->motion_type = MCHAR;
cap->oap->inclusive = TRUE;
// In virtual mode when off the edge of a line and an operator
// is pending (whew!) keep the cursor where it is.
// Otherwise, send it to the end of the line.
if (!virtual_active() || gchar_cursor() != NUL
|| cap->oap->op_type == OP_NOP)
curwin->w_curswant = MAXCOL; // so we stay at the end
if (cursor_down((long)(cap->count1 - 1),
cap->oap->op_type == OP_NOP) == FAIL)
clearopbeep(cap->oap);
#ifdef FEAT_FOLDING
else if ((fdo_flags & FDO_HOR) && KeyTyped && cap->oap->op_type == OP_NOP)
foldOpenCursor();
#endif
}
| 0
|
195,295
|
gen_assignment(codegen_scope *s, node *tree, node *rhs, int sp, int val)
{
int idx;
int type = nint(tree->car);
switch (type) {
case NODE_GVAR:
case NODE_ARG:
case NODE_LVAR:
case NODE_IVAR:
case NODE_CVAR:
case NODE_CONST:
case NODE_NIL:
case NODE_MASGN:
if (rhs) {
codegen(s, rhs, VAL);
pop();
sp = cursp();
}
break;
case NODE_COLON2:
case NODE_CALL:
case NODE_SCALL:
/* keep evaluation order */
break;
case NODE_NVAR:
codegen_error(s, "Can't assign to numbered parameter");
break;
default:
codegen_error(s, "unknown lhs");
break;
}
tree = tree->cdr;
switch (type) {
case NODE_GVAR:
gen_setxv(s, OP_SETGV, sp, nsym(tree), val);
break;
case NODE_ARG:
case NODE_LVAR:
idx = lv_idx(s, nsym(tree));
if (idx > 0) {
if (idx != sp) {
gen_move(s, idx, sp, val);
}
break;
}
else { /* upvar */
gen_setupvar(s, sp, nsym(tree));
}
break;
case NODE_IVAR:
gen_setxv(s, OP_SETIV, sp, nsym(tree), val);
break;
case NODE_CVAR:
gen_setxv(s, OP_SETCV, sp, nsym(tree), val);
break;
case NODE_CONST:
gen_setxv(s, OP_SETCONST, sp, nsym(tree), val);
break;
case NODE_COLON2:
if (sp) {
gen_move(s, cursp(), sp, 0);
}
sp = cursp();
push();
codegen(s, tree->car, VAL);
if (rhs) {
codegen(s, rhs, VAL); pop();
gen_move(s, sp, cursp(), 0);
}
pop_n(2);
idx = new_sym(s, nsym(tree->cdr));
genop_2(s, OP_SETMCNST, sp, idx);
break;
case NODE_CALL:
case NODE_SCALL:
{
int noself = 0, safe = (type == NODE_SCALL), skip = 0, top, call, n = 0;
mrb_sym mid = nsym(tree->cdr->car);
top = cursp();
if (val || sp == cursp()) {
push(); /* room for retval */
}
call = cursp();
if (!tree->car) {
noself = 1;
push();
}
else {
codegen(s, tree->car, VAL); /* receiver */
}
if (safe) {
int recv = cursp()-1;
gen_move(s, cursp(), recv, 1);
skip = genjmp2_0(s, OP_JMPNIL, cursp(), val);
}
tree = tree->cdr->cdr->car;
if (tree) {
if (tree->car) { /* positional arguments */
n = gen_values(s, tree->car, VAL, (tree->cdr->car)?13:14);
if (n < 0) { /* variable length */
n = 15;
push();
}
}
if (tree->cdr->car) { /* keyword arguments */
if (n == 14) {
pop_n(n);
genop_2(s, OP_ARRAY, cursp(), n);
push();
n = 15;
}
gen_hash(s, tree->cdr->car->cdr, VAL, 0);
if (n < 14) {
n++;
}
else {
pop_n(2);
genop_2(s, OP_ARYPUSH, cursp(), 1);
}
push();
}
}
if (rhs) {
codegen(s, rhs, VAL);
pop();
}
else {
gen_move(s, cursp(), sp, 0);
}
if (val) {
gen_move(s, top, cursp(), 1);
}
if (n < 15) {
n++;
if (n == 15) {
pop_n(14);
genop_2(s, OP_ARRAY, cursp(), 15);
}
}
else {
pop();
genop_2(s, OP_ARYPUSH, cursp(), 1);
}
s->sp = call;
if (mid == MRB_OPSYM_2(s->mrb, aref) && n == 2) {
genop_1(s, OP_SETIDX, cursp());
}
else {
genop_3(s, noself ? OP_SSEND : OP_SEND, cursp(), new_sym(s, attrsym(s, mid)), n);
}
if (safe) {
dispatch(s, skip);
}
s->sp = top;
}
break;
case NODE_MASGN:
gen_massignment(s, tree->car, sp, val);
break;
/* splat without assignment */
case NODE_NIL:
break;
default:
codegen_error(s, "unknown lhs");
break;
}
if (val) push();
}
| 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.