idx
int64 | func
string | target
int64 |
|---|---|---|
502,855
|
promptexpand(char *s, int ns, char *rs, char *Rs, zattr *txtchangep)
{
struct buf_vars new_vars;
if(!s)
return ztrdup("");
if ((termflags & TERM_UNKNOWN) && (unset(INTERACTIVE)))
init_term();
if (isset(PROMPTSUBST)) {
int olderr = errflag;
int oldval = lastval;
s = dupstring(s);
if (!parsestr(&s))
singsub(&s);
/*
* We don't need the special Nularg hack here and we're
* going to be using Nularg for other things.
*/
if (*s == Nularg && s[1] == '\0')
*s = '\0';
/*
* Ignore errors and status change in prompt substitution.
* However, keep any user interrupt error that occurred.
*/
errflag = olderr | (errflag & ERRFLAG_INT);
lastval = oldval;
}
memset(&new_vars, 0, sizeof(new_vars));
new_vars.last = bv;
bv = &new_vars;
new_vars.rstring = rs;
new_vars.Rstring = Rs;
new_vars.fm = s;
new_vars.bufspc = 256;
new_vars.bp = new_vars.bufline = new_vars.buf = zshcalloc(new_vars.bufspc);
new_vars.bp1 = NULL;
new_vars.truncwidth = 0;
putpromptchar(1, '\0', txtchangep);
addbufspc(2);
if (new_vars.dontcount)
*new_vars.bp++ = Outpar;
*new_vars.bp = '\0';
if (!ns) {
/* If zero, Inpar, Outpar and Nularg should be removed. */
for (new_vars.bp = new_vars.buf; *new_vars.bp; ) {
if (*new_vars.bp == Meta)
new_vars.bp += 2;
else if (*new_vars.bp == Inpar || *new_vars.bp == Outpar ||
*new_vars.bp == Nularg)
chuck(new_vars.bp);
else
new_vars.bp++;
}
}
bv = new_vars.last;
return new_vars.buf;
}
| 0
|
32,225
|
static void infolistcheck(GWindow gw, struct gmenuitem *mi, GEvent *UNUSED(e)) {
FontView *fv = (FontView *) GDrawGetUserData(gw);
int anychars = FVAnyCharSelected(fv);
for ( mi = mi->sub; mi->ti.text!=NULL || mi->ti.line ; ++mi ) {
switch ( mi->mid ) {
case MID_StrikeInfo:
mi->ti.disabled = fv->b.sf->bitmaps==NULL;
break;
case MID_MassRename:
mi->ti.disabled = anychars==-1;
break;
case MID_SetColor:
mi->ti.disabled = anychars==-1;
break;
}
}
}
| 0
|
331,286
|
static int local_symlink(FsContext *fs_ctx, const char *oldpath,
V9fsPath *dir_path, const char *name, FsCred *credp)
{
int err = -1;
int serrno = 0;
char *newpath;
V9fsString fullname;
char *buffer;
v9fs_string_init(&fullname);
v9fs_string_sprintf(&fullname, "%s/%s", dir_path->data, name);
newpath = fullname.data;
/* Determine the security model */
if (fs_ctx->export_flags & V9FS_SM_MAPPED) {
int fd;
ssize_t oldpath_size, write_size;
buffer = rpath(fs_ctx, newpath);
fd = open(buffer, O_CREAT|O_EXCL|O_RDWR|O_NOFOLLOW, SM_LOCAL_MODE_BITS);
if (fd == -1) {
g_free(buffer);
err = fd;
goto out;
}
/* Write the oldpath (target) to the file. */
oldpath_size = strlen(oldpath);
do {
write_size = write(fd, (void *)oldpath, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
serrno = errno;
close(fd);
err = -1;
goto err_end;
}
close(fd);
/* Set cleint credentials in symlink's xattr */
credp->fc_mode = credp->fc_mode|S_IFLNK;
err = local_set_xattr(buffer, credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if (fs_ctx->export_flags & V9FS_SM_MAPPED_FILE) {
int fd;
ssize_t oldpath_size, write_size;
buffer = rpath(fs_ctx, newpath);
fd = open(buffer, O_CREAT|O_EXCL|O_RDWR|O_NOFOLLOW, SM_LOCAL_MODE_BITS);
if (fd == -1) {
g_free(buffer);
err = fd;
goto out;
}
/* Write the oldpath (target) to the file. */
oldpath_size = strlen(oldpath);
do {
write_size = write(fd, (void *)oldpath, oldpath_size);
} while (write_size == -1 && errno == EINTR);
if (write_size != oldpath_size) {
serrno = errno;
close(fd);
err = -1;
goto err_end;
}
close(fd);
/* Set cleint credentials in symlink's xattr */
credp->fc_mode = credp->fc_mode|S_IFLNK;
err = local_set_mapped_file_attr(fs_ctx, newpath, credp);
if (err == -1) {
serrno = errno;
goto err_end;
}
} else if ((fs_ctx->export_flags & V9FS_SM_PASSTHROUGH) ||
(fs_ctx->export_flags & V9FS_SM_NONE)) {
buffer = rpath(fs_ctx, newpath);
err = symlink(oldpath, buffer);
if (err) {
g_free(buffer);
goto out;
}
err = lchown(buffer, credp->fc_uid, credp->fc_gid);
if (err == -1) {
/*
* If we fail to change ownership and if we are
* using security model none. Ignore the error
*/
if ((fs_ctx->export_flags & V9FS_SEC_MASK) != V9FS_SM_NONE) {
serrno = errno;
goto err_end;
} else
err = 0;
}
}
goto out;
err_end:
remove(buffer);
errno = serrno;
g_free(buffer);
out:
v9fs_string_free(&fullname);
return err;
}
| 1
|
518,036
|
void Item_field::cleanup()
{
DBUG_ENTER("Item_field::cleanup");
Item_ident::cleanup();
depended_from= NULL;
/*
Even if this object was created by direct link to field in setup_wild()
it will be linked correctly next time by name of field and table alias.
I.e. we can drop 'field'.
*/
field= 0;
item_equal= NULL;
null_value= FALSE;
DBUG_VOID_RETURN;
}
| 0
|
442,779
|
connect_blocking(void *data)
{
struct connect_arg *arg = data;
return (VALUE)connect(arg->fd, arg->sockaddr, arg->len);
}
| 0
|
387,604
|
static int shadow_copy2_chown(vfs_handle_struct *handle, const char *fname,
uid_t uid, gid_t gid)
{
time_t timestamp;
char *stripped;
int ret, saved_errno;
char *conv;
if (!shadow_copy2_strip_snapshot(talloc_tos(), handle, fname,
×tamp, &stripped)) {
return -1;
}
if (timestamp == 0) {
return SMB_VFS_NEXT_CHOWN(handle, fname, uid, gid);
}
conv = shadow_copy2_convert(talloc_tos(), handle, stripped, timestamp);
TALLOC_FREE(stripped);
if (conv == NULL) {
return -1;
}
ret = SMB_VFS_NEXT_CHOWN(handle, conv, uid, gid);
saved_errno = errno;
TALLOC_FREE(conv);
errno = saved_errno;
return ret;
}
| 0
|
64,747
|
BGD_DECLARE(int) gdImageColorReplaceCallback (gdImagePtr im, gdCallbackImageColor callback)
{
int c, d, n = 0;
if (!callback) {
return 0;
}
if (im->trueColor) {
register int x, y;
for (y = im->cy1; y <= im->cy2; y++) {
for (x = im->cx1; x <= im->cx2; x++) {
c = gdImageTrueColorPixel(im, x, y);
if ( (d = callback(im, c)) != c) {
gdImageSetPixel(im, x, y, d);
n++;
}
}
}
} else { /* palette */
int *sarr, *darr;
int k, len = 0;
sarr = (int *)gdCalloc(im->colorsTotal, sizeof(int));
if (!sarr) {
return -1;
}
for (c = 0; c < im->colorsTotal; c++) {
if (!im->open[c]) {
sarr[len++] = c;
}
}
darr = (int *)gdCalloc(len, sizeof(int));
if (!darr) {
gdFree(sarr);
return -1;
}
for (k = 0; k < len; k++) {
darr[k] = callback(im, sarr[k]);
}
n = gdImageColorReplaceArray(im, k, sarr, darr);
gdFree(darr);
gdFree(sarr);
}
return n;
}
| 0
|
424,515
|
print_optimize_info(FILE* f, regex_t* reg)
{
static const char* on[] = { "NONE", "EXACT", "EXACT_BM", "EXACT_BM_NOT_REV",
"EXACT_IC", "MAP" };
fprintf(f, "optimize: %s\n", on[reg->optimize]);
fprintf(f, " anchor: "); print_anchor(f, reg->anchor);
if ((reg->anchor & ANCHOR_END_BUF_MASK) != 0)
print_distance_range(f, reg->anchor_dmin, reg->anchor_dmax);
fprintf(f, "\n");
if (reg->optimize) {
fprintf(f, " sub anchor: "); print_anchor(f, reg->sub_anchor);
fprintf(f, "\n");
}
fprintf(f, "\n");
if (reg->exact) {
UChar *p;
fprintf(f, "exact: [");
for (p = reg->exact; p < reg->exact_end; p++) {
fputc(*p, f);
}
fprintf(f, "]: length: %d\n", (reg->exact_end - reg->exact));
}
else if (reg->optimize & ONIG_OPTIMIZE_MAP) {
int c, i, n = 0;
for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++)
if (reg->map[i]) n++;
fprintf(f, "map: n=%d\n", n);
if (n > 0) {
c = 0;
fputc('[', f);
for (i = 0; i < ONIG_CHAR_TABLE_SIZE; i++) {
if (reg->map[i] != 0) {
if (c > 0) fputs(", ", f);
c++;
if (ONIGENC_MBC_MAXLEN(reg->enc) == 1 &&
ONIGENC_IS_CODE_PRINT(reg->enc, (OnigCodePoint )i))
fputc(i, f);
else
fprintf(f, "%d", i);
}
}
fprintf(f, "]\n");
}
}
}
| 0
|
234,671
|
static void enforcedRangeUnsignedShortAttrAttributeSetter(v8::Local<v8::Value> jsValue, const v8::PropertyCallbackInfo<void>& info)
{
ExceptionState exceptionState(ExceptionState::SetterContext, "enforcedRangeUnsignedShortAttr", "TestObject", info.Holder(), info.GetIsolate());
TestObject* imp = V8TestObject::toNative(info.Holder());
V8TRYCATCH_EXCEPTION_VOID(unsigned, cppValue, toUInt16(jsValue, EnforceRange, exceptionState), exceptionState);
imp->setEnforcedRangeUnsignedShortAttr(cppValue);
}
| 0
|
47,719
|
static int cm_drep_handler(struct cm_work *work)
{
struct cm_id_private *cm_id_priv;
struct cm_drep_msg *drep_msg;
int ret;
drep_msg = (struct cm_drep_msg *)work->mad_recv_wc->recv_buf.mad;
cm_id_priv = cm_acquire_id(drep_msg->remote_comm_id,
drep_msg->local_comm_id);
if (!cm_id_priv)
return -EINVAL;
work->cm_event.private_data = &drep_msg->private_data;
spin_lock_irq(&cm_id_priv->lock);
if (cm_id_priv->id.state != IB_CM_DREQ_SENT &&
cm_id_priv->id.state != IB_CM_DREQ_RCVD) {
spin_unlock_irq(&cm_id_priv->lock);
goto out;
}
cm_enter_timewait(cm_id_priv);
ib_cancel_mad(cm_id_priv->av.port->mad_agent, cm_id_priv->msg);
ret = atomic_inc_and_test(&cm_id_priv->work_count);
if (!ret)
list_add_tail(&work->list, &cm_id_priv->work_list);
spin_unlock_irq(&cm_id_priv->lock);
if (ret)
cm_process_work(cm_id_priv, work);
else
cm_deref_id(cm_id_priv);
return 0;
out:
cm_deref_id(cm_id_priv);
return -EINVAL;
}
| 0
|
19,755
|
static void virtio_net_handle_tx_bh ( VirtIODevice * vdev , VirtQueue * vq ) {
VirtIONet * n = to_virtio_net ( vdev ) ;
if ( unlikely ( n -> tx_waiting ) ) {
return ;
}
n -> tx_waiting = 1 ;
if ( ! n -> vdev . vm_running ) {
return ;
}
virtio_queue_set_notification ( vq , 0 ) ;
qemu_bh_schedule ( n -> tx_bh ) ;
}
| 0
|
514,716
|
int llhttp__internal__c_is_equal_upgrade(
llhttp__internal_t* state,
const unsigned char* p,
const unsigned char* endp) {
return state->upgrade == 1;
}
| 0
|
345,731
|
PS_SERIALIZER_DECODE_FUNC(php) /* {{{ */
{
const char *p, *q;
char *name;
const char *endptr = val + vallen;
zval *current;
int namelen;
int has_value;
php_unserialize_data_t var_hash;
PHP_VAR_UNSERIALIZE_INIT(var_hash);
p = val;
while (p < endptr) {
zval **tmp;
q = p;
while (*q != PS_DELIMITER) {
if (++q >= endptr) goto break_outer_loop;
}
if (p[0] == PS_UNDEF_MARKER) {
p++;
has_value = 0;
} else {
has_value = 1;
}
namelen = q - p;
name = estrndup(p, namelen);
q++;
if (zend_hash_find(&EG(symbol_table), name, namelen + 1, (void **) &tmp) == SUCCESS) {
if ((Z_TYPE_PP(tmp) == IS_ARRAY && Z_ARRVAL_PP(tmp) == &EG(symbol_table)) || *tmp == PS(http_session_vars)) {
goto skip;
}
}
if (has_value) {
ALLOC_INIT_ZVAL(current);
if (php_var_unserialize(¤t, (const unsigned char **) &q, (const unsigned char *) endptr, &var_hash TSRMLS_CC)) {
php_set_session_var(name, namelen, current, &var_hash TSRMLS_CC);
}
zval_ptr_dtor(¤t);
}
PS_ADD_VARL(name, namelen);
skip:
efree(name);
p = q;
}
break_outer_loop:
PHP_VAR_UNSERIALIZE_DESTROY(var_hash);
return SUCCESS;
}
| 1
|
33,865
|
void skipPortUsageValidation() { skip_port_usage_validation_ = true; }
| 0
|
452,646
|
void MonClient::handle_monmap(MMonMap *m)
{
ldout(cct, 10) << __func__ << " " << *m << dendl;
auto con_addrs = m->get_source_addrs();
string old_name = monmap.get_name(con_addrs);
// NOTE: we're not paying attention to the epoch, here.
auto p = m->monmapbl.cbegin();
decode(monmap, p);
ldout(cct, 10) << " got monmap " << monmap.epoch
<< " from mon." << old_name
<< " (according to old e" << monmap.get_epoch() << ")"
<< dendl;
ldout(cct, 10) << "dump:\n";
monmap.print(*_dout);
*_dout << dendl;
if (old_name.size() == 0) {
ldout(cct,10) << " can't identify which mon we were connected to" << dendl;
_reopen_session();
} else {
int new_rank = monmap.get_rank(m->get_source_addr());
if (new_rank < 0) {
ldout(cct, 10) << "mon." << new_rank << " at " << m->get_source_addrs()
<< " went away" << dendl;
// can't find the mon we were talking to (above)
_reopen_session();
} else if (messenger->should_use_msgr2() &&
monmap.get_addrs(new_rank).has_msgr2() &&
!con_addrs.has_msgr2()) {
ldout(cct,1) << " mon." << new_rank << " has (v2) addrs "
<< monmap.get_addrs(new_rank) << " but i'm connected to "
<< con_addrs << ", reconnecting" << dendl;
_reopen_session();
}
}
cct->set_mon_addrs(monmap);
sub.got("monmap", monmap.get_epoch());
map_cond.Signal();
want_monmap = false;
if (authenticate_err == 1) {
_finish_auth(0);
}
}
| 0
|
454,824
|
void __init udbg_init_rtas_console(void)
{
udbg_putc = udbg_rtascon_putc;
udbg_getc = udbg_rtascon_getc;
udbg_getc_poll = udbg_rtascon_getc_poll;
}
| 0
|
239,803
|
void smp_send_keypress_notification(tSMP_CB* p_cb, tSMP_INT_DATA* p_data) {
p_cb->local_keypress_notification = *(uint8_t*)p_data;
smp_send_cmd(SMP_OPCODE_PAIR_KEYPR_NOTIF, p_cb);
}
| 0
|
306,283
|
assembly_add_resource_manifest (MonoReflectionModuleBuilder *mb, MonoDynamicImage *assembly, MonoReflectionResource *rsrc, guint32 implementation)
{
MonoDynamicTable *table;
guint32 *values;
table = &assembly->tables [MONO_TABLE_MANIFESTRESOURCE];
table->rows++;
alloc_table (table, table->rows);
values = table->values + table->next_idx * MONO_MANIFEST_SIZE;
values [MONO_MANIFEST_OFFSET] = rsrc->offset;
values [MONO_MANIFEST_FLAGS] = rsrc->attrs;
values [MONO_MANIFEST_NAME] = string_heap_insert_mstring (&assembly->sheap, rsrc->name);
values [MONO_MANIFEST_IMPLEMENTATION] = implementation;
table->next_idx++;
}
| 0
|
65,336
|
static enum hrtimer_restart io_timeout_fn(struct hrtimer *timer)
{
struct io_timeout_data *data = container_of(timer,
struct io_timeout_data, timer);
struct io_kiocb *req = data->req;
struct io_ring_ctx *ctx = req->ctx;
unsigned long flags;
spin_lock_irqsave(&ctx->timeout_lock, flags);
list_del_init(&req->timeout.list);
atomic_set(&req->ctx->cq_timeouts,
atomic_read(&req->ctx->cq_timeouts) + 1);
spin_unlock_irqrestore(&ctx->timeout_lock, flags);
if (!(data->flags & IORING_TIMEOUT_ETIME_SUCCESS))
req_set_fail(req);
req->result = -ETIME;
req->io_task_work.func = io_req_task_complete;
io_req_task_work_add(req, false);
return HRTIMER_NORESTART;
| 0
|
283,424
|
AttestationPermissionRequestSheetModel::AttestationPermissionRequestSheetModel(
AuthenticatorRequestDialogModel* dialog_model)
: AuthenticatorSheetModelBase(dialog_model) {}
| 0
|
175,397
|
bool GDataDirectory::RemoveEntry(GDataEntry* entry) {
DCHECK(entry);
if (!RemoveChild(entry))
return false;
delete entry;
return true;
}
| 0
|
293,181
|
static int do_recv_XKeyEvent(rpc_message_t *message, XEvent *xevent)
{
int32_t x, y, x_root, y_root, same_screen;
uint32_t root, subwindow, time, state, keycode;
int error;
if ((error = do_recv_XAnyEvent(message, xevent)) < 0)
return error;
if ((error = rpc_message_recv_uint32(message, &root)) < 0)
return error;
if ((error = rpc_message_recv_uint32(message, &subwindow)) < 0)
return error;
if ((error = rpc_message_recv_uint32(message, &time)) < 0)
return error;
if ((error = rpc_message_recv_int32(message, &x)) < 0)
return error;
if ((error = rpc_message_recv_int32(message, &y)) < 0)
return error;
if ((error = rpc_message_recv_int32(message, &x_root)) < 0)
return error;
if ((error = rpc_message_recv_int32(message, &y_root)) < 0)
return error;
if ((error = rpc_message_recv_uint32(message, &state)) < 0)
return error;
if ((error = rpc_message_recv_uint32(message, &keycode)) < 0)
return error;
if ((error = rpc_message_recv_int32(message, &same_screen)) < 0)
return error;
xevent->xkey.root = root;
xevent->xkey.subwindow = subwindow;
xevent->xkey.time = time;
xevent->xkey.x = x;
xevent->xkey.y = y;
xevent->xkey.x_root = x_root;
xevent->xkey.y_root = y_root;
xevent->xkey.state = state;
xevent->xkey.keycode = keycode;
xevent->xkey.same_screen = same_screen;
return RPC_ERROR_NO_ERROR;
}
| 0
|
41,913
|
static unsigned long keyring_get_key_chunk(const void *data, int level)
{
const struct keyring_index_key *index_key = data;
unsigned long chunk = 0;
long offset = 0;
int desc_len = index_key->desc_len, n = sizeof(chunk);
level /= ASSOC_ARRAY_KEY_CHUNK_SIZE;
switch (level) {
case 0:
return hash_key_type_and_desc(index_key);
case 1:
return ((unsigned long)index_key->type << 8) | desc_len;
case 2:
if (desc_len == 0)
return (u8)((unsigned long)index_key->type >>
(ASSOC_ARRAY_KEY_CHUNK_SIZE - 8));
n--;
offset = 1;
default:
offset += sizeof(chunk) - 1;
offset += (level - 3) * sizeof(chunk);
if (offset >= desc_len)
return 0;
desc_len -= offset;
if (desc_len > n)
desc_len = n;
offset += desc_len;
do {
chunk <<= 8;
chunk |= ((u8*)index_key->description)[--offset];
} while (--desc_len > 0);
if (level == 2) {
chunk <<= 8;
chunk |= (u8)((unsigned long)index_key->type >>
(ASSOC_ARRAY_KEY_CHUNK_SIZE - 8));
}
return chunk;
}
}
| 0
|
494,575
|
flow_hash_table_t *flow_hash_table_init(size_t n)
{
flow_hash_table_t *fht;
if (!is_power_of_2(n))
errx(-1, "invalid table size: %zu", n);
fht = safe_malloc(sizeof(*fht));
fht->num_buckets = n;
fht->buckets = safe_malloc(sizeof(flow_hash_entry_t) * n);
return fht;
}
| 0
|
403,262
|
RAMBlock *qemu_ram_alloc_from_ptr(ram_addr_t size, void *host,
MemoryRegion *mr, Error **errp)
{
return qemu_ram_alloc_internal(size, size, NULL, host, false, mr, errp);
}
| 0
|
298,120
|
static void resolve_stun_entry(pjsua_stun_resolve *sess)
{
pj_status_t status = PJ_EUNKNOWN;
/* Loop while we have entry to try */
for (; sess->idx < sess->count;
(pjsua_var.ua_cfg.stun_try_ipv6 && sess->af == pj_AF_INET())?
sess->af = pj_AF_INET6(): (++sess->idx, sess->af = pj_AF_INET()))
{
int af;
char target[64];
pj_str_t hostpart;
pj_uint16_t port;
pj_stun_sock_cb stun_sock_cb;
pj_assert(sess->idx < sess->count);
if (pjsua_var.ua_cfg.stun_try_ipv6 &&
pjsua_var.stun_opt != PJSUA_NAT64_DISABLED &&
sess->af == pj_AF_INET())
{
/* Skip IPv4 STUN resolution if NAT64 is not disabled. */
PJ_LOG(4,(THIS_FILE, "Skipping IPv4 resolution of STUN server "
"%s (%d of %d)", target,
sess->idx+1, sess->count));
continue;
}
pj_ansi_snprintf(target, sizeof(target), "%.*s",
(int)sess->srv[sess->idx].slen,
sess->srv[sess->idx].ptr);
/* Parse the server entry into host:port */
status = pj_sockaddr_parse2(pj_AF_UNSPEC(), 0, &sess->srv[sess->idx],
&hostpart, &port, &af);
if (status != PJ_SUCCESS) {
PJ_LOG(2,(THIS_FILE, "Invalid STUN server entry %s", target));
continue;
}
/* Use default port if not specified */
if (port == 0)
port = PJ_STUN_PORT;
pj_assert(sess->stun_sock == NULL);
PJ_LOG(4,(THIS_FILE, "Trying STUN server %s %s (%d of %d)..",
target, (sess->af == pj_AF_INET()? "IPv4": "IPv6"),
sess->idx+1, sess->count));
/* Use STUN_sock to test this entry */
pj_bzero(&stun_sock_cb, sizeof(stun_sock_cb));
stun_sock_cb.on_status = &test_stun_on_status;
sess->async_wait = PJ_FALSE;
status = pj_stun_sock_create(&pjsua_var.stun_cfg, "stunresolve",
sess->af, &stun_sock_cb,
NULL, sess, &sess->stun_sock);
if (status != PJ_SUCCESS) {
char errmsg[PJ_ERR_MSG_SIZE];
pj_strerror(status, errmsg, sizeof(errmsg));
PJ_LOG(4,(THIS_FILE,
"Error creating STUN socket for %s: %s",
target, errmsg));
continue;
}
status = pj_stun_sock_start(sess->stun_sock, &hostpart, port,
pjsua_var.resolver);
if (status != PJ_SUCCESS) {
char errmsg[PJ_ERR_MSG_SIZE];
pj_strerror(status, errmsg, sizeof(errmsg));
PJ_LOG(4,(THIS_FILE,
"Error starting STUN socket for %s: %s",
target, errmsg));
if (sess->stun_sock) {
pj_stun_sock_destroy(sess->stun_sock);
sess->stun_sock = NULL;
}
continue;
}
/* Done for now, testing will resume/complete asynchronously in
* stun_sock_cb()
*/
sess->async_wait = PJ_TRUE;
return;
}
if (sess->idx >= sess->count) {
/* No more entries to try */
stun_resolve_add_ref(sess);
pj_assert(status != PJ_SUCCESS || sess->status != PJ_EPENDING);
if (sess->status == PJ_EPENDING)
sess->status = status;
stun_resolve_complete(sess);
stun_resolve_dec_ref(sess);
}
}
| 0
|
47,453
|
static void i40e_link_event(struct i40e_pf *pf)
{
struct i40e_vsi *vsi = pf->vsi[pf->lan_vsi];
u8 new_link_speed, old_link_speed;
i40e_status status;
bool new_link, old_link;
/* set this to force the get_link_status call to refresh state */
pf->hw.phy.get_link_info = true;
old_link = (pf->hw.phy.link_info_old.link_info & I40E_AQ_LINK_UP);
status = i40e_get_link_status(&pf->hw, &new_link);
/* On success, disable temp link polling */
if (status == I40E_SUCCESS) {
clear_bit(__I40E_TEMP_LINK_POLLING, pf->state);
} else {
/* Enable link polling temporarily until i40e_get_link_status
* returns I40E_SUCCESS
*/
set_bit(__I40E_TEMP_LINK_POLLING, pf->state);
dev_dbg(&pf->pdev->dev, "couldn't get link state, status: %d\n",
status);
return;
}
old_link_speed = pf->hw.phy.link_info_old.link_speed;
new_link_speed = pf->hw.phy.link_info.link_speed;
if (new_link == old_link &&
new_link_speed == old_link_speed &&
(test_bit(__I40E_VSI_DOWN, vsi->state) ||
new_link == netif_carrier_ok(vsi->netdev)))
return;
i40e_print_link_message(vsi, new_link);
/* Notify the base of the switch tree connected to
* the link. Floating VEBs are not notified.
*/
if (pf->lan_veb < I40E_MAX_VEB && pf->veb[pf->lan_veb])
i40e_veb_link_event(pf->veb[pf->lan_veb], new_link);
else
i40e_vsi_link_event(vsi, new_link);
if (pf->vf)
i40e_vc_notify_link_state(pf);
if (pf->flags & I40E_FLAG_PTP)
i40e_ptp_set_increment(pf);
}
| 0
|
199,809
|
void AutomationProvider::GetEnabledExtensions(
std::vector<FilePath>* result) {
ExtensionService* service = profile_->GetExtensionService();
DCHECK(service);
if (service->extensions_enabled()) {
const ExtensionList* extensions = service->extensions();
DCHECK(extensions);
for (size_t i = 0; i < extensions->size(); ++i) {
const Extension* extension = (*extensions)[i];
DCHECK(extension);
if (!extension->is_app() &&
(extension->location() == Extension::INTERNAL ||
extension->location() == Extension::LOAD)) {
result->push_back(extension->path());
}
}
}
}
| 0
|
277,832
|
static Image *ReadWEBPImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
Image
*image;
int
webp_status;
MagickBooleanType
status;
register unsigned char
*p;
size_t
length;
ssize_t
count,
y;
unsigned char
header[12],
*stream;
WebPDecoderConfig
configure;
WebPDecBuffer
*restrict webp_image = &configure.output;
WebPBitstreamFeatures
*restrict features = &configure.input;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
if (WebPInitDecoderConfig(&configure) == 0)
ThrowReaderException(ResourceLimitError,"UnableToDecodeImageFile");
webp_image->colorspace=MODE_RGBA;
count=ReadBlob(image,12,header);
if (count != 12)
ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
status=IsWEBP(header,count);
if (status == MagickFalse)
ThrowReaderException(CorruptImageError,"CorruptImage");
length=(size_t) (ReadWebPLSBWord(header+4)+8);
if (length < 12)
ThrowReaderException(CorruptImageError,"CorruptImage");
stream=(unsigned char *) AcquireQuantumMemory(length,sizeof(*stream));
if (stream == (unsigned char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
(void) memcpy(stream,header,12);
count=ReadBlob(image,length-12,stream+12);
if (count != (ssize_t) (length-12))
ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
webp_status=WebPGetFeatures(stream,length,features);
if (webp_status == VP8_STATUS_OK)
{
image->columns=(size_t) features->width;
image->rows=(size_t) features->height;
image->depth=8;
image->matte=features->has_alpha != 0 ? MagickTrue : MagickFalse;
if (IsWEBPImageLossless(stream,length) != MagickFalse)
image->quality=100;
if (image_info->ping != MagickFalse)
{
stream=(unsigned char*) RelinquishMagickMemory(stream);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
status=SetImageExtent(image,image->columns,image->rows);
if (status == MagickFalse)
{
InheritException(exception,&image->exception);
return(DestroyImageList(image));
}
webp_status=WebPDecode(stream,length,&configure);
}
if (webp_status != VP8_STATUS_OK)
{
stream=(unsigned char*) RelinquishMagickMemory(stream);
switch (webp_status)
{
case VP8_STATUS_OUT_OF_MEMORY:
{
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
break;
}
case VP8_STATUS_INVALID_PARAM:
{
ThrowReaderException(CorruptImageError,"invalid parameter");
break;
}
case VP8_STATUS_BITSTREAM_ERROR:
{
ThrowReaderException(CorruptImageError,"CorruptImage");
break;
}
case VP8_STATUS_UNSUPPORTED_FEATURE:
{
ThrowReaderException(CoderError,"DataEncodingSchemeIsNotSupported");
break;
}
case VP8_STATUS_SUSPENDED:
{
ThrowReaderException(CorruptImageError,"decoder suspended");
break;
}
case VP8_STATUS_USER_ABORT:
{
ThrowReaderException(CorruptImageError,"user abort");
break;
}
case VP8_STATUS_NOT_ENOUGH_DATA:
{
ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
break;
}
default:
ThrowReaderException(CorruptImageError,"CorruptImage");
}
}
p=(unsigned char *) webp_image->u.RGBA.rgba;
for (y=0; y < (ssize_t) image->rows; y++)
{
register PixelPacket
*q;
register ssize_t
x;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelRed(q,ScaleCharToQuantum(*p++));
SetPixelGreen(q,ScaleCharToQuantum(*p++));
SetPixelBlue(q,ScaleCharToQuantum(*p++));
SetPixelAlpha(q,ScaleCharToQuantum(*p++));
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
WebPFreeDecBuffer(webp_image);
stream=(unsigned char*) RelinquishMagickMemory(stream);
return(image);
}
| 0
|
228,180
|
static void GrowCapacityAndConvertImpl(Handle<JSObject> object,
uint32_t capacity) {
UNREACHABLE();
}
| 0
|
172,847
|
String referrerPolicy(net::URLRequest::ReferrerPolicy referrer_policy) {
switch (referrer_policy) {
case net::URLRequest::CLEAR_REFERRER_ON_TRANSITION_FROM_SECURE_TO_INSECURE:
return Network::Request::ReferrerPolicyEnum::NoReferrerWhenDowngrade;
case net::URLRequest::
REDUCE_REFERRER_GRANULARITY_ON_TRANSITION_CROSS_ORIGIN:
return Network::Request::ReferrerPolicyEnum::StrictOriginWhenCrossOrigin;
case net::URLRequest::ORIGIN_ONLY_ON_TRANSITION_CROSS_ORIGIN:
return Network::Request::ReferrerPolicyEnum::OriginWhenCrossOrigin;
case net::URLRequest::NEVER_CLEAR_REFERRER:
return Network::Request::ReferrerPolicyEnum::Origin;
case net::URLRequest::ORIGIN:
return Network::Request::ReferrerPolicyEnum::Origin;
case net::URLRequest::NO_REFERRER:
return Network::Request::ReferrerPolicyEnum::NoReferrer;
default:
break;
}
NOTREACHED();
return Network::Request::ReferrerPolicyEnum::NoReferrerWhenDowngrade;
}
| 0
|
315,508
|
parse_SET_TUNNEL(char *arg, struct ofpbuf *ofpacts,
enum ofputil_protocol *usable_protocols OVS_UNUSED)
{
return parse_set_tunnel(arg, ofpacts, NXAST_RAW_SET_TUNNEL);
}
| 0
|
340,718
|
static void aer915_class_init(ObjectClass *klass, void *data)
{
DeviceClass *dc = DEVICE_CLASS(klass);
I2CSlaveClass *k = I2C_SLAVE_CLASS(klass);
k->init = aer915_init;
k->event = aer915_event;
k->recv = aer915_recv;
k->send = aer915_send;
dc->vmsd = &vmstate_aer915_state;
}
| 0
|
135,284
|
f_fullcommand(typval_T *argvars, typval_T *rettv)
{
exarg_T ea;
char_u *name;
char_u *p;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = NULL;
if (in_vim9script() && check_for_string_arg(argvars, 0) == FAIL)
return;
name = argvars[0].vval.v_string;
if (name == NULL)
return;
while (*name == ':')
name++;
name = skip_range(name, TRUE, NULL);
ea.cmd = (*name == '2' || *name == '3') ? name + 1 : name;
ea.cmdidx = (cmdidx_T)0;
ea.addr_count = 0;
p = find_ex_command(&ea, NULL, NULL, NULL);
if (p == NULL || ea.cmdidx == CMD_SIZE)
return;
if (in_vim9script())
{
int res;
++emsg_silent;
res = not_in_vim9(&ea);
--emsg_silent;
if (res == FAIL)
return;
}
rettv->vval.v_string = vim_strsave(IS_USER_CMDIDX(ea.cmdidx)
? get_user_command_name(ea.useridx, ea.cmdidx)
: cmdnames[ea.cmdidx].cmd_name);
}
| 0
|
44,695
|
static int ip_vs_genl_set_daemon(struct sk_buff *skb, struct genl_info *info)
{
int ret = 0, cmd;
struct net *net;
struct netns_ipvs *ipvs;
net = skb_sknet(skb);
ipvs = net_ipvs(net);
cmd = info->genlhdr->cmd;
if (cmd == IPVS_CMD_NEW_DAEMON || cmd == IPVS_CMD_DEL_DAEMON) {
struct nlattr *daemon_attrs[IPVS_DAEMON_ATTR_MAX + 1];
mutex_lock(&ipvs->sync_mutex);
if (!info->attrs[IPVS_CMD_ATTR_DAEMON] ||
nla_parse_nested(daemon_attrs, IPVS_DAEMON_ATTR_MAX,
info->attrs[IPVS_CMD_ATTR_DAEMON],
ip_vs_daemon_policy)) {
ret = -EINVAL;
goto out;
}
if (cmd == IPVS_CMD_NEW_DAEMON)
ret = ip_vs_genl_new_daemon(net, daemon_attrs);
else
ret = ip_vs_genl_del_daemon(net, daemon_attrs);
out:
mutex_unlock(&ipvs->sync_mutex);
}
return ret;
}
| 0
|
37,997
|
static int h264_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame, AVPacket *avpkt)
{
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
H264Context *h = avctx->priv_data;
AVFrame *pict = data;
int buf_index = 0;
H264Picture *out;
int i, out_idx;
int ret;
h->flags = avctx->flags;
/* reset data partitioning here, to ensure GetBitContexts from previous
* packets do not get used. */
h->data_partitioning = 0;
/* end of stream, output what is still in the buffers */
if (buf_size == 0) {
out:
h->cur_pic_ptr = NULL;
h->first_field = 0;
// FIXME factorize this with the output code below
out = h->delayed_pic[0];
out_idx = 0;
for (i = 1;
h->delayed_pic[i] &&
!h->delayed_pic[i]->f.key_frame &&
!h->delayed_pic[i]->mmco_reset;
i++)
if (h->delayed_pic[i]->poc < out->poc) {
out = h->delayed_pic[i];
out_idx = i;
}
for (i = out_idx; h->delayed_pic[i]; i++)
h->delayed_pic[i] = h->delayed_pic[i + 1];
if (out) {
out->reference &= ~DELAYED_PIC_REF;
ret = output_frame(h, pict, out);
if (ret < 0)
return ret;
*got_frame = 1;
}
return buf_index;
}
if (h->is_avc && av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, NULL)) {
int side_size;
uint8_t *side = av_packet_get_side_data(avpkt, AV_PKT_DATA_NEW_EXTRADATA, &side_size);
if (is_extra(side, side_size))
ff_h264_decode_extradata(h, side, side_size);
}
if(h->is_avc && buf_size >= 9 && buf[0]==1 && buf[2]==0 && (buf[4]&0xFC)==0xFC && (buf[5]&0x1F) && buf[8]==0x67){
if (is_extra(buf, buf_size))
return ff_h264_decode_extradata(h, buf, buf_size);
}
buf_index = decode_nal_units(h, buf, buf_size, 0);
if (buf_index < 0)
return AVERROR_INVALIDDATA;
if (!h->cur_pic_ptr && h->nal_unit_type == NAL_END_SEQUENCE) {
av_assert0(buf_index <= buf_size);
goto out;
}
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS) && !h->cur_pic_ptr) {
if (avctx->skip_frame >= AVDISCARD_NONREF ||
buf_size >= 4 && !memcmp("Q264", buf, 4))
return buf_size;
av_log(avctx, AV_LOG_ERROR, "no frame!\n");
return AVERROR_INVALIDDATA;
}
if (!(avctx->flags2 & CODEC_FLAG2_CHUNKS) ||
(h->mb_y >= h->mb_height && h->mb_height)) {
if (avctx->flags2 & CODEC_FLAG2_CHUNKS)
decode_postinit(h, 1);
ff_h264_field_end(h, 0);
/* Wait for second field. */
*got_frame = 0;
if (h->next_output_pic && (
h->next_output_pic->recovered)) {
if (!h->next_output_pic->recovered)
h->next_output_pic->f.flags |= AV_FRAME_FLAG_CORRUPT;
ret = output_frame(h, pict, h->next_output_pic);
if (ret < 0)
return ret;
*got_frame = 1;
if (CONFIG_MPEGVIDEO) {
ff_print_debug_info2(h->avctx, pict, h->er.mbskip_table,
h->next_output_pic->mb_type,
h->next_output_pic->qscale_table,
h->next_output_pic->motion_val,
&h->low_delay,
h->mb_width, h->mb_height, h->mb_stride, 1);
}
}
}
assert(pict->buf[0] || !*got_frame);
return get_consumed_bytes(buf_index, buf_size);
}
| 0
|
419,720
|
void server_maybe_append_tags(Server *s) {
#if HAVE_GCRYPT
JournalFile *f;
Iterator i;
usec_t n;
n = now(CLOCK_REALTIME);
if (s->system_journal)
journal_file_maybe_append_tag(s->system_journal, n);
ORDERED_HASHMAP_FOREACH(f, s->user_journals, i)
journal_file_maybe_append_tag(f, n);
#endif
| 0
|
168,521
|
int64 MakeFolderWithParent(UserShare* share,
ModelType model_type,
int64 parent_id,
BaseNode* predecessor) {
WriteTransaction trans(FROM_HERE, share);
ReadNode parent_node(&trans);
EXPECT_TRUE(parent_node.InitByIdLookup(parent_id));
WriteNode node(&trans);
EXPECT_TRUE(node.InitByCreation(model_type, parent_node, predecessor));
node.SetIsFolder(true);
return node.GetId();
}
| 0
|
371,706
|
_archive_entry_copy_file_info (struct archive_entry *entry,
GFileInfo *info,
SaveData *save_data)
{
int filetype;
char *username;
char *groupname;
gint64 id;
switch (g_file_info_get_file_type (info)) {
case G_FILE_TYPE_REGULAR:
filetype = AE_IFREG;
break;
case G_FILE_TYPE_DIRECTORY:
filetype = AE_IFDIR;
break;
case G_FILE_TYPE_SYMBOLIC_LINK:
filetype = AE_IFLNK;
break;
default:
return FALSE;
break;
}
archive_entry_set_filetype (entry, filetype);
archive_entry_set_atime (entry,
g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_ACCESS),
g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_TIME_ACCESS_USEC) * 1000);
archive_entry_set_ctime (entry,
g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_CREATED),
g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_TIME_CREATED_USEC) * 1000);
archive_entry_set_mtime (entry,
g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED),
g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_TIME_MODIFIED_USEC) * 1000);
archive_entry_unset_birthtime (entry);
archive_entry_set_dev (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_DEVICE));
archive_entry_set_gid (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_GID));
archive_entry_set_uid (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_UID));
archive_entry_set_ino64 (entry, g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_UNIX_INODE));
archive_entry_set_mode (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_MODE));
archive_entry_set_nlink (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_NLINK));
archive_entry_set_rdev (entry, g_file_info_get_attribute_uint32 (info, G_FILE_ATTRIBUTE_UNIX_RDEV));
archive_entry_set_size (entry, g_file_info_get_attribute_uint64 (info, G_FILE_ATTRIBUTE_STANDARD_SIZE));
if (filetype == AE_IFLNK)
archive_entry_set_symlink (entry, g_file_info_get_attribute_byte_string (info, G_FILE_ATTRIBUTE_STANDARD_SYMLINK_TARGET));
/* username */
id = archive_entry_uid (entry);
username = g_hash_table_lookup (save_data->usernames, &id);
if (username == NULL) {
struct passwd *pwd = getpwuid (id);
if (pwd != NULL) {
username = g_strdup (pwd->pw_name);
g_hash_table_insert (save_data->usernames, _g_int64_pointer_new (id), username);
}
}
if (username != NULL)
archive_entry_set_uname (entry, username);
/* groupname */
id = archive_entry_gid (entry);
groupname = g_hash_table_lookup (save_data->groupnames, &id);
if (groupname == NULL) {
struct group *grp = getgrgid (id);
if (grp != NULL) {
groupname = g_strdup (grp->gr_name);
g_hash_table_insert (save_data->groupnames, _g_int64_pointer_new (id), groupname);
}
}
if (groupname != NULL)
archive_entry_set_gname (entry, groupname);
return TRUE;
}
| 0
|
493,619
|
static struct fuse_module *fuse_find_module(const char *module)
{
struct fuse_module *m;
for (m = fuse_modules; m; m = m->next) {
if (strcmp(module, m->name) == 0) {
m->ctr++;
break;
}
}
return m;
}
| 0
|
11,950
|
TargetThread::TargetThread()
: thread_started_event_(false, false), finish_event_(false, false),
id_(0) {}
| 1
|
457,377
|
rpc_C_DigestUpdate (CK_X_FUNCTION_LIST *self,
p11_rpc_message *msg)
{
CK_SESSION_HANDLE session;
CK_BYTE_PTR part;
CK_ULONG part_len;
BEGIN_CALL (DigestUpdate);
IN_ULONG (session);
IN_BYTE_ARRAY (part, part_len);
PROCESS_CALL ((self, session, part, part_len));
END_CALL;
}
| 0
|
28,859
|
int jbig2_end_of_stripe ( Jbig2Ctx * ctx , Jbig2Segment * segment , const uint8_t * segment_data ) {
Jbig2Page page = ctx -> pages [ ctx -> current_page ] ;
uint32_t end_row ;
end_row = jbig2_get_uint32 ( segment_data ) ;
if ( end_row < page . end_row ) {
jbig2_error ( ctx , JBIG2_SEVERITY_WARNING , segment -> number , "end of stripe segment with non-positive end row advance" " (new end row %d vs current end row %d)" , end_row , page . end_row ) ;
}
else {
jbig2_error ( ctx , JBIG2_SEVERITY_INFO , segment -> number , "end of stripe: advancing end row to %d" , end_row ) ;
}
page . end_row = end_row ;
return 0 ;
}
| 0
|
482,630
|
static void set_cursor(struct vc_data *vc)
{
if (!con_is_fg(vc) || console_blanked || vc->vc_mode == KD_GRAPHICS)
return;
if (vc->vc_deccm) {
if (vc_is_sel(vc))
clear_selection();
add_softcursor(vc);
if ((vc->vc_cursor_type & 0x0f) != 1)
vc->vc_sw->con_cursor(vc, CM_DRAW);
} else
hide_cursor(vc);
}
| 0
|
361,793
|
int ethtool_op_set_flags(struct net_device *dev, u32 data)
{
const struct ethtool_ops *ops = dev->ethtool_ops;
unsigned long features = dev->features;
if (data & ETH_FLAG_LRO)
features |= NETIF_F_LRO;
else
features &= ~NETIF_F_LRO;
if (data & ETH_FLAG_NTUPLE) {
if (!ops->set_rx_ntuple)
return -EOPNOTSUPP;
features |= NETIF_F_NTUPLE;
} else {
/* safe to clear regardless */
features &= ~NETIF_F_NTUPLE;
}
if (data & ETH_FLAG_RXHASH)
features |= NETIF_F_RXHASH;
else
features &= ~NETIF_F_RXHASH;
dev->features = features;
return 0;
}
| 0
|
185,820
|
fbCombineDisjointOutReverseC (CARD32 *dest, CARD32 *src, CARD32 *mask, int width)
{
fbCombineDisjointGeneralC (dest, src, mask, width, CombineBOut);
}
| 0
|
461,411
|
static void add_option(gpointer key, gpointer value, gpointer user_data)
{
const char *option_value = value;
uint8_t option_code = GPOINTER_TO_INT(key);
struct in_addr nip;
struct dhcp_packet *packet = user_data;
if (!option_value)
return;
switch (option_code) {
case G_DHCP_SUBNET:
case G_DHCP_ROUTER:
case G_DHCP_DNS_SERVER:
if (inet_aton(option_value, &nip) == 0)
return;
dhcp_add_option_uint32(packet, (uint8_t) option_code,
ntohl(nip.s_addr));
break;
default:
return;
}
}
| 0
|
55,135
|
static void tracked_request_begin(BdrvTrackedRequest *req,
BlockDriverState *bs,
int64_t sector_num,
int nb_sectors, bool is_write)
{
*req = (BdrvTrackedRequest){
.bs = bs,
.sector_num = sector_num,
.nb_sectors = nb_sectors,
.is_write = is_write,
};
qemu_co_queue_init(&req->wait_queue);
QLIST_INSERT_HEAD(&bs->tracked_requests, req, list);
}
| 1
|
419,550
|
int sa_open_read_magic(int *fd, char *dfile, struct file_magic *file_magic,
int ignore, int *endian_mismatch, int do_swap)
{
int n;
unsigned int fm_types_nr[] = {FILE_MAGIC_ULL_NR, FILE_MAGIC_UL_NR, FILE_MAGIC_U_NR};
/* Open sa data file */
if ((*fd = open(dfile, O_RDONLY)) < 0) {
int saved_errno = errno;
fprintf(stderr, _("Cannot open %s: %s\n"), dfile, strerror(errno));
if ((saved_errno == ENOENT) && default_file_used) {
fprintf(stderr, _("Please check if data collecting is enabled\n"));
}
exit(2);
}
/* Read file magic data */
n = read(*fd, file_magic, FILE_MAGIC_SIZE);
if ((n != FILE_MAGIC_SIZE) ||
((file_magic->sysstat_magic != SYSSTAT_MAGIC) && (file_magic->sysstat_magic != SYSSTAT_MAGIC_SWAPPED)) ||
((file_magic->format_magic != FORMAT_MAGIC) && (file_magic->format_magic != FORMAT_MAGIC_SWAPPED) && !ignore)) {
#ifdef DEBUG
fprintf(stderr, "%s: Bytes read=%d sysstat_magic=%x format_magic=%x\n",
__FUNCTION__, n, file_magic->sysstat_magic, file_magic->format_magic);
#endif
/* Display error message and exit */
handle_invalid_sa_file(*fd, file_magic, dfile, n);
}
*endian_mismatch = (file_magic->sysstat_magic != SYSSTAT_MAGIC);
if (*endian_mismatch) {
if (do_swap) {
/* Swap bytes for file_magic fields */
file_magic->sysstat_magic = SYSSTAT_MAGIC;
file_magic->format_magic = __builtin_bswap16(file_magic->format_magic);
}
/*
* Start swapping at field "header_size" position.
* May not exist for older versions but in this case, it won't be used.
*/
swap_struct(fm_types_nr, &file_magic->header_size, 0);
}
if ((file_magic->sysstat_version > 10) ||
((file_magic->sysstat_version == 10) && (file_magic->sysstat_patchlevel >= 3))) {
/* header_size field exists only for sysstat versions 10.3.1 and later */
if ((file_magic->header_size <= MIN_FILE_HEADER_SIZE) ||
(file_magic->header_size > MAX_FILE_HEADER_SIZE) ||
((file_magic->header_size < FILE_HEADER_SIZE) && !ignore)) {
#ifdef DEBUG
fprintf(stderr, "%s: header_size=%u\n",
__FUNCTION__, file_magic->header_size);
#endif
/* Display error message and exit */
handle_invalid_sa_file(*fd, file_magic, dfile, n);
}
}
if ((file_magic->sysstat_version > 11) ||
((file_magic->sysstat_version == 11) && (file_magic->sysstat_patchlevel >= 7))) {
/* hdr_types_nr field exists only for sysstat versions 11.7.1 and later */
if (MAP_SIZE(file_magic->hdr_types_nr) > file_magic->header_size) {
#ifdef DEBUG
fprintf(stderr, "%s: map_size=%u header_size=%u\n",
__FUNCTION__, MAP_SIZE(file_magic->hdr_types_nr), file_magic->header_size);
#endif
handle_invalid_sa_file(*fd, file_magic, dfile, n);
}
}
if ((file_magic->format_magic != FORMAT_MAGIC) &&
(file_magic->format_magic != FORMAT_MAGIC_SWAPPED))
/*
* This is an old (or new) sa datafile format to
* be read by sadf (since @ignore was set to TRUE).
*/
return -1;
return 0;
}
| 0
|
316,414
|
void RegisterDumpProvider(
MemoryDumpProvider* mdp,
scoped_refptr<base::SingleThreadTaskRunner> task_runner) {
RegisterDumpProvider(mdp, task_runner, MemoryDumpProvider::Options());
}
| 0
|
70,249
|
void push(char_t_to val)
{
assert(to_next != to_end);
*to_next++ = val;
}
| 0
|
37,306
|
static void established_upcall(struct iwch_ep *ep)
{
struct iw_cm_event event;
PDBG("%s ep %p\n", __func__, ep);
memset(&event, 0, sizeof(event));
event.event = IW_CM_EVENT_ESTABLISHED;
/*
* Until ird/ord negotiation via MPAv2 support is added, send max
* supported values
*/
event.ird = event.ord = 8;
if (ep->com.cm_id) {
PDBG("%s ep %p tid %d\n", __func__, ep, ep->hwtid);
ep->com.cm_id->event_handler(ep->com.cm_id, &event);
}
}
| 0
|
289,026
|
int qemuAssignDeviceNetAlias ( virDomainDefPtr def , virDomainNetDefPtr net , int idx ) {
if ( networkGetActualType ( net ) == VIR_DOMAIN_NET_TYPE_HOSTDEV ) return qemuAssignDeviceHostdevAlias ( def , & net -> info . alias , - 1 ) ;
if ( idx == - 1 ) {
size_t i ;
idx = 0 ;
for ( i = 0 ;
i < def -> nnets ;
i ++ ) {
int thisidx ;
if ( ( thisidx = qemuDomainDeviceAliasIndex ( & def -> nets [ i ] -> info , "net" ) ) < 0 ) continue ;
if ( thisidx >= idx ) idx = thisidx + 1 ;
}
}
if ( virAsprintf ( & net -> info . alias , "net%d" , idx ) < 0 ) return - 1 ;
return 0 ;
}
| 0
|
279,995
|
static void Ins_POP( INS_ARG )
{ (void)exc; (void)args;
/* nothing to do */
}
| 0
|
256,252
|
static int spl_filesystem_file_read_line(zval * this_ptr, spl_filesystem_object *intern, int silent TSRMLS_DC) /* {{{ */
{
int ret = spl_filesystem_file_read_line_ex(this_ptr, intern, silent TSRMLS_CC);
while (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_SKIP_EMPTY) && ret == SUCCESS && spl_filesystem_file_is_empty_line(intern TSRMLS_CC)) {
spl_filesystem_file_free_line(intern TSRMLS_CC);
ret = spl_filesystem_file_read_line_ex(this_ptr, intern, silent TSRMLS_CC);
}
return ret;
}
/* }}} */
| 1
|
59,331
|
void rds_conn_connect_if_down(struct rds_connection *conn)
{
WARN_ON(conn->c_trans->t_mp_capable);
rds_conn_path_connect_if_down(&conn->c_path[0]);
}
| 0
|
92,505
|
iperf_send(struct iperf_test *test, fd_set *write_setP)
{
register int multisend, r, streams_active;
register struct iperf_stream *sp;
struct timeval now;
/* Can we do multisend mode? */
if (test->settings->burst != 0)
multisend = test->settings->burst;
else if (test->settings->rate == 0)
multisend = test->multisend;
else
multisend = 1; /* nope */
for (; multisend > 0; --multisend) {
if (test->settings->rate != 0 && test->settings->burst == 0)
gettimeofday(&now, NULL);
streams_active = 0;
SLIST_FOREACH(sp, &test->streams, streams) {
if (sp->green_light &&
(write_setP == NULL || FD_ISSET(sp->socket, write_setP))) {
if ((r = sp->snd(sp)) < 0) {
if (r == NET_SOFTERROR)
break;
i_errno = IESTREAMWRITE;
return r;
}
streams_active = 1;
test->bytes_sent += r;
++test->blocks_sent;
if (test->settings->rate != 0 && test->settings->burst == 0)
iperf_check_throttle(sp, &now);
if (multisend > 1 && test->settings->bytes != 0 && test->bytes_sent >= test->settings->bytes)
break;
if (multisend > 1 && test->settings->blocks != 0 && test->blocks_sent >= test->settings->blocks)
break;
}
}
if (!streams_active)
break;
}
if (test->settings->burst != 0) {
gettimeofday(&now, NULL);
SLIST_FOREACH(sp, &test->streams, streams)
iperf_check_throttle(sp, &now);
}
if (write_setP != NULL)
SLIST_FOREACH(sp, &test->streams, streams)
if (FD_ISSET(sp->socket, write_setP))
FD_CLR(sp->socket, write_setP);
return 0;
}
| 0
|
490,581
|
const char *gf_filter_get_dst_args(GF_Filter *filter)
{
return gf_filter_get_args_stripped(filter->session, filter->dst_args, GF_TRUE);
}
| 0
|
378,557
|
static void *wsgi_create_server_config(apr_pool_t *p, server_rec *s)
{
WSGIServerConfig *config = NULL;
config = newWSGIServerConfig(p);
return config;
}
| 0
|
221,945
|
filter_report_error(stream_state * st, const char *str)
{
if_debug1m('s', st->memory, "[s]stream error: %s\n", str);
strncpy(st->error_string, str, STREAM_MAX_ERROR_STRING);
/* Ensure null termination. */
st->error_string[STREAM_MAX_ERROR_STRING] = 0;
return 0;
}
| 0
|
8,765
|
static bool is_legal_file(const std::string &filename)
{
DBG_FS << "Looking for '" << filename << "'.\n";
if (filename.empty()) {
LOG_FS << " invalid filename\n";
return false;
}
if (filename.find("..") != std::string::npos) {
ERR_FS << "Illegal path '" << filename << "' (\"..\" not allowed).\n";
return false;
}
if (ends_with(filename, ".pbl")) {
ERR_FS << "Illegal path '" << filename << "' (.pbl files are not allowed)." << std::endl;
return false;
}
return true;
}
| 1
|
25,458
|
static inline uint16_t tswap16 ( uint16_t s ) {
return s ;
}
| 0
|
7,914
|
static PyObject *__pyx_pw_17clickhouse_driver_6varint_1write_varint(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
Py_ssize_t __pyx_v_number;
PyObject *__pyx_v_buf = 0;
PyObject *__pyx_r = 0;
__Pyx_RefNannyDeclarations
__Pyx_RefNannySetupContext("write_varint (wrapper)", 0);
{
static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_number,&__pyx_n_s_buf,0};
PyObject* values[2] = {0,0};
if (unlikely(__pyx_kwds)) {
Py_ssize_t kw_args;
const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
switch (pos_args) {
case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
CYTHON_FALLTHROUGH;
case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
CYTHON_FALLTHROUGH;
case 0: break;
default: goto __pyx_L5_argtuple_error;
}
kw_args = PyDict_Size(__pyx_kwds);
switch (pos_args) {
case 0:
if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_number)) != 0)) kw_args--;
else goto __pyx_L5_argtuple_error;
CYTHON_FALLTHROUGH;
case 1:
if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_buf)) != 0)) kw_args--;
else {
__Pyx_RaiseArgtupleInvalid("write_varint", 1, 2, 2, 1); __PYX_ERR(0, 4, __pyx_L3_error)
}
}
if (unlikely(kw_args > 0)) {
if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write_varint") < 0)) __PYX_ERR(0, 4, __pyx_L3_error)
}
} else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
goto __pyx_L5_argtuple_error;
} else {
values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
}
__pyx_v_number = __Pyx_PyIndex_AsSsize_t(values[0]); if (unlikely((__pyx_v_number == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 4, __pyx_L3_error)
__pyx_v_buf = values[1];
}
goto __pyx_L4_argument_unpacking_done;
__pyx_L5_argtuple_error:;
__Pyx_RaiseArgtupleInvalid("write_varint", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 4, __pyx_L3_error)
__pyx_L3_error:;
__Pyx_AddTraceback("clickhouse_driver.varint.write_varint", __pyx_clineno, __pyx_lineno, __pyx_filename);
__Pyx_RefNannyFinishContext();
return NULL;
__pyx_L4_argument_unpacking_done:;
__pyx_r = __pyx_pf_17clickhouse_driver_6varint_write_varint(__pyx_self, __pyx_v_number, __pyx_v_buf);
/* function exit code */
__Pyx_RefNannyFinishContext();
return __pyx_r;
}
| 1
|
108,443
|
encode_REG_MOVE(const struct ofpact_reg_move *move,
enum ofp_version ofp_version, struct ofpbuf *out)
{
/* For OpenFlow 1.3, the choice of ONFACT_RAW13_COPY_FIELD versus
* NXAST_RAW_REG_MOVE is somewhat difficult. Neither one is guaranteed to
* be supported by every OpenFlow 1.3 implementation. It would be ideal to
* probe for support. Until we have that ability, we currently prefer
* NXAST_RAW_REG_MOVE for backward compatibility with older Open vSwitch
* versions. */
size_t start_ofs = out->size;
if (ofp_version >= OFP15_VERSION) {
struct ofp15_action_copy_field *copy = put_OFPAT15_COPY_FIELD(out);
copy->n_bits = htons(move->dst.n_bits);
copy->src_offset = htons(move->src.ofs);
copy->dst_offset = htons(move->dst.ofs);
out->size = out->size - sizeof copy->pad2;
nx_put_mff_header(out, move->src.field, ofp_version, false);
nx_put_mff_header(out, move->dst.field, ofp_version, false);
} else if (ofp_version == OFP13_VERSION
&& move->ofpact.raw == ONFACT_RAW13_COPY_FIELD) {
struct onf_action_copy_field *copy = put_ONFACT13_COPY_FIELD(out);
copy->n_bits = htons(move->dst.n_bits);
copy->src_offset = htons(move->src.ofs);
copy->dst_offset = htons(move->dst.ofs);
out->size = out->size - sizeof copy->pad3;
nx_put_mff_header(out, move->src.field, ofp_version, false);
nx_put_mff_header(out, move->dst.field, ofp_version, false);
} else {
struct nx_action_reg_move *narm = put_NXAST_REG_MOVE(out);
narm->n_bits = htons(move->dst.n_bits);
narm->src_ofs = htons(move->src.ofs);
narm->dst_ofs = htons(move->dst.ofs);
nx_put_mff_header(out, move->src.field, 0, false);
nx_put_mff_header(out, move->dst.field, 0, false);
}
pad_ofpat(out, start_ofs);
}
| 0
|
58,903
|
void HeaderMapImpl::HeaderEntryImpl::value(uint64_t value) { value_.setInteger(value); }
| 0
|
33,775
|
static int mem_control_stat_show(struct cgroup *cont, struct cftype *cft,
struct cgroup_map_cb *cb)
{
struct mem_cgroup *mem_cont = mem_cgroup_from_cont(cont);
struct mcs_total_stat mystat;
int i;
memset(&mystat, 0, sizeof(mystat));
mem_cgroup_get_local_stat(mem_cont, &mystat);
for (i = 0; i < NR_MCS_STAT; i++) {
if (i == MCS_SWAP && !do_swap_account)
continue;
cb->fill(cb, memcg_stat_strings[i].local_name, mystat.stat[i]);
}
/* Hierarchical information */
{
unsigned long long limit, memsw_limit;
memcg_get_hierarchical_limit(mem_cont, &limit, &memsw_limit);
cb->fill(cb, "hierarchical_memory_limit", limit);
if (do_swap_account)
cb->fill(cb, "hierarchical_memsw_limit", memsw_limit);
}
memset(&mystat, 0, sizeof(mystat));
mem_cgroup_get_total_stat(mem_cont, &mystat);
for (i = 0; i < NR_MCS_STAT; i++) {
if (i == MCS_SWAP && !do_swap_account)
continue;
cb->fill(cb, memcg_stat_strings[i].total_name, mystat.stat[i]);
}
#ifdef CONFIG_DEBUG_VM
{
int nid, zid;
struct mem_cgroup_per_zone *mz;
unsigned long recent_rotated[2] = {0, 0};
unsigned long recent_scanned[2] = {0, 0};
for_each_online_node(nid)
for (zid = 0; zid < MAX_NR_ZONES; zid++) {
mz = mem_cgroup_zoneinfo(mem_cont, nid, zid);
recent_rotated[0] +=
mz->reclaim_stat.recent_rotated[0];
recent_rotated[1] +=
mz->reclaim_stat.recent_rotated[1];
recent_scanned[0] +=
mz->reclaim_stat.recent_scanned[0];
recent_scanned[1] +=
mz->reclaim_stat.recent_scanned[1];
}
cb->fill(cb, "recent_rotated_anon", recent_rotated[0]);
cb->fill(cb, "recent_rotated_file", recent_rotated[1]);
cb->fill(cb, "recent_scanned_anon", recent_scanned[0]);
cb->fill(cb, "recent_scanned_file", recent_scanned[1]);
}
#endif
return 0;
}
| 0
|
83,757
|
static char *fix_table_name(char *dest, char *src)
{
*dest++= '`';
for (; *src; src++)
{
switch (*src) {
case '.': /* add backticks around '.' */
*dest++= '`';
*dest++= '.';
*dest++= '`';
break;
case '`': /* escape backtick character */
*dest++= '`';
/* fall through */
default:
*dest++= *src;
}
}
*dest++= '`';
return dest;
}
| 0
|
448,283
|
static int nfsd_buffered_filldir(struct dir_context *ctx, const char *name,
int namlen, loff_t offset, u64 ino,
unsigned int d_type)
{
struct readdir_data *buf =
container_of(ctx, struct readdir_data, ctx);
struct buffered_dirent *de = (void *)(buf->dirent + buf->used);
unsigned int reclen;
reclen = ALIGN(sizeof(struct buffered_dirent) + namlen, sizeof(u64));
if (buf->used + reclen > PAGE_SIZE) {
buf->full = 1;
return -EINVAL;
}
de->namlen = namlen;
de->offset = offset;
de->ino = ino;
de->d_type = d_type;
memcpy(de->name, name, namlen);
buf->used += reclen;
return 0;
}
| 0
|
414,405
|
static void findHotKeys(void) {
redisReply *keys, *reply;
unsigned long long counters[HOTKEYS_SAMPLE] = {0};
sds hotkeys[HOTKEYS_SAMPLE] = {NULL};
unsigned long long sampled = 0, total_keys, *freqs = NULL, it = 0;
unsigned int arrsize = 0, i, k;
double pct;
/* Total keys pre scanning */
total_keys = getDbSize();
/* Status message */
printf("\n# Scanning the entire keyspace to find hot keys as well as\n");
printf("# average sizes per key type. You can use -i 0.1 to sleep 0.1 sec\n");
printf("# per 100 SCAN commands (not usually needed).\n\n");
/* SCAN loop */
do {
/* Calculate approximate percentage completion */
pct = 100 * (double)sampled/total_keys;
/* Grab some keys and point to the keys array */
reply = sendScan(&it);
keys = reply->element[1];
/* Reallocate our freqs array if we need to */
if(keys->elements > arrsize) {
freqs = zrealloc(freqs, sizeof(unsigned long long)*keys->elements);
if(!freqs) {
fprintf(stderr, "Failed to allocate storage for keys!\n");
exit(1);
}
arrsize = keys->elements;
}
getKeyFreqs(keys, freqs);
/* Now update our stats */
for(i=0;i<keys->elements;i++) {
sampled++;
/* Update overall progress */
if(sampled % 1000000 == 0) {
printf("[%05.2f%%] Sampled %llu keys so far\n", pct, sampled);
}
/* Use eviction pool here */
k = 0;
while (k < HOTKEYS_SAMPLE && freqs[i] > counters[k]) k++;
if (k == 0) continue;
k--;
if (k == 0 || counters[k] == 0) {
sdsfree(hotkeys[k]);
} else {
sdsfree(hotkeys[0]);
memmove(counters,counters+1,sizeof(counters[0])*k);
memmove(hotkeys,hotkeys+1,sizeof(hotkeys[0])*k);
}
counters[k] = freqs[i];
hotkeys[k] = sdsnew(keys->element[i]->str);
printf(
"[%05.2f%%] Hot key '%s' found so far with counter %llu\n",
pct, keys->element[i]->str, freqs[i]);
}
/* Sleep if we've been directed to do so */
if(sampled && (sampled %100) == 0 && config.interval) {
usleep(config.interval);
}
freeReplyObject(reply);
} while(it != 0);
if (freqs) zfree(freqs);
/* We're done */
printf("\n-------- summary -------\n\n");
printf("Sampled %llu keys in the keyspace!\n", sampled);
for (i=1; i<= HOTKEYS_SAMPLE; i++) {
k = HOTKEYS_SAMPLE - i;
if(counters[k]>0) {
printf("hot key found with counter: %llu\tkeyname: %s\n", counters[k], hotkeys[k]);
sdsfree(hotkeys[k]);
}
}
exit(0);
}
| 0
|
289,620
|
int vp9_find_best_sub_pixel_tree ( const MACROBLOCK * x , MV * bestmv , const MV * ref_mv , int allow_hp , int error_per_bit , const vp9_variance_fn_ptr_t * vfp , int forced_stop , int iters_per_step , int * sad_list , int * mvjcost , int * mvcost [ 2 ] , int * distortion , unsigned int * sse1 , const uint8_t * second_pred , int w , int h ) {
SETUP_SUBPEL_SEARCH ;
( void ) sad_list ;
FIRST_LEVEL_CHECKS ;
if ( halfiters > 1 ) {
SECOND_LEVEL_CHECKS ;
}
tr = br ;
tc = bc ;
if ( forced_stop != 2 ) {
hstep >>= 1 ;
FIRST_LEVEL_CHECKS ;
if ( quarteriters > 1 ) {
SECOND_LEVEL_CHECKS ;
}
tr = br ;
tc = bc ;
}
if ( allow_hp && vp9_use_mv_hp ( ref_mv ) && forced_stop == 0 ) {
hstep >>= 1 ;
FIRST_LEVEL_CHECKS ;
if ( eighthiters > 1 ) {
SECOND_LEVEL_CHECKS ;
}
tr = br ;
tc = bc ;
}
( void ) tr ;
( void ) tc ;
bestmv -> row = br ;
bestmv -> col = bc ;
if ( ( abs ( bestmv -> col - ref_mv -> col ) > ( MAX_FULL_PEL_VAL << 3 ) ) || ( abs ( bestmv -> row - ref_mv -> row ) > ( MAX_FULL_PEL_VAL << 3 ) ) ) return INT_MAX ;
return besterr ;
}
| 0
|
210,859
|
net::CertStatus ChromePasswordManagerClient::GetMainFrameCertStatus() const {
content::NavigationEntry* entry =
web_contents()->GetController().GetLastCommittedEntry();
if (!entry)
return 0;
return entry->GetSSL().cert_status;
}
| 0
|
306,849
|
static int read_ahead(struct archive_read* a, size_t how_many,
const uint8_t** ptr)
{
ssize_t avail = -1;
if(!ptr)
return 0;
*ptr = __archive_read_ahead(a, how_many, &avail);
if(*ptr == NULL) {
return 0;
}
return 1;
}
| 0
|
165,724
|
void LocalDOMWindow::RemovedEventListener(
const AtomicString& event_type,
const RegisteredEventListener& registered_listener) {
DOMWindow::RemovedEventListener(event_type, registered_listener);
if (GetFrame() && GetFrame()->GetPage())
GetFrame()->GetPage()->GetEventHandlerRegistry().DidRemoveEventHandler(
*this, event_type, registered_listener.Options());
for (auto& it : event_listener_observers_) {
it->DidRemoveEventListener(this, event_type);
}
if (event_type == EventTypeNames::unload) {
UntrackUnloadEventListener(this);
} else if (event_type == EventTypeNames::beforeunload) {
UntrackBeforeUnloadEventListener(this);
}
}
| 0
|
1,507
|
static void gx_ttfReader__Read ( ttfReader * self , void * p , int n ) {
gx_ttfReader * r = ( gx_ttfReader * ) self ;
const byte * q ;
if ( ! r -> error ) {
if ( r -> extra_glyph_index != - 1 ) {
q = r -> glyph_data . bits . data + r -> pos ;
r -> error = ( r -> glyph_data . bits . size - r -> pos < n ? gs_note_error ( gs_error_invalidfont ) : 0 ) ;
if ( r -> error == 0 ) memcpy ( p , q , n ) ;
}
else {
unsigned int cnt ;
for ( cnt = 0 ;
cnt < ( uint ) n ;
cnt += r -> error ) {
r -> error = r -> pfont -> data . string_proc ( r -> pfont , ( ulong ) r -> pos + cnt , ( ulong ) n - cnt , & q ) ;
if ( r -> error < 0 ) break ;
else if ( r -> error == 0 ) {
memcpy ( ( char * ) p + cnt , q , n - cnt ) ;
break ;
}
else {
memcpy ( ( char * ) p + cnt , q , r -> error ) ;
}
}
}
}
if ( r -> error ) {
memset ( p , 0 , n ) ;
return ;
}
r -> pos += n ;
}
| 1
|
89,162
|
static void gf_isom_check_sample_desc(GF_TrackBox *trak)
{
GF_BitStream *bs;
GF_UnknownBox *a;
u32 i;
if (!trak->Media || !trak->Media->information) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Track with no media box !\n" ));
return;
}
if (!trak->Media->information->sampleTable) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Track with no sample table !\n" ));
trak->Media->information->sampleTable = (GF_SampleTableBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_STBL);
}
if (!trak->Media->information->sampleTable->SampleDescription) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Track with no sample description box !\n" ));
trak->Media->information->sampleTable->SampleDescription = (GF_SampleDescriptionBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_STSD);
return;
}
i=0;
while ((a = (GF_UnknownBox*)gf_list_enum(trak->Media->information->sampleTable->SampleDescription->other_boxes, &i))) {
switch (a->type) {
case GF_ISOM_BOX_TYPE_MP4S:
case GF_ISOM_BOX_TYPE_ENCS:
case GF_ISOM_BOX_TYPE_MP4A:
case GF_ISOM_BOX_TYPE_ENCA:
case GF_ISOM_BOX_TYPE_MP4V:
case GF_ISOM_BOX_TYPE_ENCV:
case GF_ISOM_BOX_TYPE_RESV:
case GF_ISOM_SUBTYPE_3GP_AMR:
case GF_ISOM_SUBTYPE_3GP_AMR_WB:
case GF_ISOM_SUBTYPE_3GP_EVRC:
case GF_ISOM_SUBTYPE_3GP_QCELP:
case GF_ISOM_SUBTYPE_3GP_SMV:
case GF_ISOM_SUBTYPE_3GP_H263:
case GF_ISOM_BOX_TYPE_GHNT:
case GF_ISOM_BOX_TYPE_RTP_STSD:
case GF_ISOM_BOX_TYPE_SRTP_STSD:
case GF_ISOM_BOX_TYPE_FDP_STSD:
case GF_ISOM_BOX_TYPE_RRTP_STSD:
case GF_ISOM_BOX_TYPE_RTCP_STSD:
case GF_ISOM_BOX_TYPE_METX:
case GF_ISOM_BOX_TYPE_METT:
case GF_ISOM_BOX_TYPE_STXT:
case GF_ISOM_BOX_TYPE_AVC1:
case GF_ISOM_BOX_TYPE_AVC2:
case GF_ISOM_BOX_TYPE_AVC3:
case GF_ISOM_BOX_TYPE_AVC4:
case GF_ISOM_BOX_TYPE_SVC1:
case GF_ISOM_BOX_TYPE_MVC1:
case GF_ISOM_BOX_TYPE_HVC1:
case GF_ISOM_BOX_TYPE_HEV1:
case GF_ISOM_BOX_TYPE_HVC2:
case GF_ISOM_BOX_TYPE_HEV2:
case GF_ISOM_BOX_TYPE_HVT1:
case GF_ISOM_BOX_TYPE_LHV1:
case GF_ISOM_BOX_TYPE_LHE1:
case GF_ISOM_BOX_TYPE_TX3G:
case GF_ISOM_BOX_TYPE_TEXT:
case GF_ISOM_BOX_TYPE_ENCT:
case GF_ISOM_BOX_TYPE_DIMS:
case GF_ISOM_BOX_TYPE_AC3:
case GF_ISOM_BOX_TYPE_EC3:
case GF_ISOM_BOX_TYPE_LSR1:
case GF_ISOM_BOX_TYPE_WVTT:
case GF_ISOM_BOX_TYPE_STPP:
case GF_ISOM_BOX_TYPE_SBTT:
case GF_ISOM_BOX_TYPE_MP3:
case GF_ISOM_BOX_TYPE_JPEG:
case GF_ISOM_BOX_TYPE_PNG:
case GF_ISOM_BOX_TYPE_JP2K:
continue;
case GF_ISOM_BOX_TYPE_UNKNOWN:
break;
default:
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Unexpected box %s in stsd!\n", gf_4cc_to_str(a->type)));
continue;
}
//we are sure to have an unknown box here
assert(a->type==GF_ISOM_BOX_TYPE_UNKNOWN);
if (!a->data || (a->dataSize<8) ) {
GF_LOG(GF_LOG_WARNING, GF_LOG_CONTAINER, ("[iso file] Sample description %s does not have at least 8 bytes!\n", gf_4cc_to_str(a->original_4cc) ));
continue;
}
else if (a->dataSize > a->size) {
GF_LOG(GF_LOG_ERROR, GF_LOG_CONTAINER, ("[iso file] Sample description %s has wrong data size %d!\n", gf_4cc_to_str(a->original_4cc), a->dataSize));
continue;
}
/*only process visual or audio*/
switch (trak->Media->handler->handlerType) {
case GF_ISOM_MEDIA_VISUAL:
case GF_ISOM_MEDIA_AUXV:
case GF_ISOM_MEDIA_PICT:
{
GF_GenericVisualSampleEntryBox *genv;
/*remove entry*/
gf_list_rem(trak->Media->information->sampleTable->SampleDescription->other_boxes, i-1);
genv = (GF_GenericVisualSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_GNRV);
bs = gf_bs_new(a->data, a->dataSize, GF_BITSTREAM_READ);
genv->size = a->size-8;
gf_isom_video_sample_entry_read((GF_VisualSampleEntryBox *) genv, bs);
if (gf_bs_available(bs)) {
u64 pos = gf_bs_get_position(bs);
//try to parse as boxes
GF_Err e = gf_isom_box_array_read((GF_Box *) genv, bs, gf_isom_box_add_default);
if (e) {
gf_bs_seek(bs, pos);
genv->data_size = (u32) gf_bs_available(bs);
if (genv->data_size) {
genv->data = a->data;
a->data = NULL;
memmove(genv->data, genv->data + pos, genv->data_size);
}
} else {
genv->data_size = 0;
}
}
gf_bs_del(bs);
if (!genv->data_size && genv->data) {
gf_free(genv->data);
genv->data = NULL;
}
genv->size = 0;
genv->EntryType = a->original_4cc;
gf_isom_box_del((GF_Box *)a);
gf_list_insert(trak->Media->information->sampleTable->SampleDescription->other_boxes, genv, i-1);
}
break;
case GF_ISOM_MEDIA_AUDIO:
{
GF_GenericAudioSampleEntryBox *gena;
/*remove entry*/
gf_list_rem(trak->Media->information->sampleTable->SampleDescription->other_boxes, i-1);
gena = (GF_GenericAudioSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_GNRA);
gena->size = a->size-8;
bs = gf_bs_new(a->data, a->dataSize, GF_BITSTREAM_READ);
gf_isom_audio_sample_entry_read((GF_AudioSampleEntryBox *) gena, bs);
if (gf_bs_available(bs)) {
u64 pos = gf_bs_get_position(bs);
//try to parse as boxes
GF_Err e = gf_isom_box_array_read((GF_Box *) gena, bs, gf_isom_box_add_default);
if (e) {
gf_bs_seek(bs, pos);
gena->data_size = (u32) gf_bs_available(bs);
if (gena->data_size) {
gena->data = a->data;
a->data = NULL;
memmove(gena->data, gena->data + pos, gena->data_size);
}
} else {
gena->data_size = 0;
}
}
gf_bs_del(bs);
if (!gena->data_size && gena->data) {
gf_free(gena->data);
gena->data = NULL;
}
gena->size = 0;
gena->EntryType = a->original_4cc;
gf_isom_box_del((GF_Box *)a);
gf_list_insert(trak->Media->information->sampleTable->SampleDescription->other_boxes, gena, i-1);
}
break;
default:
{
GF_Err e;
GF_GenericSampleEntryBox *genm;
/*remove entry*/
gf_list_rem(trak->Media->information->sampleTable->SampleDescription->other_boxes, i-1);
genm = (GF_GenericSampleEntryBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_GNRM);
genm->size = a->size-8;
bs = gf_bs_new(a->data, a->dataSize, GF_BITSTREAM_READ);
e = gf_isom_base_sample_entry_read((GF_SampleEntryBox *)genm, bs);
if (e) return;
genm->size -= 8;
if (gf_bs_available(bs)) {
u64 pos = gf_bs_get_position(bs);
//try to parse as boxes
GF_Err e = gf_isom_box_array_read((GF_Box *) genm, bs, gf_isom_box_add_default);
if (e) {
gf_bs_seek(bs, pos);
genm->data_size = (u32) gf_bs_available(bs);
if (genm->data_size) {
genm->data = a->data;
a->data = NULL;
memmove(genm->data, genm->data + pos, genm->data_size);
}
} else {
genm->data_size = 0;
}
}
gf_bs_del(bs);
if (!genm->data_size && genm->data) {
gf_free(genm->data);
genm->data = NULL;
}
genm->size = 0;
genm->EntryType = a->original_4cc;
gf_isom_box_del((GF_Box *)a);
gf_list_insert(trak->Media->information->sampleTable->SampleDescription->other_boxes, genm, i-1);
}
break;
}
}
}
| 0
|
494,365
|
static char *skip_space(char *ptr)
{
for(; *ptr; ptr++)
if (*ptr != ' ' && *ptr != '\t')
break;
return ptr;
}
| 0
|
355,882
|
int vmtruncate(struct inode * inode, loff_t offset)
{
if (inode->i_size < offset) {
unsigned long limit;
limit = current->signal->rlim[RLIMIT_FSIZE].rlim_cur;
if (limit != RLIM_INFINITY && offset > limit)
goto out_sig;
if (offset > inode->i_sb->s_maxbytes)
goto out_big;
i_size_write(inode, offset);
} else {
struct address_space *mapping = inode->i_mapping;
/*
* truncation of in-use swapfiles is disallowed - it would
* cause subsequent swapout to scribble on the now-freed
* blocks.
*/
if (IS_SWAPFILE(inode))
return -ETXTBSY;
i_size_write(inode, offset);
/*
* unmap_mapping_range is called twice, first simply for
* efficiency so that truncate_inode_pages does fewer
* single-page unmaps. However after this first call, and
* before truncate_inode_pages finishes, it is possible for
* private pages to be COWed, which remain after
* truncate_inode_pages finishes, hence the second
* unmap_mapping_range call must be made for correctness.
*/
unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
truncate_inode_pages(mapping, offset);
unmap_mapping_range(mapping, offset + PAGE_SIZE - 1, 0, 1);
}
if (inode->i_op && inode->i_op->truncate)
inode->i_op->truncate(inode);
return 0;
out_sig:
send_sig(SIGXFSZ, current, 0);
out_big:
return -EFBIG;
}
| 0
|
323,081
|
vcard_emul_login(VCard *card, unsigned char *pin, int pin_len)
{
PK11SlotInfo *slot;
unsigned char *pin_string = NULL;
int i;
SECStatus rv;
if (!nss_emul_init) {
return VCARD7816_STATUS_ERROR_CONDITION_NOT_SATISFIED;
}
slot = vcard_emul_card_get_slot(card);
/* We depend on the PKCS #11 module internal login state here because we
* create a separate process to handle each guest instance. If we needed
* to handle multiple guests from one process, then we would need to keep
* a lot of extra state in our card structure
* */
pin_string = g_malloc(pin_len+1);
memcpy(pin_string, pin, pin_len);
pin_string[pin_len] = 0;
/* handle CAC expanded pins correctly */
for (i = pin_len-1; i >= 0 && (pin_string[i] == 0xff); i--) {
pin_string[i] = 0;
}
rv = PK11_Authenticate(slot, PR_FALSE, pin_string);
memset(pin_string, 0, pin_len); /* don't let the pin hang around in memory
to be snooped */
g_free(pin_string);
if (rv == SECSuccess) {
return VCARD7816_STATUS_SUCCESS;
}
/* map the error from port get error */
return VCARD7816_STATUS_ERROR_CONDITION_NOT_SATISFIED;
}
| 0
|
7,640
|
static Image *ReadVIFFImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
#define VFF_CM_genericRGB 15
#define VFF_CM_ntscRGB 1
#define VFF_CM_NONE 0
#define VFF_DEP_DECORDER 0x4
#define VFF_DEP_NSORDER 0x8
#define VFF_DES_RAW 0
#define VFF_LOC_IMPLICIT 1
#define VFF_MAPTYP_NONE 0
#define VFF_MAPTYP_1_BYTE 1
#define VFF_MAPTYP_2_BYTE 2
#define VFF_MAPTYP_4_BYTE 4
#define VFF_MAPTYP_FLOAT 5
#define VFF_MAPTYP_DOUBLE 7
#define VFF_MS_NONE 0
#define VFF_MS_ONEPERBAND 1
#define VFF_MS_SHARED 3
#define VFF_TYP_BIT 0
#define VFF_TYP_1_BYTE 1
#define VFF_TYP_2_BYTE 2
#define VFF_TYP_4_BYTE 4
#define VFF_TYP_FLOAT 5
#define VFF_TYP_DOUBLE 9
typedef struct _ViffInfo
{
unsigned char
identifier,
file_type,
release,
version,
machine_dependency,
reserve[3];
char
comment[512];
unsigned int
rows,
columns,
subrows;
int
x_offset,
y_offset;
float
x_bits_per_pixel,
y_bits_per_pixel;
unsigned int
location_type,
location_dimension,
number_of_images,
number_data_bands,
data_storage_type,
data_encode_scheme,
map_scheme,
map_storage_type,
map_rows,
map_columns,
map_subrows,
map_enable,
maps_per_cycle,
color_space_model;
} ViffInfo;
double
min_value,
scale_factor,
value;
Image
*image;
int
bit;
MagickBooleanType
status;
MagickSizeType
number_pixels;
register ssize_t
x;
register Quantum
*q;
register ssize_t
i;
register unsigned char
*p;
size_t
bytes_per_pixel,
max_packets,
quantum;
ssize_t
count,
y;
unsigned char
*pixels;
unsigned long
lsb_first;
ViffInfo
viff_info;
/*
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,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Read VIFF header (1024 bytes).
*/
count=ReadBlob(image,1,&viff_info.identifier);
do
{
/*
Verify VIFF identifier.
*/
if ((count != 1) || ((unsigned char) viff_info.identifier != 0xab))
ThrowReaderException(CorruptImageError,"NotAVIFFImage");
/*
Initialize VIFF image.
*/
(void) ReadBlob(image,sizeof(viff_info.file_type),&viff_info.file_type);
(void) ReadBlob(image,sizeof(viff_info.release),&viff_info.release);
(void) ReadBlob(image,sizeof(viff_info.version),&viff_info.version);
(void) ReadBlob(image,sizeof(viff_info.machine_dependency),
&viff_info.machine_dependency);
(void) ReadBlob(image,sizeof(viff_info.reserve),viff_info.reserve);
count=ReadBlob(image,512,(unsigned char *) viff_info.comment);
viff_info.comment[511]='\0';
if (strlen(viff_info.comment) > 4)
(void) SetImageProperty(image,"comment",viff_info.comment,exception);
if ((viff_info.machine_dependency == VFF_DEP_DECORDER) ||
(viff_info.machine_dependency == VFF_DEP_NSORDER))
image->endian=LSBEndian;
else
image->endian=MSBEndian;
viff_info.rows=ReadBlobLong(image);
viff_info.columns=ReadBlobLong(image);
viff_info.subrows=ReadBlobLong(image);
viff_info.x_offset=ReadBlobSignedLong(image);
viff_info.y_offset=ReadBlobSignedLong(image);
viff_info.x_bits_per_pixel=(float) ReadBlobLong(image);
viff_info.y_bits_per_pixel=(float) ReadBlobLong(image);
viff_info.location_type=ReadBlobLong(image);
viff_info.location_dimension=ReadBlobLong(image);
viff_info.number_of_images=ReadBlobLong(image);
viff_info.number_data_bands=ReadBlobLong(image);
viff_info.data_storage_type=ReadBlobLong(image);
viff_info.data_encode_scheme=ReadBlobLong(image);
viff_info.map_scheme=ReadBlobLong(image);
viff_info.map_storage_type=ReadBlobLong(image);
viff_info.map_rows=ReadBlobLong(image);
viff_info.map_columns=ReadBlobLong(image);
viff_info.map_subrows=ReadBlobLong(image);
viff_info.map_enable=ReadBlobLong(image);
viff_info.maps_per_cycle=ReadBlobLong(image);
viff_info.color_space_model=ReadBlobLong(image);
for (i=0; i < 420; i++)
(void) ReadBlobByte(image);
if (EOFBlob(image) != MagickFalse)
ThrowReaderException(CorruptImageError,"UnexpectedEndOfFile");
image->columns=viff_info.rows;
image->rows=viff_info.columns;
image->depth=viff_info.x_bits_per_pixel <= 8 ? 8UL :
MAGICKCORE_QUANTUM_DEPTH;
/*
Verify that we can read this VIFF image.
*/
number_pixels=(MagickSizeType) viff_info.columns*viff_info.rows;
if (number_pixels != (size_t) number_pixels)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if (number_pixels == 0)
ThrowReaderException(CoderError,"ImageColumnOrRowSizeIsNotSupported");
if ((viff_info.number_data_bands < 1) || (viff_info.number_data_bands > 4))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
if ((viff_info.data_storage_type != VFF_TYP_BIT) &&
(viff_info.data_storage_type != VFF_TYP_1_BYTE) &&
(viff_info.data_storage_type != VFF_TYP_2_BYTE) &&
(viff_info.data_storage_type != VFF_TYP_4_BYTE) &&
(viff_info.data_storage_type != VFF_TYP_FLOAT) &&
(viff_info.data_storage_type != VFF_TYP_DOUBLE))
ThrowReaderException(CoderError,"DataStorageTypeIsNotSupported");
if (viff_info.data_encode_scheme != VFF_DES_RAW)
ThrowReaderException(CoderError,"DataEncodingSchemeIsNotSupported");
if ((viff_info.map_storage_type != VFF_MAPTYP_NONE) &&
(viff_info.map_storage_type != VFF_MAPTYP_1_BYTE) &&
(viff_info.map_storage_type != VFF_MAPTYP_2_BYTE) &&
(viff_info.map_storage_type != VFF_MAPTYP_4_BYTE) &&
(viff_info.map_storage_type != VFF_MAPTYP_FLOAT) &&
(viff_info.map_storage_type != VFF_MAPTYP_DOUBLE))
ThrowReaderException(CoderError,"MapStorageTypeIsNotSupported");
if ((viff_info.color_space_model != VFF_CM_NONE) &&
(viff_info.color_space_model != VFF_CM_ntscRGB) &&
(viff_info.color_space_model != VFF_CM_genericRGB))
ThrowReaderException(CoderError,"ColorspaceModelIsNotSupported");
if (viff_info.location_type != VFF_LOC_IMPLICIT)
ThrowReaderException(CoderError,"LocationTypeIsNotSupported");
if (viff_info.number_of_images != 1)
ThrowReaderException(CoderError,"NumberOfImagesIsNotSupported");
if (viff_info.map_rows == 0)
viff_info.map_scheme=VFF_MS_NONE;
switch ((int) viff_info.map_scheme)
{
case VFF_MS_NONE:
{
if (viff_info.number_data_bands < 3)
{
/*
Create linear color ramp.
*/
if (viff_info.data_storage_type == VFF_TYP_BIT)
image->colors=2;
else
if (viff_info.data_storage_type == VFF_MAPTYP_1_BYTE)
image->colors=256UL;
else
image->colors=image->depth <= 8 ? 256UL : 65536UL;
status=AcquireImageColormap(image,image->colors,exception);
if (status == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
}
break;
}
case VFF_MS_ONEPERBAND:
case VFF_MS_SHARED:
{
unsigned char
*viff_colormap;
/*
Allocate VIFF colormap.
*/
switch ((int) viff_info.map_storage_type)
{
case VFF_MAPTYP_1_BYTE: bytes_per_pixel=1; break;
case VFF_MAPTYP_2_BYTE: bytes_per_pixel=2; break;
case VFF_MAPTYP_4_BYTE: bytes_per_pixel=4; break;
case VFF_MAPTYP_FLOAT: bytes_per_pixel=4; break;
case VFF_MAPTYP_DOUBLE: bytes_per_pixel=8; break;
default: bytes_per_pixel=1; break;
}
image->colors=viff_info.map_columns;
if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if (viff_info.map_rows >
(viff_info.map_rows*bytes_per_pixel*sizeof(*viff_colormap)))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
viff_colormap=(unsigned char *) AcquireQuantumMemory(image->colors,
viff_info.map_rows*bytes_per_pixel*sizeof(*viff_colormap));
if (viff_colormap == (unsigned char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
/*
Read VIFF raster colormap.
*/
count=ReadBlob(image,bytes_per_pixel*image->colors*viff_info.map_rows,
viff_colormap);
lsb_first=1;
if (*(char *) &lsb_first &&
((viff_info.machine_dependency != VFF_DEP_DECORDER) &&
(viff_info.machine_dependency != VFF_DEP_NSORDER)))
switch ((int) viff_info.map_storage_type)
{
case VFF_MAPTYP_2_BYTE:
{
MSBOrderShort(viff_colormap,(bytes_per_pixel*image->colors*
viff_info.map_rows));
break;
}
case VFF_MAPTYP_4_BYTE:
case VFF_MAPTYP_FLOAT:
{
MSBOrderLong(viff_colormap,(bytes_per_pixel*image->colors*
viff_info.map_rows));
break;
}
default: break;
}
for (i=0; i < (ssize_t) (viff_info.map_rows*image->colors); i++)
{
switch ((int) viff_info.map_storage_type)
{
case VFF_MAPTYP_2_BYTE: value=1.0*((short *) viff_colormap)[i]; break;
case VFF_MAPTYP_4_BYTE: value=1.0*((int *) viff_colormap)[i]; break;
case VFF_MAPTYP_FLOAT: value=((float *) viff_colormap)[i]; break;
case VFF_MAPTYP_DOUBLE: value=((double *) viff_colormap)[i]; break;
default: value=1.0*viff_colormap[i]; break;
}
if (i < (ssize_t) image->colors)
{
image->colormap[i].red=ScaleCharToQuantum((unsigned char) value);
image->colormap[i].green=
ScaleCharToQuantum((unsigned char) value);
image->colormap[i].blue=ScaleCharToQuantum((unsigned char) value);
}
else
if (i < (ssize_t) (2*image->colors))
image->colormap[i % image->colors].green=
ScaleCharToQuantum((unsigned char) value);
else
if (i < (ssize_t) (3*image->colors))
image->colormap[i % image->colors].blue=
ScaleCharToQuantum((unsigned char) value);
}
viff_colormap=(unsigned char *) RelinquishMagickMemory(viff_colormap);
break;
}
default:
ThrowReaderException(CoderError,"ColormapTypeNotSupported");
}
/*
Initialize image structure.
*/
image->alpha_trait=viff_info.number_data_bands == 4 ? BlendPixelTrait :
UndefinedPixelTrait;
image->storage_class=(viff_info.number_data_bands < 3 ? PseudoClass :
DirectClass);
image->columns=viff_info.rows;
image->rows=viff_info.columns;
if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
return(DestroyImageList(image));
/*
Allocate VIFF pixels.
*/
switch ((int) viff_info.data_storage_type)
{
case VFF_TYP_2_BYTE: bytes_per_pixel=2; break;
case VFF_TYP_4_BYTE: bytes_per_pixel=4; break;
case VFF_TYP_FLOAT: bytes_per_pixel=4; break;
case VFF_TYP_DOUBLE: bytes_per_pixel=8; break;
default: bytes_per_pixel=1; break;
}
if (viff_info.data_storage_type == VFF_TYP_BIT)
{
if (CheckMemoryOverflow((image->columns+7UL) >> 3UL,image->rows) != MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
max_packets=((image->columns+7UL) >> 3UL)*image->rows;
}
else
{
if (CheckMemoryOverflow(number_pixels,viff_info.number_data_bands) != MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
max_packets=(size_t) (number_pixels*viff_info.number_data_bands);
}
pixels=(unsigned char *) AcquireQuantumMemory(MagickMax(number_pixels,
max_packets),bytes_per_pixel*sizeof(*pixels));
if (pixels == (unsigned char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
count=ReadBlob(image,bytes_per_pixel*max_packets,pixels);
lsb_first=1;
if (*(char *) &lsb_first &&
((viff_info.machine_dependency != VFF_DEP_DECORDER) &&
(viff_info.machine_dependency != VFF_DEP_NSORDER)))
switch ((int) viff_info.data_storage_type)
{
case VFF_TYP_2_BYTE:
{
MSBOrderShort(pixels,bytes_per_pixel*max_packets);
break;
}
case VFF_TYP_4_BYTE:
case VFF_TYP_FLOAT:
{
MSBOrderLong(pixels,bytes_per_pixel*max_packets);
break;
}
default: break;
}
min_value=0.0;
scale_factor=1.0;
if ((viff_info.data_storage_type != VFF_TYP_1_BYTE) &&
(viff_info.map_scheme == VFF_MS_NONE))
{
double
max_value;
/*
Determine scale factor.
*/
switch ((int) viff_info.data_storage_type)
{
case VFF_TYP_2_BYTE: value=1.0*((short *) pixels)[0]; break;
case VFF_TYP_4_BYTE: value=1.0*((int *) pixels)[0]; break;
case VFF_TYP_FLOAT: value=((float *) pixels)[0]; break;
case VFF_TYP_DOUBLE: value=((double *) pixels)[0]; break;
default: value=1.0*pixels[0]; break;
}
max_value=value;
min_value=value;
for (i=0; i < (ssize_t) max_packets; i++)
{
switch ((int) viff_info.data_storage_type)
{
case VFF_TYP_2_BYTE: value=1.0*((short *) pixels)[i]; break;
case VFF_TYP_4_BYTE: value=1.0*((int *) pixels)[i]; break;
case VFF_TYP_FLOAT: value=((float *) pixels)[i]; break;
case VFF_TYP_DOUBLE: value=((double *) pixels)[i]; break;
default: value=1.0*pixels[i]; break;
}
if (value > max_value)
max_value=value;
else
if (value < min_value)
min_value=value;
}
if ((min_value == 0) && (max_value == 0))
scale_factor=0;
else
if (min_value == max_value)
{
scale_factor=(double) QuantumRange/min_value;
min_value=0;
}
else
scale_factor=(double) QuantumRange/(max_value-min_value);
}
/*
Convert pixels to Quantum size.
*/
p=(unsigned char *) pixels;
for (i=0; i < (ssize_t) max_packets; i++)
{
switch ((int) viff_info.data_storage_type)
{
case VFF_TYP_2_BYTE: value=1.0*((short *) pixels)[i]; break;
case VFF_TYP_4_BYTE: value=1.0*((int *) pixels)[i]; break;
case VFF_TYP_FLOAT: value=((float *) pixels)[i]; break;
case VFF_TYP_DOUBLE: value=((double *) pixels)[i]; break;
default: value=1.0*pixels[i]; break;
}
if (viff_info.map_scheme == VFF_MS_NONE)
{
value=(value-min_value)*scale_factor;
if (value > QuantumRange)
value=QuantumRange;
else
if (value < 0)
value=0;
}
*p=(unsigned char) ((Quantum) value);
p++;
}
/*
Convert VIFF raster image to pixel packets.
*/
p=(unsigned char *) pixels;
if (viff_info.data_storage_type == VFF_TYP_BIT)
{
/*
Convert bitmap scanline.
*/
for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) (image->columns-7); x+=8)
{
for (bit=0; bit < 8; bit++)
{
quantum=(size_t) ((*p) & (0x01 << bit) ? 0 : 1);
SetPixelRed(image,quantum == 0 ? 0 : QuantumRange,q);
SetPixelGreen(image,quantum == 0 ? 0 : QuantumRange,q);
SetPixelBlue(image,quantum == 0 ? 0 : QuantumRange,q);
if (image->storage_class == PseudoClass)
SetPixelIndex(image,(Quantum) quantum,q);
q+=GetPixelChannels(image);
}
p++;
}
if ((image->columns % 8) != 0)
{
for (bit=0; bit < (int) (image->columns % 8); bit++)
{
quantum=(size_t) ((*p) & (0x01 << bit) ? 0 : 1);
SetPixelRed(image,quantum == 0 ? 0 : QuantumRange,q);
SetPixelGreen(image,quantum == 0 ? 0 : QuantumRange,q);
SetPixelBlue(image,quantum == 0 ? 0 : QuantumRange,q);
if (image->storage_class == PseudoClass)
SetPixelIndex(image,(Quantum) quantum,q);
q+=GetPixelChannels(image);
}
p++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
}
else
if (image->storage_class == PseudoClass)
for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelIndex(image,*p++,q);
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
else
{
/*
Convert DirectColor scanline.
*/
number_pixels=(MagickSizeType) image->columns*image->rows;
for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelRed(image,ScaleCharToQuantum(*p),q);
SetPixelGreen(image,ScaleCharToQuantum(*(p+number_pixels)),q);
SetPixelBlue(image,ScaleCharToQuantum(*(p+2*number_pixels)),q);
if (image->colors != 0)
{
ssize_t
index;
index=(ssize_t) GetPixelRed(image,q);
SetPixelRed(image,image->colormap[
ConstrainColormapIndex(image,index,exception)].red,q);
index=(ssize_t) GetPixelGreen(image,q);
SetPixelGreen(image,image->colormap[
ConstrainColormapIndex(image,index,exception)].green,q);
index=(ssize_t) GetPixelBlue(image,q);
SetPixelBlue(image,image->colormap[
ConstrainColormapIndex(image,index,exception)].blue,q);
}
SetPixelAlpha(image,image->alpha_trait != UndefinedPixelTrait ?
ScaleCharToQuantum(*(p+number_pixels*3)) : OpaqueAlpha,q);
p++;
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
image->rows);
if (status == MagickFalse)
break;
}
}
}
pixels=(unsigned char *) RelinquishMagickMemory(pixels);
if (image->storage_class == PseudoClass)
(void) SyncImage(image,exception);
if (EOFBlob(image) != MagickFalse)
{
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
break;
}
/*
Proceed to next image.
*/
if (image_info->number_scenes != 0)
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
count=ReadBlob(image,1,&viff_info.identifier);
if ((count != 0) && (viff_info.identifier == 0xab))
{
/*
Allocate next image structure.
*/
AcquireNextImage(image_info,image,exception);
if (GetNextImageInList(image) == (Image *) NULL)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
image=SyncNextImageInList(image);
status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
GetBlobSize(image));
if (status == MagickFalse)
break;
}
} while ((count != 0) && (viff_info.identifier == 0xab));
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
| 1
|
97,491
|
static opj_pi_iterator_t * opj_pi_create(const opj_image_t *image,
const opj_cp_t *cp,
OPJ_UINT32 tileno)
{
/* loop*/
OPJ_UINT32 pino, compno;
/* number of poc in the p_pi*/
OPJ_UINT32 l_poc_bound;
/* pointers to tile coding parameters and components.*/
opj_pi_iterator_t *l_pi = 00;
opj_tcp_t *tcp = 00;
const opj_tccp_t *tccp = 00;
/* current packet iterator being allocated*/
opj_pi_iterator_t *l_current_pi = 00;
/* preconditions in debug*/
assert(cp != 00);
assert(image != 00);
assert(tileno < cp->tw * cp->th);
/* initializations*/
tcp = &cp->tcps[tileno];
l_poc_bound = tcp->numpocs + 1;
/* memory allocations*/
l_pi = (opj_pi_iterator_t*) opj_calloc((l_poc_bound),
sizeof(opj_pi_iterator_t));
if (!l_pi) {
return NULL;
}
l_current_pi = l_pi;
for (pino = 0; pino < l_poc_bound ; ++pino) {
l_current_pi->comps = (opj_pi_comp_t*) opj_calloc(image->numcomps,
sizeof(opj_pi_comp_t));
if (! l_current_pi->comps) {
opj_pi_destroy(l_pi, l_poc_bound);
return NULL;
}
l_current_pi->numcomps = image->numcomps;
for (compno = 0; compno < image->numcomps; ++compno) {
opj_pi_comp_t *comp = &l_current_pi->comps[compno];
tccp = &tcp->tccps[compno];
comp->resolutions = (opj_pi_resolution_t*) opj_calloc(tccp->numresolutions,
sizeof(opj_pi_resolution_t));
if (!comp->resolutions) {
opj_pi_destroy(l_pi, l_poc_bound);
return 00;
}
comp->numresolutions = tccp->numresolutions;
}
++l_current_pi;
}
return l_pi;
}
| 0
|
254,389
|
void FrameView::flushAnyPendingPostLayoutTasks()
{
ASSERT(!isInPerformLayout());
if (m_postLayoutTasksTimer.isActive())
performPostLayoutTasks();
if (m_updateWidgetsTimer.isActive())
updateWidgetsTimerFired(0);
}
| 0
|
114,278
|
PGTYPEStimestamp_add_interval(timestamp * tin, interval * span, timestamp * tout)
{
if (TIMESTAMP_NOT_FINITE(*tin))
*tout = *tin;
else
{
if (span->month != 0)
{
struct tm tt,
*tm = &tt;
fsec_t fsec;
if (timestamp2tm(*tin, NULL, tm, &fsec, NULL) != 0)
return -1;
tm->tm_mon += span->month;
if (tm->tm_mon > MONTHS_PER_YEAR)
{
tm->tm_year += (tm->tm_mon - 1) / MONTHS_PER_YEAR;
tm->tm_mon = (tm->tm_mon - 1) % MONTHS_PER_YEAR + 1;
}
else if (tm->tm_mon < 1)
{
tm->tm_year += tm->tm_mon / MONTHS_PER_YEAR - 1;
tm->tm_mon = tm->tm_mon % MONTHS_PER_YEAR + MONTHS_PER_YEAR;
}
/* adjust for end of month boundary problems... */
if (tm->tm_mday > day_tab[isleap(tm->tm_year)][tm->tm_mon - 1])
tm->tm_mday = (day_tab[isleap(tm->tm_year)][tm->tm_mon - 1]);
if (tm2timestamp(tm, fsec, NULL, tin) != 0)
return -1;
}
*tin += span->time;
*tout = *tin;
}
return 0;
}
| 0
|
252,676
|
virtual bool ethernet_enabled() const {
return enabled_devices_ & (1 << TYPE_ETHERNET);
}
| 0
|
469,456
|
static void intel_hda_set_ics(IntelHDAState *d, const IntelHDAReg *reg, uint32_t old)
{
if (d->ics & ICH6_IRS_BUSY) {
intel_hda_corb_run(d);
}
}
| 0
|
460,967
|
vmxnet3_read_next_rx_descr(VMXNET3State *s, int qidx, int ridx,
struct Vmxnet3_RxDesc *dbuf, uint32_t *didx)
{
PCIDevice *d = PCI_DEVICE(s);
Vmxnet3Ring *ring = &s->rxq_descr[qidx].rx_ring[ridx];
*didx = vmxnet3_ring_curr_cell_idx(ring);
vmxnet3_ring_read_curr_cell(d, ring, dbuf);
dbuf->addr = le64_to_cpu(dbuf->addr);
dbuf->val1 = le32_to_cpu(dbuf->val1);
dbuf->ext1 = le32_to_cpu(dbuf->ext1);
}
| 0
|
249,163
|
void AudioRendererHost::OnPlayStream(int stream_id) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
AudioOutputDelegate* delegate = LookupById(stream_id);
if (!delegate) {
SendErrorMessage(stream_id);
return;
}
delegate->OnPlayStream();
}
| 0
|
325,398
|
static void virtio_blk_rw_complete(void *opaque, int ret)
{
VirtIOBlockReq *req = opaque;
trace_virtio_blk_rw_complete(req, ret);
if (ret) {
int p = virtio_ldl_p(VIRTIO_DEVICE(req->dev), &req->out.type);
bool is_read = !(p & VIRTIO_BLK_T_OUT);
if (virtio_blk_handle_rw_error(req, -ret, is_read))
return;
}
virtio_blk_req_complete(req, VIRTIO_BLK_S_OK);
block_acct_done(bdrv_get_stats(req->dev->bs), &req->acct);
virtio_blk_free_request(req);
}
| 0
|
149,541
|
void inet_csk_reset_keepalive_timer(struct sock *sk, unsigned long len)
{
sk_reset_timer(sk, &sk->sk_timer, jiffies + len);
}
| 0
|
10,810
|
void PluginChannel::OnChannelError() {
base::CloseProcessHandle(renderer_handle_);
renderer_handle_ = 0;
NPChannelBase::OnChannelError();
CleanUp();
}
| 1
|
426,197
|
flatpak_add_bus_filters (GPtrArray *dbus_proxy_argv,
GHashTable *ht,
const char *app_id,
FlatpakContext *context)
{
GHashTableIter iter;
gpointer key, value;
g_ptr_array_add (dbus_proxy_argv, g_strdup ("--filter"));
if (app_id)
{
g_ptr_array_add (dbus_proxy_argv, g_strdup_printf ("--own=%s", app_id));
g_ptr_array_add (dbus_proxy_argv, g_strdup_printf ("--own=%s.*", app_id));
}
g_hash_table_iter_init (&iter, ht);
while (g_hash_table_iter_next (&iter, &key, &value))
{
FlatpakPolicy policy = GPOINTER_TO_INT (value);
if (policy > 0)
g_ptr_array_add (dbus_proxy_argv, g_strdup_printf ("--%s=%s", flatpak_policy_to_string (policy), (char *) key));
}
}
| 0
|
202,421
|
void InputDispatcher::traceWaitQueueLengthLocked(const sp<Connection>& connection) {
if (ATRACE_ENABLED()) {
char counterName[40];
snprintf(counterName, sizeof(counterName), "wq:%s", connection->getWindowName());
ATRACE_INT(counterName, connection->waitQueue.count());
}
}
| 0
|
89,562
|
//! Estimate displacement field between two images \newinstance.
CImg<floatT> get_displacement(const CImg<T>& source,
const float smoothness=0.1f, const float precision=5.f,
const unsigned int nb_scales=0, const unsigned int iteration_max=10000,
const bool is_backward=false,
const CImg<floatT>& guide=CImg<floatT>::const_empty()) const {
if (is_empty() || !source) return +*this;
if (!is_sameXYZC(source))
throw CImgArgumentException(_cimg_instance
"displacement(): Instance and source image (%u,%u,%u,%u,%p) have "
"different dimensions.",
cimg_instance,
source._width,source._height,source._depth,source._spectrum,source._data);
if (precision<0)
throw CImgArgumentException(_cimg_instance
"displacement(): Invalid specified precision %g "
"(should be >=0)",
cimg_instance,
precision);
const bool is_3d = source._depth>1;
const unsigned int constraint = is_3d?3:2;
if (guide &&
(guide._width!=_width || guide._height!=_height || guide._depth!=_depth || guide._spectrum<constraint))
throw CImgArgumentException(_cimg_instance
"displacement(): Specified guide (%u,%u,%u,%u,%p) "
"has invalid dimensions.",
cimg_instance,
guide._width,guide._height,guide._depth,guide._spectrum,guide._data);
const unsigned int
mins = is_3d?cimg::min(_width,_height,_depth):std::min(_width,_height),
_nb_scales = nb_scales>0?nb_scales:
(unsigned int)cimg::round(std::log(mins/8.)/std::log(1.5),1,1);
const float _precision = (float)std::pow(10.,-(double)precision);
float sm, sM = source.max_min(sm), tm, tM = max_min(tm);
const float sdelta = sm==sM?1:(sM - sm), tdelta = tm==tM?1:(tM - tm);
CImg<floatT> U, V;
floatT bound = 0;
for (int scale = (int)_nb_scales - 1; scale>=0; --scale) {
const float factor = (float)std::pow(1.5,(double)scale);
const unsigned int
_sw = (unsigned int)(_width/factor), sw = _sw?_sw:1,
_sh = (unsigned int)(_height/factor), sh = _sh?_sh:1,
_sd = (unsigned int)(_depth/factor), sd = _sd?_sd:1;
if (sw<5 && sh<5 && (!is_3d || sd<5)) continue; // Skip too small scales
const CImg<Tfloat>
I1 = (source.get_resize(sw,sh,sd,-100,2)-=sm)/=sdelta,
I2 = (get_resize(I1,2)-=tm)/=tdelta;
if (guide._spectrum>constraint) guide.get_resize(I2._width,I2._height,I2._depth,-100,1).move_to(V);
if (U) (U*=1.5f).resize(I2._width,I2._height,I2._depth,-100,3);
else {
if (guide)
guide.get_shared_channels(0,is_3d?2:1).get_resize(I2._width,I2._height,I2._depth,-100,2).move_to(U);
else U.assign(I2._width,I2._height,I2._depth,is_3d?3:2,0);
}
float dt = 2, energy = cimg::type<float>::max();
const CImgList<Tfloat> dI = is_backward?I1.get_gradient():I2.get_gradient();
cimg_abort_init;
for (unsigned int iteration = 0; iteration<iteration_max; ++iteration) {
cimg_abort_test;
float _energy = 0;
if (is_3d) { // 3D version
if (smoothness>=0) // Isotropic regularization
cimg_pragma_openmp(parallel for cimg_openmp_collapse(2)
cimg_openmp_if(_height*_depth>=(cimg_openmp_sizefactor)*8 &&
_width>=(cimg_openmp_sizefactor)*16)
reduction(+:_energy))
cimg_forYZ(U,y,z) {
const int
_p1y = y?y - 1:0, _n1y = y<U.height() - 1?y + 1:y,
_p1z = z?z - 1:0, _n1z = z<U.depth() - 1?z + 1:z;
cimg_for3X(U,x) {
const float
X = is_backward?x - U(x,y,z,0):x + U(x,y,z,0),
Y = is_backward?y - U(x,y,z,1):y + U(x,y,z,1),
Z = is_backward?z - U(x,y,z,2):z + U(x,y,z,2);
float delta_I = 0, _energy_regul = 0;
if (is_backward) cimg_forC(I2,c) delta_I+=(float)(I1._linear_atXYZ(X,Y,Z,c) - I2(x,y,z,c));
else cimg_forC(I2,c) delta_I+=(float)(I1(x,y,z,c) - I2._linear_atXYZ(X,Y,Z,c));
cimg_forC(U,c) {
const float
Ux = 0.5f*(U(_n1x,y,z,c) - U(_p1x,y,z,c)),
Uy = 0.5f*(U(x,_n1y,z,c) - U(x,_p1y,z,c)),
Uz = 0.5f*(U(x,y,_n1z,c) - U(x,y,_p1z,c)),
Uxx = U(_n1x,y,z,c) + U(_p1x,y,z,c),
Uyy = U(x,_n1y,z,c) + U(x,_p1y,z,c),
Uzz = U(x,y,_n1z,c) + U(x,y,_p1z,c);
U(x,y,z,c) = (float)(U(x,y,z,c) + dt*(delta_I*dI[c]._linear_atXYZ(X,Y,Z) +
smoothness* ( Uxx + Uyy + Uzz)))/(1 + 6*smoothness*dt);
_energy_regul+=Ux*Ux + Uy*Uy + Uz*Uz;
}
if (is_backward) { // Constraint displacement vectors to stay in image
if (U(x,y,z,0)>x) U(x,y,z,0) = (float)x;
if (U(x,y,z,1)>y) U(x,y,z,1) = (float)y;
if (U(x,y,z,2)>z) U(x,y,z,2) = (float)z;
bound = (float)x - _width; if (U(x,y,z,0)<=bound) U(x,y,z,0) = bound;
bound = (float)y - _height; if (U(x,y,z,1)<=bound) U(x,y,z,1) = bound;
bound = (float)z - _depth; if (U(x,y,z,2)<=bound) U(x,y,z,2) = bound;
} else {
if (U(x,y,z,0)<-x) U(x,y,z,0) = -(float)x;
if (U(x,y,z,1)<-y) U(x,y,z,1) = -(float)y;
if (U(x,y,z,2)<-z) U(x,y,z,2) = -(float)z;
bound = (float)_width - x; if (U(x,y,z,0)>=bound) U(x,y,z,0) = bound;
bound = (float)_height - y; if (U(x,y,z,1)>=bound) U(x,y,z,1) = bound;
bound = (float)_depth - z; if (U(x,y,z,2)>=bound) U(x,y,z,2) = bound;
}
_energy+=delta_I*delta_I + smoothness*_energy_regul;
}
if (V) cimg_forXYZ(V,_x,_y,_z) if (V(_x,_y,_z,3)) { // Apply constraints
U(_x,_y,_z,0) = V(_x,_y,_z,0)/factor;
U(_x,_y,_z,1) = V(_x,_y,_z,1)/factor;
U(_x,_y,_z,2) = V(_x,_y,_z,2)/factor;
}
} else { // Anisotropic regularization
const float nsmoothness = -smoothness;
cimg_pragma_openmp(parallel for cimg_openmp_collapse(2)
cimg_openmp_if(_height*_depth>=(cimg_openmp_sizefactor)*8 &&
_width>=(cimg_openmp_sizefactor)*16)
reduction(+:_energy))
cimg_forYZ(U,y,z) {
const int
_p1y = y?y - 1:0, _n1y = y<U.height() - 1?y + 1:y,
_p1z = z?z - 1:0, _n1z = z<U.depth() - 1?z + 1:z;
cimg_for3X(U,x) {
const float
X = is_backward?x - U(x,y,z,0):x + U(x,y,z,0),
Y = is_backward?y - U(x,y,z,1):y + U(x,y,z,1),
Z = is_backward?z - U(x,y,z,2):z + U(x,y,z,2);
float delta_I = 0, _energy_regul = 0;
if (is_backward) cimg_forC(I2,c) delta_I+=(float)(I1._linear_atXYZ(X,Y,Z,c) - I2(x,y,z,c));
else cimg_forC(I2,c) delta_I+=(float)(I1(x,y,z,c) - I2._linear_atXYZ(X,Y,Z,c));
cimg_forC(U,c) {
const float
Ux = 0.5f*(U(_n1x,y,z,c) - U(_p1x,y,z,c)),
Uy = 0.5f*(U(x,_n1y,z,c) - U(x,_p1y,z,c)),
Uz = 0.5f*(U(x,y,_n1z,c) - U(x,y,_p1z,c)),
N2 = Ux*Ux + Uy*Uy + Uz*Uz,
N = std::sqrt(N2),
N3 = 1e-5f + N2*N,
coef_a = (1 - Ux*Ux/N2)/N,
coef_b = -2*Ux*Uy/N3,
coef_c = -2*Ux*Uz/N3,
coef_d = (1 - Uy*Uy/N2)/N,
coef_e = -2*Uy*Uz/N3,
coef_f = (1 - Uz*Uz/N2)/N,
Uxx = U(_n1x,y,z,c) + U(_p1x,y,z,c),
Uyy = U(x,_n1y,z,c) + U(x,_p1y,z,c),
Uzz = U(x,y,_n1z,c) + U(x,y,_p1z,c),
Uxy = 0.25f*(U(_n1x,_n1y,z,c) + U(_p1x,_p1y,z,c) - U(_n1x,_p1y,z,c) - U(_n1x,_p1y,z,c)),
Uxz = 0.25f*(U(_n1x,y,_n1z,c) + U(_p1x,y,_p1z,c) - U(_n1x,y,_p1z,c) - U(_n1x,y,_p1z,c)),
Uyz = 0.25f*(U(x,_n1y,_n1z,c) + U(x,_p1y,_p1z,c) - U(x,_n1y,_p1z,c) - U(x,_n1y,_p1z,c));
U(x,y,z,c) = (float)(U(x,y,z,c) + dt*(delta_I*dI[c]._linear_atXYZ(X,Y,Z) +
nsmoothness* ( coef_a*Uxx + coef_b*Uxy +
coef_c*Uxz + coef_d*Uyy +
coef_e*Uyz + coef_f*Uzz ))
)/(1 + 2*(coef_a + coef_d + coef_f)*nsmoothness*dt);
_energy_regul+=N;
}
if (is_backward) { // Constraint displacement vectors to stay in image
if (U(x,y,z,0)>x) U(x,y,z,0) = (float)x;
if (U(x,y,z,1)>y) U(x,y,z,1) = (float)y;
if (U(x,y,z,2)>z) U(x,y,z,2) = (float)z;
bound = (float)x - _width; if (U(x,y,z,0)<=bound) U(x,y,z,0) = bound;
bound = (float)y - _height; if (U(x,y,z,1)<=bound) U(x,y,z,1) = bound;
bound = (float)z - _depth; if (U(x,y,z,2)<=bound) U(x,y,z,2) = bound;
} else {
if (U(x,y,z,0)<-x) U(x,y,z,0) = -(float)x;
if (U(x,y,z,1)<-y) U(x,y,z,1) = -(float)y;
if (U(x,y,z,2)<-z) U(x,y,z,2) = -(float)z;
bound = (float)_width - x; if (U(x,y,z,0)>=bound) U(x,y,z,0) = bound;
bound = (float)_height - y; if (U(x,y,z,1)>=bound) U(x,y,z,1) = bound;
bound = (float)_depth - z; if (U(x,y,z,2)>=bound) U(x,y,z,2) = bound;
}
_energy+=delta_I*delta_I + nsmoothness*_energy_regul;
}
if (V) cimg_forXYZ(V,_x,_y,_z) if (V(_x,_y,_z,3)) { // Apply constraints
U(_x,_y,_z,0) = V(_x,_y,_z,0)/factor;
U(_x,_y,_z,1) = V(_x,_y,_z,1)/factor;
U(_x,_y,_z,2) = V(_x,_y,_z,2)/factor;
}
}
}
} else { // 2D version
if (smoothness>=0) // Isotropic regularization
cimg_pragma_openmp(parallel for cimg_openmp_if(_height>=(cimg_openmp_sizefactor)*8 &&
_width>=(cimg_openmp_sizefactor)*16) reduction(+:_energy))
cimg_forY(U,y) {
const int _p1y = y?y - 1:0, _n1y = y<U.height() - 1?y + 1:y;
cimg_for3X(U,x) {
const float
X = is_backward?x - U(x,y,0):x + U(x,y,0),
Y = is_backward?y - U(x,y,1):y + U(x,y,1);
float delta_I = 0, _energy_regul = 0;
if (is_backward) cimg_forC(I2,c) delta_I+=(float)(I1._linear_atXY(X,Y,c) - I2(x,y,c));
else cimg_forC(I2,c) delta_I+=(float)(I1(x,y,c) - I2._linear_atXY(X,Y,c));
cimg_forC(U,c) {
const float
Ux = 0.5f*(U(_n1x,y,c) - U(_p1x,y,c)),
Uy = 0.5f*(U(x,_n1y,c) - U(x,_p1y,c)),
Uxx = U(_n1x,y,c) + U(_p1x,y,c),
Uyy = U(x,_n1y,c) + U(x,_p1y,c);
U(x,y,c) = (float)(U(x,y,c) + dt*(delta_I*dI[c]._linear_atXY(X,Y) +
smoothness*( Uxx + Uyy )))/(1 + 4*smoothness*dt);
_energy_regul+=Ux*Ux + Uy*Uy;
}
if (is_backward) { // Constraint displacement vectors to stay in image
if (U(x,y,0)>x) U(x,y,0) = (float)x;
if (U(x,y,1)>y) U(x,y,1) = (float)y;
bound = (float)x - _width; if (U(x,y,0)<=bound) U(x,y,0) = bound;
bound = (float)y - _height; if (U(x,y,1)<=bound) U(x,y,1) = bound;
} else {
if (U(x,y,0)<-x) U(x,y,0) = -(float)x;
if (U(x,y,1)<-y) U(x,y,1) = -(float)y;
bound = (float)_width - x; if (U(x,y,0)>=bound) U(x,y,0) = bound;
bound = (float)_height - y; if (U(x,y,1)>=bound) U(x,y,1) = bound;
}
_energy+=delta_I*delta_I + smoothness*_energy_regul;
}
if (V) cimg_forXY(V,_x,_y) if (V(_x,_y,2)) { // Apply constraints
U(_x,_y,0) = V(_x,_y,0)/factor;
U(_x,_y,1) = V(_x,_y,1)/factor;
}
} else { // Anisotropic regularization
const float nsmoothness = -smoothness;
cimg_pragma_openmp(parallel for cimg_openmp_if(_height>=(cimg_openmp_sizefactor)*8 &&
_width>=(cimg_openmp_sizefactor)*16) reduction(+:_energy))
cimg_forY(U,y) {
const int _p1y = y?y - 1:0, _n1y = y<U.height() - 1?y + 1:y;
cimg_for3X(U,x) {
const float
X = is_backward?x - U(x,y,0):x + U(x,y,0),
Y = is_backward?y - U(x,y,1):y + U(x,y,1);
float delta_I = 0, _energy_regul = 0;
if (is_backward) cimg_forC(I2,c) delta_I+=(float)(I1._linear_atXY(X,Y,c) - I2(x,y,c));
else cimg_forC(I2,c) delta_I+=(float)(I1(x,y,c) - I2._linear_atXY(X,Y,c));
cimg_forC(U,c) {
const float
Ux = 0.5f*(U(_n1x,y,c) - U(_p1x,y,c)),
Uy = 0.5f*(U(x,_n1y,c) - U(x,_p1y,c)),
N2 = Ux*Ux + Uy*Uy,
N = std::sqrt(N2),
N3 = 1e-5f + N2*N,
coef_a = Uy*Uy/N3,
coef_b = -2*Ux*Uy/N3,
coef_c = Ux*Ux/N3,
Uxx = U(_n1x,y,c) + U(_p1x,y,c),
Uyy = U(x,_n1y,c) + U(x,_p1y,c),
Uxy = 0.25f*(U(_n1x,_n1y,c) + U(_p1x,_p1y,c) - U(_n1x,_p1y,c) - U(_n1x,_p1y,c));
U(x,y,c) = (float)(U(x,y,c) + dt*(delta_I*dI[c]._linear_atXY(X,Y) +
nsmoothness*( coef_a*Uxx + coef_b*Uxy + coef_c*Uyy )))/
(1 + 2*(coef_a + coef_c)*nsmoothness*dt);
_energy_regul+=N;
}
if (is_backward) { // Constraint displacement vectors to stay in image
if (U(x,y,0)>x) U(x,y,0) = (float)x;
if (U(x,y,1)>y) U(x,y,1) = (float)y;
bound = (float)x - _width; if (U(x,y,0)<=bound) U(x,y,0) = bound;
bound = (float)y - _height; if (U(x,y,1)<=bound) U(x,y,1) = bound;
} else {
if (U(x,y,0)<-x) U(x,y,0) = -(float)x;
if (U(x,y,1)<-y) U(x,y,1) = -(float)y;
bound = (float)_width - x; if (U(x,y,0)>=bound) U(x,y,0) = bound;
bound = (float)_height - y; if (U(x,y,1)>=bound) U(x,y,1) = bound;
}
_energy+=delta_I*delta_I + nsmoothness*_energy_regul;
}
if (V) cimg_forXY(V,_x,_y) if (V(_x,_y,2)) { // Apply constraints
U(_x,_y,0) = V(_x,_y,0)/factor;
U(_x,_y,1) = V(_x,_y,1)/factor;
}
}
}
}
const float d_energy = (_energy - energy)/(sw*sh*sd);
if (d_energy<=0 && -d_energy<_precision) break;
if (d_energy>0) dt*=0.5f;
energy = _energy;
}
}
return U;
| 0
|
331,308
|
static void rtsp_cmd_setup(HTTPContext *c, const char *url,
RTSPHeader *h)
{
FFStream *stream;
int stream_index, port;
char buf[1024];
char path1[1024];
const char *path;
HTTPContext *rtp_c;
RTSPTransportField *th;
struct sockaddr_in dest_addr;
RTSPActionServerSetup setup;
/* find which url is asked */
url_split(NULL, 0, NULL, 0, NULL, 0, NULL, path1, sizeof(path1), url);
path = path1;
if (*path == '/')
path++;
/* now check each stream */
for(stream = first_stream; stream != NULL; stream = stream->next) {
if (!stream->is_feed && !strcmp(stream->fmt->name, "rtp")) {
/* accept aggregate filenames only if single stream */
if (!strcmp(path, stream->filename)) {
if (stream->nb_streams != 1) {
rtsp_reply_error(c, RTSP_STATUS_AGGREGATE);
return;
}
stream_index = 0;
goto found;
}
for(stream_index = 0; stream_index < stream->nb_streams;
stream_index++) {
snprintf(buf, sizeof(buf), "%s/streamid=%d",
stream->filename, stream_index);
if (!strcmp(path, buf))
goto found;
}
}
}
/* no stream found */
rtsp_reply_error(c, RTSP_STATUS_SERVICE); /* XXX: right error ? */
return;
found:
/* generate session id if needed */
if (h->session_id[0] == '\0')
snprintf(h->session_id, sizeof(h->session_id), "%08x%08x",
av_random(&random_state), av_random(&random_state));
/* find rtp session, and create it if none found */
rtp_c = find_rtp_session(h->session_id);
if (!rtp_c) {
/* always prefer UDP */
th = find_transport(h, RTSP_PROTOCOL_RTP_UDP);
if (!th) {
th = find_transport(h, RTSP_PROTOCOL_RTP_TCP);
if (!th) {
rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);
return;
}
}
rtp_c = rtp_new_connection(&c->from_addr, stream, h->session_id,
th->protocol);
if (!rtp_c) {
rtsp_reply_error(c, RTSP_STATUS_BANDWIDTH);
return;
}
/* open input stream */
if (open_input_stream(rtp_c, "") < 0) {
rtsp_reply_error(c, RTSP_STATUS_INTERNAL);
return;
}
}
/* test if stream is OK (test needed because several SETUP needs
to be done for a given file) */
if (rtp_c->stream != stream) {
rtsp_reply_error(c, RTSP_STATUS_SERVICE);
return;
}
/* test if stream is already set up */
if (rtp_c->rtp_ctx[stream_index]) {
rtsp_reply_error(c, RTSP_STATUS_STATE);
return;
}
/* check transport */
th = find_transport(h, rtp_c->rtp_protocol);
if (!th || (th->protocol == RTSP_PROTOCOL_RTP_UDP &&
th->client_port_min <= 0)) {
rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);
return;
}
/* setup default options */
setup.transport_option[0] = '\0';
dest_addr = rtp_c->from_addr;
dest_addr.sin_port = htons(th->client_port_min);
/* setup stream */
if (rtp_new_av_stream(rtp_c, stream_index, &dest_addr, c) < 0) {
rtsp_reply_error(c, RTSP_STATUS_TRANSPORT);
return;
}
/* now everything is OK, so we can send the connection parameters */
rtsp_reply_header(c, RTSP_STATUS_OK);
/* session ID */
url_fprintf(c->pb, "Session: %s\r\n", rtp_c->session_id);
switch(rtp_c->rtp_protocol) {
case RTSP_PROTOCOL_RTP_UDP:
port = rtp_get_local_port(rtp_c->rtp_handles[stream_index]);
url_fprintf(c->pb, "Transport: RTP/AVP/UDP;unicast;"
"client_port=%d-%d;server_port=%d-%d",
th->client_port_min, th->client_port_min + 1,
port, port + 1);
break;
case RTSP_PROTOCOL_RTP_TCP:
url_fprintf(c->pb, "Transport: RTP/AVP/TCP;interleaved=%d-%d",
stream_index * 2, stream_index * 2 + 1);
break;
default:
break;
}
if (setup.transport_option[0] != '\0')
url_fprintf(c->pb, ";%s", setup.transport_option);
url_fprintf(c->pb, "\r\n");
url_fprintf(c->pb, "\r\n");
}
| 1
|
368,643
|
dirvote_get_start_of_next_interval(time_t now, int interval)
{
struct tm tm;
time_t midnight_today=0;
time_t midnight_tomorrow;
time_t next;
tor_gmtime_r(&now, &tm);
tm.tm_hour = 0;
tm.tm_min = 0;
tm.tm_sec = 0;
if (tor_timegm(&tm, &midnight_today) < 0) {
log_warn(LD_BUG, "Ran into an invalid time when trying to find midnight.");
}
midnight_tomorrow = midnight_today + (24*60*60);
next = midnight_today + ((now-midnight_today)/interval + 1)*interval;
/* Intervals never cross midnight. */
if (next > midnight_tomorrow)
next = midnight_tomorrow;
/* If the interval would only last half as long as it's supposed to, then
* skip over to the next day. */
if (next + interval/2 > midnight_tomorrow)
next = midnight_tomorrow;
return next;
}
| 0
|
423,568
|
dns_zone_setviewrevert(dns_zone_t *zone) {
REQUIRE(DNS_ZONE_VALID(zone));
LOCK_ZONE(zone);
if (zone->prev_view != NULL) {
dns_zone_setview_helper(zone, zone->prev_view);
dns_view_weakdetach(&zone->prev_view);
}
UNLOCK_ZONE(zone);
}
| 0
|
495,455
|
njs_string_prototype_to_lower_case(njs_vm_t *vm, njs_value_t *args,
njs_uint_t nargs, njs_index_t unused)
{
size_t size, length;
u_char *p;
uint32_t code;
njs_int_t ret;
const u_char *s, *end;
njs_string_prop_t string;
ret = njs_string_object_validate(vm, njs_argument(args, 0));
if (njs_slow_path(ret != NJS_OK)) {
return ret;
}
(void) njs_string_prop(&string, njs_argument(args, 0));
if (njs_is_byte_or_ascii_string(&string)) {
p = njs_string_alloc(vm, &vm->retval, string.size, string.length);
if (njs_slow_path(p == NULL)) {
return NJS_ERROR;
}
s = string.start;
size = string.size;
while (size != 0) {
*p++ = njs_lower_case(*s++);
size--;
}
} else {
/* UTF-8 string. */
s = string.start;
end = s + string.size;
length = string.length;
size = 0;
while (length != 0) {
code = njs_utf8_lower_case(&s, end);
size += njs_utf8_size(code);
length--;
}
p = njs_string_alloc(vm, &vm->retval, size, string.length);
if (njs_slow_path(p == NULL)) {
return NJS_ERROR;
}
s = string.start;
length = string.length;
while (length != 0) {
code = njs_utf8_lower_case(&s, end);
p = njs_utf8_encode(p, code);
length--;
}
}
return NJS_OK;
}
| 0
|
261,036
|
circuit_guard_state_free(circuit_guard_state_t *state)
{
if (!state)
return;
entry_guard_restriction_free(state->restrictions);
entry_guard_handle_free(state->guard);
tor_free(state);
}
| 0
|
327,262
|
static void test_validate_list(TestInputVisitorData *data,
const void *unused)
{
UserDefOneList *head = NULL;
Visitor *v;
v = validate_test_init(data, "[ { 'string': 'string0', 'integer': 42 }, { 'string': 'string1', 'integer': 43 }, { 'string': 'string2', 'integer': 44 } ]");
visit_type_UserDefOneList(v, NULL, &head, &error_abort);
qapi_free_UserDefOneList(head);
}
| 0
|
481,219
|
void kvm_mmu_unload(struct kvm_vcpu *vcpu)
{
struct kvm *kvm = vcpu->kvm;
kvm_mmu_free_roots(kvm, &vcpu->arch.root_mmu, KVM_MMU_ROOTS_ALL);
WARN_ON(VALID_PAGE(vcpu->arch.root_mmu.root.hpa));
kvm_mmu_free_roots(kvm, &vcpu->arch.guest_mmu, KVM_MMU_ROOTS_ALL);
WARN_ON(VALID_PAGE(vcpu->arch.guest_mmu.root.hpa));
vcpu_clear_mmio_info(vcpu, MMIO_GVA_ANY);
}
| 0
|
82,313
|
int gdImageCompare (gdImagePtr im1, gdImagePtr im2)
{
int x, y;
int p1, p2;
int cmpStatus = 0;
int sx, sy;
if (im1->interlace != im2->interlace) {
cmpStatus |= GD_CMP_INTERLACE;
}
if (im1->transparent != im2->transparent) {
cmpStatus |= GD_CMP_TRANSPARENT;
}
if (im1->trueColor != im2->trueColor) {
cmpStatus |= GD_CMP_TRUECOLOR;
}
sx = im1->sx;
if (im1->sx != im2->sx) {
cmpStatus |= GD_CMP_SIZE_X + GD_CMP_IMAGE;
if (im2->sx < im1->sx) {
sx = im2->sx;
}
}
sy = im1->sy;
if (im1->sy != im2->sy) {
cmpStatus |= GD_CMP_SIZE_Y + GD_CMP_IMAGE;
if (im2->sy < im1->sy) {
sy = im2->sy;
}
}
if (im1->colorsTotal != im2->colorsTotal) {
cmpStatus |= GD_CMP_NUM_COLORS;
}
for (y = 0; y < sy; y++) {
for (x = 0; x < sx; x++) {
p1 = im1->trueColor ? gdImageTrueColorPixel(im1, x, y) : gdImagePalettePixel(im1, x, y);
p2 = im2->trueColor ? gdImageTrueColorPixel(im2, x, y) : gdImagePalettePixel(im2, x, y);
if (gdImageRed(im1, p1) != gdImageRed(im2, p2)) {
cmpStatus |= GD_CMP_COLOR + GD_CMP_IMAGE;
break;
}
if (gdImageGreen(im1, p1) != gdImageGreen(im2, p2)) {
cmpStatus |= GD_CMP_COLOR + GD_CMP_IMAGE;
break;
}
if (gdImageBlue(im1, p1) != gdImageBlue(im2, p2)) {
cmpStatus |= GD_CMP_COLOR + GD_CMP_IMAGE;
break;
}
#if 0
/* Soon we'll add alpha channel to palettes */
if (gdImageAlpha(im1, p1) != gdImageAlpha(im2, p2)) {
cmpStatus |= GD_CMP_COLOR + GD_CMP_IMAGE;
break;
}
#endif
}
if (cmpStatus & GD_CMP_COLOR) {
break;
}
}
return cmpStatus;
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.