idx
int64 | func
string | target
int64 |
|---|---|---|
513,224
|
static void update_func_bool(THD *thd, struct st_mysql_sys_var *var,
void *tgt, const void *save)
{
*(my_bool *) tgt= *(my_bool *) save ? 1 : 0;
}
| 0
|
369,251
|
static inline bool io_alloc_async_data(struct io_kiocb *req)
{
WARN_ON_ONCE(!io_op_defs[req->opcode].async_size);
req->async_data = kmalloc(io_op_defs[req->opcode].async_size, GFP_KERNEL);
if (req->async_data) {
req->flags |= REQ_F_ASYNC_DATA;
return false;
}
return true;
}
| 0
|
309,833
|
failed(const char *msg)
{
fprintf(stderr, "%s\n", msg);
ExitProgram(EXIT_FAILURE);
}
| 0
|
270,390
|
static bool ok_inflater_init_fixed_huffman(ok_inflater *inflater) {
if (!inflater->fixed_literal_huffman) {
ok_inflater_huffman_tree *tree = ok_alloc(inflater, sizeof(ok_inflater_huffman_tree));
if (tree) {
uint8_t code_length[288];
int i;
for (i = 0; i < 144; i++) {
code_length[i] = 8;
}
for (i = 144; i < 256; i++) {
code_length[i] = 9;
}
for (i = 256; i < 280; i++) {
code_length[i] = 7;
}
for (i = 280; i < 288; i++) {
code_length[i] = 8;
}
ok_inflater_make_huffman_tree_from_array(tree, code_length,
sizeof(code_length) / sizeof(code_length[0]));
inflater->fixed_literal_huffman = tree;
}
}
if (!inflater->fixed_distance_huffman) {
ok_inflater_huffman_tree *tree = ok_alloc(inflater, sizeof(ok_inflater_huffman_tree));
if (tree) {
uint8_t distance_code_length[32];
for (int i = 0; i < 32; i++) {
distance_code_length[i] = 5;
}
ok_inflater_make_huffman_tree_from_array(tree, distance_code_length, 32);
inflater->fixed_distance_huffman = tree;
}
}
return inflater->fixed_literal_huffman && inflater->fixed_distance_huffman;
}
| 0
|
369,144
|
static __cold void io_ring_ctx_wait_and_kill(struct io_ring_ctx *ctx)
{
unsigned long index;
struct creds *creds;
mutex_lock(&ctx->uring_lock);
percpu_ref_kill(&ctx->refs);
if (ctx->rings)
__io_cqring_overflow_flush(ctx, true);
xa_for_each(&ctx->personalities, index, creds)
io_unregister_personality(ctx, index);
mutex_unlock(&ctx->uring_lock);
io_kill_timeouts(ctx, NULL, true);
io_poll_remove_all(ctx, NULL, true);
/* if we failed setting up the ctx, we might not have any rings */
io_iopoll_try_reap_events(ctx);
INIT_WORK(&ctx->exit_work, io_ring_exit_work);
/*
* Use system_unbound_wq to avoid spawning tons of event kworkers
* if we're exiting a ton of rings at the same time. It just adds
* noise and overhead, there's no discernable change in runtime
* over using system_wq.
*/
queue_work(system_unbound_wq, &ctx->exit_work);
| 0
|
512,600
|
int Arg_comparator::compare_e_json_str()
{
return compare_e_json_str_basic(*a, *b);
}
| 0
|
398,503
|
static inline ut64 dwarf_read_address(size_t size, bool big_endian, const ut8 **buf, const ut8 *buf_end) {
ut64 result;
switch (size) {
case 2:
result = READ16(*buf);
break;
case 4:
result = READ32(*buf);
break;
case 8:
result = READ64(*buf);
break;
default:
result = 0;
*buf += size;
eprintf("Weird dwarf address size: %zu.", size);
}
return result;
}
| 0
|
449,297
|
nv_ident(cmdarg_T *cap)
{
char_u *ptr = NULL;
char_u *buf;
unsigned buflen;
char_u *newbuf;
char_u *p;
char_u *kp; // value of 'keywordprg'
int kp_help; // 'keywordprg' is ":he"
int kp_ex; // 'keywordprg' starts with ":"
int n = 0; // init for GCC
int cmdchar;
int g_cmd; // "g" command
int tag_cmd = FALSE;
char_u *aux_ptr;
int isman;
int isman_s;
if (cap->cmdchar == 'g') // "g*", "g#", "g]" and "gCTRL-]"
{
cmdchar = cap->nchar;
g_cmd = TRUE;
}
else
{
cmdchar = cap->cmdchar;
g_cmd = FALSE;
}
if (cmdchar == POUND) // the pound sign, '#' for English keyboards
cmdchar = '#';
/*
* The "]", "CTRL-]" and "K" commands accept an argument in Visual mode.
*/
if (cmdchar == ']' || cmdchar == Ctrl_RSB || cmdchar == 'K')
{
if (VIsual_active && get_visual_text(cap, &ptr, &n) == FAIL)
return;
if (checkclearopq(cap->oap))
return;
}
if (ptr == NULL && (n = find_ident_under_cursor(&ptr,
(cmdchar == '*' || cmdchar == '#')
? FIND_IDENT|FIND_STRING : FIND_IDENT)) == 0)
{
clearop(cap->oap);
return;
}
// Allocate buffer to put the command in. Inserting backslashes can
// double the length of the word. p_kp / curbuf->b_p_kp could be added
// and some numbers.
kp = (*curbuf->b_p_kp == NUL ? p_kp : curbuf->b_p_kp);
kp_help = (*kp == NUL || STRCMP(kp, ":he") == 0
|| STRCMP(kp, ":help") == 0);
if (kp_help && *skipwhite(ptr) == NUL)
{
emsg(_(e_noident)); // found white space only
return;
}
kp_ex = (*kp == ':');
buflen = (unsigned)(n * 2 + 30 + STRLEN(kp));
buf = alloc(buflen);
if (buf == NULL)
return;
buf[0] = NUL;
switch (cmdchar)
{
case '*':
case '#':
/*
* Put cursor at start of word, makes search skip the word
* under the cursor.
* Call setpcmark() first, so "*``" puts the cursor back where
* it was.
*/
setpcmark();
curwin->w_cursor.col = (colnr_T) (ptr - ml_get_curline());
if (!g_cmd && vim_iswordp(ptr))
STRCPY(buf, "\\<");
no_smartcase = TRUE; // don't use 'smartcase' now
break;
case 'K':
if (kp_help)
STRCPY(buf, "he! ");
else if (kp_ex)
{
if (cap->count0 != 0)
vim_snprintf((char *)buf, buflen, "%s %ld",
kp, cap->count0);
else
STRCPY(buf, kp);
STRCAT(buf, " ");
}
else
{
// An external command will probably use an argument starting
// with "-" as an option. To avoid trouble we skip the "-".
while (*ptr == '-' && n > 0)
{
++ptr;
--n;
}
if (n == 0)
{
emsg(_(e_noident)); // found dashes only
vim_free(buf);
return;
}
// When a count is given, turn it into a range. Is this
// really what we want?
isman = (STRCMP(kp, "man") == 0);
isman_s = (STRCMP(kp, "man -s") == 0);
if (cap->count0 != 0 && !(isman || isman_s))
sprintf((char *)buf, ".,.+%ld", cap->count0 - 1);
STRCAT(buf, "! ");
if (cap->count0 == 0 && isman_s)
STRCAT(buf, "man");
else
STRCAT(buf, kp);
STRCAT(buf, " ");
if (cap->count0 != 0 && (isman || isman_s))
{
sprintf((char *)buf + STRLEN(buf), "%ld", cap->count0);
STRCAT(buf, " ");
}
}
break;
case ']':
tag_cmd = TRUE;
#ifdef FEAT_CSCOPE
if (p_cst)
STRCPY(buf, "cstag ");
else
#endif
STRCPY(buf, "ts ");
break;
default:
tag_cmd = TRUE;
if (curbuf->b_help)
STRCPY(buf, "he! ");
else
{
if (g_cmd)
STRCPY(buf, "tj ");
else if (cap->count0 == 0)
STRCPY(buf, "ta ");
else
sprintf((char *)buf, ":%ldta ", cap->count0);
}
}
/*
* Now grab the chars in the identifier
*/
if (cmdchar == 'K' && !kp_help)
{
ptr = vim_strnsave(ptr, n);
if (kp_ex)
// Escape the argument properly for an Ex command
p = vim_strsave_fnameescape(ptr, VSE_NONE);
else
// Escape the argument properly for a shell command
p = vim_strsave_shellescape(ptr, TRUE, TRUE);
vim_free(ptr);
if (p == NULL)
{
vim_free(buf);
return;
}
newbuf = vim_realloc(buf, STRLEN(buf) + STRLEN(p) + 1);
if (newbuf == NULL)
{
vim_free(buf);
vim_free(p);
return;
}
buf = newbuf;
STRCAT(buf, p);
vim_free(p);
}
else
{
if (cmdchar == '*')
aux_ptr = (char_u *)(magic_isset() ? "/.*~[^$\\" : "/^$\\");
else if (cmdchar == '#')
aux_ptr = (char_u *)(magic_isset() ? "/?.*~[^$\\" : "/?^$\\");
else if (tag_cmd)
{
if (curbuf->b_help)
// ":help" handles unescaped argument
aux_ptr = (char_u *)"";
else
aux_ptr = (char_u *)"\\|\"\n[";
}
else
aux_ptr = (char_u *)"\\|\"\n*?[";
p = buf + STRLEN(buf);
while (n-- > 0)
{
// put a backslash before \ and some others
if (vim_strchr(aux_ptr, *ptr) != NULL)
*p++ = '\\';
// When current byte is a part of multibyte character, copy all
// bytes of that character.
if (has_mbyte)
{
int i;
int len = (*mb_ptr2len)(ptr) - 1;
for (i = 0; i < len && n >= 1; ++i, --n)
*p++ = *ptr++;
}
*p++ = *ptr++;
}
*p = NUL;
}
/*
* Execute the command.
*/
if (cmdchar == '*' || cmdchar == '#')
{
if (!g_cmd && (has_mbyte
? vim_iswordp(mb_prevptr(ml_get_curline(), ptr))
: vim_iswordc(ptr[-1])))
STRCAT(buf, "\\>");
// put pattern in search history
init_history();
add_to_history(HIST_SEARCH, buf, TRUE, NUL);
(void)normal_search(cap, cmdchar == '*' ? '/' : '?', buf, 0, NULL);
}
else
{
g_tag_at_cursor = TRUE;
do_cmdline_cmd(buf);
g_tag_at_cursor = FALSE;
}
vim_free(buf);
}
| 0
|
246,697
|
u32 parse_base_url(char *arg_val, u32 opt)
{
mpd_base_urls = gf_realloc(mpd_base_urls, (nb_mpd_base_urls + 1)*sizeof(char**));
if (!mpd_base_urls) return 2;
mpd_base_urls[nb_mpd_base_urls] = arg_val;
nb_mpd_base_urls++;
return 0;
}
| 0
|
393,490
|
static SQInteger array_slice(HSQUIRRELVM v)
{
SQInteger sidx,eidx;
SQObjectPtr o;
if(get_slice_params(v,sidx,eidx,o)==-1)return -1;
SQInteger alen = _array(o)->Size();
if(sidx < 0)sidx = alen + sidx;
if(eidx < 0)eidx = alen + eidx;
if(eidx < sidx)return sq_throwerror(v,_SC("wrong indexes"));
if(eidx > alen || sidx < 0)return sq_throwerror(v, _SC("slice out of range"));
SQArray *arr=SQArray::Create(_ss(v),eidx-sidx);
SQObjectPtr t;
SQInteger count=0;
for(SQInteger i=sidx;i<eidx;i++){
_array(o)->Get(i,t);
arr->Set(count++,t);
}
v->Push(arr);
return 1;
}
| 0
|
376,316
|
gpg_ctx_get_argv (struct _GpgCtx *gpg,
gint status_fd,
gchar **sfd,
gint passwd_fd,
gchar **pfd)
{
const gchar *hash_str;
GPtrArray *argv;
gchar *buf;
gint i;
argv = g_ptr_array_new ();
g_ptr_array_add (argv, (guint8 *) gpg_ctx_get_executable_name ());
g_ptr_array_add (argv, (guint8 *) "--verbose");
g_ptr_array_add (argv, (guint8 *) "--no-secmem-warning");
g_ptr_array_add (argv, (guint8 *) "--no-greeting");
g_ptr_array_add (argv, (guint8 *) "--no-tty");
if (passwd_fd == -1) {
/* only use batch mode if we don't intend on using the
* interactive --command-fd option */
g_ptr_array_add (argv, (guint8 *) "--batch");
g_ptr_array_add (argv, (guint8 *) "--yes");
}
*sfd = buf = g_strdup_printf ("--status-fd=%d", status_fd);
g_ptr_array_add (argv, buf);
if (passwd_fd != -1) {
*pfd = buf = g_strdup_printf ("--command-fd=%d", passwd_fd);
g_ptr_array_add (argv, buf);
}
switch (gpg->mode) {
case GPG_CTX_MODE_SIGN:
g_ptr_array_add (argv, (guint8 *) "--sign");
g_ptr_array_add (argv, (guint8 *) "--detach");
if (gpg->armor)
g_ptr_array_add (argv, (guint8 *) "--armor");
hash_str = gpg_hash_str (gpg->hash);
if (hash_str)
g_ptr_array_add (argv, (guint8 *) hash_str);
if (gpg->userids) {
GSList *uiter;
for (uiter = gpg->userids; uiter; uiter = uiter->next) {
g_ptr_array_add (argv, (guint8 *) "-u");
g_ptr_array_add (argv, (guint8 *) uiter->data);
}
}
g_ptr_array_add (argv, (guint8 *) "--output");
g_ptr_array_add (argv, (guint8 *) "-");
break;
case GPG_CTX_MODE_VERIFY:
if (!camel_session_get_online (gpg->session)) {
/* this is a deprecated flag to gpg since 1.0.7 */
/*g_ptr_array_add (argv, "--no-auto-key-retrieve");*/
g_ptr_array_add (argv, (guint8 *) "--keyserver-options");
g_ptr_array_add (argv, (guint8 *) "no-auto-key-retrieve");
}
g_ptr_array_add (argv, (guint8 *) "--verify");
if (gpg->sigfile)
g_ptr_array_add (argv, gpg->sigfile);
g_ptr_array_add (argv, (guint8 *) "-");
break;
case GPG_CTX_MODE_ENCRYPT:
g_ptr_array_add (argv, (guint8 *) "--encrypt");
if (gpg->armor)
g_ptr_array_add (argv, (guint8 *) "--armor");
if (gpg->always_trust)
g_ptr_array_add (argv, (guint8 *) "--always-trust");
if (gpg->userids) {
GSList *uiter;
for (uiter = gpg->userids; uiter; uiter = uiter->next) {
g_ptr_array_add (argv, (guint8 *) "-u");
g_ptr_array_add (argv, (guint8 *) uiter->data);
}
}
if (gpg->recipients) {
for (i = 0; i < gpg->recipients->len; i++) {
g_ptr_array_add (argv, (guint8 *) "-r");
g_ptr_array_add (argv, gpg->recipients->pdata[i]);
}
}
g_ptr_array_add (argv, (guint8 *) "--output");
g_ptr_array_add (argv, (guint8 *) "-");
break;
case GPG_CTX_MODE_DECRYPT:
g_ptr_array_add (argv, (guint8 *) "--decrypt");
g_ptr_array_add (argv, (guint8 *) "--output");
g_ptr_array_add (argv, (guint8 *) "-");
break;
case GPG_CTX_MODE_IMPORT:
g_ptr_array_add (argv, (guint8 *) "--import");
g_ptr_array_add (argv, (guint8 *) "-");
break;
case GPG_CTX_MODE_EXPORT:
if (gpg->armor)
g_ptr_array_add (argv, (guint8 *) "--armor");
g_ptr_array_add (argv, (guint8 *) "--export");
for (i = 0; i < gpg->recipients->len; i++)
g_ptr_array_add (argv, gpg->recipients->pdata[i]);
break;
}
g_ptr_array_add (argv, NULL);
return argv;
}
| 0
|
512,845
|
Item *remove_item_direct_ref()
{
*ref= (*ref)->remove_item_direct_ref();
return this;
}
| 0
|
512,828
|
bool save_in_param(THD *thd, Item_param *param)
{
// It should not be possible to have "EXECUTE .. USING DEFAULT(a)"
DBUG_ASSERT(0);
param->set_default();
return false;
}
| 0
|
333,092
|
copy_sub_off(regsub_T *to, regsub_T *from)
{
if (to->in_use < from->in_use)
to->in_use = from->in_use;
if (from->in_use > 1)
{
// Copy the match start and end positions.
if (REG_MULTI)
mch_memmove(&to->list.multi[1],
&from->list.multi[1],
sizeof(struct multipos) * (from->in_use - 1));
else
mch_memmove(&to->list.line[1],
&from->list.line[1],
sizeof(struct linepos) * (from->in_use - 1));
}
}
| 0
|
452,990
|
static int nft_flow_offload_rule(const struct nft_chain *chain,
struct nft_rule *rule,
struct nft_flow_rule *flow,
enum flow_cls_command command)
{
struct flow_cls_offload cls_flow;
return nft_flow_offload_cmd(chain, rule, flow, command, &cls_flow);
}
| 0
|
513,241
|
static bool create_hj_key_for_table(JOIN *join, JOIN_TAB *join_tab,
KEYUSE *org_keyuse, table_map used_tables)
{
KEY *keyinfo;
KEY_PART_INFO *key_part_info;
KEYUSE *keyuse= org_keyuse;
uint key_parts= 0;
THD *thd= join->thd;
TABLE *table= join_tab->table;
bool first_keyuse= TRUE;
DBUG_ENTER("create_hj_key_for_table");
do
{
if (!(~used_tables & keyuse->used_tables) &&
join_tab->keyuse_is_valid_for_access_in_chosen_plan(join, keyuse) &&
are_tables_local(join_tab, keyuse->used_tables))
{
if (first_keyuse)
{
key_parts++;
}
else
{
KEYUSE *curr= org_keyuse;
for( ; curr < keyuse; curr++)
{
if (curr->keypart == keyuse->keypart &&
!(~used_tables & curr->used_tables) &&
join_tab->keyuse_is_valid_for_access_in_chosen_plan(join,
curr) &&
are_tables_local(join_tab, curr->used_tables))
break;
}
if (curr == keyuse)
key_parts++;
}
}
first_keyuse= FALSE;
keyuse++;
} while (keyuse->table == table && keyuse->is_for_hash_join());
if (!key_parts)
DBUG_RETURN(TRUE);
/* This memory is allocated only once for the joined table join_tab */
if (!(keyinfo= (KEY *) thd->alloc(sizeof(KEY))) ||
!(key_part_info = (KEY_PART_INFO *) thd->alloc(sizeof(KEY_PART_INFO)*
key_parts)))
DBUG_RETURN(TRUE);
keyinfo->usable_key_parts= keyinfo->user_defined_key_parts = key_parts;
keyinfo->ext_key_parts= keyinfo->user_defined_key_parts;
keyinfo->key_part= key_part_info;
keyinfo->key_length=0;
keyinfo->algorithm= HA_KEY_ALG_UNDEF;
keyinfo->flags= HA_GENERATED_KEY;
keyinfo->is_statistics_from_stat_tables= FALSE;
keyinfo->name= (char *) "$hj";
keyinfo->rec_per_key= (ulong*) thd->calloc(sizeof(ulong)*key_parts);
if (!keyinfo->rec_per_key)
DBUG_RETURN(TRUE);
keyinfo->key_part= key_part_info;
first_keyuse= TRUE;
keyuse= org_keyuse;
do
{
if (!(~used_tables & keyuse->used_tables) &&
join_tab->keyuse_is_valid_for_access_in_chosen_plan(join, keyuse) &&
are_tables_local(join_tab, keyuse->used_tables))
{
bool add_key_part= TRUE;
if (!first_keyuse)
{
for(KEYUSE *curr= org_keyuse; curr < keyuse; curr++)
{
if (curr->keypart == keyuse->keypart &&
!(~used_tables & curr->used_tables) &&
join_tab->keyuse_is_valid_for_access_in_chosen_plan(join,
curr) &&
are_tables_local(join_tab, curr->used_tables))
{
keyuse->keypart= NO_KEYPART;
add_key_part= FALSE;
break;
}
}
}
if (add_key_part)
{
Field *field= table->field[keyuse->keypart];
uint fieldnr= keyuse->keypart+1;
table->create_key_part_by_field(key_part_info, field, fieldnr);
keyinfo->key_length += key_part_info->store_length;
key_part_info++;
}
}
first_keyuse= FALSE;
keyuse++;
} while (keyuse->table == table && keyuse->is_for_hash_join());
keyinfo->ext_key_parts= keyinfo->user_defined_key_parts;
keyinfo->ext_key_flags= keyinfo->flags;
keyinfo->ext_key_part_map= 0;
join_tab->hj_key= keyinfo;
DBUG_RETURN(FALSE);
}
| 0
|
369,426
|
static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe)
{
struct io_sr_msg *sr = &req->sr_msg;
if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL))
return -EINVAL;
if (unlikely(sqe->addr2 || sqe->file_index))
return -EINVAL;
sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr));
sr->len = READ_ONCE(sqe->len);
sr->msg_flags = READ_ONCE(sqe->msg_flags) | MSG_NOSIGNAL;
if (sr->msg_flags & MSG_DONTWAIT)
req->flags |= REQ_F_NOWAIT;
#ifdef CONFIG_COMPAT
if (req->ctx->compat)
sr->msg_flags |= MSG_CMSG_COMPAT;
#endif
return 0;
}
| 0
|
220,168
|
void DecodePngV2(OpKernelContext* context, StringPiece input) {
int channel_bits = (data_type_ == DataType::DT_UINT8) ? 8 : 16;
png::DecodeContext decode;
OP_REQUIRES(
context, png::CommonInitDecode(input, channels_, channel_bits, &decode),
errors::InvalidArgument("Invalid PNG. Failed to initialize decoder."));
// If we reach this point, then there is data in `decode` which must be
// freed by the time we end execution in this function. We cannot call
// `png::CommonFreeDecode()` before an `OP_REQUIRES` because if
// `OP_REQUIRES` constraint is satisfied then the data would be freed
// prematurely. Instead, let's use a `Cleanup` object.
auto cleanup = gtl::MakeCleanup([&decode]() {
std::cerr << "Cleanup called...\n";
png::CommonFreeDecode(&decode);
});
// Verify that width and height are not too large:
// - verify width and height don't overflow int.
// - width can later be multiplied by channels_ and sizeof(uint16), so
// verify single dimension is not too large.
// - verify when width and height are multiplied together, there are a few
// bits to spare as well.
const int width = static_cast<int>(decode.width);
const int height = static_cast<int>(decode.height);
const int64_t total_size =
static_cast<int64_t>(width) * static_cast<int64_t>(height);
if (width != static_cast<int64_t>(decode.width) || width <= 0 ||
width >= (1LL << 27) || height != static_cast<int64_t>(decode.height) ||
height <= 0 || height >= (1LL << 27) || total_size >= (1LL << 29)) {
OP_REQUIRES(context, false,
errors::InvalidArgument("PNG size too large for int: ",
decode.width, " by ", decode.height));
}
Tensor* output = nullptr;
// By the existing API, we support decoding PNG with `DecodeGif` op.
// We need to make sure to return 4-D shapes when using `DecodeGif`.
if (op_type_ == "DecodeGif") {
OP_REQUIRES_OK(
context,
context->allocate_output(
0, TensorShape({1, height, width, decode.channels}), &output));
} else {
OP_REQUIRES_OK(
context,
context->allocate_output(
0, TensorShape({height, width, decode.channels}), &output));
}
if (op_type_ == "DecodeBmp") {
// TODO(b/171060723): Only DecodeBmp as op_type_ is not acceptable here
// because currently `decode_(jpeg|png|gif)` ops can decode any one of
// jpeg, png or gif but not bmp. Similarly, `decode_bmp` cannot decode
// anything but bmp formats. This behavior needs to be revisited. For more
// details, please refer to the bug.
OP_REQUIRES(context, false,
errors::InvalidArgument(
"Trying to decode PNG format using DecodeBmp op. Use "
"`decode_png` or `decode_image` instead."));
} else if (op_type_ == "DecodeAndCropJpeg") {
OP_REQUIRES(context, false,
errors::InvalidArgument(
"DecodeAndCropJpeg operation can run on JPEG only, but "
"detected PNG."));
}
if (data_type_ == DataType::DT_UINT8) {
OP_REQUIRES(
context,
png::CommonFinishDecode(
reinterpret_cast<png_bytep>(output->flat<uint8>().data()),
decode.channels * width * sizeof(uint8), &decode),
errors::InvalidArgument("Invalid PNG data, size ", input.size()));
} else if (data_type_ == DataType::DT_UINT16) {
OP_REQUIRES(
context,
png::CommonFinishDecode(
reinterpret_cast<png_bytep>(output->flat<uint16>().data()),
decode.channels * width * sizeof(uint16), &decode),
errors::InvalidArgument("Invalid PNG data, size ", input.size()));
} else if (data_type_ == DataType::DT_FLOAT) {
// `png::CommonFinishDecode` does not support `float`. First allocate
// uint16 buffer for the image and decode in uint16 (lossless). Wrap the
// buffer in `unique_ptr` so that we don't forget to delete the buffer.
std::unique_ptr<uint16[]> buffer(
new uint16[height * width * decode.channels]);
OP_REQUIRES(
context,
png::CommonFinishDecode(reinterpret_cast<png_bytep>(buffer.get()),
decode.channels * width * sizeof(uint16),
&decode),
errors::InvalidArgument("Invalid PNG data, size ", input.size()));
// Convert uint16 image data to desired data type.
// Use eigen threadpooling to speed up the copy operation.
const auto& device = context->eigen_device<Eigen::ThreadPoolDevice>();
TTypes<uint16, 3>::UnalignedConstTensor buf(buffer.get(), height, width,
decode.channels);
float scale = 1. / std::numeric_limits<uint16>::max();
// Fill output tensor with desired dtype.
output->tensor<float, 3>().device(device) = buf.cast<float>() * scale;
}
}
| 0
|
411,889
|
router_parse_directory(const char *str)
{
directory_token_t *tok;
char digest[DIGEST_LEN];
time_t published_on;
int r;
const char *end, *cp, *str_dup = str;
smartlist_t *tokens = NULL;
crypto_pk_env_t *declared_key = NULL;
memarea_t *area = memarea_new();
/* XXXX This could be simplified a lot, but it will all go away
* once pre-0.1.1.8 is obsolete, and for now it's better not to
* touch it. */
if (router_get_dir_hash(str, digest)) {
log_warn(LD_DIR, "Unable to compute digest of directory");
goto err;
}
log_debug(LD_DIR,"Received directory hashes to %s",hex_str(digest,4));
/* Check signature first, before we try to tokenize. */
cp = str;
while (cp && (end = strstr(cp+1, "\ndirectory-signature")))
cp = end;
if (cp == str || !cp) {
log_warn(LD_DIR, "No signature found on directory."); goto err;
}
++cp;
tokens = smartlist_create();
if (tokenize_string(area,cp,strchr(cp,'\0'),tokens,dir_token_table,0)) {
log_warn(LD_DIR, "Error tokenizing directory signature"); goto err;
}
if (smartlist_len(tokens) != 1) {
log_warn(LD_DIR, "Unexpected number of tokens in signature"); goto err;
}
tok=smartlist_get(tokens,0);
if (tok->tp != K_DIRECTORY_SIGNATURE) {
log_warn(LD_DIR,"Expected a single directory signature"); goto err;
}
declared_key = find_dir_signing_key(str, str+strlen(str));
note_crypto_pk_op(VERIFY_DIR);
if (check_signature_token(digest, DIGEST_LEN, tok, declared_key,
CST_CHECK_AUTHORITY, "directory")<0)
goto err;
SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t));
smartlist_clear(tokens);
memarea_clear(area);
/* Now try to parse the first part of the directory. */
if ((end = strstr(str,"\nrouter "))) {
++end;
} else if ((end = strstr(str, "\ndirectory-signature"))) {
++end;
} else {
end = str + strlen(str);
}
if (tokenize_string(area,str,end,tokens,dir_token_table,0)) {
log_warn(LD_DIR, "Error tokenizing directory"); goto err;
}
tok = find_by_keyword(tokens, K_PUBLISHED);
tor_assert(tok->n_args == 1);
if (parse_iso_time(tok->args[0], &published_on) < 0) {
goto err;
}
/* Now that we know the signature is okay, and we have a
* publication time, cache the directory. */
if (directory_caches_v1_dir_info(get_options()) &&
!authdir_mode_v1(get_options()))
dirserv_set_cached_directory(str, published_on, 0);
r = 0;
goto done;
err:
dump_desc(str_dup, "v1 directory");
r = -1;
done:
if (declared_key) crypto_free_pk_env(declared_key);
if (tokens) {
SMARTLIST_FOREACH(tokens, directory_token_t *, t, token_clear(t));
smartlist_free(tokens);
}
if (area) {
DUMP_AREA(area, "v1 directory");
memarea_drop_all(area);
}
return r;
}
| 0
|
195,471
|
IRC_PROTOCOL_CALLBACK(352)
{
char *pos_attr, *pos_hopcount, *pos_realname, *str_host;
int arg_start, length;
struct t_irc_channel *ptr_channel;
struct t_irc_nick *ptr_nick;
IRC_PROTOCOL_MIN_ARGS(5);
/* silently ignore malformed 352 message (missing infos) */
if (argc < 8)
return WEECHAT_RC_OK;
pos_attr = NULL;
pos_hopcount = NULL;
pos_realname = NULL;
if (argc > 8)
{
arg_start = (strcmp (argv[8], "*") == 0) ? 9 : 8;
if (argv[arg_start][0] == ':')
{
pos_attr = NULL;
pos_hopcount = (argc > arg_start) ? argv[arg_start] + 1 : NULL;
pos_realname = (argc > arg_start + 1) ? argv_eol[arg_start + 1] : NULL;
}
else
{
pos_attr = argv[arg_start];
pos_hopcount = (argc > arg_start + 1) ? argv[arg_start + 1] + 1 : NULL;
pos_realname = (argc > arg_start + 2) ? argv_eol[arg_start + 2] : NULL;
}
}
ptr_channel = irc_channel_search (server, argv[3]);
ptr_nick = (ptr_channel) ?
irc_nick_search (server, ptr_channel, argv[7]) : NULL;
/* update host in nick */
if (ptr_nick)
{
length = strlen (argv[4]) + 1 + strlen (argv[5]) + 1;
str_host = malloc (length);
if (str_host)
{
snprintf (str_host, length, "%s@%s", argv[4], argv[5]);
irc_nick_set_host (ptr_nick, str_host);
free (str_host);
}
}
/* update away flag in nick */
if (ptr_channel && ptr_nick && pos_attr)
{
irc_nick_set_away (server, ptr_channel, ptr_nick,
(pos_attr[0] == 'G') ? 1 : 0);
}
/* update realname in nick */
if (ptr_channel && ptr_nick && pos_realname)
{
if (ptr_nick->realname)
free (ptr_nick->realname);
if (pos_realname &&
weechat_hashtable_has_key (server->cap_list, "extended-join"))
{
ptr_nick->realname = strdup (pos_realname);
}
else
{
ptr_nick->realname = NULL;
}
}
/* display output of who (manual who from user) */
if (!ptr_channel || (ptr_channel->checking_whox <= 0))
{
weechat_printf_date_tags (
irc_msgbuffer_get_target_buffer (
server, NULL, command, "who", NULL),
date,
irc_protocol_tags (command, "irc_numeric", NULL, NULL),
"%s%s[%s%s%s] %s%s %s(%s%s@%s%s)%s %s%s%s%s(%s)",
weechat_prefix ("network"),
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_CHANNEL,
argv[3],
IRC_COLOR_CHAT_DELIMITERS,
irc_nick_color_for_msg (server, 1, NULL, argv[7]),
argv[7],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_CHAT_HOST,
argv[4],
argv[5],
IRC_COLOR_CHAT_DELIMITERS,
IRC_COLOR_RESET,
(pos_attr) ? pos_attr : "",
(pos_attr) ? " " : "",
(pos_hopcount) ? pos_hopcount : "",
(pos_hopcount) ? " " : "",
(pos_realname) ? pos_realname : "");
}
return WEECHAT_RC_OK;
}
| 1
|
364,751
|
tag_full_fname(tagptrs_T *tagp)
{
char_u *fullname;
int c;
#ifdef FEAT_EMACS_TAGS
if (tagp->is_etag)
c = 0; // to shut up GCC
else
#endif
{
c = *tagp->fname_end;
*tagp->fname_end = NUL;
}
fullname = expand_tag_fname(tagp->fname, tagp->tag_fname, FALSE);
#ifdef FEAT_EMACS_TAGS
if (!tagp->is_etag)
#endif
*tagp->fname_end = c;
return fullname;
}
| 0
|
232,302
|
u32 gf_isom_sample_get_subsamples_count(GF_ISOFile *movie, u32 track)
{
GF_TrackBox *trak = gf_isom_get_track_from_file(movie, track);
if (!track) return 0;
if (!trak->Media || !trak->Media->information->sampleTable || !trak->Media->information->sampleTable->sub_samples) return 0;
return gf_list_count(trak->Media->information->sampleTable->sub_samples);
}
| 0
|
292,186
|
void CallInfo::set_virtual(Klass* resolved_klass,
Klass* selected_klass,
const methodHandle& resolved_method,
const methodHandle& selected_method,
int vtable_index, TRAPS) {
assert(vtable_index >= 0 || vtable_index == Method::nonvirtual_vtable_index, "valid index");
assert(vtable_index < 0 || !resolved_method->has_vtable_index() || vtable_index == resolved_method->vtable_index(), "");
CallKind kind = (vtable_index >= 0 && !resolved_method->can_be_statically_bound() ? CallInfo::vtable_call : CallInfo::direct_call);
set_common(resolved_klass, selected_klass, resolved_method, selected_method, kind, vtable_index, CHECK);
assert(!resolved_method->is_compiled_lambda_form(), "these must be handled via an invokehandle call");
}
| 0
|
459,139
|
static int tc_chain_notify(struct tcf_chain *chain, struct sk_buff *oskb,
u32 seq, u16 flags, int event, bool unicast)
{
u32 portid = oskb ? NETLINK_CB(oskb).portid : 0;
struct tcf_block *block = chain->block;
struct net *net = block->net;
struct sk_buff *skb;
int err = 0;
skb = alloc_skb(NLMSG_GOODSIZE, GFP_KERNEL);
if (!skb)
return -ENOBUFS;
if (tc_chain_fill_node(chain->tmplt_ops, chain->tmplt_priv,
chain->index, net, skb, block, portid,
seq, flags, event) <= 0) {
kfree_skb(skb);
return -EINVAL;
}
if (unicast)
err = rtnl_unicast(skb, net, portid);
else
err = rtnetlink_send(skb, net, portid, RTNLGRP_TC,
flags & NLM_F_ECHO);
return err;
}
| 0
|
267,968
|
R_IPI RBinFile *r_bin_file_new(RBin *bin, const char *file, ut64 file_sz, int rawstr, int fd, const char *xtrname, Sdb *sdb, bool steal_ptr) {
ut32 bf_id;
if (!r_id_pool_grab_id (bin->ids->pool, &bf_id)) {
return NULL;
}
RBinFile *bf = R_NEW0 (RBinFile);
if (bf) {
bf->id = bf_id;
bf->rbin = bin;
bf->file = file ? strdup (file) : NULL;
bf->rawstr = rawstr;
bf->fd = fd;
bf->curxtr = xtrname ? r_bin_get_xtrplugin_by_name (bin, xtrname) : NULL;
bf->sdb = sdb;
bf->size = file_sz;
bf->xtr_data = r_list_newf ((RListFree)r_bin_xtrdata_free);
bf->xtr_obj = NULL;
bf->sdb = sdb_new0 ();
bf->sdb_addrinfo = sdb_new0 (); //ns (bf->sdb, "addrinfo", 1);
// bf->sdb_addrinfo->refs++;
}
return bf;
}
| 0
|
338,230
|
bool WasmBinaryBuilder::maybeVisitStore(Expression*& out,
uint8_t code,
bool isAtomic) {
Store* curr;
if (!isAtomic) {
switch (code) {
case BinaryConsts::I32StoreMem8:
curr = allocator.alloc<Store>();
curr->bytes = 1;
curr->valueType = Type::i32;
break;
case BinaryConsts::I32StoreMem16:
curr = allocator.alloc<Store>();
curr->bytes = 2;
curr->valueType = Type::i32;
break;
case BinaryConsts::I32StoreMem:
curr = allocator.alloc<Store>();
curr->bytes = 4;
curr->valueType = Type::i32;
break;
case BinaryConsts::I64StoreMem8:
curr = allocator.alloc<Store>();
curr->bytes = 1;
curr->valueType = Type::i64;
break;
case BinaryConsts::I64StoreMem16:
curr = allocator.alloc<Store>();
curr->bytes = 2;
curr->valueType = Type::i64;
break;
case BinaryConsts::I64StoreMem32:
curr = allocator.alloc<Store>();
curr->bytes = 4;
curr->valueType = Type::i64;
break;
case BinaryConsts::I64StoreMem:
curr = allocator.alloc<Store>();
curr->bytes = 8;
curr->valueType = Type::i64;
break;
case BinaryConsts::F32StoreMem:
curr = allocator.alloc<Store>();
curr->bytes = 4;
curr->valueType = Type::f32;
break;
case BinaryConsts::F64StoreMem:
curr = allocator.alloc<Store>();
curr->bytes = 8;
curr->valueType = Type::f64;
break;
default:
return false;
}
} else {
switch (code) {
case BinaryConsts::I32AtomicStore8:
curr = allocator.alloc<Store>();
curr->bytes = 1;
curr->valueType = Type::i32;
break;
case BinaryConsts::I32AtomicStore16:
curr = allocator.alloc<Store>();
curr->bytes = 2;
curr->valueType = Type::i32;
break;
case BinaryConsts::I32AtomicStore:
curr = allocator.alloc<Store>();
curr->bytes = 4;
curr->valueType = Type::i32;
break;
case BinaryConsts::I64AtomicStore8:
curr = allocator.alloc<Store>();
curr->bytes = 1;
curr->valueType = Type::i64;
break;
case BinaryConsts::I64AtomicStore16:
curr = allocator.alloc<Store>();
curr->bytes = 2;
curr->valueType = Type::i64;
break;
case BinaryConsts::I64AtomicStore32:
curr = allocator.alloc<Store>();
curr->bytes = 4;
curr->valueType = Type::i64;
break;
case BinaryConsts::I64AtomicStore:
curr = allocator.alloc<Store>();
curr->bytes = 8;
curr->valueType = Type::i64;
break;
default:
return false;
}
}
curr->isAtomic = isAtomic;
BYN_TRACE("zz node: Store\n");
readMemoryAccess(curr->align, curr->offset);
curr->value = popNonVoidExpression();
curr->ptr = popNonVoidExpression();
curr->finalize();
out = curr;
return true;
}
| 0
|
247,601
|
TEST_P(SslReadBufferLimitTest, NoLimit) {
readBufferLimitTest(0, 256 * 1024, 256 * 1024, 1, false);
}
| 0
|
256,161
|
void wrapper_libxsmm_spmdm_compute_generic_thread(
empty_type_wrapper<float>, const libxsmm_spmdm_handle* handle, char transA,
char transB, const float* alpha, libxsmm_CSR_sparseslice* A_sparse,
const float* B, char transC, const float* beta, float* C, int block_id,
int tid, int nthreads) {
return libxsmm_spmdm_compute_fp32_thread(handle, transA, transB, alpha,
A_sparse, B, transC, beta, C,
block_id, tid, nthreads);
}
| 0
|
317,347
|
static int selinux_inode_symlink(struct inode *dir, struct dentry *dentry, const char *name)
{
return may_create(dir, dentry, SECCLASS_LNK_FILE);
}
| 0
|
242,264
|
static int PamLocalCallback(int num_msg,
#if defined(__sun)
struct pam_message** msgm,
#else
const struct pam_message** msgm,
#endif
struct pam_response** response,
void* appdata_ptr)
{
struct pam_response* resp = static_cast<pam_response*>(
calloc(num_msg, sizeof(struct pam_response)));
PamData* pam_data = static_cast<PamData*>(appdata_ptr);
if (num_msg == 1) {
resp[0].resp = strdup(pam_data->passwd_.c_str());
resp[0].resp_retcode = 0;
}
*response = resp;
return PAM_SUCCESS;
}
| 0
|
386,488
|
void DL_Dxf::addImageDef(DL_CreationInterface* creationInterface) {
DL_ImageDefData id(// handle
getStringValue(5, ""),
getStringValue(1, ""));
creationInterface->linkImage(id);
creationInterface->endEntity();
currentObjectType = DL_UNKNOWN;
}
| 0
|
430,361
|
void seq_puts(struct seq_file *m, const char *s)
{
int len = strlen(s);
if (m->count + len >= m->size) {
seq_set_overflow(m);
return;
}
memcpy(m->buf + m->count, s, len);
m->count += len;
}
| 0
|
220,429
|
mrb_ary_index_m(mrb_state *mrb, mrb_value self)
{
mrb_value obj = mrb_get_arg1(mrb);
mrb_int i;
for (i = 0; i < RARRAY_LEN(self); i++) {
if (mrb_equal(mrb, RARRAY_PTR(self)[i], obj)) {
return mrb_int_value(mrb, i);
}
}
return mrb_nil_value();
}
| 0
|
365,622
|
_asn1_change_integer_value (asn1_node node)
{
asn1_node p;
unsigned char val[SIZEOF_UNSIGNED_LONG_INT];
unsigned char val2[SIZEOF_UNSIGNED_LONG_INT + 1];
int len;
if (node == NULL)
return ASN1_ELEMENT_NOT_FOUND;
p = node;
while (p)
{
if ((type_field (p->type) == ASN1_ETYPE_INTEGER)
&& (p->type & CONST_ASSIGN))
{
if (p->value)
{
_asn1_convert_integer (p->value, val, sizeof (val), &len);
asn1_octet_der (val, len, val2, &len);
_asn1_set_value (p, val2, len);
}
}
if (p->down)
{
p = p->down;
}
else
{
if (p == node)
p = NULL;
else if (p->right)
p = p->right;
else
{
while (1)
{
p = _asn1_get_up (p);
if (p == node)
{
p = NULL;
break;
}
if (p->right)
{
p = p->right;
break;
}
}
}
}
}
return ASN1_SUCCESS;
}
| 0
|
219,916
|
GF_Err gf_isom_setup_hint_track(GF_ISOFile *movie, u32 trackNumber, GF_ISOHintFormat HintType)
{
GF_Err e;
GF_TrackBox *trak;
GF_TrackReferenceBox *tref;
GF_TrackReferenceTypeBox *dpnd;
GF_HintMediaHeaderBox *hmhd;
//UDTA related ...
GF_UserDataBox *udta;
//what do we support
switch (HintType) {
case GF_ISOM_HINT_RTP:
break;
default:
return GF_NOT_SUPPORTED;
}
e = CanAccessMovie(movie, GF_ISOM_OPEN_WRITE);
if (e) return e;
trak = gf_isom_get_track_from_file(movie, trackNumber);
if (!trak) return gf_isom_last_error(movie);
//check we have a hint ...
if ( !IsHintTrack(trak)) {
return GF_BAD_PARAM;
}
hmhd = (GF_HintMediaHeaderBox *)trak->Media->information->InfoHeader;
//make sure the subtype was not already defined
if (hmhd->subType) return GF_BAD_PARAM;
//store the HintTrack format for later use...
hmhd->subType = HintType;
//hint tracks always have a tref and everything ...
if (!trak->References) {
tref = (GF_TrackReferenceBox *) gf_isom_box_new_parent(&trak->child_boxes, GF_ISOM_BOX_TYPE_TREF);
if (!tref) return GF_OUT_OF_MEM;
e = trak_on_child_box((GF_Box*)trak, (GF_Box *)tref, GF_FALSE);
if (e) return e;
}
tref = trak->References;
//do we have a hint reference on this trak ???
e = Track_FindRef(trak, GF_ISOM_BOX_TYPE_HINT, &dpnd);
if (e) return e;
//if yes, return false (existing hint track...)
if (dpnd) return GF_BAD_PARAM;
//create our dep
dpnd = (GF_TrackReferenceTypeBox *) gf_isom_box_new_parent(&tref->child_boxes, GF_ISOM_BOX_TYPE_REFT);
if (!dpnd) return GF_OUT_OF_MEM;
dpnd->reference_type = GF_ISOM_BOX_TYPE_HINT;
//for RTP, we need to do some UDTA-related stuff...
if (HintType != GF_ISOM_HINT_RTP) return GF_OK;
if (!trak->udta) {
//create one
udta = (GF_UserDataBox *) gf_isom_box_new_parent(&trak->child_boxes, GF_ISOM_BOX_TYPE_UDTA);
if (!udta) return GF_OUT_OF_MEM;
e = trak_on_child_box((GF_Box*)trak, (GF_Box *) udta, GF_FALSE);
if (e) return e;
}
udta = trak->udta;
//HNTI
e = udta_on_child_box((GF_Box *)udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HNTI), GF_FALSE);
if (e) return e;
/*
//NAME
e = udta_on_child_box((GF_Box *)udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_NAME));
if (e) return e;
//HINF
return udta_on_child_box((GF_Box *)udta, gf_isom_box_new(GF_ISOM_BOX_TYPE_HINF));
*/
return GF_OK;
}
| 0
|
312,568
|
qf_grow_linebuf(qfstate_T *state, int newsz)
{
char_u *p;
// If the line exceeds LINE_MAXLEN exclude the last
// byte since it's not a NL character.
state->linelen = newsz > LINE_MAXLEN ? LINE_MAXLEN - 1 : newsz;
if (state->growbuf == NULL)
{
state->growbuf = alloc_id(state->linelen + 1, aid_qf_linebuf);
if (state->growbuf == NULL)
return NULL;
state->growbufsiz = state->linelen;
}
else if (state->linelen > state->growbufsiz)
{
if ((p = vim_realloc(state->growbuf, state->linelen + 1)) == NULL)
return NULL;
state->growbuf = p;
state->growbufsiz = state->linelen;
}
return state->growbuf;
}
| 0
|
225,871
|
void trak_box_del(GF_Box *s)
{
#ifndef GPAC_DISABLE_ISOM_WRITE
GF_TrackBox *ptr = (GF_TrackBox *)s;
if (ptr->chunk_cache)
gf_bs_del(ptr->chunk_cache);
#endif
gf_free(s);
}
| 0
|
336,529
|
static void pthreads_locking_callback(int mode, int type, const char *file, int line)
{
if (mode & CRYPTO_LOCK) {
pthread_mutex_lock(&(lock_cs[type]));
} else {
pthread_mutex_unlock(&(lock_cs[type]));
}
}
| 0
|
238,815
|
update_search_stat(
int dirc,
pos_T *pos,
pos_T *cursor_pos,
searchstat_T *stat,
int recompute,
int maxcount,
long timeout UNUSED)
{
int save_ws = p_ws;
int wraparound = FALSE;
pos_T p = (*pos);
static pos_T lastpos = {0, 0, 0};
static int cur = 0;
static int cnt = 0;
static int exact_match = FALSE;
static int incomplete = 0;
static int last_maxcount = SEARCH_STAT_DEF_MAX_COUNT;
static int chgtick = 0;
static char_u *lastpat = NULL;
static buf_T *lbuf = NULL;
#ifdef FEAT_RELTIME
proftime_T start;
#endif
vim_memset(stat, 0, sizeof(searchstat_T));
if (dirc == 0 && !recompute && !EMPTY_POS(lastpos))
{
stat->cur = cur;
stat->cnt = cnt;
stat->exact_match = exact_match;
stat->incomplete = incomplete;
stat->last_maxcount = last_maxcount;
return;
}
last_maxcount = maxcount;
wraparound = ((dirc == '?' && LT_POS(lastpos, p))
|| (dirc == '/' && LT_POS(p, lastpos)));
// If anything relevant changed the count has to be recomputed.
// MB_STRNICMP ignores case, but we should not ignore case.
// Unfortunately, there is no MB_STRNICMP function.
// XXX: above comment should be "no MB_STRCMP function" ?
if (!(chgtick == CHANGEDTICK(curbuf)
&& MB_STRNICMP(lastpat, spats[last_idx].pat, STRLEN(lastpat)) == 0
&& STRLEN(lastpat) == STRLEN(spats[last_idx].pat)
&& EQUAL_POS(lastpos, *cursor_pos)
&& lbuf == curbuf) || wraparound || cur < 0
|| (maxcount > 0 && cur > maxcount) || recompute)
{
cur = 0;
cnt = 0;
exact_match = FALSE;
incomplete = 0;
CLEAR_POS(&lastpos);
lbuf = curbuf;
}
if (EQUAL_POS(lastpos, *cursor_pos) && !wraparound
&& (dirc == 0 || dirc == '/' ? cur < cnt : cur > 0))
cur += dirc == 0 ? 0 : dirc == '/' ? 1 : -1;
else
{
int done_search = FALSE;
pos_T endpos = {0, 0, 0};
p_ws = FALSE;
#ifdef FEAT_RELTIME
if (timeout > 0)
profile_setlimit(timeout, &start);
#endif
while (!got_int && searchit(curwin, curbuf, &lastpos, &endpos,
FORWARD, NULL, 1, SEARCH_KEEP, RE_LAST, NULL) != FAIL)
{
done_search = TRUE;
#ifdef FEAT_RELTIME
// Stop after passing the time limit.
if (timeout > 0 && profile_passed_limit(&start))
{
incomplete = 1;
break;
}
#endif
cnt++;
if (LTOREQ_POS(lastpos, p))
{
cur = cnt;
if (LT_POS(p, endpos))
exact_match = TRUE;
}
fast_breakcheck();
if (maxcount > 0 && cnt > maxcount)
{
incomplete = 2; // max count exceeded
break;
}
}
if (got_int)
cur = -1; // abort
if (done_search)
{
vim_free(lastpat);
lastpat = vim_strsave(spats[last_idx].pat);
chgtick = CHANGEDTICK(curbuf);
lbuf = curbuf;
lastpos = p;
}
}
stat->cur = cur;
stat->cnt = cnt;
stat->exact_match = exact_match;
stat->incomplete = incomplete;
stat->last_maxcount = last_maxcount;
p_ws = save_ws;
}
| 0
|
513,353
|
change_cond_ref_to_const(THD *thd, I_List<COND_CMP> *save_list,
Item *and_father, Item *cond,
Item_bool_func2 *field_value_owner,
Item *field, Item *value)
{
if (cond->type() == Item::COND_ITEM)
{
bool and_level= ((Item_cond*) cond)->functype() ==
Item_func::COND_AND_FUNC;
List_iterator<Item> li(*((Item_cond*) cond)->argument_list());
Item *item;
while ((item=li++))
change_cond_ref_to_const(thd, save_list,and_level ? cond : item, item,
field_value_owner, field, value);
return;
}
if (cond->eq_cmp_result() == Item::COND_OK)
return; // Not a boolean function
Item_bool_func2 *func= (Item_bool_func2*) cond;
Item **args= func->arguments();
Item *left_item= args[0];
Item *right_item= args[1];
Item_func::Functype functype= func->functype();
if (can_change_cond_ref_to_const(func, right_item, left_item,
field_value_owner, field, value))
{
Item *tmp=value->clone_item(thd);
if (tmp)
{
tmp->collation.set(right_item->collation);
thd->change_item_tree(args + 1, tmp);
func->update_used_tables();
if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC)
&& and_father != cond && !left_item->const_item())
{
cond->marker=1;
COND_CMP *tmp2;
if ((tmp2= new (thd->mem_root) COND_CMP(and_father, func)))
save_list->push_back(tmp2);
}
/*
LIKE can be optimized for BINARY/VARBINARY/BLOB columns, e.g.:
from: WHERE CONCAT(c1)='const1' AND CONCAT(c1) LIKE 'const2'
to: WHERE CONCAT(c1)='const1' AND 'const1' LIKE 'const2'
So make sure to use set_cmp_func() only for non-LIKE operators.
*/
if (functype != Item_func::LIKE_FUNC)
((Item_bool_rowready_func2*) func)->set_cmp_func();
}
}
else if (can_change_cond_ref_to_const(func, left_item, right_item,
field_value_owner, field, value))
{
Item *tmp= value->clone_item(thd);
if (tmp)
{
tmp->collation.set(left_item->collation);
thd->change_item_tree(args, tmp);
value= tmp;
func->update_used_tables();
if ((functype == Item_func::EQ_FUNC || functype == Item_func::EQUAL_FUNC)
&& and_father != cond && !right_item->const_item())
{
args[0]= args[1]; // For easy check
thd->change_item_tree(args + 1, value);
cond->marker=1;
COND_CMP *tmp2;
if ((tmp2=new (thd->mem_root) COND_CMP(and_father, func)))
save_list->push_back(tmp2);
}
if (functype != Item_func::LIKE_FUNC)
((Item_bool_rowready_func2*) func)->set_cmp_func();
}
}
}
| 0
|
220,903
|
int DependencyOptimizer::NumEdgesIfBypassed(
const NodeDef& node, const std::vector<NodeDef*>& output_nodes) const {
const bool is_multi_input_identity_n =
IsIdentityN(node) && !IsIdentityNSingleInput(node);
const int num_outputs = output_nodes.size();
const int num_inputs = node.input_size();
if (is_multi_input_identity_n) {
// multi-input identity_n with input/output control dependencies will likely
// increase number of edges after optimization.
int num_edges_if_bypassed(0);
for (const string& input_node_name : node.input()) {
if (IsControlInput(input_node_name)) {
num_edges_if_bypassed += num_outputs;
} else {
++num_edges_if_bypassed;
}
}
for (auto consumer : output_nodes) {
for (int j = 0; j < consumer->input_size(); ++j) {
const TensorId consumer_input = ParseTensorName(consumer->input(j));
if (consumer_input.node() == node.name()) {
if (IsControlInput(consumer_input)) {
num_edges_if_bypassed += num_inputs;
} else {
++num_edges_if_bypassed;
}
}
}
}
return num_edges_if_bypassed;
} else {
return num_inputs * num_outputs;
}
}
| 0
|
487,630
|
asmlinkage long sys_setdomainname(char __user *name, int len)
{
int errno;
char tmp[__NEW_UTS_LEN];
if (!capable(CAP_SYS_ADMIN))
return -EPERM;
if (len < 0 || len > __NEW_UTS_LEN)
return -EINVAL;
down_write(&uts_sem);
errno = -EFAULT;
if (!copy_from_user(tmp, name, len)) {
memcpy(utsname()->domainname, tmp, len);
utsname()->domainname[len] = 0;
errno = 0;
}
up_write(&uts_sem);
return errno;
}
| 0
|
218,964
|
bool ExtractShape(const NodeDef& shape_node, const GraphProperties& properties,
BCast::Vec* shape, int64_t* min_id) {
if (shape_node.op() == "Shape") {
const std::vector<OpInfo::TensorProperties>& prop1 =
properties.GetInputProperties(shape_node.name());
if (prop1.size() != 1) {
return false;
}
const TensorShapeProto& shp = prop1[0].shape();
if (shp.unknown_rank()) {
return false;
}
for (const auto& dim : shp.dim()) {
shape->push_back(dim.size());
*min_id = std::min<int64_t>(*min_id, dim.size());
}
} else {
if (shape_node.attr().count("value") == 0) {
return false;
}
const TensorProto& raw_val = shape_node.attr().at("value").tensor();
if (raw_val.dtype() != DT_INT64 && raw_val.dtype() != DT_INT32) {
return false;
}
Tensor value(raw_val.dtype(), raw_val.tensor_shape());
if (!value.FromProto(raw_val)) {
return false;
}
for (int j = 0; j < value.NumElements(); ++j) {
if (raw_val.dtype() == DT_INT64) {
shape->push_back(value.vec<int64_t>()(j));
} else {
shape->push_back(value.vec<int>()(j));
}
}
}
return true;
}
| 0
|
213,482
|
nbd_internal_command_common (struct nbd_handle *h,
uint16_t flags, uint16_t type,
uint64_t offset, uint64_t count, int count_err,
void *data, struct command_cb *cb)
{
struct command *cmd;
if (h->disconnect_request) {
set_error (EINVAL, "cannot request more commands after NBD_CMD_DISC");
goto err;
}
if (h->in_flight == INT_MAX) {
set_error (ENOMEM, "too many commands already in flight");
goto err;
}
if (count_err) {
if ((h->strict & LIBNBD_STRICT_ZERO_SIZE) && count == 0) {
set_error (EINVAL, "count cannot be 0");
goto err;
}
if ((h->strict & LIBNBD_STRICT_BOUNDS) &&
(offset > h->exportsize || count > h->exportsize - offset)) {
set_error (count_err, "request out of bounds");
goto err;
}
if (h->block_minimum && (h->strict & LIBNBD_STRICT_ALIGN) &&
(offset | count) & (h->block_minimum - 1)) {
set_error (EINVAL, "request is unaligned");
goto err;
}
}
switch (type) {
/* Commands which send or receive data are limited to MAX_REQUEST_SIZE. */
case NBD_CMD_READ:
case NBD_CMD_WRITE:
if (count > MAX_REQUEST_SIZE) {
set_error (ERANGE, "request too large: maximum request size is %d",
MAX_REQUEST_SIZE);
goto err;
}
break;
/* Other commands are currently limited by the 32 bit field in the
* command structure on the wire, but in future we hope to support
* 64 bit values here with a change to the NBD protocol which is
* being discussed upstream.
*/
default:
if (count > UINT32_MAX) {
set_error (ERANGE, "request too large: maximum request size is %" PRIu32,
UINT32_MAX);
goto err;
}
break;
}
cmd = calloc (1, sizeof *cmd);
if (cmd == NULL) {
set_error (errno, "calloc");
goto err;
}
cmd->flags = flags;
cmd->type = type;
cmd->cookie = h->unique++;
cmd->offset = offset;
cmd->count = count;
cmd->data = data;
if (cb)
cmd->cb = *cb;
/* If structured replies were negotiated then we trust the server to
* send back sufficient data to cover the whole buffer. It's tricky
* to check this, so an easier thing is simply to zero the buffer
* ahead of time which avoids any security problems. I measured the
* overhead of this and for non-TLS there is no measurable overhead
* in the highly intensive loopback case. For TLS we get a
* performance gain, go figure.
*/
if (h->structured_replies && cmd->data && type == NBD_CMD_READ)
memset (cmd->data, 0, cmd->count);
/* Add the command to the end of the queue. Kick the state machine
* if there is no other command being processed, otherwise, it will
* be handled automatically on a future cycle around to READY.
* Beyond this point, we have to return a cookie to the user, since
* we are queuing the command, even if kicking the state machine
* detects a failure. Not reporting a state machine failure here is
* okay - any caller of an async command will be calling more API to
* await results, and will eventually learn that the machine has
* moved on to DEAD at that time.
*/
h->in_flight++;
if (h->cmds_to_issue != NULL) {
assert (nbd_internal_is_state_processing (get_next_state (h)));
h->cmds_to_issue_tail = h->cmds_to_issue_tail->next = cmd;
}
else {
assert (h->cmds_to_issue_tail == NULL);
h->cmds_to_issue = h->cmds_to_issue_tail = cmd;
if (nbd_internal_is_state_ready (get_next_state (h)) &&
nbd_internal_run (h, cmd_issue) == -1)
debug (h, "command queued, ignoring state machine failure");
}
return cmd->cookie;
err:
/* Since we did not queue the command, we must free the callbacks. */
if (cb) {
if (type == NBD_CMD_BLOCK_STATUS)
FREE_CALLBACK (cb->fn.extent);
if (type == NBD_CMD_READ)
FREE_CALLBACK (cb->fn.chunk);
FREE_CALLBACK (cb->completion);
}
return -1;
}
| 1
|
369,123
|
static int io_add_buffers(struct io_ring_ctx *ctx, struct io_provide_buf *pbuf,
struct io_buffer_list *bl)
{
struct io_buffer *buf;
u64 addr = pbuf->addr;
int i, bid = pbuf->bid;
for (i = 0; i < pbuf->nbufs; i++) {
if (list_empty(&ctx->io_buffers_cache) &&
io_refill_buffer_cache(ctx))
break;
buf = list_first_entry(&ctx->io_buffers_cache, struct io_buffer,
list);
list_move_tail(&buf->list, &bl->buf_list);
buf->addr = addr;
buf->len = min_t(__u32, pbuf->len, MAX_RW_COUNT);
buf->bid = bid;
buf->bgid = pbuf->bgid;
addr += pbuf->len;
bid++;
cond_resched();
}
return i ? 0 : -ENOMEM;
}
| 0
|
401,560
|
static void expire_timers(struct timer_base *base, struct hlist_head *head)
{
/*
* This value is required only for tracing. base->clk was
* incremented directly before expire_timers was called. But expiry
* is related to the old base->clk value.
*/
unsigned long baseclk = base->clk - 1;
while (!hlist_empty(head)) {
struct timer_list *timer;
void (*fn)(struct timer_list *);
timer = hlist_entry(head->first, struct timer_list, entry);
base->running_timer = timer;
detach_timer(timer, true);
fn = timer->function;
if (timer->flags & TIMER_IRQSAFE) {
raw_spin_unlock(&base->lock);
call_timer_fn(timer, fn, baseclk);
base->running_timer = NULL;
raw_spin_lock(&base->lock);
} else {
raw_spin_unlock_irq(&base->lock);
call_timer_fn(timer, fn, baseclk);
base->running_timer = NULL;
timer_sync_wait_running(base);
raw_spin_lock_irq(&base->lock);
}
}
}
| 0
|
90,787
|
void QuotaManager::LazyInitialize() {
DCHECK(io_thread_->BelongsToCurrentThread());
if (database_.get()) {
return;
}
database_.reset(new QuotaDatabase(is_incognito_ ? FilePath() :
profile_path_.AppendASCII(kDatabaseName)));
temporary_usage_tracker_.reset(
new UsageTracker(clients_, kStorageTypeTemporary,
special_storage_policy_));
persistent_usage_tracker_.reset(
new UsageTracker(clients_, kStorageTypePersistent,
special_storage_policy_));
scoped_refptr<InitializeTask> task(
new InitializeTask(this, profile_path_, is_incognito_));
task->Start();
}
| 0
|
359,357
|
extcommunity_list_unset_vty (struct vty *vty, int argc, const char **argv,
int style)
{
int ret;
int direct = 0;
char *str = NULL;
if (argc > 1)
{
/* Check the list direct. */
if (strncmp (argv[1], "p", 1) == 0)
direct = COMMUNITY_PERMIT;
else if (strncmp (argv[1], "d", 1) == 0)
direct = COMMUNITY_DENY;
else
{
vty_out (vty, "%% Matching condition must be permit or deny%s",
VTY_NEWLINE);
return CMD_WARNING;
}
/* Concat community string argument. */
str = argv_concat (argv, argc, 2);
}
/* Unset community list. */
ret = extcommunity_list_unset (bgp_clist, argv[0], str, direct, style);
/* Free temporary community list string allocated by
argv_concat(). */
if (str)
XFREE (MTYPE_TMP, str);
if (ret < 0)
{
community_list_perror (vty, ret);
return CMD_WARNING;
}
return CMD_SUCCESS;
}
| 0
|
226,160
|
GF_Err dimm_box_write(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
GF_DIMMBox *ptr = (GF_DIMMBox *)s;
if (ptr == NULL) return GF_BAD_PARAM;
e = gf_isom_box_write_header(s, bs);
if (e) return e;
gf_bs_write_u64(bs, ptr->nbBytes);
return GF_OK;
}
| 0
|
436,990
|
get_lisp_indent(void)
{
pos_T *pos, realpos, paren;
int amount;
char_u *that;
colnr_T col;
colnr_T firsttry;
int parencount, quotecount;
int vi_lisp;
// Set vi_lisp to use the vi-compatible method
vi_lisp = (vim_strchr(p_cpo, CPO_LISP) != NULL);
realpos = curwin->w_cursor;
curwin->w_cursor.col = 0;
if ((pos = findmatch(NULL, '(')) == NULL)
pos = findmatch(NULL, '[');
else
{
paren = *pos;
pos = findmatch(NULL, '[');
if (pos == NULL || LT_POSP(pos, &paren))
pos = &paren;
}
if (pos != NULL)
{
// Extra trick: Take the indent of the first previous non-white
// line that is at the same () level.
amount = -1;
parencount = 0;
while (--curwin->w_cursor.lnum >= pos->lnum)
{
if (linewhite(curwin->w_cursor.lnum))
continue;
for (that = ml_get_curline(); *that != NUL; ++that)
{
if (*that == ';')
{
while (*(that + 1) != NUL)
++that;
continue;
}
if (*that == '\\')
{
if (*(that + 1) != NUL)
++that;
continue;
}
if (*that == '"' && *(that + 1) != NUL)
{
while (*++that && *that != '"')
{
// skipping escaped characters in the string
if (*that == '\\')
{
if (*++that == NUL)
break;
if (that[1] == NUL)
{
++that;
break;
}
}
}
if (*that == NUL)
break;
}
if (*that == '(' || *that == '[')
++parencount;
else if (*that == ')' || *that == ']')
--parencount;
}
if (parencount == 0)
{
amount = get_indent();
break;
}
}
if (amount == -1)
{
curwin->w_cursor.lnum = pos->lnum;
curwin->w_cursor.col = pos->col;
col = pos->col;
that = ml_get_curline();
if (vi_lisp && get_indent() == 0)
amount = 2;
else
{
char_u *line = that;
amount = 0;
while (*that && col)
{
amount += lbr_chartabsize_adv(line, &that, (colnr_T)amount);
col--;
}
// Some keywords require "body" indenting rules (the
// non-standard-lisp ones are Scheme special forms):
//
// (let ((a 1)) instead (let ((a 1))
// (...)) of (...))
if (!vi_lisp && (*that == '(' || *that == '[')
&& lisp_match(that + 1))
amount += 2;
else
{
if (*that != NUL)
{
that++;
amount++;
}
firsttry = amount;
while (VIM_ISWHITE(*that))
{
amount += lbr_chartabsize(line, that, (colnr_T)amount);
++that;
}
if (*that && *that != ';') // not a comment line
{
// test *that != '(' to accommodate first let/do
// argument if it is more than one line
if (!vi_lisp && *that != '(' && *that != '[')
firsttry++;
parencount = 0;
quotecount = 0;
if (vi_lisp
|| (*that != '"'
&& *that != '\''
&& *that != '#'
&& (*that < '0' || *that > '9')))
{
while (*that
&& (!VIM_ISWHITE(*that)
|| quotecount
|| parencount)
&& (!((*that == '(' || *that == '[')
&& !quotecount
&& !parencount
&& vi_lisp)))
{
if (*that == '"')
quotecount = !quotecount;
if ((*that == '(' || *that == '[')
&& !quotecount)
++parencount;
if ((*that == ')' || *that == ']')
&& !quotecount)
--parencount;
if (*that == '\\' && *(that+1) != NUL)
amount += lbr_chartabsize_adv(
line, &that, (colnr_T)amount);
amount += lbr_chartabsize_adv(
line, &that, (colnr_T)amount);
}
}
while (VIM_ISWHITE(*that))
{
amount += lbr_chartabsize(
line, that, (colnr_T)amount);
that++;
}
if (!*that || *that == ';')
amount = firsttry;
}
}
}
}
}
else
amount = 0; // no matching '(' or '[' found, use zero indent
curwin->w_cursor = realpos;
return amount;
}
| 0
|
247,745
|
absl::string_view name() override { return "envoy.tls.cert_validator.default"; }
| 0
|
457,871
|
get_bounding_box (GeglOperation *operation)
{
GeglRectangle result = {0,0,0,0};
GeglProperties *o = GEGL_PROPERTIES (operation);
gint width, height;
load_cache (o);
g_object_get (o->user_data, "width", &width,
"height", &height, NULL);
result.width = width;
result.height = height;
return result;
}
| 0
|
459,118
|
static struct tcf_chain *__tcf_chain_get(struct tcf_block *block,
u32 chain_index, bool create,
bool by_act)
{
struct tcf_chain *chain = NULL;
bool is_first_reference;
mutex_lock(&block->lock);
chain = tcf_chain_lookup(block, chain_index);
if (chain) {
tcf_chain_hold(chain);
} else {
if (!create)
goto errout;
chain = tcf_chain_create(block, chain_index);
if (!chain)
goto errout;
}
if (by_act)
++chain->action_refcnt;
is_first_reference = chain->refcnt - chain->action_refcnt == 1;
mutex_unlock(&block->lock);
/* Send notification only in case we got the first
* non-action reference. Until then, the chain acts only as
* a placeholder for actions pointing to it and user ought
* not know about them.
*/
if (is_first_reference && !by_act)
tc_chain_notify(chain, NULL, 0, NLM_F_CREATE | NLM_F_EXCL,
RTM_NEWCHAIN, false);
return chain;
errout:
mutex_unlock(&block->lock);
return chain;
}
| 0
|
312,462
|
qf_get_next_list_line(qfstate_T *state)
{
listitem_T *p_li = state->p_li;
int len;
while (p_li != NULL
&& (p_li->li_tv.v_type != VAR_STRING
|| p_li->li_tv.vval.v_string == NULL))
p_li = p_li->li_next; // Skip non-string items
if (p_li == NULL) // End of the list
{
state->p_li = NULL;
return QF_END_OF_INPUT;
}
len = (int)STRLEN(p_li->li_tv.vval.v_string);
if (len > IOSIZE - 2)
{
state->linebuf = qf_grow_linebuf(state, len);
if (state->linebuf == NULL)
return QF_NOMEM;
}
else
{
state->linebuf = IObuff;
state->linelen = len;
}
vim_strncpy(state->linebuf, p_li->li_tv.vval.v_string, state->linelen);
state->p_li = p_li->li_next; // next item
return QF_OK;
}
| 0
|
233,847
|
i64 fmtutil_hlp_get_cul_p(dbuf *f, i64 *ppos)
{
i64 x1, x2;
x1 = dbuf_getu16le_p(f, ppos);
if(x1%2 == 0) {
// If it's even, divide by two.
return x1>>1;
}
// If it's odd, divide by two, and add 32768 times the value of
// the next two bytes.
x2 = dbuf_getu16le_p(f, ppos);
return (x1>>1) | (x2<<15);
}
| 0
|
427,233
|
static UnOpr getunopr (int op) {
switch (op) {
case TK_NOT: return OPR_NOT;
case '-': return OPR_MINUS;
case '~': return OPR_BNOT;
case '#': return OPR_LEN;
default: return OPR_NOUNOPR;
}
}
| 0
|
238,563
|
static bool may_be_acquire_function(enum bpf_func_id func_id)
{
return func_id == BPF_FUNC_sk_lookup_tcp ||
func_id == BPF_FUNC_sk_lookup_udp ||
func_id == BPF_FUNC_skc_lookup_tcp ||
func_id == BPF_FUNC_map_lookup_elem ||
func_id == BPF_FUNC_ringbuf_reserve;
}
| 0
|
507,772
|
static int ec_asn1_group2curve(const EC_GROUP *group, X9_62_CURVE *curve)
{
int ok = 0;
BIGNUM *tmp_1 = NULL, *tmp_2 = NULL;
unsigned char *a_buf = NULL, *b_buf = NULL;
size_t len;
if (!group || !curve || !curve->a || !curve->b)
return 0;
if ((tmp_1 = BN_new()) == NULL || (tmp_2 = BN_new()) == NULL) {
ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_MALLOC_FAILURE);
goto err;
}
/* get a and b */
if (!EC_GROUP_get_curve(group, NULL, tmp_1, tmp_2, NULL)) {
ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_EC_LIB);
goto err;
}
/*
* Per SEC 1, the curve coefficients must be padded up to size. See C.2's
* definition of Curve, C.1's definition of FieldElement, and 2.3.5's
* definition of how to encode the field elements.
*/
len = ((size_t)EC_GROUP_get_degree(group) + 7) / 8;
if ((a_buf = OPENSSL_malloc(len)) == NULL
|| (b_buf = OPENSSL_malloc(len)) == NULL) {
ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_MALLOC_FAILURE);
goto err;
}
if (BN_bn2binpad(tmp_1, a_buf, len) < 0
|| BN_bn2binpad(tmp_2, b_buf, len) < 0) {
ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_BN_LIB);
goto err;
}
/* set a and b */
if (!ASN1_OCTET_STRING_set(curve->a, a_buf, len)
|| !ASN1_OCTET_STRING_set(curve->b, b_buf, len)) {
ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_ASN1_LIB);
goto err;
}
/* set the seed (optional) */
if (group->seed) {
if (!curve->seed)
if ((curve->seed = ASN1_BIT_STRING_new()) == NULL) {
ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_MALLOC_FAILURE);
goto err;
}
curve->seed->flags &= ~(ASN1_STRING_FLAG_BITS_LEFT | 0x07);
curve->seed->flags |= ASN1_STRING_FLAG_BITS_LEFT;
if (!ASN1_BIT_STRING_set(curve->seed, group->seed,
(int)group->seed_len)) {
ECerr(EC_F_EC_ASN1_GROUP2CURVE, ERR_R_ASN1_LIB);
goto err;
}
} else {
ASN1_BIT_STRING_free(curve->seed);
curve->seed = NULL;
}
ok = 1;
err:
OPENSSL_free(a_buf);
OPENSSL_free(b_buf);
BN_free(tmp_1);
BN_free(tmp_2);
return ok;
}
| 0
|
500,061
|
kssl_ctx_setstring(KSSL_CTX *kssl_ctx, int which, char *text)
{
char **string;
if (!kssl_ctx) return KSSL_CTX_ERR;
switch (which)
{
case KSSL_SERVICE: string = &kssl_ctx->service_name; break;
case KSSL_SERVER: string = &kssl_ctx->service_host; break;
case KSSL_CLIENT: string = &kssl_ctx->client_princ; break;
case KSSL_KEYTAB: string = &kssl_ctx->keytab_file; break;
default: return KSSL_CTX_ERR; break;
}
if (*string) kssl_free(*string);
if (!text)
{
*string = '\0';
return KSSL_CTX_OK;
}
if ((*string = kssl_calloc(1, strlen(text) + 1)) == NULL)
return KSSL_CTX_ERR;
else
strcpy(*string, text);
return KSSL_CTX_OK;
}
| 0
|
275,969
|
const uECC_word_t *uECC_curve_G(uECC_Curve curve) {
return curve->G;
}
| 0
|
225,372
|
static int vidioc_s_parm(struct file *file, void *priv,
struct v4l2_streamparm *parm)
{
struct v4l2_loopback_device *dev;
int err = 0;
MARK();
dev = v4l2loopback_getdevice(file);
dprintk("vidioc_s_parm called frate=%d/%d\n",
parm->parm.capture.timeperframe.numerator,
parm->parm.capture.timeperframe.denominator);
switch (parm->type) {
case V4L2_BUF_TYPE_VIDEO_CAPTURE:
if ((err = set_timeperframe(
dev, &parm->parm.capture.timeperframe)) < 0)
return err;
break;
case V4L2_BUF_TYPE_VIDEO_OUTPUT:
if ((err = set_timeperframe(
dev, &parm->parm.capture.timeperframe)) < 0)
return err;
break;
default:
return -1;
}
parm->parm.capture = dev->capture_param;
return 0;
}
| 0
|
512,525
|
virtual bool with_subquery() const
{
return (*ref)->with_subquery();
}
| 0
|
292,171
|
void LinkResolver::check_field_loader_constraints(Symbol* field, Symbol* sig,
Klass* current_klass,
Klass* sel_klass, TRAPS) {
Handle ref_loader(THREAD, current_klass->class_loader());
Handle sel_loader(THREAD, sel_klass->class_loader());
ResourceMark rm(THREAD); // needed for check_signature_loaders
Symbol* failed_type_symbol =
SystemDictionary::check_signature_loaders(sig,
ref_loader, sel_loader,
false,
CHECK);
if (failed_type_symbol != NULL) {
stringStream ss;
const char* failed_type_name = failed_type_symbol->as_klass_external_name();
ss.print("loader constraint violation: when resolving field"
" \"%s\" of type %s, the class loader %s of the current class, "
"%s, and the class loader %s for the field's defining "
"type, %s, have different Class objects for type %s (%s; %s)",
field->as_C_string(),
failed_type_name,
current_klass->class_loader_data()->loader_name_and_id(),
current_klass->external_name(),
sel_klass->class_loader_data()->loader_name_and_id(),
sel_klass->external_name(),
failed_type_name,
current_klass->class_in_module_of_loader(false, true),
sel_klass->class_in_module_of_loader(false, true));
THROW_MSG(vmSymbols::java_lang_LinkageError(), ss.as_string());
}
}
| 0
|
484,063
|
setup_secureChannel(void) {
TestingPolicy(&dummyPolicy, dummyCertificate, &fCalled, &keySizes);
UA_SecureChannel_init(&testChannel, &UA_ConnectionConfig_default);
UA_SecureChannel_setSecurityPolicy(&testChannel, &dummyPolicy, &dummyCertificate);
testingConnection =
createDummyConnection(UA_ConnectionConfig_default.sendBufferSize, &sentData);
UA_Connection_attachSecureChannel(&testingConnection, &testChannel);
testChannel.connection = &testingConnection;
testChannel.state = UA_SECURECHANNELSTATE_OPEN;
}
| 0
|
285,161
|
void __init(RBuffer *buf, r_bin_ne_obj_t *bin) {
bin->header_offset = r_buf_read_le16_at (buf, 0x3c);
bin->ne_header = R_NEW0 (NE_image_header);
if (!bin->ne_header) {
return;
}
bin->buf = buf;
// XXX this is endian unsafe
if (r_buf_read_at (buf, bin->header_offset, (ut8 *)bin->ne_header, sizeof (NE_image_header)) < 1) {
R_FREE (bin->ne_header);
return;
}
if (bin->ne_header->FileAlnSzShftCnt > 15) {
bin->ne_header->FileAlnSzShftCnt = 15;
}
ut64 from = bin->ne_header->ModRefTable + bin->header_offset;
ut64 left = r_buf_size (bin->buf) - from;
if (from + bin->ne_header->ModRefs * sizeof (ut16) >= left) {
bin->ne_header->ModRefs = left / sizeof (ut16);
}
bin->alignment = 1 << bin->ne_header->FileAlnSzShftCnt;
if (!bin->alignment) {
bin->alignment = 1 << 9;
}
bin->os = __get_target_os (bin);
ut16 offset = bin->ne_header->SegTableOffset + bin->header_offset;
size_t size = bin->ne_header->SegCount * sizeof (NE_image_segment_entry);
if (offset >= r_buf_size (bin->buf)) {
return;
}
size_t remaining = r_buf_size (bin->buf) - offset;
size = R_MIN (remaining, size);
bin->ne_header->SegCount = size / sizeof (NE_image_segment_entry); // * sizeof (NE_image_segment_entry);
bin->segment_entries = calloc (1, size);
if (size >= remaining) {
bin->ne_header->SegCount = size / sizeof (NE_image_segment_entry);
}
if (!bin->segment_entries) {
return;
}
r_buf_read_at (buf, offset, (ut8 *)bin->segment_entries, size);
bin->entry_table = calloc (4, bin->ne_header->EntryTableLength);
if (!bin->entry_table) {
R_FREE (bin->segment_entries);
return;
}
r_buf_read_at (buf, (ut64)bin->header_offset + bin->ne_header->EntryTableOffset, bin->entry_table, bin->ne_header->EntryTableLength);
bin->imports = r_bin_ne_get_imports (bin);
__ne_get_resources (bin);
}
| 0
|
512,478
|
Item *and_expressions(THD *thd, Item *a, Item *b, Item **org_item)
{
if (!a)
return (*org_item= (Item*) b);
if (a == *org_item)
{
Item_cond *res;
if ((res= new (thd->mem_root) Item_cond_and(thd, a, (Item*) b)))
{
res->used_tables_cache= a->used_tables() | b->used_tables();
res->not_null_tables_cache= a->not_null_tables() | b->not_null_tables();
}
return res;
}
if (((Item_cond_and*) a)->add((Item*) b, thd->mem_root))
return 0;
((Item_cond_and*) a)->used_tables_cache|= b->used_tables();
((Item_cond_and*) a)->not_null_tables_cache|= b->not_null_tables();
return a;
}
| 0
|
234,718
|
int btrfs_get_dev_stats(struct btrfs_fs_info *fs_info,
struct btrfs_ioctl_get_dev_stats *stats)
{
struct btrfs_device *dev;
struct btrfs_fs_devices *fs_devices = fs_info->fs_devices;
int i;
mutex_lock(&fs_devices->device_list_mutex);
dev = btrfs_find_device(fs_info->fs_devices, stats->devid, NULL, NULL);
mutex_unlock(&fs_devices->device_list_mutex);
if (!dev) {
btrfs_warn(fs_info, "get dev_stats failed, device not found");
return -ENODEV;
} else if (!dev->dev_stats_valid) {
btrfs_warn(fs_info, "get dev_stats failed, not yet valid");
return -ENODEV;
} else if (stats->flags & BTRFS_DEV_STATS_RESET) {
for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++) {
if (stats->nr_items > i)
stats->values[i] =
btrfs_dev_stat_read_and_reset(dev, i);
else
btrfs_dev_stat_set(dev, i, 0);
}
btrfs_info(fs_info, "device stats zeroed by %s (%d)",
current->comm, task_pid_nr(current));
} else {
for (i = 0; i < BTRFS_DEV_STAT_VALUES_MAX; i++)
if (stats->nr_items > i)
stats->values[i] = btrfs_dev_stat_read(dev, i);
}
if (stats->nr_items > BTRFS_DEV_STAT_VALUES_MAX)
stats->nr_items = BTRFS_DEV_STAT_VALUES_MAX;
return 0;
}
| 0
|
434,101
|
do_argfile(exarg_T *eap, int argn)
{
int other;
char_u *p;
int old_arg_idx = curwin->w_arg_idx;
if (ERROR_IF_ANY_POPUP_WINDOW)
return;
if (argn < 0 || argn >= ARGCOUNT)
{
if (ARGCOUNT <= 1)
emsg(_("E163: There is only one file to edit"));
else if (argn < 0)
emsg(_("E164: Cannot go before first file"));
else
emsg(_("E165: Cannot go beyond last file"));
}
else
{
setpcmark();
#ifdef FEAT_GUI
need_mouse_correct = TRUE;
#endif
// split window or create new tab page first
if (*eap->cmd == 's' || cmdmod.cmod_tab != 0)
{
if (win_split(0, 0) == FAIL)
return;
RESET_BINDING(curwin);
}
else
{
// if 'hidden' set, only check for changed file when re-editing
// the same buffer
other = TRUE;
if (buf_hide(curbuf))
{
p = fix_fname(alist_name(&ARGLIST[argn]));
other = otherfile(p);
vim_free(p);
}
if ((!buf_hide(curbuf) || !other)
&& check_changed(curbuf, CCGD_AW
| (other ? 0 : CCGD_MULTWIN)
| (eap->forceit ? CCGD_FORCEIT : 0)
| CCGD_EXCMD))
return;
}
curwin->w_arg_idx = argn;
if (argn == ARGCOUNT - 1 && curwin->w_alist == &global_alist)
arg_had_last = TRUE;
// Edit the file; always use the last known line number.
// When it fails (e.g. Abort for already edited file) restore the
// argument index.
if (do_ecmd(0, alist_name(&ARGLIST[curwin->w_arg_idx]), NULL,
eap, ECMD_LAST,
(buf_hide(curwin->w_buffer) ? ECMD_HIDE : 0)
+ (eap->forceit ? ECMD_FORCEIT : 0), curwin) == FAIL)
curwin->w_arg_idx = old_arg_idx;
// like Vi: set the mark where the cursor is in the file.
else if (eap->cmdidx != CMD_argdo)
setmark('\'');
}
}
| 0
|
226,408
|
GF_Err segr_box_size(GF_Box *s)
{
u32 i;
FDSessionGroupBox *ptr = (FDSessionGroupBox *)s;
ptr->size += 2;
for (i=0; i<ptr->num_session_groups; i++) {
ptr->size += 1 + 4*ptr->session_groups[i].nb_groups;
ptr->size += 2 + 4*ptr->session_groups[i].nb_channels;
}
return GF_OK;
| 0
|
383,385
|
HWB_Diff (int r1, int g1, int b1, int r2, int g2, int b2)
{
RGBType RGB1, RGB2;
HWBType HWB1, HWB2;
float diff;
SETUP_RGB (RGB1, r1, g1, b1);
SETUP_RGB (RGB2, r2, g2, b2);
RGB_to_HWB (RGB1, &HWB1);
RGB_to_HWB (RGB2, &HWB2);
/*
* I made this bit up; it seems to produce OK results, and it is certainly
* more visually correct than the current RGB metric. (PJW)
*/
if ((HWB1.H == HWB_UNDEFINED) || (HWB2.H == HWB_UNDEFINED))
{
diff = 0.0f; /* Undefined hues always match... */
}
else
{
diff = fabsf(HWB1.H - HWB2.H);
if (diff > 3.0f)
{
diff = 6.0f - diff; /* Remember, it's a colour circle */
}
}
diff = diff * diff + (HWB1.W - HWB2.W) * (HWB1.W - HWB2.W) + (HWB1.B - HWB2.B) * (HWB1.B - HWB2.B);
return diff;
}
| 0
|
90,850
|
void DumpOriginInfoTable() {
origin_info_entries_.clear();
quota_manager_->DumpOriginInfoTable(
callback_factory_.NewCallback(
&QuotaManagerTest::DidDumpOriginInfoTable));
}
| 0
|
223,394
|
static void compile_ref_matchingpath(compiler_common *common, PCRE2_SPTR cc, jump_list **backtracks, BOOL withchecks, BOOL emptyfail)
{
DEFINE_COMPILER;
BOOL ref = (*cc == OP_REF || *cc == OP_REFI);
int offset = 0;
struct sljit_jump *jump = NULL;
struct sljit_jump *partial;
struct sljit_jump *nopartial;
#if defined SUPPORT_UNICODE
struct sljit_label *loop;
struct sljit_label *caseless_loop;
jump_list *no_match = NULL;
int source_reg = COUNT_MATCH;
int source_end_reg = ARGUMENTS;
int char1_reg = STACK_LIMIT;
#endif /* SUPPORT_UNICODE */
if (ref)
{
offset = GET2(cc, 1) << 1;
OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset));
/* OVECTOR(1) contains the "string begin - 1" constant. */
if (withchecks && !common->unset_backref)
add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(1)));
}
else
OP1(SLJIT_MOV, TMP1, 0, SLJIT_MEM1(TMP2), 0);
#if defined SUPPORT_UNICODE
if (common->utf && *cc == OP_REFI)
{
SLJIT_ASSERT(common->iref_ptr != 0);
if (ref)
OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1));
else
OP1(SLJIT_MOV, TMP2, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw));
if (withchecks && emptyfail)
add_jump(compiler, backtracks, CMP(SLJIT_EQUAL, TMP1, 0, TMP2, 0));
OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->iref_ptr, source_reg, 0);
OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw), source_end_reg, 0);
OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw) * 2, char1_reg, 0);
OP1(SLJIT_MOV, source_reg, 0, TMP1, 0);
OP1(SLJIT_MOV, source_end_reg, 0, TMP2, 0);
loop = LABEL();
jump = CMP(SLJIT_GREATER_EQUAL, source_reg, 0, source_end_reg, 0);
partial = CMP(SLJIT_GREATER_EQUAL, STR_PTR, 0, STR_END, 0);
/* Read original character. It must be a valid UTF character. */
OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);
OP1(SLJIT_MOV, STR_PTR, 0, source_reg, 0);
read_char(common, 0, READ_CHAR_MAX, NULL, READ_CHAR_UPDATE_STR_PTR | READ_CHAR_VALID_UTF);
OP1(SLJIT_MOV, source_reg, 0, STR_PTR, 0);
OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0);
OP1(SLJIT_MOV, char1_reg, 0, TMP1, 0);
/* Read second character. */
read_char(common, 0, READ_CHAR_MAX, &no_match, READ_CHAR_UPDATE_STR_PTR);
CMPTO(SLJIT_EQUAL, TMP1, 0, char1_reg, 0, loop);
OP1(SLJIT_MOV, TMP3, 0, TMP1, 0);
add_jump(compiler, &common->getucd, JUMP(SLJIT_FAST_CALL));
OP2(SLJIT_SHL, TMP1, 0, TMP2, 0, SLJIT_IMM, 2);
OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 3);
OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, TMP1, 0);
OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_records));
OP1(SLJIT_MOV_S32, TMP1, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(ucd_record, other_case));
OP1(SLJIT_MOV_U8, TMP2, 0, SLJIT_MEM1(TMP2), SLJIT_OFFSETOF(ucd_record, caseset));
OP2(SLJIT_ADD, TMP1, 0, TMP1, 0, TMP3, 0);
CMPTO(SLJIT_EQUAL, TMP1, 0, char1_reg, 0, loop);
add_jump(compiler, &no_match, CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
OP2(SLJIT_SHL, TMP2, 0, TMP2, 0, SLJIT_IMM, 2);
OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, (sljit_sw)PRIV(ucd_caseless_sets));
caseless_loop = LABEL();
OP1(SLJIT_MOV_U32, TMP1, 0, SLJIT_MEM1(TMP2), 0);
OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, SLJIT_IMM, sizeof(uint32_t));
OP2U(SLJIT_SUB | SLJIT_SET_Z | SLJIT_SET_LESS, TMP1, 0, char1_reg, 0);
JUMPTO(SLJIT_EQUAL, loop);
JUMPTO(SLJIT_LESS, caseless_loop);
set_jumps(no_match, LABEL());
if (common->mode == PCRE2_JIT_COMPLETE)
JUMPHERE(partial);
OP1(SLJIT_MOV, source_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr);
OP1(SLJIT_MOV, source_end_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw));
OP1(SLJIT_MOV, char1_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw) * 2);
add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
if (common->mode != PCRE2_JIT_COMPLETE)
{
JUMPHERE(partial);
OP1(SLJIT_MOV, source_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr);
OP1(SLJIT_MOV, source_end_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw));
OP1(SLJIT_MOV, char1_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw) * 2);
check_partial(common, FALSE);
add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
}
JUMPHERE(jump);
OP1(SLJIT_MOV, source_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr);
OP1(SLJIT_MOV, source_end_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw));
OP1(SLJIT_MOV, char1_reg, 0, SLJIT_MEM1(SLJIT_SP), common->iref_ptr + sizeof(sljit_sw) * 2);
return;
}
else
#endif /* SUPPORT_UNICODE */
{
if (ref)
OP2(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, SLJIT_MEM1(SLJIT_SP), OVECTOR(offset + 1), TMP1, 0);
else
OP2(SLJIT_SUB | SLJIT_SET_Z, TMP2, 0, SLJIT_MEM1(TMP2), sizeof(sljit_sw), TMP1, 0);
if (withchecks)
jump = JUMP(SLJIT_ZERO);
OP2(SLJIT_ADD, STR_PTR, 0, STR_PTR, 0, TMP2, 0);
partial = CMP(SLJIT_GREATER, STR_PTR, 0, STR_END, 0);
if (common->mode == PCRE2_JIT_COMPLETE)
add_jump(compiler, backtracks, partial);
add_jump(compiler, *cc == OP_REF ? &common->casefulcmp : &common->caselesscmp, JUMP(SLJIT_FAST_CALL));
add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
if (common->mode != PCRE2_JIT_COMPLETE)
{
nopartial = JUMP(SLJIT_JUMP);
JUMPHERE(partial);
/* TMP2 -= STR_END - STR_PTR */
OP2(SLJIT_SUB, TMP2, 0, TMP2, 0, STR_PTR, 0);
OP2(SLJIT_ADD, TMP2, 0, TMP2, 0, STR_END, 0);
partial = CMP(SLJIT_EQUAL, TMP2, 0, SLJIT_IMM, 0);
OP1(SLJIT_MOV, STR_PTR, 0, STR_END, 0);
add_jump(compiler, *cc == OP_REF ? &common->casefulcmp : &common->caselesscmp, JUMP(SLJIT_FAST_CALL));
add_jump(compiler, backtracks, CMP(SLJIT_NOT_EQUAL, TMP2, 0, SLJIT_IMM, 0));
JUMPHERE(partial);
check_partial(common, FALSE);
add_jump(compiler, backtracks, JUMP(SLJIT_JUMP));
JUMPHERE(nopartial);
}
}
if (jump != NULL)
{
if (emptyfail)
add_jump(compiler, backtracks, jump);
else
JUMPHERE(jump);
}
}
| 0
|
384,768
|
halfpage(int flag, linenr_T Prenum)
{
long scrolled = 0;
int i;
int n;
int room;
if (Prenum)
curwin->w_p_scr = (Prenum > curwin->w_height) ?
curwin->w_height : Prenum;
n = (curwin->w_p_scr <= curwin->w_height) ?
curwin->w_p_scr : curwin->w_height;
update_topline();
validate_botline();
room = curwin->w_empty_rows;
#ifdef FEAT_DIFF
room += curwin->w_filler_rows;
#endif
if (flag)
{
/*
* scroll the text up
*/
while (n > 0 && curwin->w_botline <= curbuf->b_ml.ml_line_count)
{
#ifdef FEAT_DIFF
if (curwin->w_topfill > 0)
{
i = 1;
--n;
--curwin->w_topfill;
}
else
#endif
{
i = PLINES_NOFILL(curwin->w_topline);
n -= i;
if (n < 0 && scrolled > 0)
break;
#ifdef FEAT_FOLDING
(void)hasFolding(curwin->w_topline, NULL, &curwin->w_topline);
#endif
++curwin->w_topline;
#ifdef FEAT_DIFF
curwin->w_topfill = diff_check_fill(curwin, curwin->w_topline);
#endif
if (curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)
{
++curwin->w_cursor.lnum;
curwin->w_valid &=
~(VALID_VIRTCOL|VALID_CHEIGHT|VALID_WCOL);
}
}
curwin->w_valid &= ~(VALID_CROW|VALID_WROW);
scrolled += i;
/*
* Correct w_botline for changed w_topline.
* Won't work when there are filler lines.
*/
#ifdef FEAT_DIFF
if (curwin->w_p_diff)
curwin->w_valid &= ~(VALID_BOTLINE|VALID_BOTLINE_AP);
else
#endif
{
room += i;
do
{
i = plines(curwin->w_botline);
if (i > room)
break;
#ifdef FEAT_FOLDING
(void)hasFolding(curwin->w_botline, NULL,
&curwin->w_botline);
#endif
++curwin->w_botline;
room -= i;
} while (curwin->w_botline <= curbuf->b_ml.ml_line_count);
}
}
/*
* When hit bottom of the file: move cursor down.
*/
if (n > 0)
{
# ifdef FEAT_FOLDING
if (hasAnyFolding(curwin))
{
while (--n >= 0
&& curwin->w_cursor.lnum < curbuf->b_ml.ml_line_count)
{
(void)hasFolding(curwin->w_cursor.lnum, NULL,
&curwin->w_cursor.lnum);
++curwin->w_cursor.lnum;
}
}
else
# endif
curwin->w_cursor.lnum += n;
check_cursor_lnum();
}
}
else
{
/*
* scroll the text down
*/
while (n > 0 && curwin->w_topline > 1)
{
#ifdef FEAT_DIFF
if (curwin->w_topfill < diff_check_fill(curwin, curwin->w_topline))
{
i = 1;
--n;
++curwin->w_topfill;
}
else
#endif
{
i = PLINES_NOFILL(curwin->w_topline - 1);
n -= i;
if (n < 0 && scrolled > 0)
break;
--curwin->w_topline;
#ifdef FEAT_FOLDING
(void)hasFolding(curwin->w_topline, &curwin->w_topline, NULL);
#endif
#ifdef FEAT_DIFF
curwin->w_topfill = 0;
#endif
}
curwin->w_valid &= ~(VALID_CROW|VALID_WROW|
VALID_BOTLINE|VALID_BOTLINE_AP);
scrolled += i;
if (curwin->w_cursor.lnum > 1)
{
--curwin->w_cursor.lnum;
curwin->w_valid &= ~(VALID_VIRTCOL|VALID_CHEIGHT|VALID_WCOL);
}
}
/*
* When hit top of the file: move cursor up.
*/
if (n > 0)
{
if (curwin->w_cursor.lnum <= (linenr_T)n)
curwin->w_cursor.lnum = 1;
else
# ifdef FEAT_FOLDING
if (hasAnyFolding(curwin))
{
while (--n >= 0 && curwin->w_cursor.lnum > 1)
{
--curwin->w_cursor.lnum;
(void)hasFolding(curwin->w_cursor.lnum,
&curwin->w_cursor.lnum, NULL);
}
}
else
# endif
curwin->w_cursor.lnum -= n;
}
}
# ifdef FEAT_FOLDING
// Move cursor to first line of closed fold.
foldAdjustCursor();
# endif
#ifdef FEAT_DIFF
check_topfill(curwin, !flag);
#endif
cursor_correct();
beginline(BL_SOL | BL_FIX);
redraw_later(VALID);
}
| 0
|
269,306
|
static inline int get_symbol(RangeCoder *c, uint8_t *state, int is_signed){
if(get_rac(c, state+0))
return 0;
else{
int i, e, a;
e= 0;
while(get_rac(c, state+1 + FFMIN(e,9))){ //1..10
e++;
}
a= 1;
for(i=e-1; i>=0; i--){
a += a + get_rac(c, state+22 + FFMIN(i,9)); //22..31
}
e= -(is_signed && get_rac(c, state+11 + FFMIN(e,10))); //11..21
return (a^e)-e;
}
}
| 0
|
294,497
|
jd_to_weeknum(VALUE jd, int f, double sg,
VALUE *nth, int *rjd,
int *ry, int *rw, int *rd)
{
decode_jd(jd, nth, rjd);
c_jd_to_weeknum(*rjd, f, sg, ry, rw, rd);
}
| 0
|
317,266
|
static int selinux_kernel_load_data(enum kernel_load_data_id id, bool contents)
{
int rc = 0;
switch (id) {
case LOADING_MODULE:
rc = selinux_kernel_module_from_file(NULL);
break;
default:
break;
}
return rc;
}
| 0
|
345,220
|
static int con_do_clear_unimap(struct vc_data *vc)
{
struct uni_pagedir *p, *q;
p = *vc->vc_uni_pagedir_loc;
if (!p || --p->refcount) {
q = kzalloc(sizeof(*p), GFP_KERNEL);
if (!q) {
if (p)
p->refcount++;
return -ENOMEM;
}
q->refcount=1;
*vc->vc_uni_pagedir_loc = q;
} else {
if (p == dflt) dflt = NULL;
p->refcount++;
p->sum = 0;
con_release_unimap(p);
}
return 0;
}
| 0
|
225,857
|
GF_Box *rely_box_new()
{
ISOM_DECL_BOX_ALLOC(GF_RelyHintBox, GF_ISOM_BOX_TYPE_RELY);
return (GF_Box *)tmp;
}
| 0
|
401,520
|
static void enqueue_timer(struct timer_base *base, struct timer_list *timer,
unsigned int idx)
{
hlist_add_head(&timer->entry, base->vectors + idx);
__set_bit(idx, base->pending_map);
timer_set_idx(timer, idx);
trace_timer_start(timer, timer->expires, timer->flags);
}
| 0
|
513,079
|
bool has_int_value() const
{
return state == SHORT_DATA_VALUE &&
value.type_handler()->cmp_type() == INT_RESULT;
}
| 0
|
314,532
|
PJ_DEF(pj_status_t) pjmedia_sdp_media_remove_attr(pjmedia_sdp_media *m,
pjmedia_sdp_attr *attr)
{
return pjmedia_sdp_attr_remove(&m->attr_count, m->attr, attr);
}
| 0
|
230,390
|
static int xml_print_node( const pj_xml_node *node, int indent,
char *buf, pj_size_t len )
{
int i;
char *p = buf;
pj_xml_attr *attr;
pj_xml_node *sub_node;
#define SIZE_LEFT() ((int)(len - (p-buf)))
PJ_CHECK_STACK();
/* Print name. */
if (SIZE_LEFT() < node->name.slen + indent + 5)
return -1;
for (i=0; i<indent; ++i)
*p++ = ' ';
*p++ = '<';
pj_memcpy(p, node->name.ptr, node->name.slen);
p += node->name.slen;
/* Print attributes. */
attr = node->attr_head.next;
while (attr != &node->attr_head) {
if (SIZE_LEFT() < attr->name.slen + attr->value.slen + 4)
return -1;
*p++ = ' ';
/* Attribute name. */
pj_memcpy(p, attr->name.ptr, attr->name.slen);
p += attr->name.slen;
/* Attribute value. */
if (attr->value.slen) {
*p++ = '=';
*p++ = '"';
pj_memcpy(p, attr->value.ptr, attr->value.slen);
p += attr->value.slen;
*p++ = '"';
}
attr = attr->next;
}
/* Check for empty node. */
if (node->content.slen==0 &&
node->node_head.next==(pj_xml_node*)&node->node_head)
{
if (SIZE_LEFT() < 3) return -1;
*p++ = ' ';
*p++ = '/';
*p++ = '>';
return (int)(p-buf);
}
/* Enclosing '>' */
if (SIZE_LEFT() < 1) return -1;
*p++ = '>';
/* Print sub nodes. */
sub_node = node->node_head.next;
while (sub_node != (pj_xml_node*)&node->node_head) {
int printed;
if (SIZE_LEFT() < indent + 3)
return -1;
//*p++ = '\r';
*p++ = '\n';
printed = xml_print_node(sub_node, indent + 1, p, SIZE_LEFT());
if (printed < 0)
return -1;
p += printed;
sub_node = sub_node->next;
}
/* Content. */
if (node->content.slen) {
if (SIZE_LEFT() < node->content.slen) return -1;
pj_memcpy(p, node->content.ptr, node->content.slen);
p += node->content.slen;
}
/* Enclosing node. */
if (node->node_head.next != (pj_xml_node*)&node->node_head) {
if (SIZE_LEFT() < node->name.slen + 5 + indent)
return -1;
//*p++ = '\r';
*p++ = '\n';
for (i=0; i<indent; ++i)
*p++ = ' ';
} else {
if (SIZE_LEFT() < node->name.slen + 3)
return -1;
}
*p++ = '<';
*p++ = '/';
pj_memcpy(p, node->name.ptr, node->name.slen);
p += node->name.slen;
*p++ = '>';
#undef SIZE_LEFT
return (int)(p-buf);
}
| 0
|
244,334
|
GF_Err bloc_box_size(GF_Box *s)
{
s->size += 1024;
return GF_OK;
}
| 0
|
254,711
|
njs_typed_array_compare_f64(const void *a, const void *b, void *c)
{
return njs_typed_array_compare(*(const double *) a, *(const double *) b);
}
| 0
|
291,822
|
static struct rtrs_clt_path *get_next_path_min_inflight(struct path_it *it)
{
struct rtrs_clt_path *min_path = NULL;
struct rtrs_clt_sess *clt = it->clt;
struct rtrs_clt_path *clt_path;
int min_inflight = INT_MAX;
int inflight;
list_for_each_entry_rcu(clt_path, &clt->paths_list, s.entry) {
if (READ_ONCE(clt_path->state) != RTRS_CLT_CONNECTED)
continue;
if (!list_empty(raw_cpu_ptr(clt_path->mp_skip_entry)))
continue;
inflight = atomic_read(&clt_path->stats->inflight);
if (inflight < min_inflight) {
min_inflight = inflight;
min_path = clt_path;
}
}
/*
* add the path to the skip list, so that next time we can get
* a different one
*/
if (min_path)
list_add(raw_cpu_ptr(min_path->mp_skip_entry), &it->skip_list);
return min_path;
}
| 0
|
353,212
|
void SplashOutputDev::updateFlatness(GfxState *state) {
#if 0 // Acrobat ignores the flatness setting, and always renders curves
// with a fairly small flatness value
splash->setFlatness(state->getFlatness());
#endif
}
| 0
|
294,485
|
m_cwyear(union DateData *x)
{
int ry, rw, rd;
c_jd_to_commercial(m_local_jd(x), m_virtual_sg(x), /* !=m_sg() */
&ry, &rw, &rd);
return ry;
}
| 0
|
439,266
|
static Image *ReadBMPImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
BMPInfo
bmp_info;
Image
*image;
IndexPacket
index;
MagickBooleanType
status;
MagickOffsetType
offset,
start_position;
MemoryInfo
*pixel_info;
register IndexPacket
*indexes;
register PixelPacket
*q;
register ssize_t
i,
x;
register unsigned char
*p;
size_t
bit,
bytes_per_line,
length;
ssize_t
count,
y;
unsigned char
magick[12],
*pixels;
unsigned int
blue,
green,
offset_bits,
red;
/*
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
image=DestroyImageList(image);
return((Image *) NULL);
}
/*
Determine if this a BMP file.
*/
(void) memset(&bmp_info,0,sizeof(bmp_info));
bmp_info.ba_offset=0;
start_position=0;
offset_bits=0;
count=ReadBlob(image,2,magick);
if (count != 2)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
do
{
LongPixelPacket
shift;
PixelPacket
quantum_bits;
/*
Verify BMP identifier.
*/
start_position=TellBlob(image)-2;
bmp_info.ba_offset=0;
while (LocaleNCompare((char *) magick,"BA",2) == 0)
{
bmp_info.file_size=ReadBlobLSBLong(image);
bmp_info.ba_offset=ReadBlobLSBLong(image);
bmp_info.offset_bits=ReadBlobLSBLong(image);
count=ReadBlob(image,2,magick);
if (count != 2)
break;
}
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule()," Magick: %c%c",
magick[0],magick[1]);
if ((count != 2) || ((LocaleNCompare((char *) magick,"BM",2) != 0) &&
(LocaleNCompare((char *) magick,"CI",2) != 0)))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
bmp_info.file_size=ReadBlobLSBLong(image);
(void) ReadBlobLSBLong(image);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" File_size in header: %u bytes",bmp_info.file_size);
bmp_info.offset_bits=ReadBlobLSBLong(image);
bmp_info.size=ReadBlobLSBLong(image);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule()," BMP size: %u",
bmp_info.size);
if (bmp_info.size == 12)
{
/*
OS/2 BMP image file.
*/
(void) CopyMagickString(image->magick,"BMP2",MaxTextExtent);
bmp_info.width=(ssize_t) ((short) ReadBlobLSBShort(image));
bmp_info.height=(ssize_t) ((short) ReadBlobLSBShort(image));
bmp_info.planes=ReadBlobLSBShort(image);
bmp_info.bits_per_pixel=ReadBlobLSBShort(image);
bmp_info.x_pixels=0;
bmp_info.y_pixels=0;
bmp_info.number_colors=0;
bmp_info.compression=BI_RGB;
bmp_info.image_size=0;
bmp_info.alpha_mask=0;
if (image->debug != MagickFalse)
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Format: OS/2 Bitmap");
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Geometry: %.20gx%.20g",(double) bmp_info.width,(double)
bmp_info.height);
}
}
else
{
/*
Microsoft Windows BMP image file.
*/
if (bmp_info.size < 40)
ThrowReaderException(CorruptImageError,"NonOS2HeaderSizeError");
bmp_info.width=(ssize_t) ReadBlobLSBSignedLong(image);
bmp_info.height=(ssize_t) ReadBlobLSBSignedLong(image);
bmp_info.planes=ReadBlobLSBShort(image);
bmp_info.bits_per_pixel=ReadBlobLSBShort(image);
bmp_info.compression=ReadBlobLSBLong(image);
bmp_info.image_size=ReadBlobLSBLong(image);
bmp_info.x_pixels=ReadBlobLSBLong(image);
bmp_info.y_pixels=ReadBlobLSBLong(image);
bmp_info.number_colors=ReadBlobLSBLong(image);
if (bmp_info.number_colors > GetBlobSize(image))
ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
bmp_info.colors_important=ReadBlobLSBLong(image);
if (image->debug != MagickFalse)
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Format: MS Windows bitmap");
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Geometry: %.20gx%.20g",(double) bmp_info.width,(double)
bmp_info.height);
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Bits per pixel: %.20g",(double) bmp_info.bits_per_pixel);
switch (bmp_info.compression)
{
case BI_RGB:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: BI_RGB");
break;
}
case BI_RLE4:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: BI_RLE4");
break;
}
case BI_RLE8:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: BI_RLE8");
break;
}
case BI_BITFIELDS:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: BI_BITFIELDS");
break;
}
case BI_PNG:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: BI_PNG");
break;
}
case BI_JPEG:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: BI_JPEG");
break;
}
default:
{
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Compression: UNKNOWN (%u)",bmp_info.compression);
}
}
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Number of colors: %u",bmp_info.number_colors);
}
bmp_info.red_mask=ReadBlobLSBLong(image);
bmp_info.green_mask=ReadBlobLSBLong(image);
bmp_info.blue_mask=ReadBlobLSBLong(image);
if (bmp_info.size > 40)
{
double
gamma;
/*
Read color management information.
*/
bmp_info.alpha_mask=ReadBlobLSBLong(image);
bmp_info.colorspace=ReadBlobLSBSignedLong(image);
/*
Decode 2^30 fixed point formatted CIE primaries.
*/
# define BMP_DENOM ((double) 0x40000000)
bmp_info.red_primary.x=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.red_primary.y=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.red_primary.z=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.green_primary.x=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.green_primary.y=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.green_primary.z=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.blue_primary.x=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.blue_primary.y=(double) ReadBlobLSBLong(image)/BMP_DENOM;
bmp_info.blue_primary.z=(double) ReadBlobLSBLong(image)/BMP_DENOM;
gamma=bmp_info.red_primary.x+bmp_info.red_primary.y+
bmp_info.red_primary.z;
gamma=PerceptibleReciprocal(gamma);
bmp_info.red_primary.x*=gamma;
bmp_info.red_primary.y*=gamma;
image->chromaticity.red_primary.x=bmp_info.red_primary.x;
image->chromaticity.red_primary.y=bmp_info.red_primary.y;
gamma=bmp_info.green_primary.x+bmp_info.green_primary.y+
bmp_info.green_primary.z;
gamma=PerceptibleReciprocal(gamma);
bmp_info.green_primary.x*=gamma;
bmp_info.green_primary.y*=gamma;
image->chromaticity.green_primary.x=bmp_info.green_primary.x;
image->chromaticity.green_primary.y=bmp_info.green_primary.y;
gamma=bmp_info.blue_primary.x+bmp_info.blue_primary.y+
bmp_info.blue_primary.z;
gamma=PerceptibleReciprocal(gamma);
bmp_info.blue_primary.x*=gamma;
bmp_info.blue_primary.y*=gamma;
image->chromaticity.blue_primary.x=bmp_info.blue_primary.x;
image->chromaticity.blue_primary.y=bmp_info.blue_primary.y;
/*
Decode 16^16 fixed point formatted gamma_scales.
*/
bmp_info.gamma_scale.x=(double) ReadBlobLSBLong(image)/0x10000;
bmp_info.gamma_scale.y=(double) ReadBlobLSBLong(image)/0x10000;
bmp_info.gamma_scale.z=(double) ReadBlobLSBLong(image)/0x10000;
/*
Compute a single gamma from the BMP 3-channel gamma.
*/
image->gamma=(bmp_info.gamma_scale.x+bmp_info.gamma_scale.y+
bmp_info.gamma_scale.z)/3.0;
}
else
(void) CopyMagickString(image->magick,"BMP3",MaxTextExtent);
if (bmp_info.size > 108)
{
size_t
intent;
/*
Read BMP Version 5 color management information.
*/
intent=ReadBlobLSBLong(image);
switch ((int) intent)
{
case LCS_GM_BUSINESS:
{
image->rendering_intent=SaturationIntent;
break;
}
case LCS_GM_GRAPHICS:
{
image->rendering_intent=RelativeIntent;
break;
}
case LCS_GM_IMAGES:
{
image->rendering_intent=PerceptualIntent;
break;
}
case LCS_GM_ABS_COLORIMETRIC:
{
image->rendering_intent=AbsoluteIntent;
break;
}
}
(void) ReadBlobLSBLong(image); /* Profile data */
(void) ReadBlobLSBLong(image); /* Profile size */
(void) ReadBlobLSBLong(image); /* Reserved byte */
}
}
if ((MagickSizeType) bmp_info.file_size > GetBlobSize(image))
(void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
"LengthAndFilesizeDoNotMatch","`%s'",image->filename);
else
if ((MagickSizeType) bmp_info.file_size < GetBlobSize(image))
(void) ThrowMagickException(exception,GetMagickModule(),
CorruptImageWarning,"LengthAndFilesizeDoNotMatch","`%s'",
image->filename);
if (bmp_info.width <= 0)
ThrowReaderException(CorruptImageError,"NegativeOrZeroImageSize");
if (bmp_info.height == 0)
ThrowReaderException(CorruptImageError,"NegativeOrZeroImageSize");
if (bmp_info.planes != 1)
ThrowReaderException(CorruptImageError,"StaticPlanesValueNotEqualToOne");
if ((bmp_info.bits_per_pixel != 1) && (bmp_info.bits_per_pixel != 4) &&
(bmp_info.bits_per_pixel != 8) && (bmp_info.bits_per_pixel != 16) &&
(bmp_info.bits_per_pixel != 24) && (bmp_info.bits_per_pixel != 32))
ThrowReaderException(CorruptImageError,"UnrecognizedBitsPerPixel");
if (bmp_info.bits_per_pixel < 16 &&
bmp_info.number_colors > (1U << bmp_info.bits_per_pixel))
ThrowReaderException(CorruptImageError,"UnrecognizedNumberOfColors");
if ((bmp_info.compression == 1) && (bmp_info.bits_per_pixel != 8))
ThrowReaderException(CorruptImageError,"UnrecognizedBitsPerPixel");
if ((bmp_info.compression == 2) && (bmp_info.bits_per_pixel != 4))
ThrowReaderException(CorruptImageError,"UnrecognizedBitsPerPixel");
if ((bmp_info.compression == 3) && (bmp_info.bits_per_pixel < 16))
ThrowReaderException(CorruptImageError,"UnrecognizedBitsPerPixel");
switch (bmp_info.compression)
{
case BI_RGB:
image->compression=NoCompression;
break;
case BI_RLE8:
case BI_RLE4:
image->compression=RLECompression;
break;
case BI_BITFIELDS:
break;
case BI_JPEG:
ThrowReaderException(CoderError,"JPEGCompressNotSupported");
case BI_PNG:
ThrowReaderException(CoderError,"PNGCompressNotSupported");
default:
ThrowReaderException(CorruptImageError,"UnrecognizedImageCompression");
}
image->columns=(size_t) MagickAbsoluteValue(bmp_info.width);
image->rows=(size_t) MagickAbsoluteValue(bmp_info.height);
image->depth=bmp_info.bits_per_pixel <= 8 ? bmp_info.bits_per_pixel : 8;
image->matte=((bmp_info.alpha_mask != 0) &&
(bmp_info.compression == BI_BITFIELDS)) ? MagickTrue : MagickFalse;
if (bmp_info.bits_per_pixel < 16)
{
size_t
one;
image->storage_class=PseudoClass;
image->colors=bmp_info.number_colors;
one=1;
if (image->colors == 0)
image->colors=one << bmp_info.bits_per_pixel;
}
image->x_resolution=(double) bmp_info.x_pixels/100.0;
image->y_resolution=(double) bmp_info.y_pixels/100.0;
image->units=PixelsPerCentimeterResolution;
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);
if (status == MagickFalse)
{
InheritException(exception,&image->exception);
return(DestroyImageList(image));
}
if (image->storage_class == PseudoClass)
{
unsigned char
*bmp_colormap;
size_t
packet_size;
/*
Read BMP raster colormap.
*/
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Reading colormap of %.20g colors",(double) image->colors);
if (AcquireImageColormap(image,image->colors) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
bmp_colormap=(unsigned char *) AcquireQuantumMemory((size_t)
image->colors,4*sizeof(*bmp_colormap));
if (bmp_colormap == (unsigned char *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if ((bmp_info.size == 12) || (bmp_info.size == 64))
packet_size=3;
else
packet_size=4;
offset=SeekBlob(image,start_position+14+bmp_info.size,SEEK_SET);
if (offset < 0)
{
bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
}
count=ReadBlob(image,packet_size*image->colors,bmp_colormap);
if (count != (ssize_t) (packet_size*image->colors))
{
bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);
ThrowReaderException(CorruptImageError,
"InsufficientImageDataInFile");
}
p=bmp_colormap;
for (i=0; i < (ssize_t) image->colors; i++)
{
image->colormap[i].blue=ScaleCharToQuantum(*p++);
image->colormap[i].green=ScaleCharToQuantum(*p++);
image->colormap[i].red=ScaleCharToQuantum(*p++);
if (packet_size == 4)
p++;
}
bmp_colormap=(unsigned char *) RelinquishMagickMemory(bmp_colormap);
}
/*
Read image data.
*/
if (bmp_info.offset_bits == offset_bits)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
offset_bits=bmp_info.offset_bits;
offset=SeekBlob(image,start_position+bmp_info.offset_bits,SEEK_SET);
if (offset < 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
if (bmp_info.compression == BI_RLE4)
bmp_info.bits_per_pixel<<=1;
bytes_per_line=4*((image->columns*bmp_info.bits_per_pixel+31)/32);
length=(size_t) bytes_per_line*image->rows;
if (((MagickSizeType) length/8) > GetBlobSize(image))
ThrowReaderException(CorruptImageError,"InsufficientImageDataInFile");
if ((bmp_info.compression == BI_RGB) ||
(bmp_info.compression == BI_BITFIELDS))
{
pixel_info=AcquireVirtualMemory(image->rows,MagickMax(bytes_per_line,
image->columns+256UL)*sizeof(*pixels));
if (pixel_info == (MemoryInfo *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);
if (image->debug != MagickFalse)
(void) LogMagickEvent(CoderEvent,GetMagickModule(),
" Reading pixels (%.20g bytes)",(double) length);
count=ReadBlob(image,length,pixels);
if (count != (ssize_t) length)
{
pixel_info=RelinquishVirtualMemory(pixel_info);
ThrowReaderException(CorruptImageError,
"InsufficientImageDataInFile");
}
}
else
{
/*
Convert run-length encoded raster pixels.
*/
pixel_info=AcquireVirtualMemory(image->rows,MagickMax(bytes_per_line,
image->columns+256UL)*sizeof(*pixels));
if (pixel_info == (MemoryInfo *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
pixels=(unsigned char *) GetVirtualMemoryBlob(pixel_info);
status=DecodeImage(image,bmp_info.compression,pixels,
image->columns*image->rows);
if (status == MagickFalse)
{
pixel_info=RelinquishVirtualMemory(pixel_info);
ThrowReaderException(CorruptImageError,
"UnableToRunlengthDecodeImage");
}
}
/*
Convert BMP raster image to pixel packets.
*/
if (bmp_info.compression == BI_RGB)
{
/*
We should ignore the alpha value in BMP3 files but there have been
reports about 32 bit files with alpha. We do a quick check to see if
the alpha channel contains a value that is not zero (default value).
If we find a non zero value we asume the program that wrote the file
wants to use the alpha channel.
*/
if ((image->matte == MagickFalse) && (bmp_info.size == 40) &&
(bmp_info.bits_per_pixel == 32))
{
bytes_per_line=4*(image->columns);
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=pixels+(image->rows-y-1)*bytes_per_line;
for (x=0; x < (ssize_t) image->columns; x++)
{
if (*(p+3) != 0)
{
image->matte=MagickTrue;
y=-1;
break;
}
p+=4;
}
}
}
bmp_info.alpha_mask=image->matte != MagickFalse ? 0xff000000U : 0U;
bmp_info.red_mask=0x00ff0000U;
bmp_info.green_mask=0x0000ff00U;
bmp_info.blue_mask=0x000000ffU;
if (bmp_info.bits_per_pixel == 16)
{
/*
RGB555.
*/
bmp_info.red_mask=0x00007c00U;
bmp_info.green_mask=0x000003e0U;
bmp_info.blue_mask=0x0000001fU;
}
}
(void) memset(&shift,0,sizeof(shift));
(void) memset(&quantum_bits,0,sizeof(quantum_bits));
if ((bmp_info.bits_per_pixel == 16) || (bmp_info.bits_per_pixel == 32))
{
register size_t
sample;
/*
Get shift and quantum bits info from bitfield masks.
*/
if (bmp_info.red_mask != 0)
while (((bmp_info.red_mask << shift.red) & 0x80000000UL) == 0)
{
shift.red++;
if (shift.red > 32U)
break;
}
if (bmp_info.green_mask != 0)
while (((bmp_info.green_mask << shift.green) & 0x80000000UL) == 0)
{
shift.green++;
if (shift.green > 32U)
break;
}
if (bmp_info.blue_mask != 0)
while (((bmp_info.blue_mask << shift.blue) & 0x80000000UL) == 0)
{
shift.blue++;
if (shift.blue > 32U)
break;
}
if (bmp_info.alpha_mask != 0)
while (((bmp_info.alpha_mask << shift.opacity) & 0x80000000UL) == 0)
{
shift.opacity++;
if (shift.opacity > 32U)
break;
}
sample=shift.red;
while (((bmp_info.red_mask << sample) & 0x80000000UL) != 0)
{
sample++;
if (sample > 32U)
break;
}
quantum_bits.red=ClampToQuantum((MagickRealType) sample-shift.red);
sample=shift.green;
while (((bmp_info.green_mask << sample) & 0x80000000UL) != 0)
{
sample++;
if (sample > 32U)
break;
}
quantum_bits.green=ClampToQuantum((MagickRealType) sample-shift.green);
sample=shift.blue;
while (((bmp_info.blue_mask << sample) & 0x80000000UL) != 0)
{
sample++;
if (sample > 32U)
break;
}
quantum_bits.blue=ClampToQuantum((MagickRealType) sample-shift.blue);
sample=shift.opacity;
while (((bmp_info.alpha_mask << sample) & 0x80000000UL) != 0)
{
sample++;
if (sample > 32U)
break;
}
quantum_bits.opacity=ClampToQuantum((MagickRealType) sample-
shift.opacity);
}
switch (bmp_info.bits_per_pixel)
{
case 1:
{
/*
Convert bitmap scanline.
*/
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=pixels+(image->rows-y-1)*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
for (x=0; x < ((ssize_t) image->columns-7); x+=8)
{
for (bit=0; bit < 8; bit++)
{
index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);
SetPixelIndex(indexes+x+bit,index);
q++;
}
p++;
}
if ((image->columns % 8) != 0)
{
for (bit=0; bit < (image->columns % 8); bit++)
{
index=(IndexPacket) (((*p) & (0x80 >> bit)) != 0 ? 0x01 : 0x00);
SetPixelIndex(indexes+x+bit,index);
}
p++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
(image->rows-y),image->rows);
if (status == MagickFalse)
break;
}
}
(void) SyncImage(image);
break;
}
case 4:
{
/*
Convert PseudoColor scanline.
*/
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=pixels+(image->rows-y-1)*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
for (x=0; x < ((ssize_t) image->columns-1); x+=2)
{
(void) IsValidColormapIndex(image,(ssize_t) ((*p >> 4) & 0x0f),
&index,exception);
SetPixelIndex(indexes+x,index);
(void) IsValidColormapIndex(image,(ssize_t) (*p & 0x0f),&index,
exception);
SetPixelIndex(indexes+x+1,index);
p++;
}
if ((image->columns % 2) != 0)
{
(void) IsValidColormapIndex(image,(ssize_t) ((*p >> 4) & 0xf),
&index,exception);
SetPixelIndex(indexes+(x++),index);
p++;
}
if (x < (ssize_t) image->columns)
break;
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
(image->rows-y),image->rows);
if (status == MagickFalse)
break;
}
}
(void) SyncImage(image);
break;
}
case 8:
{
/*
Convert PseudoColor scanline.
*/
if ((bmp_info.compression == BI_RLE8) ||
(bmp_info.compression == BI_RLE4))
bytes_per_line=image->columns;
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=pixels+(image->rows-y-1)*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
for (x=(ssize_t) image->columns; x != 0; --x)
{
(void) IsValidColormapIndex(image,(ssize_t) *p,&index,exception);
SetPixelIndex(indexes,index);
indexes++;
p++;
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
offset=(MagickOffsetType) (image->rows-y-1);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
(image->rows-y),image->rows);
if (status == MagickFalse)
break;
}
}
(void) SyncImage(image);
break;
}
case 16:
{
unsigned int
alpha,
pixel;
/*
Convert bitfield encoded 16-bit PseudoColor scanline.
*/
if (bmp_info.compression != BI_RGB &&
bmp_info.compression != BI_BITFIELDS)
{
pixel_info=RelinquishVirtualMemory(pixel_info);
ThrowReaderException(CorruptImageError,
"UnrecognizedImageCompression");
}
bytes_per_line=2*(image->columns+image->columns % 2);
image->storage_class=DirectClass;
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=pixels+(image->rows-y-1)*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
pixel=(unsigned int) (*p++);
pixel|=(*p++) << 8;
red=((pixel & bmp_info.red_mask) << shift.red) >> 16;
if (quantum_bits.red == 5)
red|=((red & 0xe000) >> 5);
if (quantum_bits.red <= 8)
red|=((red & 0xff00) >> 8);
green=((pixel & bmp_info.green_mask) << shift.green) >> 16;
if (quantum_bits.green == 5)
green|=((green & 0xe000) >> 5);
if (quantum_bits.green == 6)
green|=((green & 0xc000) >> 6);
if (quantum_bits.green <= 8)
green|=((green & 0xff00) >> 8);
blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16;
if (quantum_bits.blue == 5)
blue|=((blue & 0xe000) >> 5);
if (quantum_bits.blue <= 8)
blue|=((blue & 0xff00) >> 8);
SetPixelRed(q,ScaleShortToQuantum((unsigned short) red));
SetPixelGreen(q,ScaleShortToQuantum((unsigned short) green));
SetPixelBlue(q,ScaleShortToQuantum((unsigned short) blue));
SetPixelOpacity(q,OpaqueOpacity);
if (image->matte != MagickFalse)
{
alpha=((pixel & bmp_info.alpha_mask) << shift.opacity) >> 16;
if (quantum_bits.opacity <= 8)
alpha|=((alpha & 0xff00) >> 8);
SetPixelAlpha(q,ScaleShortToQuantum((unsigned short) alpha));
}
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
offset=(MagickOffsetType) (image->rows-y-1);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
(image->rows-y),image->rows);
if (status == MagickFalse)
break;
}
}
break;
}
case 24:
{
/*
Convert DirectColor scanline.
*/
bytes_per_line=4*((image->columns*24+31)/32);
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
p=pixels+(image->rows-y-1)*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
SetPixelBlue(q,ScaleCharToQuantum(*p++));
SetPixelGreen(q,ScaleCharToQuantum(*p++));
SetPixelRed(q,ScaleCharToQuantum(*p++));
SetPixelOpacity(q,OpaqueOpacity);
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
offset=(MagickOffsetType) (image->rows-y-1);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
(image->rows-y),image->rows);
if (status == MagickFalse)
break;
}
}
break;
}
case 32:
{
/*
Convert bitfield encoded DirectColor scanline.
*/
if ((bmp_info.compression != BI_RGB) &&
(bmp_info.compression != BI_BITFIELDS))
{
pixel_info=RelinquishVirtualMemory(pixel_info);
ThrowReaderException(CorruptImageError,
"UnrecognizedImageCompression");
}
bytes_per_line=4*(image->columns);
for (y=(ssize_t) image->rows-1; y >= 0; y--)
{
unsigned int
alpha,
pixel;
p=pixels+(image->rows-y-1)*bytes_per_line;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
pixel=(unsigned int) (*p++);
pixel|=((unsigned int) *p++ << 8);
pixel|=((unsigned int) *p++ << 16);
pixel|=((unsigned int) *p++ << 24);
red=((pixel & bmp_info.red_mask) << shift.red) >> 16;
if (quantum_bits.red == 8)
red|=(red >> 8);
green=((pixel & bmp_info.green_mask) << shift.green) >> 16;
if (quantum_bits.green == 8)
green|=(green >> 8);
blue=((pixel & bmp_info.blue_mask) << shift.blue) >> 16;
if (quantum_bits.blue == 8)
blue|=(blue >> 8);
SetPixelRed(q,ScaleShortToQuantum((unsigned short) red));
SetPixelGreen(q,ScaleShortToQuantum((unsigned short) green));
SetPixelBlue(q,ScaleShortToQuantum((unsigned short) blue));
SetPixelAlpha(q,OpaqueOpacity);
if (image->matte != MagickFalse)
{
alpha=((pixel & bmp_info.alpha_mask) << shift.opacity) >> 16;
if (quantum_bits.opacity == 8)
alpha|=(alpha >> 8);
SetPixelAlpha(q,ScaleShortToQuantum((unsigned short) alpha));
}
q++;
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
offset=(MagickOffsetType) (image->rows-y-1);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType)
(image->rows-y),image->rows);
if (status == MagickFalse)
break;
}
}
break;
}
default:
{
pixel_info=RelinquishVirtualMemory(pixel_info);
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
}
}
pixel_info=RelinquishVirtualMemory(pixel_info);
if (y > 0)
break;
if (EOFBlob(image) != MagickFalse)
{
ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
image->filename);
break;
}
if (bmp_info.height < 0)
{
Image
*flipped_image;
/*
Correct image orientation.
*/
flipped_image=FlipImage(image,exception);
if (flipped_image != (Image *) NULL)
{
DuplicateBlob(flipped_image,image);
ReplaceImageInList(&image, flipped_image);
image=flipped_image;
}
}
/*
Proceed to next image.
*/
if (image_info->number_scenes != 0)
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
*magick='\0';
if (bmp_info.ba_offset != 0)
{
offset=SeekBlob(image,(MagickOffsetType) bmp_info.ba_offset,SEEK_SET);
if (offset < 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
}
count=ReadBlob(image,2,magick);
if ((count == 2) && (IsBMP(magick,2) != MagickFalse))
{
/*
Acquire next image structure.
*/
AcquireNextImage(image_info,image);
if (GetNextImageInList(image) == (Image *) NULL)
{
status=MagickFalse;
break;
}
image=SyncNextImageInList(image);
status=SetImageProgress(image,LoadImagesTag,TellBlob(image),
GetBlobSize(image));
if (status == MagickFalse)
break;
}
} while (IsBMP(magick,2) != MagickFalse);
(void) CloseBlob(image);
if (status == MagickFalse)
return(DestroyImageList(image));
return(GetFirstImageInList(image));
}
| 0
|
294,723
|
d_lite_julian_p(VALUE self)
{
get_d1(self);
return f_boolcast(m_julian_p(dat));
}
| 0
|
227,006
|
irc_protocol_is_numeric_command (const char *str)
{
while (str && str[0])
{
if (!isdigit ((unsigned char)str[0]))
return 0;
str++;
}
return 1;
}
| 0
|
242,636
|
void isor_declare_pssh(ISOMChannel *ch)
{
u32 i, PSSH_count;
u8 *psshd;
GF_BitStream *pssh_bs = gf_bs_new(NULL, 0, GF_BITSTREAM_WRITE);
u32 s;
PSSH_count = gf_isom_get_pssh_count(ch->owner->mov);
gf_bs_write_u32(pssh_bs, PSSH_count);
/*fill PSSH in the structure. We will free it in CENC_Setup*/
for (i=0; i<PSSH_count; i++) {
bin128 SystemID;
u32 version;
u32 KID_count;
bin128 *KIDs;
u32 private_data_size;
u8 *private_data;
gf_isom_get_pssh_info(ch->owner->mov, i+1, SystemID, &version, &KID_count, (const bin128 **) & KIDs, (const u8 **) &private_data, &private_data_size);
gf_bs_write_data(pssh_bs, SystemID, 16);
gf_bs_write_u32(pssh_bs, version);
gf_bs_write_u32(pssh_bs, KID_count);
for (s=0; s<KID_count; s++) {
gf_bs_write_data(pssh_bs, KIDs[s], 16);
}
gf_bs_write_u32(pssh_bs, private_data_size);
gf_bs_write_data(pssh_bs, private_data, private_data_size);
}
gf_bs_get_content(pssh_bs, &psshd, &s);
gf_bs_del(pssh_bs);
gf_filter_pid_set_property(ch->pid, GF_PROP_PID_CENC_PSSH, & PROP_DATA_NO_COPY(psshd, s) );
}
| 0
|
331,764
|
void QPaintEngineEx::updateState(const QPaintEngineState &)
{
// do nothing...
}
| 0
|
317,349
|
static int selinux_socket_recvmsg(struct socket *sock, struct msghdr *msg,
int size, int flags)
{
return sock_has_perm(sock->sk, SOCKET__READ);
}
| 0
|
197,326
|
static Status ParseEquation(const string& equation,
OperandLabels* input_labels,
Labels* output_labels,
std::vector<DimensionType>* label_types,
OperandLabelCounts* input_label_counts,
LabelCounts* output_label_counts,
gtl::InlinedVector<bool, 2>* input_has_ellipsis,
bool* output_has_ellipsis) {
gtl::InlinedVector<string, 2> input_str;
string output_str;
TF_RETURN_IF_ERROR(ParseEinsumEquation(equation, &input_str, &output_str));
// Temporary map from single character labels to (consecutive) integer
// labels.
absl::flat_hash_map<char, int> label_mapping;
int num_inputs = input_str.size();
input_labels->resize(num_inputs);
// Map from single characters to integer labels.
for (int i = 0; i < num_inputs; ++i) {
MapToLabels(input_str[i], &input_labels->at(i), &label_mapping);
}
MapToLabels(output_str, output_labels, &label_mapping);
// Compute counts for input and output labels.
int num_labels = label_mapping.size();
input_label_counts->resize(num_inputs);
input_has_ellipsis->resize(num_inputs);
for (int i = 0; i < num_inputs; ++i) {
input_label_counts->at(i).resize(num_labels);
for (const int label : input_labels->at(i)) {
if (label != kEllipsisLabel)
input_label_counts->at(i)[label] += 1;
else
input_has_ellipsis->at(i) = true;
}
}
output_label_counts->resize(num_labels);
for (const int label : *output_labels) {
if (label != kEllipsisLabel)
output_label_counts->at(label) += 1;
else
*output_has_ellipsis = true;
}
// Map each label to a unique DimensionType.
label_types->resize(num_labels);
for (int label = 0; label < num_labels; ++label) {
if (label == kEllipsisLabel) continue;
bool removed = (*output_label_counts)[label] == 0;
bool unique = num_inputs == 1 || (*input_label_counts)[0][label] == 0 ||
(*input_label_counts)[1][label] == 0;
(*label_types)[label] = GetDimensionType(removed, unique);
}
return Status::OK();
}
| 1
|
310,115
|
uses_SGR_39_49(const char *value)
{
return (strstr(value, "39;49") != 0
|| strstr(value, "49;39") != 0);
}
| 0
|
238,634
|
void bpf_verifier_vlog(struct bpf_verifier_log *log, const char *fmt,
va_list args)
{
unsigned int n;
n = vscnprintf(log->kbuf, BPF_VERIFIER_TMP_LOG_SIZE, fmt, args);
WARN_ONCE(n >= BPF_VERIFIER_TMP_LOG_SIZE - 1,
"verifier log line truncated - local buffer too short\n");
if (log->level == BPF_LOG_KERNEL) {
bool newline = n > 0 && log->kbuf[n - 1] == '\n';
pr_err("BPF: %s%s", log->kbuf, newline ? "" : "\n");
return;
}
n = min(log->len_total - log->len_used - 1, n);
log->kbuf[n] = '\0';
if (!copy_to_user(log->ubuf + log->len_used, log->kbuf, n + 1))
log->len_used += n;
else
log->ubuf = NULL;
}
| 0
|
329,911
|
_cairo_image_compositor_reset_static_data (void)
{
}
| 0
|
328,814
|
R_API bool sdb_iterate_build_list(void *user, const char *k, const char *v) {
RList *bin_objs_list = (RList *) user;
size_t value = (size_t) sdb_atoi (v);
RBinJavaObj *bin_obj = NULL;
IFDBG eprintf ("Found %s == %"PFMT64x " bin_objs db\n", k, (ut64) value);
if (value != 0 && value != (size_t) -1) {
bin_obj = (RBinJavaObj *) value;
r_list_append (bin_objs_list, bin_obj);
}
return true;
}
| 0
|
450,424
|
static void vnc_tight_start(VncState *vs)
{
buffer_reset(&vs->tight->tight);
// make the output buffer be the zlib buffer, so we can compress it later
vs->tight->tmp = vs->output;
vs->output = vs->tight->tight;
}
| 0
|
210,619
|
u_undo_end(
int did_undo, // just did an undo
int absolute) // used ":undo N"
{
char *msgstr;
u_header_T *uhp;
char_u msgbuf[80];
#ifdef FEAT_FOLDING
if ((fdo_flags & FDO_UNDO) && KeyTyped)
foldOpenCursor();
#endif
if (global_busy // no messages now, wait until global is finished
|| !messaging()) // 'lazyredraw' set, don't do messages now
return;
if (curbuf->b_ml.ml_flags & ML_EMPTY)
--u_newcount;
u_oldcount -= u_newcount;
if (u_oldcount == -1)
msgstr = N_("more line");
else if (u_oldcount < 0)
msgstr = N_("more lines");
else if (u_oldcount == 1)
msgstr = N_("line less");
else if (u_oldcount > 1)
msgstr = N_("fewer lines");
else
{
u_oldcount = u_newcount;
if (u_newcount == 1)
msgstr = N_("change");
else
msgstr = N_("changes");
}
if (curbuf->b_u_curhead != NULL)
{
// For ":undo N" we prefer a "after #N" message.
if (absolute && curbuf->b_u_curhead->uh_next.ptr != NULL)
{
uhp = curbuf->b_u_curhead->uh_next.ptr;
did_undo = FALSE;
}
else if (did_undo)
uhp = curbuf->b_u_curhead;
else
uhp = curbuf->b_u_curhead->uh_next.ptr;
}
else
uhp = curbuf->b_u_newhead;
if (uhp == NULL)
*msgbuf = NUL;
else
add_time(msgbuf, sizeof(msgbuf), uhp->uh_time);
#ifdef FEAT_CONCEAL
{
win_T *wp;
FOR_ALL_WINDOWS(wp)
{
if (wp->w_buffer == curbuf && wp->w_p_cole > 0)
redraw_win_later(wp, NOT_VALID);
}
}
#endif
smsg_attr_keep(0, _("%ld %s; %s #%ld %s"),
u_oldcount < 0 ? -u_oldcount : u_oldcount,
_(msgstr),
did_undo ? _("before") : _("after"),
uhp == NULL ? 0L : uhp->uh_seq,
msgbuf);
}
| 1
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.