idx
int64 | func
string | target
int64 |
|---|---|---|
248,236
|
static char *strndup(const char *s, size_t n)
{
char *r;
r = malloc(n + 1);
if (!r)
return NULL;
strncpy(r, s, n);
r[n] = 0;
return r;
}
| 0
|
238,390
|
njs_function_native_frame(njs_vm_t *vm, njs_function_t *function,
const njs_value_t *this, const njs_value_t *args, njs_uint_t nargs,
njs_bool_t ctor)
{
size_t size;
njs_uint_t n;
njs_value_t *value, *bound;
njs_native_frame_t *frame;
size = NJS_NATIVE_FRAME_SIZE
+ (function->args_offset + nargs) * sizeof(njs_value_t);
frame = njs_function_frame_alloc(vm, size);
if (njs_slow_path(frame == NULL)) {
return NJS_ERROR;
}
frame->function = function;
frame->nargs = function->args_offset + nargs;
frame->ctor = ctor;
frame->native = 1;
frame->pc = NULL;
value = (njs_value_t *) ((u_char *) frame + NJS_NATIVE_FRAME_SIZE);
frame->arguments = value;
frame->arguments_offset = value + function->args_offset;
bound = function->bound;
if (bound == NULL) {
/* GC: njs_retain(this); */
*value++ = *this;
} else {
n = function->args_offset;
do {
/* GC: njs_retain(bound); */
*value++ = *bound++;
n--;
} while (n != 0);
}
if (args != NULL) {
memcpy(value, args, nargs * sizeof(njs_value_t));
}
return NJS_OK;
}
| 0
|
236,187
|
void diST_box_del(GF_Box *s)
{
GF_DIMSScriptTypesBox *p = (GF_DIMSScriptTypesBox *)s;
if (p->content_script_types) gf_free(p->content_script_types);
gf_free(p);
}
| 0
|
243,989
|
void trgr_box_del(GF_Box *s)
{
GF_TrackGroupBox *ptr = (GF_TrackGroupBox *)s;
if (ptr == NULL) return;
gf_list_del(ptr->groups);
gf_free(ptr);
}
| 0
|
344,759
|
put_u16(void *vp, u_int16_t v)
{
u_char *p = (u_char *)vp;
p[0] = (u_char)(v >> 8) & 0xff;
p[1] = (u_char)v & 0xff;
}
| 0
|
217,556
|
MagickExport MagickBooleanType CloneImageProperties(Image *image,
const Image *clone_image)
{
assert(image != (Image *) NULL);
assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(clone_image != (const Image *) NULL);
assert(clone_image->signature == MagickCoreSignature);
if (clone_image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
clone_image->filename);
(void) CopyMagickString(image->filename,clone_image->filename,MaxTextExtent);
(void) CopyMagickString(image->magick_filename,clone_image->magick_filename,
MaxTextExtent);
image->compression=clone_image->compression;
image->quality=clone_image->quality;
image->depth=clone_image->depth;
image->background_color=clone_image->background_color;
image->border_color=clone_image->border_color;
image->matte_color=clone_image->matte_color;
image->transparent_color=clone_image->transparent_color;
image->gamma=clone_image->gamma;
image->chromaticity=clone_image->chromaticity;
image->rendering_intent=clone_image->rendering_intent;
image->black_point_compensation=clone_image->black_point_compensation;
image->units=clone_image->units;
image->montage=(char *) NULL;
image->directory=(char *) NULL;
(void) CloneString(&image->geometry,clone_image->geometry);
image->offset=clone_image->offset;
image->x_resolution=clone_image->x_resolution;
image->y_resolution=clone_image->y_resolution;
image->page=clone_image->page;
image->tile_offset=clone_image->tile_offset;
image->extract_info=clone_image->extract_info;
image->bias=clone_image->bias;
image->filter=clone_image->filter;
image->blur=clone_image->blur;
image->fuzz=clone_image->fuzz;
image->intensity=clone_image->intensity;
image->interlace=clone_image->interlace;
image->interpolate=clone_image->interpolate;
image->endian=clone_image->endian;
image->gravity=clone_image->gravity;
image->compose=clone_image->compose;
image->orientation=clone_image->orientation;
image->scene=clone_image->scene;
image->dispose=clone_image->dispose;
image->delay=clone_image->delay;
image->ticks_per_second=clone_image->ticks_per_second;
image->iterations=clone_image->iterations;
image->total_colors=clone_image->total_colors;
image->taint=clone_image->taint;
image->progress_monitor=clone_image->progress_monitor;
image->client_data=clone_image->client_data;
image->start_loop=clone_image->start_loop;
image->error=clone_image->error;
image->signature=clone_image->signature;
if (clone_image->properties != (void *) NULL)
{
if (image->properties != (void *) NULL)
DestroyImageProperties(image);
image->properties=CloneSplayTree((SplayTreeInfo *)
clone_image->properties,(void *(*)(void *)) ConstantString,
(void *(*)(void *)) ConstantString);
}
return(MagickTrue);
}
| 0
|
286,731
|
SWTPM_NVRAM_StoreData_Intern(const unsigned char *data,
uint32_t length,
uint32_t tpm_number,
const char *name,
TPM_BOOL encrypt /* encrypt if key is set */)
{
TPM_RESULT rc = 0;
unsigned char *filedata = NULL;
uint32_t filedata_length = 0;
tlv_data td[3];
size_t td_len = 0;
uint16_t flags = 0;
const char *backend_uri = NULL;
TPM_DEBUG(" SWTPM_NVRAM_StoreData: To name %s\n", name);
if (rc == 0) {
if (encrypt && SWTPM_NVRAM_Has_FileKey()) {
td_len = 3;
rc = SWTPM_NVRAM_EncryptData(&filekey, &td[0], &td_len,
TAG_ENCRYPTED_DATA, data, length,
TAG_IVEC_ENCRYPTED_DATA);
if (rc) {
logprintf(STDERR_FILENO,
"SWTPM_NVRAM_EncryptData failed: 0x%02x\n", rc);
} else {
TPM_DEBUG(" SWTPM_NVRAM_StoreData: Encrypted %u bytes before "
"write, will write %u bytes\n", length,
td[0].tlv.length);
}
flags |= BLOB_FLAG_ENCRYPTED;
if (SWTPM_NVRAM_FileKey_Size() == SWTPM_AES256_BLOCK_SIZE)
flags |= BLOB_FLAG_ENCRYPTED_256BIT_KEY;
} else {
td_len = 1;
td[0] = TLV_DATA_CONST(TAG_DATA, length, data);
}
}
if (rc == 0)
rc = tlv_data_append(&filedata, &filedata_length, td, td_len);
if (rc == 0)
rc = SWTPM_NVRAM_PrependHeader(&filedata, &filedata_length, flags);
if (rc == 0) {
backend_uri = tpmstate_get_backend_uri();
rc = g_nvram_backend_ops->store(filedata, filedata_length, tpm_number, name,
backend_uri);
}
tlv_data_free(td, td_len);
free(filedata);
TPM_DEBUG(" SWTPM_NVRAM_StoreData: rc=%d\n", rc);
return rc;
}
| 0
|
198,374
|
void Compute(OpKernelContext* ctx) override {
const Tensor* x_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("x", &x_tensor));
const Tensor* cs_prev_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("cs_prev", &cs_prev_tensor));
const Tensor* h_prev_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("h_prev", &h_prev_tensor));
const Tensor* w_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("w", &w_tensor));
const Tensor* wci_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("wci", &wci_tensor));
const Tensor* wcf_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("wcf", &wcf_tensor));
const Tensor* wco_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("wco", &wco_tensor));
const Tensor* b_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->input("b", &b_tensor));
const int64_t batch_size = x_tensor->dim_size(0);
const int64_t input_size = x_tensor->dim_size(1);
const int64_t cell_size = cs_prev_tensor->dim_size(1);
// Sanity checks for our input shapes.
OP_REQUIRES(ctx, cs_prev_tensor->dim_size(0) == batch_size,
errors::InvalidArgument("cs_prev.dims(0) != batch_size: ",
cs_prev_tensor->dim_size(0), " vs. ",
batch_size));
OP_REQUIRES(ctx, cs_prev_tensor->dim_size(1) == cell_size,
errors::InvalidArgument("cs_prev.dims(1) != cell_size: ",
cs_prev_tensor->dim_size(1), " vs. ",
cell_size));
OP_REQUIRES(ctx, h_prev_tensor->dim_size(0) == batch_size,
errors::InvalidArgument("h_prev.dims(0) != batch_size: ",
h_prev_tensor->dim_size(0), " vs. ",
batch_size));
OP_REQUIRES(ctx, h_prev_tensor->dim_size(1) == cell_size,
errors::InvalidArgument(
"h_prev.dims(1) != cell_size: ", h_prev_tensor->dim_size(1),
" vs. ", cell_size));
OP_REQUIRES(ctx, w_tensor->dim_size(0) == input_size + cell_size,
errors::InvalidArgument(
"w.dim_size(0) != input_size + cell_size: ",
w_tensor->dim_size(0), " vs. ", input_size + cell_size));
OP_REQUIRES(ctx, w_tensor->dim_size(1) == cell_size * 4,
errors::InvalidArgument(
"w.dim_size(1) != cell_size * 4: ", w_tensor->dim_size(1),
" vs. ", cell_size * 4));
OP_REQUIRES(ctx, b_tensor->dim_size(0) == cell_size * 4,
errors::InvalidArgument(
"b.dim_size(0) != cell_size * 4: ", b_tensor->dim_size(0),
" vs. ", cell_size * 4));
// Allocate our output tensors.
Tensor* i_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(
{"h_prev"}, "i",
TensorShape({batch_size, cell_size}), &i_tensor));
Tensor* cs_tensor = nullptr;
OP_REQUIRES_OK(
ctx, ctx->allocate_output("cs", TensorShape({batch_size, cell_size}),
&cs_tensor));
Tensor* f_tensor = nullptr;
OP_REQUIRES_OK(
ctx, ctx->allocate_output("f", TensorShape({batch_size, cell_size}),
&f_tensor));
Tensor* o_tensor = nullptr;
OP_REQUIRES_OK(ctx, ctx->forward_input_or_allocate_output(
{"cs_prev"}, "o",
TensorShape({batch_size, cell_size}), &o_tensor));
Tensor* ci_tensor = nullptr;
OP_REQUIRES_OK(
ctx, ctx->allocate_output("ci", TensorShape({batch_size, cell_size}),
&ci_tensor));
Tensor* co_tensor = nullptr;
OP_REQUIRES_OK(
ctx, ctx->allocate_output("co", TensorShape({batch_size, cell_size}),
&co_tensor));
Tensor* h_tensor = nullptr;
OP_REQUIRES_OK(
ctx, ctx->allocate_output("h", TensorShape({batch_size, cell_size}),
&h_tensor));
// Allocate our temp tensors.
Tensor xh_tensor;
OP_REQUIRES_OK(ctx, ctx->allocate_temp(
DataTypeToEnum<T>::v(),
TensorShape({batch_size, input_size + cell_size}),
&xh_tensor));
Tensor gates_tensor;
OP_REQUIRES_OK(ctx,
ctx->allocate_temp(DataTypeToEnum<T>::v(),
TensorShape({batch_size, cell_size * 4}),
&gates_tensor));
const Device& device = ctx->eigen_device<Device>();
functor::LSTMBlockCellFprop<Device, T, USE_CUBLAS, gate_layout>(
batch_size, input_size, cell_size)(
ctx, device, forget_bias_, cell_clip_, use_peephole_,
x_tensor->matrix<T>(), cs_prev_tensor->matrix<T>(),
h_prev_tensor->matrix<T>(), w_tensor->matrix<T>(), wci_tensor->vec<T>(),
wcf_tensor->vec<T>(), wco_tensor->vec<T>(), b_tensor->vec<T>(),
xh_tensor.matrix<T>(), i_tensor->matrix<T>(), cs_tensor->matrix<T>(),
f_tensor->matrix<T>(), o_tensor->matrix<T>(), ci_tensor->matrix<T>(),
co_tensor->matrix<T>(), gates_tensor.matrix<T>(),
h_tensor->matrix<T>());
}
| 1
|
90,779
|
GetPersistentHostQuotaTask(
QuotaManager* manager,
const std::string& host,
HostQuotaCallback* callback)
: DatabaseTaskBase(manager),
host_(host),
quota_(-1),
callback_(callback) {
}
| 0
|
273,922
|
static void handle_ABOR(ctrl_t *ctrl, char *arg)
{
DBG("Aborting any current transfer ...");
if (do_abort(ctrl))
send_msg(ctrl->sd, "426 Connection closed; transfer aborted.\r\n");
send_msg(ctrl->sd, "226 Closing data connection.\r\n");
}
| 0
|
310,315
|
add_fingerprint_to_dir(const char *nickname, const char *fp,
authdir_config_t *list)
{
char *fingerprint;
char d[DIGEST_LEN];
router_status_t *status;
tor_assert(nickname);
tor_assert(fp);
tor_assert(list);
fingerprint = tor_strdup(fp);
tor_strstrip(fingerprint, " ");
if (base16_decode(d, DIGEST_LEN, fingerprint, strlen(fingerprint))) {
log_warn(LD_DIRSERV, "Couldn't decode fingerprint \"%s\"",
escaped(fp));
tor_free(fingerprint);
return 0;
}
if (!strcasecmp(nickname, UNNAMED_ROUTER_NICKNAME)) {
log_warn(LD_DIRSERV, "Tried to add a mapping for reserved nickname %s",
UNNAMED_ROUTER_NICKNAME);
tor_free(fingerprint);
return 0;
}
status = digestmap_get(list->status_by_digest, d);
if (!status) {
status = tor_malloc_zero(sizeof(router_status_t));
digestmap_set(list->status_by_digest, d, status);
}
if (nickname[0] != '!') {
char *old_fp = strmap_get_lc(list->fp_by_name, nickname);
if (old_fp && !strcasecmp(fingerprint, old_fp)) {
tor_free(fingerprint);
} else {
tor_free(old_fp);
strmap_set_lc(list->fp_by_name, nickname, fingerprint);
}
status->status |= FP_NAMED;
strlcpy(status->nickname, nickname, sizeof(status->nickname));
} else {
tor_free(fingerprint);
if (!strcasecmp(nickname, "!reject")) {
status->status |= FP_REJECT;
} else if (!strcasecmp(nickname, "!invalid")) {
status->status |= FP_INVALID;
} else if (!strcasecmp(nickname, "!baddir")) {
status->status |= FP_BADDIR;
} else if (!strcasecmp(nickname, "!badexit")) {
status->status |= FP_BADEXIT;
}
}
return 0;
}
| 0
|
254,891
|
DepsTracker::State GroupFromFirstDocumentTransformation::addDependencies(DepsTracker* deps) const {
for (auto&& expr : _accumulatorExprs) {
expr.second->addDependencies(deps);
}
// This stage will replace the entire document with a new document, so any existing fields
// will be replaced and cannot be required as dependencies. We use EXHAUSTIVE_ALL here
// instead of EXHAUSTIVE_FIELDS, as in ReplaceRootTransformation, because the stages that
// follow a $group stage should not depend on document metadata.
return DepsTracker::State::EXHAUSTIVE_ALL;
}
| 0
|
294,683
|
equal_gen(VALUE self, VALUE other)
{
get_d1(self);
if (k_numeric_p(other))
return f_eqeq_p(m_real_local_jd(dat), other);
else if (k_date_p(other))
return f_eqeq_p(m_real_local_jd(dat), f_jd(other));
return rb_num_coerce_cmp(self, other, id_eqeq_p);
}
| 0
|
390,555
|
XkbComputeGetGeometryReplySize( XkbGeometryPtr geom,
xkbGetGeometryReply * rep,
Atom name)
{
int len;
if (geom!=NULL) {
len= XkbSizeCountedString(geom->label_font);
len+= XkbSizeGeomProperties(geom);
len+= XkbSizeGeomColors(geom);
len+= XkbSizeGeomShapes(geom);
len+= XkbSizeGeomSections(geom);
len+= XkbSizeGeomDoodads(geom->num_doodads,geom->doodads);
len+= XkbSizeGeomKeyAliases(geom);
rep->length= len/4;
rep->found= True;
rep->name= geom->name;
rep->widthMM= geom->width_mm;
rep->heightMM= geom->height_mm;
rep->nProperties= geom->num_properties;
rep->nColors= geom->num_colors;
rep->nShapes= geom->num_shapes;
rep->nSections= geom->num_sections;
rep->nDoodads= geom->num_doodads;
rep->nKeyAliases= geom->num_key_aliases;
rep->baseColorNdx= XkbGeomColorIndex(geom,geom->base_color);
rep->labelColorNdx= XkbGeomColorIndex(geom,geom->label_color);
}
else {
rep->length= 0;
rep->found= False;
rep->name= name;
rep->widthMM= rep->heightMM= 0;
rep->nProperties= rep->nColors= rep->nShapes= 0;
rep->nSections= rep->nDoodads= 0;
rep->nKeyAliases= 0;
rep->labelColorNdx= rep->baseColorNdx= 0;
}
return Success;
}
| 0
|
389,705
|
clear_tv(typval_T *varp)
{
if (varp != NULL)
{
switch (varp->v_type)
{
case VAR_FUNC:
func_unref(varp->vval.v_string);
// FALLTHROUGH
case VAR_STRING:
VIM_CLEAR(varp->vval.v_string);
break;
case VAR_PARTIAL:
partial_unref(varp->vval.v_partial);
varp->vval.v_partial = NULL;
break;
case VAR_BLOB:
blob_unref(varp->vval.v_blob);
varp->vval.v_blob = NULL;
break;
case VAR_LIST:
list_unref(varp->vval.v_list);
varp->vval.v_list = NULL;
break;
case VAR_DICT:
dict_unref(varp->vval.v_dict);
varp->vval.v_dict = NULL;
break;
case VAR_NUMBER:
case VAR_BOOL:
case VAR_SPECIAL:
varp->vval.v_number = 0;
break;
case VAR_FLOAT:
#ifdef FEAT_FLOAT
varp->vval.v_float = 0.0;
break;
#endif
case VAR_JOB:
#ifdef FEAT_JOB_CHANNEL
job_unref(varp->vval.v_job);
varp->vval.v_job = NULL;
#endif
break;
case VAR_CHANNEL:
#ifdef FEAT_JOB_CHANNEL
channel_unref(varp->vval.v_channel);
varp->vval.v_channel = NULL;
#endif
break;
case VAR_INSTR:
VIM_CLEAR(varp->vval.v_instr);
break;
case VAR_UNKNOWN:
case VAR_ANY:
case VAR_VOID:
break;
}
varp->v_lock = 0;
}
}
| 0
|
484,809
|
static u16 xennet_select_queue(struct net_device *dev, struct sk_buff *skb,
struct net_device *sb_dev)
{
unsigned int num_queues = dev->real_num_tx_queues;
u32 hash;
u16 queue_idx;
/* First, check if there is only one queue */
if (num_queues == 1) {
queue_idx = 0;
} else {
hash = skb_get_hash(skb);
queue_idx = hash % num_queues;
}
return queue_idx;
}
| 0
|
248,335
|
static void cfg_indent(FILE *fp, int indent)
{
while (indent--)
fprintf(fp, " ");
}
| 0
|
512,664
|
bool in_vector::find(Item *item)
{
uchar *result=get_value(item);
if (!result || !used_count)
return false; // Null value
uint start,end;
start=0; end=used_count-1;
while (start != end)
{
uint mid=(start+end+1)/2;
int res;
if ((res=(*compare)(collation, base+mid*size, result)) == 0)
return true;
if (res < 0)
start=mid;
else
end=mid-1;
}
return ((*compare)(collation, base+start*size, result) == 0);
}
| 0
|
195,409
|
void gitn_box_del(GF_Box *s)
{
u32 i;
GroupIdToNameBox *ptr = (GroupIdToNameBox *)s;
if (ptr == NULL) return;
for (i=0; i<ptr->nb_entries; i++) {
if (ptr->entries[i].name) gf_free(ptr->entries[i].name);
}
if (ptr->entries) gf_free(ptr->entries);
gf_free(ptr);
| 1
|
217,459
|
Result ZipFile::uncompressEntry (int index, const File& targetDirectory, bool shouldOverwriteFiles)
{
auto* zei = entries.getUnchecked (index);
#if JUCE_WINDOWS
auto entryPath = zei->entry.filename;
#else
auto entryPath = zei->entry.filename.replaceCharacter ('\\', '/');
#endif
if (entryPath.isEmpty())
return Result::ok();
auto targetFile = targetDirectory.getChildFile (entryPath);
if (entryPath.endsWithChar ('/') || entryPath.endsWithChar ('\\'))
return targetFile.createDirectory(); // (entry is a directory, not a file)
std::unique_ptr<InputStream> in (createStreamForEntry (index));
if (in == nullptr)
return Result::fail ("Failed to open the zip file for reading");
if (targetFile.exists())
{
if (! shouldOverwriteFiles)
return Result::ok();
if (! targetFile.deleteFile())
return Result::fail ("Failed to write to target file: " + targetFile.getFullPathName());
}
if (! targetFile.getParentDirectory().createDirectory())
return Result::fail ("Failed to create target folder: " + targetFile.getParentDirectory().getFullPathName());
if (zei->entry.isSymbolicLink)
{
String originalFilePath (in->readEntireStreamAsString()
.replaceCharacter (L'/', File::getSeparatorChar()));
if (! File::createSymbolicLink (targetFile, originalFilePath, true))
return Result::fail ("Failed to create symbolic link: " + originalFilePath);
}
else
{
FileOutputStream out (targetFile);
if (out.failedToOpen())
return Result::fail ("Failed to write to target file: " + targetFile.getFullPathName());
out << *in;
}
targetFile.setCreationTime (zei->entry.fileTime);
targetFile.setLastModificationTime (zei->entry.fileTime);
targetFile.setLastAccessTime (zei->entry.fileTime);
return Result::ok();
}
| 1
|
513,093
|
With_subquery_cache(): m_with_subquery(false) { }
| 0
|
344,742
|
colon(char *cp)
{
int flag = 0;
if (*cp == ':') /* Leading colon is part of file name. */
return NULL;
if (*cp == '[')
flag = 1;
for (; *cp; ++cp) {
if (*cp == '@' && *(cp+1) == '[')
flag = 1;
if (*cp == ']' && *(cp+1) == ':' && flag)
return (cp+1);
if (*cp == ':' && !flag)
return (cp);
if (*cp == '/')
return NULL;
}
return NULL;
}
| 0
|
512,796
|
bool Item_func_like::turboBM_matches(const char* text, int text_len) const
{
int bcShift;
int turboShift;
int shift = pattern_len;
int j = 0;
int u = 0;
CHARSET_INFO *cs= cmp_collation.collation;
const int plm1= pattern_len - 1;
const int tlmpl= text_len - pattern_len;
/* Searching */
if (!cs->sort_order)
{
while (j <= tlmpl)
{
int i= plm1;
while (i >= 0 && pattern[i] == text[i + j])
{
i--;
if (i == plm1 - shift)
i-= u;
}
if (i < 0)
return 1;
const int v= plm1 - i;
turboShift = u - v;
bcShift = bmBc[(uint) (uchar) text[i + j]] - plm1 + i;
shift = MY_MAX(turboShift, bcShift);
shift = MY_MAX(shift, bmGs[i]);
if (shift == bmGs[i])
u = MY_MIN(pattern_len - shift, v);
else
{
if (turboShift < bcShift)
shift = MY_MAX(shift, u + 1);
u = 0;
}
j+= shift;
}
return 0;
}
else
{
while (j <= tlmpl)
{
int i= plm1;
while (i >= 0 && likeconv(cs,pattern[i]) == likeconv(cs,text[i + j]))
{
i--;
if (i == plm1 - shift)
i-= u;
}
if (i < 0)
return 1;
const int v= plm1 - i;
turboShift = u - v;
bcShift = bmBc[(uint) likeconv(cs, text[i + j])] - plm1 + i;
shift = MY_MAX(turboShift, bcShift);
shift = MY_MAX(shift, bmGs[i]);
if (shift == bmGs[i])
u = MY_MIN(pattern_len - shift, v);
else
{
if (turboShift < bcShift)
shift = MY_MAX(shift, u + 1);
u = 0;
}
j+= shift;
}
return 0;
}
}
| 0
|
300,751
|
static bool tipc_sockaddr_is_sane(struct sockaddr_tipc *addr)
{
if (addr->family != AF_TIPC)
return false;
if (addr->addrtype == TIPC_SERVICE_RANGE)
return (addr->addr.nameseq.lower <= addr->addr.nameseq.upper);
return (addr->addrtype == TIPC_SERVICE_ADDR ||
addr->addrtype == TIPC_SOCKET_ADDR);
}
| 0
|
484,709
|
void mobi_buffer_free(MOBIBuffer *buf) {
if (buf == NULL) { return; }
if (buf->data != NULL) {
free(buf->data);
}
free(buf);
}
| 0
|
281,149
|
void xfrm_audit_policy_add(struct xfrm_policy *xp, int result, bool task_valid)
{
struct audit_buffer *audit_buf;
audit_buf = xfrm_audit_start("SPD-add");
if (audit_buf == NULL)
return;
xfrm_audit_helper_usrinfo(task_valid, audit_buf);
audit_log_format(audit_buf, " res=%u", result);
xfrm_audit_common_policyinfo(xp, audit_buf);
audit_log_end(audit_buf);
}
| 0
|
369,267
|
static __cold bool io_cancel_ctx_cb(struct io_wq_work *work, void *data)
{
struct io_kiocb *req = container_of(work, struct io_kiocb, work);
return req->ctx == data;
| 0
|
508,804
|
void st_select_lex::init_query()
{
st_select_lex_node::init_query();
table_list.empty();
top_join_list.empty();
join_list= &top_join_list;
embedding= 0;
leaf_tables_prep.empty();
leaf_tables.empty();
item_list.empty();
min_max_opt_list.empty();
join= 0;
having= prep_having= where= prep_where= 0;
cond_pushed_into_where= cond_pushed_into_having= 0;
olap= UNSPECIFIED_OLAP_TYPE;
having_fix_field= 0;
having_fix_field_for_pushed_cond= 0;
context.select_lex= this;
context.init();
/*
Add the name resolution context of the current (sub)query to the
stack of contexts for the whole query.
TODO:
push_context may return an error if there is no memory for a new
element in the stack, however this method has no return value,
thus push_context should be moved to a place where query
initialization is checked for failure.
*/
parent_lex->push_context(&context, parent_lex->thd->mem_root);
cond_count= between_count= with_wild= 0;
max_equal_elems= 0;
ref_pointer_array.reset();
select_n_where_fields= 0;
select_n_reserved= 0;
select_n_having_items= 0;
n_sum_items= 0;
n_child_sum_items= 0;
hidden_bit_fields= 0;
fields_in_window_functions= 0;
subquery_in_having= explicit_limit= 0;
is_item_list_lookup= 0;
changed_elements= 0;
first_natural_join_processing= 1;
first_cond_optimization= 1;
parsing_place= NO_MATTER;
exclude_from_table_unique_test= no_wrap_view_item= FALSE;
nest_level= 0;
link_next= 0;
prep_leaf_list_state= UNINIT;
have_merged_subqueries= FALSE;
bzero((char*) expr_cache_may_be_used, sizeof(expr_cache_may_be_used));
select_list_tables= 0;
m_non_agg_field_used= false;
m_agg_func_used= false;
window_specs.empty();
window_funcs.empty();
}
| 0
|
241,047
|
static int read_authkey()
{
int fd;
booth_conf->authkey[0] = '\0';
fd = open(booth_conf->authfile, O_RDONLY);
if (fd < 0) {
log_error("cannot open %s: %s",
booth_conf->authfile, strerror(errno));
return -1;
}
if (fstat(fd, &booth_conf->authstat) < 0) {
log_error("cannot stat authentication file %s (%d): %s",
booth_conf->authfile, fd, strerror(errno));
close(fd);
return -1;
}
if (booth_conf->authstat.st_mode & (S_IRGRP | S_IROTH)) {
log_error("%s: file shall not be readable for anyone but the owner",
booth_conf->authfile);
close(fd);
return -1;
}
booth_conf->authkey_len = read(fd, booth_conf->authkey, BOOTH_MAX_KEY_LEN);
close(fd);
trim_key();
log_debug("read key of size %d in authfile %s",
booth_conf->authkey_len, booth_conf->authfile);
/* make sure that the key is of minimum length */
return (booth_conf->authkey_len >= BOOTH_MIN_KEY_LEN) ? 0 : -1;
}
| 0
|
313,845
|
end_visual_mode()
{
end_visual_mode_keep_button();
reset_held_button();
}
| 0
|
466,121
|
static int em_mul_ex(struct x86_emulate_ctxt *ctxt)
{
u8 ex = 0;
emulate_1op_rax_rdx(ctxt, "mul", ex);
return X86EMUL_CONTINUE;
}
| 0
|
338,161
|
void WasmBinaryWriter::writeExports() {
if (wasm->exports.size() == 0) {
return;
}
BYN_TRACE("== writeexports\n");
auto start = startSection(BinaryConsts::Section::Export);
o << U32LEB(wasm->exports.size());
for (auto& curr : wasm->exports) {
BYN_TRACE("write one\n");
writeInlineString(curr->name.str);
o << U32LEB(int32_t(curr->kind));
switch (curr->kind) {
case ExternalKind::Function:
o << U32LEB(getFunctionIndex(curr->value));
break;
case ExternalKind::Table:
o << U32LEB(0);
break;
case ExternalKind::Memory:
o << U32LEB(0);
break;
case ExternalKind::Global:
o << U32LEB(getGlobalIndex(curr->value));
break;
case ExternalKind::Tag:
o << U32LEB(getTagIndex(curr->value));
break;
default:
WASM_UNREACHABLE("unexpected extern kind");
}
}
finishSection(start);
}
| 0
|
198,692
|
int xfrm_migrate(const struct xfrm_selector *sel, u8 dir, u8 type,
struct xfrm_migrate *m, int num_migrate,
struct xfrm_kmaddress *k, struct net *net,
struct xfrm_encap_tmpl *encap)
{
int i, err, nx_cur = 0, nx_new = 0;
struct xfrm_policy *pol = NULL;
struct xfrm_state *x, *xc;
struct xfrm_state *x_cur[XFRM_MAX_DEPTH];
struct xfrm_state *x_new[XFRM_MAX_DEPTH];
struct xfrm_migrate *mp;
if ((err = xfrm_migrate_check(m, num_migrate)) < 0)
goto out;
/* Stage 1 - find policy */
if ((pol = xfrm_migrate_policy_find(sel, dir, type, net)) == NULL) {
err = -ENOENT;
goto out;
}
/* Stage 2 - find and update state(s) */
for (i = 0, mp = m; i < num_migrate; i++, mp++) {
if ((x = xfrm_migrate_state_find(mp, net))) {
x_cur[nx_cur] = x;
nx_cur++;
xc = xfrm_state_migrate(x, mp, encap);
if (xc) {
x_new[nx_new] = xc;
nx_new++;
} else {
err = -ENODATA;
goto restore_state;
}
}
}
/* Stage 3 - update policy */
if ((err = xfrm_policy_migrate(pol, m, num_migrate)) < 0)
goto restore_state;
/* Stage 4 - delete old state(s) */
if (nx_cur) {
xfrm_states_put(x_cur, nx_cur);
xfrm_states_delete(x_cur, nx_cur);
}
/* Stage 5 - announce */
km_migrate(sel, dir, type, m, num_migrate, k, encap);
xfrm_pol_put(pol);
return 0;
out:
return err;
restore_state:
if (pol)
xfrm_pol_put(pol);
if (nx_cur)
xfrm_states_put(x_cur, nx_cur);
if (nx_new)
xfrm_states_delete(x_new, nx_new);
return err;
}
| 1
|
90,108
|
virtual void AddNetworkObserver(const std::string& service_path,
NetworkObserver* observer) {
DCHECK(observer);
if (!EnsureCrosLoaded())
return;
NetworkObserverMap::iterator iter = network_observers_.find(service_path);
NetworkObserverList* oblist;
if (iter != network_observers_.end()) {
oblist = iter->second;
} else {
std::pair<NetworkObserverMap::iterator, bool> inserted =
network_observers_.insert(
std::make_pair<std::string, NetworkObserverList*>(
service_path,
new NetworkObserverList(this, service_path)));
oblist = inserted.first->second;
}
if (!oblist->HasObserver(observer))
oblist->AddObserver(observer);
}
| 0
|
459,511
|
static int __init stack_map_init(void)
{
int cpu;
struct stack_map_irq_work *work;
for_each_possible_cpu(cpu) {
work = per_cpu_ptr(&up_read_work, cpu);
init_irq_work(&work->irq_work, do_up_read);
}
return 0;
}
| 0
|
355,640
|
fill_evalarg_from_eap(evalarg_T *evalarg, exarg_T *eap, int skip)
{
init_evalarg(evalarg);
evalarg->eval_flags = skip ? 0 : EVAL_EVALUATE;
if (eap != NULL)
{
evalarg->eval_cstack = eap->cstack;
if (getline_equal(eap->getline, eap->cookie, getsourceline))
{
evalarg->eval_getline = eap->getline;
evalarg->eval_cookie = eap->cookie;
}
}
}
| 0
|
351,183
|
static double shp_length (SHPObject *feat) {
double length = 0.0;
if (feat->nParts == 0) {
length = length2d_polyline(feat->nVertices, feat->padfX, feat->padfY);
}
else {
for (int part = 0; part < feat->nParts; part++) {
int n;
if (part < feat->nParts - 1) {
n = feat->panPartStart[part+1] - feat->panPartStart[part];
}
else {
n = feat->nVertices - feat->panPartStart[part];
}
length += length2d_polyline (n,
&(feat->padfX[feat->panPartStart[part]]),
&(feat->padfY[feat->panPartStart[part]]));
}
}
return length;
}
| 0
|
369,375
|
void __io_uring_cancel(bool cancel_all)
{
io_uring_cancel_generic(cancel_all, NULL);
| 0
|
234,841
|
int btrfs_map_sblock(struct btrfs_fs_info *fs_info, enum btrfs_map_op op,
u64 logical, u64 *length,
struct btrfs_bio **bbio_ret)
{
return __btrfs_map_block(fs_info, op, logical, length, bbio_ret, 0, 1);
}
| 0
|
400,112
|
void LogHandler::setupStdoutLogger() {
el::Logger *stdoutLogger = el::Loggers::getLogger("stdout");
// Easylogging configurations
el::Configurations stdoutConf;
stdoutConf.setToDefault();
// Values are always std::string
stdoutConf.setGlobally(el::ConfigurationType::Format, "%msg");
stdoutConf.setGlobally(el::ConfigurationType::ToStandardOutput, "true");
stdoutConf.setGlobally(el::ConfigurationType::ToFile, "false");
el::Loggers::reconfigureLogger(stdoutLogger, stdoutConf);
}
| 0
|
336,129
|
static struct ip6_tnl *ip6gre_tunnel_find(struct net *net,
const struct __ip6_tnl_parm *parms,
int type)
{
const struct in6_addr *remote = &parms->raddr;
const struct in6_addr *local = &parms->laddr;
__be32 key = parms->i_key;
int link = parms->link;
struct ip6_tnl *t;
struct ip6_tnl __rcu **tp;
struct ip6gre_net *ign = net_generic(net, ip6gre_net_id);
for (tp = __ip6gre_bucket(ign, parms);
(t = rtnl_dereference(*tp)) != NULL;
tp = &t->next)
if (ipv6_addr_equal(local, &t->parms.laddr) &&
ipv6_addr_equal(remote, &t->parms.raddr) &&
key == t->parms.i_key &&
link == t->parms.link &&
type == t->dev->type)
break;
return t;
}
| 0
|
505,657
|
void smtp_command_parser_deinit(struct smtp_command_parser **_parser)
{
struct smtp_command_parser *parser = *_parser;
i_stream_unref(&parser->data);
i_free(parser->state.cmd_name);
i_free(parser->state.cmd_params);
i_free(parser->error);
i_stream_unref(&parser->input);
i_free(parser);
*_parser = NULL;
}
| 0
|
261,957
|
njs_string_object_validate(njs_vm_t *vm, njs_value_t *object)
{
njs_int_t ret;
if (njs_slow_path(njs_is_null_or_undefined(object))) {
njs_type_error(vm, "cannot convert undefined to object");
return NJS_ERROR;
}
if (njs_slow_path(!njs_is_string(object))) {
ret = njs_value_to_string(vm, object, object);
if (njs_slow_path(ret != NJS_OK)) {
return ret;
}
}
return NJS_OK;
}
| 0
|
281,089
|
bool xfrm_selector_match(const struct xfrm_selector *sel, const struct flowi *fl,
unsigned short family)
{
switch (family) {
case AF_INET:
return __xfrm4_selector_match(sel, fl);
case AF_INET6:
return __xfrm6_selector_match(sel, fl);
}
return false;
}
| 0
|
473,850
|
is_allowed_reverse_match(const UChar* s, const UChar* end, OnigEncoding enc ARG_UNUSED)
{
const UChar c = *s;
if (c <= 0x7e || c == 0x8e || c == 0x8f)
return TRUE;
else
return FALSE;
}
| 0
|
234,869
|
static inline void btrfs_end_bbio(struct btrfs_bio *bbio, struct bio *bio)
{
bio->bi_private = bbio->private;
bio->bi_end_io = bbio->end_io;
bio_endio(bio);
btrfs_put_bbio(bbio);
}
| 0
|
248,277
|
DLLIMPORT cfg_t *cfg_opt_gettsec(cfg_opt_t *opt, const char *title)
{
long int i;
if (!opt || !title) {
errno = EINVAL;
return NULL;
}
if (!is_set(CFGF_TITLE, opt->flags)) {
errno = EINVAL;
return NULL;
}
i = cfg_opt_gettsecidx(opt, title);
if (i >= 0)
return cfg_opt_getnsec(opt, i);
errno = ENOENT;
return NULL;
}
| 0
|
307,867
|
char *ciEnv::name_buffer(int req_len) {
if (_name_buffer_len < req_len) {
if (_name_buffer == NULL) {
_name_buffer = (char*)arena()->Amalloc(sizeof(char)*req_len);
_name_buffer_len = req_len;
} else {
_name_buffer =
(char*)arena()->Arealloc(_name_buffer, _name_buffer_len, req_len);
_name_buffer_len = req_len;
}
}
return _name_buffer;
}
| 0
|
387,757
|
bool InstanceKlass::has_redefined_this_or_super() const {
const Klass* klass = this;
while (klass != NULL) {
if (InstanceKlass::cast(klass)->has_been_redefined()) {
return true;
}
klass = klass->super();
}
return false;
}
| 0
|
299,896
|
readconf_retries(void)
{
retry_config **chain = &retries;
retry_config *next;
uschar *p;
while ((p = get_config_line()) != NULL)
{
retry_rule **rchain;
uschar *pp, *error;
next = store_get(sizeof(retry_config));
next->next = NULL;
*chain = next;
chain = &(next->next);
next->basic_errno = next->more_errno = 0;
next->senders = NULL;
next->rules = NULL;
rchain = &(next->rules);
next->pattern = string_dequote(&p);
while (isspace(*p)) p++;
pp = p;
while (mac_isgraph(*p)) p++;
if (p - pp <= 0) log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
"missing error type");
/* Test error names for things we understand. */
if ((error = readconf_retry_error(pp, p, &(next->basic_errno),
&(next->more_errno))) != NULL)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "%s", error);
/* There may be an optional address list of senders to be used as another
constraint on the rule. This was added later, so the syntax is a bit of a
fudge. Anything that is not a retry rule starting "F," or "G," is treated as
an address list. */
while (isspace(*p)) p++;
if (Ustrncmp(p, "senders", 7) == 0)
{
p += 7;
while (isspace(*p)) p++;
if (*p++ != '=') log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
"\"=\" expected after \"senders\" in retry rule");
while (isspace(*p)) p++;
next->senders = string_dequote(&p);
}
/* Now the retry rules. Keep the maximum timeout encountered. */
while (isspace(*p)) p++;
while (*p != 0)
{
retry_rule *rule = store_get(sizeof(retry_rule));
*rchain = rule;
rchain = &(rule->next);
rule->next = NULL;
rule->rule = toupper(*p++);
rule->timeout = retry_arg(&p, 0);
if (rule->timeout > retry_maximum_timeout)
retry_maximum_timeout = rule->timeout;
switch (rule->rule)
{
case 'F': /* Fixed interval */
rule->p1 = retry_arg(&p, 0);
break;
case 'G': /* Geometrically increasing intervals */
case 'H': /* Ditto, but with randomness */
rule->p1 = retry_arg(&p, 0);
rule->p2 = retry_arg(&p, 1);
break;
default:
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "unknown retry rule letter");
break;
}
if (rule->timeout <= 0 || rule->p1 <= 0 ||
(rule->rule != 'F' && rule->p2 < 1000))
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN,
"bad parameters for retry rule");
while (isspace(*p)) p++;
if (*p == ';')
{
p++;
while (isspace(*p)) p++;
}
else if (*p != 0)
log_write(0, LOG_PANIC_DIE|LOG_CONFIG_IN, "semicolon expected");
}
}
}
| 0
|
247,756
|
Integer RWFunction::ApplyFunction(const Integer &in) const
{
DoQuickSanityCheck();
Integer out = in.Squared()%m_n;
const word r = 12;
// this code was written to handle both r = 6 and r = 12,
// but now only r = 12 is used in P1363
const word r2 = r/2;
const word r3a = (16 + 5 - r) % 16; // n%16 could be 5 or 13
const word r3b = (16 + 13 - r) % 16;
const word r4 = (8 + 5 - r/2) % 8; // n%8 == 5
switch (out % 16)
{
case r:
break;
case r2:
case r2+8:
out <<= 1;
break;
case r3a:
case r3b:
out.Negate();
out += m_n;
break;
case r4:
case r4+8:
out.Negate();
out += m_n;
out <<= 1;
break;
default:
out = Integer::Zero();
}
return out;
}
| 0
|
101,668
|
void WebProcessProxy::didDestroyFrame(uint64_t frameID)
{
ASSERT(isGoodKey<WebFrameProxyMap>(frameID));
m_frameMap.remove(frameID);
}
| 0
|
512,824
|
Item_equal::Item_equal(THD *thd, const Type_handler *handler,
Item *f1, Item *f2, bool with_const_item):
Item_bool_func(thd), eval_item(0), cond_false(0), cond_true(0),
context_field(NULL), link_equal_fields(FALSE),
m_compare_handler(handler),
m_compare_collation(f2->collation.collation)
{
const_item_cache= 0;
with_const= with_const_item;
equal_items.push_back(f1, thd->mem_root);
equal_items.push_back(f2, thd->mem_root);
upper_levels= NULL;
}
| 0
|
369,245
|
static int io_sqe_buffer_register(struct io_ring_ctx *ctx, struct iovec *iov,
struct io_mapped_ubuf **pimu,
struct page **last_hpage)
{
struct io_mapped_ubuf *imu = NULL;
struct vm_area_struct **vmas = NULL;
struct page **pages = NULL;
unsigned long off, start, end, ubuf;
size_t size;
int ret, pret, nr_pages, i;
if (!iov->iov_base) {
*pimu = ctx->dummy_ubuf;
return 0;
}
ubuf = (unsigned long) iov->iov_base;
end = (ubuf + iov->iov_len + PAGE_SIZE - 1) >> PAGE_SHIFT;
start = ubuf >> PAGE_SHIFT;
nr_pages = end - start;
*pimu = NULL;
ret = -ENOMEM;
pages = kvmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL);
if (!pages)
goto done;
vmas = kvmalloc_array(nr_pages, sizeof(struct vm_area_struct *),
GFP_KERNEL);
if (!vmas)
goto done;
imu = kvmalloc(struct_size(imu, bvec, nr_pages), GFP_KERNEL);
if (!imu)
goto done;
ret = 0;
mmap_read_lock(current->mm);
pret = pin_user_pages(ubuf, nr_pages, FOLL_WRITE | FOLL_LONGTERM,
pages, vmas);
if (pret == nr_pages) {
/* don't support file backed memory */
for (i = 0; i < nr_pages; i++) {
struct vm_area_struct *vma = vmas[i];
if (vma_is_shmem(vma))
continue;
if (vma->vm_file &&
!is_file_hugepages(vma->vm_file)) {
ret = -EOPNOTSUPP;
break;
}
}
} else {
ret = pret < 0 ? pret : -EFAULT;
}
mmap_read_unlock(current->mm);
if (ret) {
/*
* if we did partial map, or found file backed vmas,
* release any pages we did get
*/
if (pret > 0)
unpin_user_pages(pages, pret);
goto done;
}
ret = io_buffer_account_pin(ctx, pages, pret, imu, last_hpage);
if (ret) {
unpin_user_pages(pages, pret);
goto done;
}
off = ubuf & ~PAGE_MASK;
size = iov->iov_len;
for (i = 0; i < nr_pages; i++) {
size_t vec_len;
vec_len = min_t(size_t, size, PAGE_SIZE - off);
imu->bvec[i].bv_page = pages[i];
imu->bvec[i].bv_len = vec_len;
imu->bvec[i].bv_offset = off;
off = 0;
size -= vec_len;
}
/* store original address for later verification */
imu->ubuf = ubuf;
imu->ubuf_end = ubuf + iov->iov_len;
imu->nr_bvecs = nr_pages;
*pimu = imu;
ret = 0;
done:
if (ret)
kvfree(imu);
kvfree(pages);
kvfree(vmas);
return ret;
| 0
|
310,175
|
has_colors(void)
{
return NCURSES_SP_NAME(has_colors) (CURRENT_SCREEN);
}
| 0
|
225,036
|
setKeepalivesCount(PGconn *conn)
{
int count;
if (conn->keepalives_count == NULL)
return 1;
if (!parse_int_param(conn->keepalives_count, &count, conn,
"keepalives_count"))
return 0;
if (count < 0)
count = 0;
#ifdef TCP_KEEPCNT
if (setsockopt(conn->sock, IPPROTO_TCP, TCP_KEEPCNT,
(char *) &count, sizeof(count)) < 0)
{
char sebuf[PG_STRERROR_R_BUFLEN];
appendPQExpBuffer(&conn->errorMessage,
libpq_gettext("%s(%s) failed: %s\n"),
"setsockopt",
"TCP_KEEPCNT",
SOCK_STRERROR(SOCK_ERRNO, sebuf, sizeof(sebuf)));
return 0;
}
#endif
return 1;
}
| 0
|
236,145
|
GF_Err gppc_box_size(GF_Box *s)
{
GF_3GPPConfigBox *ptr = (GF_3GPPConfigBox *)s;
s->size += 5;
if (!ptr->cfg.type) {
switch (ptr->type) {
case GF_ISOM_BOX_TYPE_D263:
ptr->cfg.type = GF_ISOM_SUBTYPE_3GP_H263;
break;
case GF_ISOM_BOX_TYPE_DAMR:
ptr->cfg.type = GF_ISOM_SUBTYPE_3GP_AMR;
break;
case GF_ISOM_BOX_TYPE_DEVC:
ptr->cfg.type = GF_ISOM_SUBTYPE_3GP_EVRC;
break;
case GF_ISOM_BOX_TYPE_DQCP:
ptr->cfg.type = GF_ISOM_SUBTYPE_3GP_QCELP;
break;
case GF_ISOM_BOX_TYPE_DSMV:
ptr->cfg.type = GF_ISOM_SUBTYPE_3GP_SMV;
break;
}
}
switch (ptr->cfg.type) {
case GF_ISOM_SUBTYPE_3GP_H263:
s->size += 2;
break;
case GF_ISOM_SUBTYPE_3GP_AMR:
case GF_ISOM_SUBTYPE_3GP_AMR_WB:
s->size += 4;
break;
case GF_ISOM_SUBTYPE_3GP_EVRC:
case GF_ISOM_SUBTYPE_3GP_QCELP:
case GF_ISOM_SUBTYPE_3GP_SMV:
s->size += 1;
break;
}
return GF_OK;
}
| 0
|
200,163
|
static int elo_probe(struct hid_device *hdev, const struct hid_device_id *id)
{
struct elo_priv *priv;
int ret;
struct usb_device *udev;
if (!hid_is_usb(hdev))
return -EINVAL;
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
INIT_DELAYED_WORK(&priv->work, elo_work);
udev = interface_to_usbdev(to_usb_interface(hdev->dev.parent));
priv->usbdev = usb_get_dev(udev);
hid_set_drvdata(hdev, priv);
ret = hid_parse(hdev);
if (ret) {
hid_err(hdev, "parse failed\n");
goto err_free;
}
ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
if (ret) {
hid_err(hdev, "hw start failed\n");
goto err_free;
}
if (elo_broken_firmware(priv->usbdev)) {
hid_info(hdev, "broken firmware found, installing workaround\n");
queue_delayed_work(wq, &priv->work, ELO_PERIODIC_READ_INTERVAL);
}
return 0;
err_free:
kfree(priv);
return ret;
}
| 1
|
473,886
|
utf32be_get_case_fold_codes_by_str(OnigCaseFoldType flag,
const OnigUChar* p, const OnigUChar* end,
OnigCaseFoldCodeItem items[],
OnigEncoding enc)
{
return onigenc_unicode_get_case_fold_codes_by_str(enc,
flag, p, end, items);
}
| 0
|
101,658
|
void WebProcessProxy::addMessageReceiver(CoreIPC::StringReference messageReceiverName, uint64_t destinationID, CoreIPC::MessageReceiver* messageReceiver)
{
m_messageReceiverMap.addMessageReceiver(messageReceiverName, destinationID, messageReceiver);
}
| 0
|
401,574
|
void add_disk_randomness(struct gendisk *disk)
{
if (!disk || !disk->random)
return;
/* first major is 1, so we get >= 0x200 here */
add_timer_randomness(disk->random, 0x100 + disk_devt(disk));
trace_add_disk_randomness(disk_devt(disk), ENTROPY_BITS(&input_pool));
}
| 0
|
508,316
|
set_new_item_local_context(THD *thd, Item_ident *item, TABLE_LIST *table_ref)
{
Name_resolution_context *context;
if (!(context= new (thd->mem_root) Name_resolution_context))
return TRUE;
context->init();
context->first_name_resolution_table=
context->last_name_resolution_table= table_ref;
item->context= context;
return FALSE;
}
| 0
|
509,545
|
int ha_maria::index_prev(uchar * buf)
{
DBUG_ASSERT(inited == INDEX);
register_handler(file);
int error= maria_rprev(file, buf, active_index);
return error;
}
| 0
|
338,106
|
Name WasmBinaryBuilder::escape(Name name) {
bool allIdChars = true;
for (const char* p = name.str; allIdChars && *p; p++) {
allIdChars = isIdChar(*p);
}
if (allIdChars) {
return name;
}
// encode name, if at least one non-idchar (per WebAssembly spec) was found
std::string escaped;
for (const char* p = name.str; *p; p++) {
char ch = *p;
if (isIdChar(ch)) {
escaped.push_back(ch);
continue;
}
// replace non-idchar with `\xx` escape
escaped.push_back('\\');
escaped.push_back(formatNibble(ch >> 4));
escaped.push_back(formatNibble(ch & 15));
}
return escaped;
}
| 0
|
210,910
|
win_redr_status(win_T *wp, int ignore_pum UNUSED)
{
int row;
char_u *p;
int len;
int fillchar;
int attr;
int this_ru_col;
static int busy = FALSE;
// It's possible to get here recursively when 'statusline' (indirectly)
// invokes ":redrawstatus". Simply ignore the call then.
if (busy)
return;
busy = TRUE;
row = statusline_row(wp);
wp->w_redr_status = FALSE;
if (wp->w_status_height == 0)
{
// no status line, can only be last window
redraw_cmdline = TRUE;
}
else if (!redrawing()
// don't update status line when popup menu is visible and may be
// drawn over it, unless it will be redrawn later
|| (!ignore_pum && pum_visible()))
{
// Don't redraw right now, do it later.
wp->w_redr_status = TRUE;
}
#ifdef FEAT_STL_OPT
else if (*p_stl != NUL || *wp->w_p_stl != NUL)
{
// redraw custom status line
redraw_custom_statusline(wp);
}
#endif
else
{
fillchar = fillchar_status(&attr, wp);
get_trans_bufname(wp->w_buffer);
p = NameBuff;
len = (int)STRLEN(p);
if (bt_help(wp->w_buffer)
#ifdef FEAT_QUICKFIX
|| wp->w_p_pvw
#endif
|| bufIsChanged(wp->w_buffer)
|| wp->w_buffer->b_p_ro)
*(p + len++) = ' ';
if (bt_help(wp->w_buffer))
{
vim_snprintf((char *)p + len, MAXPATHL - len, "%s", _("[Help]"));
len += (int)STRLEN(p + len);
}
#ifdef FEAT_QUICKFIX
if (wp->w_p_pvw)
{
vim_snprintf((char *)p + len, MAXPATHL - len, "%s", _("[Preview]"));
len += (int)STRLEN(p + len);
}
#endif
if (bufIsChanged(wp->w_buffer)
#ifdef FEAT_TERMINAL
&& !bt_terminal(wp->w_buffer)
#endif
)
{
vim_snprintf((char *)p + len, MAXPATHL - len, "%s", "[+]");
len += (int)STRLEN(p + len);
}
if (wp->w_buffer->b_p_ro)
{
vim_snprintf((char *)p + len, MAXPATHL - len, "%s", _("[RO]"));
len += (int)STRLEN(p + len);
}
this_ru_col = ru_col - (Columns - wp->w_width);
if (this_ru_col < (wp->w_width + 1) / 2)
this_ru_col = (wp->w_width + 1) / 2;
if (this_ru_col <= 1)
{
p = (char_u *)"<"; // No room for file name!
len = 1;
}
else if (has_mbyte)
{
int clen = 0, i;
// Count total number of display cells.
clen = mb_string2cells(p, -1);
// Find first character that will fit.
// Going from start to end is much faster for DBCS.
for (i = 0; p[i] != NUL && clen >= this_ru_col - 1;
i += (*mb_ptr2len)(p + i))
clen -= (*mb_ptr2cells)(p + i);
len = clen;
if (i > 0)
{
p = p + i - 1;
*p = '<';
++len;
}
}
else if (len > this_ru_col - 1)
{
p += len - (this_ru_col - 1);
*p = '<';
len = this_ru_col - 1;
}
screen_puts(p, row, wp->w_wincol, attr);
screen_fill(row, row + 1, len + wp->w_wincol,
this_ru_col + wp->w_wincol, fillchar, fillchar, attr);
if (get_keymap_str(wp, (char_u *)"<%s>", NameBuff, MAXPATHL)
&& (int)(this_ru_col - len) > (int)(STRLEN(NameBuff) + 1))
screen_puts(NameBuff, row, (int)(this_ru_col - STRLEN(NameBuff)
- 1 + wp->w_wincol), attr);
#ifdef FEAT_CMDL_INFO
win_redr_ruler(wp, TRUE, ignore_pum);
#endif
}
/*
* May need to draw the character below the vertical separator.
*/
if (wp->w_vsep_width != 0 && wp->w_status_height != 0 && redrawing())
{
if (stl_connected(wp))
fillchar = fillchar_status(&attr, wp);
else
fillchar = fillchar_vsep(&attr);
screen_putchar(fillchar, row, W_ENDCOL(wp), attr);
}
busy = FALSE;
}
| 1
|
292,150
|
LinkInfo::LinkInfo(const constantPoolHandle& pool, int index, TRAPS) {
// resolve klass
_resolved_klass = pool->klass_ref_at(index, CHECK);
// Get name, signature, and static klass
_name = pool->name_ref_at(index);
_signature = pool->signature_ref_at(index);
_tag = pool->tag_ref_at(index);
_current_klass = pool->pool_holder();
_current_method = methodHandle();
// Coming from the constant pool always checks access
_check_access = true;
}
| 0
|
101,656
|
void WebProcessProxy::addBackForwardItem(uint64_t itemID, const String& originalURL, const String& url, const String& title, const CoreIPC::DataReference& backForwardData)
{
MESSAGE_CHECK_URL(originalURL);
MESSAGE_CHECK_URL(url);
WebBackForwardListItemMap::AddResult result = m_backForwardListItemMap.add(itemID, 0);
if (result.isNewEntry) {
result.iterator->value = WebBackForwardListItem::create(originalURL, url, title, backForwardData.data(), backForwardData.size(), itemID);
return;
}
result.iterator->value->setOriginalURL(originalURL);
result.iterator->value->setURL(url);
result.iterator->value->setTitle(title);
result.iterator->value->setBackForwardData(backForwardData.data(), backForwardData.size());
}
| 0
|
281,082
|
__xfrm_policy_lookup(struct net *net, const struct flowi *fl, u16 family, u8 dir)
{
#ifdef CONFIG_XFRM_SUB_POLICY
struct xfrm_policy *pol;
pol = xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_SUB, fl, family, dir);
if (pol != NULL)
return pol;
#endif
return xfrm_policy_lookup_bytype(net, XFRM_POLICY_TYPE_MAIN, fl, family, dir);
}
| 0
|
386,514
|
void DL_Dxf::writeXRecord(DL_WriterA& dw, int handle, const std::string& value) {
dw.dxfString( 0, "XRECORD");
dw.dxfHex(5, handle);
dw.dxfHex(330, appDictionaryHandle);
dw.dxfString(100, "AcDbXrecord");
dw.dxfInt(280, 1);
dw.dxfString(1000, value);
}
| 0
|
513,360
|
create_distinct_group(THD *thd, Ref_ptr_array ref_pointer_array,
ORDER *order_list, List<Item> &fields,
List<Item> &all_fields,
bool *all_order_by_fields_used)
{
List_iterator<Item> li(fields);
Item *item;
Ref_ptr_array orig_ref_pointer_array= ref_pointer_array;
ORDER *order,*group,**prev;
uint idx= 0;
*all_order_by_fields_used= 1;
while ((item=li++))
item->marker=0; /* Marker that field is not used */
prev= &group; group=0;
for (order=order_list ; order; order=order->next)
{
if (order->in_field_list)
{
ORDER *ord=(ORDER*) thd->memdup((char*) order,sizeof(ORDER));
if (!ord)
return 0;
*prev=ord;
prev= &ord->next;
(*ord->item)->marker=1;
}
else
*all_order_by_fields_used= 0;
}
li.rewind();
while ((item=li++))
{
if (!item->const_item() && !item->with_sum_func && !item->marker)
{
/*
Don't put duplicate columns from the SELECT list into the
GROUP BY list.
*/
ORDER *ord_iter;
for (ord_iter= group; ord_iter; ord_iter= ord_iter->next)
if ((*ord_iter->item)->eq(item, 1))
goto next_item;
ORDER *ord=(ORDER*) thd->calloc(sizeof(ORDER));
if (!ord)
return 0;
if (item->type() == Item::FIELD_ITEM &&
item->field_type() == MYSQL_TYPE_BIT)
{
/*
Because HEAP tables can't index BIT fields we need to use an
additional hidden field for grouping because later it will be
converted to a LONG field. Original field will remain of the
BIT type and will be returned [el]client.
*/
Item_field *new_item= new (thd->mem_root) Item_field(thd, (Item_field*)item);
int el= all_fields.elements;
orig_ref_pointer_array[el]= new_item;
all_fields.push_front(new_item, thd->mem_root);
ord->item=&orig_ref_pointer_array[el];
}
else
{
/*
We have here only field_list (not all_field_list), so we can use
simple indexing of ref_pointer_array (order in the array and in the
list are same)
*/
ord->item= &ref_pointer_array[idx];
}
ord->direction= ORDER::ORDER_ASC;
*prev=ord;
prev= &ord->next;
}
next_item:
idx++;
}
*prev=0;
return group;
}
| 0
|
314,512
|
PJ_DEF(unsigned) pjmedia_sdp_attr_remove_all(unsigned *count,
pjmedia_sdp_attr *attr_array[],
const char *name)
{
unsigned i, removed = 0;
pj_str_t attr_name;
PJ_ASSERT_RETURN(count && attr_array && name, PJ_EINVAL);
PJ_ASSERT_RETURN(*count <= PJMEDIA_MAX_SDP_ATTR, PJ_ETOOMANY);
attr_name.ptr = (char*)name;
attr_name.slen = pj_ansi_strlen(name);
for (i=0; i<*count; ) {
if (pj_strcmp(&attr_array[i]->name, &attr_name)==0) {
pj_array_erase(attr_array, sizeof(pjmedia_sdp_attr*),
*count, i);
--(*count);
++removed;
} else {
++i;
}
}
return removed;
}
| 0
|
286,719
|
SWTPM_CheckHash(const unsigned char *in, uint32_t in_length,
unsigned char **out, uint32_t *out_length)
{
TPM_RESULT rc = 0;
unsigned char *dest = NULL;
unsigned char hashbuf[SHA256_DIGEST_LENGTH];
const unsigned char *data = &in[sizeof(hashbuf)];
uint32_t data_length = in_length - sizeof(hashbuf);
/* hash the data */
SHA256(data, data_length, hashbuf);
if (memcmp(in, hashbuf, sizeof(hashbuf))) {
logprintf(STDOUT_FILENO, "Verification of hash failed. "
"Data integrity is compromised\n");
rc = TPM_FAIL;
}
if (rc == 0) {
dest = malloc(data_length);
if (dest) {
*out = dest;
*out_length = data_length;
memcpy(dest, data, data_length);
} else {
logprintf(STDOUT_FILENO,
"Could not allocated %u bytes.\n", data_length);
rc = TPM_FAIL;
}
}
return rc;
}
| 0
|
202,719
|
struct sctp_chunk *sctp_make_strreset_req(
const struct sctp_association *asoc,
__u16 stream_num, __be16 *stream_list,
bool out, bool in)
{
__u16 stream_len = stream_num * sizeof(__u16);
struct sctp_strreset_outreq outreq;
struct sctp_strreset_inreq inreq;
struct sctp_chunk *retval;
__u16 outlen, inlen;
outlen = (sizeof(outreq) + stream_len) * out;
inlen = (sizeof(inreq) + stream_len) * in;
retval = sctp_make_reconf(asoc, outlen + inlen);
if (!retval)
return NULL;
if (outlen) {
outreq.param_hdr.type = SCTP_PARAM_RESET_OUT_REQUEST;
outreq.param_hdr.length = htons(outlen);
outreq.request_seq = htonl(asoc->strreset_outseq);
outreq.response_seq = htonl(asoc->strreset_inseq - 1);
outreq.send_reset_at_tsn = htonl(asoc->next_tsn - 1);
sctp_addto_chunk(retval, sizeof(outreq), &outreq);
if (stream_len)
sctp_addto_chunk(retval, stream_len, stream_list);
}
if (inlen) {
inreq.param_hdr.type = SCTP_PARAM_RESET_IN_REQUEST;
inreq.param_hdr.length = htons(inlen);
inreq.request_seq = htonl(asoc->strreset_outseq + out);
sctp_addto_chunk(retval, sizeof(inreq), &inreq);
if (stream_len)
sctp_addto_chunk(retval, stream_len, stream_list);
}
return retval;
}
| 1
|
210,834
|
LogFilePrep(const char *fname, const char *backup, const char *idstring)
{
char *logFileName = NULL;
if (asprintf(&logFileName, fname, idstring) == -1)
FatalError("Cannot allocate space for the log file name\n");
if (backup && *backup) {
struct stat buf;
if (!stat(logFileName, &buf) && S_ISREG(buf.st_mode)) {
char *suffix;
char *oldLog;
if ((asprintf(&suffix, backup, idstring) == -1) ||
(asprintf(&oldLog, "%s%s", logFileName, suffix) == -1)) {
FatalError("Cannot allocate space for the log file name\n");
}
free(suffix);
if (rename(logFileName, oldLog) == -1) {
FatalError("Cannot move old log file \"%s\" to \"%s\"\n",
logFileName, oldLog);
}
free(oldLog);
}
}
else {
if (remove(logFileName) != 0 && errno != ENOENT) {
FatalError("Cannot remove old log file \"%s\": %s\n",
logFileName, strerror(errno));
}
}
return logFileName;
}
| 1
|
291,828
|
static void destroy_cm(struct rtrs_clt_con *con)
{
rdma_destroy_id(con->c.cm_id);
con->c.cm_id = NULL;
}
| 0
|
389,704
|
eval_env_var(char_u **arg, typval_T *rettv, int evaluate)
{
char_u *string = NULL;
int len;
int cc;
char_u *name;
int mustfree = FALSE;
++*arg;
name = *arg;
len = get_env_len(arg);
if (evaluate)
{
if (len == 0)
return FAIL; // invalid empty name
cc = name[len];
name[len] = NUL;
// first try vim_getenv(), fast for normal environment vars
string = vim_getenv(name, &mustfree);
if (string != NULL && *string != NUL)
{
if (!mustfree)
string = vim_strsave(string);
}
else
{
if (mustfree)
vim_free(string);
// next try expanding things like $VIM and ${HOME}
string = expand_env_save(name - 1);
if (string != NULL && *string == '$')
VIM_CLEAR(string);
}
name[len] = cc;
rettv->v_type = VAR_STRING;
rettv->vval.v_string = string;
rettv->v_lock = 0;
}
return OK;
}
| 0
|
294,538
|
d_lite_plus(VALUE self, VALUE other)
{
int try_rational = 1;
get_d1(self);
again:
switch (TYPE(other)) {
case T_FIXNUM:
{
VALUE nth;
long t;
int jd;
nth = m_nth(dat);
t = FIX2LONG(other);
if (DIV(t, CM_PERIOD)) {
nth = f_add(nth, INT2FIX(DIV(t, CM_PERIOD)));
t = MOD(t, CM_PERIOD);
}
if (!t)
jd = m_jd(dat);
else {
jd = m_jd(dat) + (int)t;
canonicalize_jd(nth, jd);
}
if (simple_dat_p(dat))
return d_simple_new_internal(rb_obj_class(self),
nth, jd,
dat->s.sg,
0, 0, 0,
(dat->s.flags | HAVE_JD) &
~HAVE_CIVIL);
else
return d_complex_new_internal(rb_obj_class(self),
nth, jd,
dat->c.df, dat->c.sf,
dat->c.of, dat->c.sg,
0, 0, 0,
#ifndef USE_PACK
dat->c.hour,
dat->c.min,
dat->c.sec,
#else
EX_HOUR(dat->c.pc),
EX_MIN(dat->c.pc),
EX_SEC(dat->c.pc),
#endif
(dat->c.flags | HAVE_JD) &
~HAVE_CIVIL);
}
break;
case T_BIGNUM:
{
VALUE nth;
int jd, s;
if (f_positive_p(other))
s = +1;
else {
s = -1;
other = f_negate(other);
}
nth = f_idiv(other, INT2FIX(CM_PERIOD));
jd = FIX2INT(f_mod(other, INT2FIX(CM_PERIOD)));
if (s < 0) {
nth = f_negate(nth);
jd = -jd;
}
if (!jd)
jd = m_jd(dat);
else {
jd = m_jd(dat) + jd;
canonicalize_jd(nth, jd);
}
if (f_zero_p(nth))
nth = m_nth(dat);
else
nth = f_add(m_nth(dat), nth);
if (simple_dat_p(dat))
return d_simple_new_internal(rb_obj_class(self),
nth, jd,
dat->s.sg,
0, 0, 0,
(dat->s.flags | HAVE_JD) &
~HAVE_CIVIL);
else
return d_complex_new_internal(rb_obj_class(self),
nth, jd,
dat->c.df, dat->c.sf,
dat->c.of, dat->c.sg,
0, 0, 0,
#ifndef USE_PACK
dat->c.hour,
dat->c.min,
dat->c.sec,
#else
EX_HOUR(dat->c.pc),
EX_MIN(dat->c.pc),
EX_SEC(dat->c.pc),
#endif
(dat->c.flags | HAVE_JD) &
~HAVE_CIVIL);
}
break;
case T_FLOAT:
{
double jd, o, tmp;
int s, df;
VALUE nth, sf;
o = RFLOAT_VALUE(other);
if (o > 0)
s = +1;
else {
s = -1;
o = -o;
}
o = modf(o, &tmp);
if (!floor(tmp / CM_PERIOD)) {
nth = INT2FIX(0);
jd = (int)tmp;
}
else {
double i, f;
f = modf(tmp / CM_PERIOD, &i);
nth = f_floor(DBL2NUM(i));
jd = (int)(f * CM_PERIOD);
}
o *= DAY_IN_SECONDS;
o = modf(o, &tmp);
df = (int)tmp;
o *= SECOND_IN_NANOSECONDS;
sf = INT2FIX((int)round(o));
if (s < 0) {
jd = -jd;
df = -df;
sf = f_negate(sf);
}
if (f_zero_p(sf))
sf = m_sf(dat);
else {
sf = f_add(m_sf(dat), sf);
if (f_lt_p(sf, INT2FIX(0))) {
df -= 1;
sf = f_add(sf, INT2FIX(SECOND_IN_NANOSECONDS));
}
else if (f_ge_p(sf, INT2FIX(SECOND_IN_NANOSECONDS))) {
df += 1;
sf = f_sub(sf, INT2FIX(SECOND_IN_NANOSECONDS));
}
}
if (!df)
df = m_df(dat);
else {
df = m_df(dat) + df;
if (df < 0) {
jd -= 1;
df += DAY_IN_SECONDS;
}
else if (df >= DAY_IN_SECONDS) {
jd += 1;
df -= DAY_IN_SECONDS;
}
}
if (!jd)
jd = m_jd(dat);
else {
jd = m_jd(dat) + jd;
canonicalize_jd(nth, jd);
}
if (f_zero_p(nth))
nth = m_nth(dat);
else
nth = f_add(m_nth(dat), nth);
if (!df && f_zero_p(sf) && !m_of(dat))
return d_simple_new_internal(rb_obj_class(self),
nth, (int)jd,
m_sg(dat),
0, 0, 0,
(dat->s.flags | HAVE_JD) &
~(HAVE_CIVIL | HAVE_TIME |
COMPLEX_DAT));
else
return d_complex_new_internal(rb_obj_class(self),
nth, (int)jd,
df, sf,
m_of(dat), m_sg(dat),
0, 0, 0,
0, 0, 0,
(dat->c.flags |
HAVE_JD | HAVE_DF) &
~(HAVE_CIVIL | HAVE_TIME));
}
break;
default:
expect_numeric(other);
other = f_to_r(other);
if (!k_rational_p(other)) {
if (!try_rational) Check_Type(other, T_RATIONAL);
try_rational = 0;
goto again;
}
/* fall through */
case T_RATIONAL:
{
VALUE nth, sf, t;
int jd, df, s;
if (wholenum_p(other)) {
other = rb_rational_num(other);
goto again;
}
if (f_positive_p(other))
s = +1;
else {
s = -1;
other = f_negate(other);
}
nth = f_idiv(other, INT2FIX(CM_PERIOD));
t = f_mod(other, INT2FIX(CM_PERIOD));
jd = FIX2INT(f_idiv(t, INT2FIX(1)));
t = f_mod(t, INT2FIX(1));
t = f_mul(t, INT2FIX(DAY_IN_SECONDS));
df = FIX2INT(f_idiv(t, INT2FIX(1)));
t = f_mod(t, INT2FIX(1));
sf = f_mul(t, INT2FIX(SECOND_IN_NANOSECONDS));
if (s < 0) {
nth = f_negate(nth);
jd = -jd;
df = -df;
sf = f_negate(sf);
}
if (f_zero_p(sf))
sf = m_sf(dat);
else {
sf = f_add(m_sf(dat), sf);
if (f_lt_p(sf, INT2FIX(0))) {
df -= 1;
sf = f_add(sf, INT2FIX(SECOND_IN_NANOSECONDS));
}
else if (f_ge_p(sf, INT2FIX(SECOND_IN_NANOSECONDS))) {
df += 1;
sf = f_sub(sf, INT2FIX(SECOND_IN_NANOSECONDS));
}
}
if (!df)
df = m_df(dat);
else {
df = m_df(dat) + df;
if (df < 0) {
jd -= 1;
df += DAY_IN_SECONDS;
}
else if (df >= DAY_IN_SECONDS) {
jd += 1;
df -= DAY_IN_SECONDS;
}
}
if (!jd)
jd = m_jd(dat);
else {
jd = m_jd(dat) + jd;
canonicalize_jd(nth, jd);
}
if (f_zero_p(nth))
nth = m_nth(dat);
else
nth = f_add(m_nth(dat), nth);
if (!df && f_zero_p(sf) && !m_of(dat))
return d_simple_new_internal(rb_obj_class(self),
nth, jd,
m_sg(dat),
0, 0, 0,
(dat->s.flags | HAVE_JD) &
~(HAVE_CIVIL | HAVE_TIME |
COMPLEX_DAT));
else
return d_complex_new_internal(rb_obj_class(self),
nth, jd,
df, sf,
m_of(dat), m_sg(dat),
0, 0, 0,
0, 0, 0,
(dat->c.flags |
HAVE_JD | HAVE_DF) &
~(HAVE_CIVIL | HAVE_TIME));
}
break;
}
}
| 0
|
289,287
|
static void snd_pcm_oss_proc_init(struct snd_pcm *pcm)
{
int stream;
for (stream = 0; stream < 2; ++stream) {
struct snd_info_entry *entry;
struct snd_pcm_str *pstr = &pcm->streams[stream];
if (pstr->substream_count == 0)
continue;
entry = snd_info_create_card_entry(pcm->card, "oss", pstr->proc_root);
if (entry) {
entry->content = SNDRV_INFO_CONTENT_TEXT;
entry->mode = S_IFREG | 0644;
entry->c.text.read = snd_pcm_oss_proc_read;
entry->c.text.write = snd_pcm_oss_proc_write;
entry->private_data = pstr;
if (snd_info_register(entry) < 0) {
snd_info_free_entry(entry);
entry = NULL;
}
}
pstr->oss.proc_entry = entry;
}
}
| 0
|
225,418
|
static int vidioc_s_fmt_cap(struct file *file, void *priv,
struct v4l2_format *fmt)
{
return vidioc_try_fmt_cap(file, priv, fmt);
}
| 0
|
402,614
|
get_password_passthrough(PK11SlotInfo *slot UNUSED,
PRBool retry, void *arg)
{
if (retry || !arg)
return NULL;
char *ret = strdup(arg);
if (!ret)
err(1, "Could not allocate memory");
return ret;
}
| 0
|
301,352
|
static int vfswrap_asys_int_recv(struct tevent_req *req, int *err)
{
struct vfswrap_asys_state *state = tevent_req_data(
req, struct vfswrap_asys_state);
if (tevent_req_is_unix_error(req, err)) {
return -1;
}
*err = state->err;
return state->ret;
}
| 0
|
436,121
|
static void io_req_complete_failed(struct io_kiocb *req, long res)
{
req_set_fail(req);
io_put_req(req);
io_req_complete_post(req, res, 0);
}
| 0
|
328,818
|
R_API RList *retrieve_all_method_access_string_and_value(void) {
return retrieve_all_access_string_and_value (METHOD_ACCESS_FLAGS);
}
| 0
|
244,140
|
GF_Err extr_box_read(GF_Box *s, GF_BitStream *bs)
{
GF_Err e;
GF_ExtraDataBox *ptr = (GF_ExtraDataBox *)s;
e = gf_isom_box_parse((GF_Box**) &ptr->feci, bs);
if (e) return e;
if (!ptr->feci || ptr->feci->size > ptr->size) return GF_ISOM_INVALID_MEDIA;
ptr->data_length = (u32) (ptr->size - ptr->feci->size);
ptr->data = gf_malloc(sizeof(char)*ptr->data_length);
if (!ptr->data) return GF_OUT_OF_MEM;
gf_bs_read_data(bs, ptr->data, ptr->data_length);
return GF_OK;
}
| 0
|
228,444
|
String WddxPacket::packet_end() {
if (!m_packetClosed) {
if (m_manualPacketCreation) {
m_packetString.append("</struct>");
}
m_packetString.append("</data></wddxPacket>");
}
m_packetClosed = true;
return m_packetString.detach();
}
| 0
|
459,183
|
void tcf_block_netif_keep_dst(struct tcf_block *block)
{
struct tcf_block_owner_item *item;
block->keep_dst = true;
list_for_each_entry(item, &block->owner_list, list)
tcf_block_owner_netif_keep_dst(block, item->q,
item->binder_type);
}
| 0
|
512,898
|
bool excl_dep_on_in_subq_left_part(Item_in_subselect *subq_pred)
{
for (uint i= 0; i < arg_count; i++)
{
if (args[i]->const_item())
continue;
if (!args[i]->excl_dep_on_in_subq_left_part(subq_pred))
return false;
}
return true;
}
| 0
|
387,873
|
bool InstanceKlass::is_same_or_direct_interface(Klass *k) const {
// Verify direct super interface
if (this == k) return true;
assert(k->is_interface(), "should be an interface class");
for (int i = 0; i < local_interfaces()->length(); i++) {
if (local_interfaces()->at(i) == k) {
return true;
}
}
return false;
}
| 0
|
207,068
|
static ssize_t remove_slot_store(struct kobject *kobj,
struct kobj_attribute *attr,
const char *buf, size_t nbytes)
{
char drc_name[MAX_DRC_NAME_LEN];
int rc;
char *end;
if (nbytes >= MAX_DRC_NAME_LEN)
return 0;
memcpy(drc_name, buf, nbytes);
end = strchr(drc_name, '\n');
if (!end)
end = &drc_name[nbytes];
*end = '\0';
rc = dlpar_remove_slot(drc_name);
if (rc)
return rc;
return nbytes;
}
| 1
|
440,885
|
LogVHdrMessageVerb(MessageType type, int verb, const char *msg_format,
va_list msg_args, const char *hdr_format, va_list hdr_args)
{
const char *type_str;
char buf[1024];
const size_t size = sizeof(buf);
Bool newline;
size_t len = 0;
int (*vprintf_func)(char *, int, const char* _X_RESTRICT_KYWD f, va_list args)
_X_ATTRIBUTE_PRINTF(3, 0);
int (*printf_func)(char *, int, const char* _X_RESTRICT_KYWD f, ...)
_X_ATTRIBUTE_PRINTF(3, 4);
type_str = LogMessageTypeVerbString(type, verb);
if (!type_str)
return;
if (inSignalContext) {
vprintf_func = vpnprintf;
printf_func = pnprintf;
} else {
vprintf_func = Xvscnprintf;
printf_func = Xscnprintf;
}
/* if type_str is not "", prepend it and ' ', to message */
if (type_str[0] != '\0')
len += printf_func(&buf[len], size - len, "%s ", type_str);
if (hdr_format && size - len > 1)
len += vprintf_func(&buf[len], size - len, hdr_format, hdr_args);
if (msg_format && size - len > 1)
len += vprintf_func(&buf[len], size - len, msg_format, msg_args);
/* Force '\n' at end of truncated line */
if (size - len == 1)
buf[len - 1] = '\n';
newline = (buf[len - 1] == '\n');
LogSWrite(verb, buf, len, newline);
}
| 0
|
403,478
|
int __init ecryptfs_init_kthread(void)
{
int rc = 0;
mutex_init(&ecryptfs_kthread_ctl.mux);
init_waitqueue_head(&ecryptfs_kthread_ctl.wait);
INIT_LIST_HEAD(&ecryptfs_kthread_ctl.req_list);
ecryptfs_kthread = kthread_run(&ecryptfs_threadfn, NULL,
"ecryptfs-kthread");
if (IS_ERR(ecryptfs_kthread)) {
rc = PTR_ERR(ecryptfs_kthread);
printk(KERN_ERR "%s: Failed to create kernel thread; rc = [%d]"
"\n", __func__, rc);
}
return rc;
}
| 0
|
346,462
|
do_source_ext(
char_u *fname,
int check_other, // check for .vimrc and _vimrc
int is_vimrc, // DOSO_ value
int *ret_sid UNUSED,
exarg_T *eap,
int clearvars UNUSED)
{
source_cookie_T cookie;
char_u *p;
char_u *fname_exp;
char_u *firstline = NULL;
int retval = FAIL;
sctx_T save_current_sctx;
#ifdef FEAT_EVAL
funccal_entry_T funccalp_entry;
int save_debug_break_level = debug_break_level;
int sid;
scriptitem_T *si = NULL;
int save_estack_compiling = estack_compiling;
#endif
#ifdef STARTUPTIME
struct timeval tv_rel;
struct timeval tv_start;
#endif
#ifdef FEAT_PROFILE
proftime_T wait_start;
#endif
int save_sticky_cmdmod_flags = sticky_cmdmod_flags;
int trigger_source_post = FALSE;
ESTACK_CHECK_DECLARATION
CLEAR_FIELD(cookie);
if (fname == NULL)
{
// sourcing lines from a buffer
fname_exp = do_source_buffer_init(&cookie, eap);
if (fname_exp == NULL)
return FAIL;
}
else
{
p = expand_env_save(fname);
if (p == NULL)
return retval;
fname_exp = fix_fname(p);
vim_free(p);
if (fname_exp == NULL)
return retval;
if (mch_isdir(fname_exp))
{
smsg(_("Cannot source a directory: \"%s\""), fname);
goto theend;
}
}
#ifdef FEAT_EVAL
estack_compiling = FALSE;
// See if we loaded this script before.
sid = find_script_by_name(fname_exp);
if (sid > 0 && ret_sid != NULL
&& SCRIPT_ITEM(sid)->sn_state != SN_STATE_NOT_LOADED)
{
// Already loaded and no need to load again, return here.
*ret_sid = sid;
retval = OK;
goto theend;
}
#endif
// Apply SourceCmd autocommands, they should get the file and source it.
if (has_autocmd(EVENT_SOURCECMD, fname_exp, NULL)
&& apply_autocmds(EVENT_SOURCECMD, fname_exp, fname_exp,
FALSE, curbuf))
{
#ifdef FEAT_EVAL
retval = aborting() ? FAIL : OK;
#else
retval = OK;
#endif
if (retval == OK)
// Apply SourcePost autocommands.
apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp,
FALSE, curbuf);
goto theend;
}
// Apply SourcePre autocommands, they may get the file.
apply_autocmds(EVENT_SOURCEPRE, fname_exp, fname_exp, FALSE, curbuf);
if (!cookie.source_from_buf)
{
#ifdef USE_FOPEN_NOINH
cookie.fp = fopen_noinh_readbin((char *)fname_exp);
#else
cookie.fp = mch_fopen((char *)fname_exp, READBIN);
#endif
}
if (cookie.fp == NULL && check_other)
{
// Try again, replacing file name ".vimrc" by "_vimrc" or vice versa,
// and ".exrc" by "_exrc" or vice versa.
p = gettail(fname_exp);
if ((*p == '.' || *p == '_')
&& (STRICMP(p + 1, "vimrc") == 0
|| STRICMP(p + 1, "gvimrc") == 0
|| STRICMP(p + 1, "exrc") == 0))
{
if (*p == '_')
*p = '.';
else
*p = '_';
#ifdef USE_FOPEN_NOINH
cookie.fp = fopen_noinh_readbin((char *)fname_exp);
#else
cookie.fp = mch_fopen((char *)fname_exp, READBIN);
#endif
}
}
if (cookie.fp == NULL && !cookie.source_from_buf)
{
if (p_verbose > 0)
{
verbose_enter();
if (SOURCING_NAME == NULL)
smsg(_("could not source \"%s\""), fname);
else
smsg(_("line %ld: could not source \"%s\""),
SOURCING_LNUM, fname);
verbose_leave();
}
goto theend;
}
// The file exists.
// - In verbose mode, give a message.
// - For a vimrc file, may want to set 'compatible', call vimrc_found().
if (p_verbose > 1)
{
verbose_enter();
if (SOURCING_NAME == NULL)
smsg(_("sourcing \"%s\""), fname);
else
smsg(_("line %ld: sourcing \"%s\""), SOURCING_LNUM, fname);
verbose_leave();
}
if (is_vimrc == DOSO_VIMRC)
vimrc_found(fname_exp, (char_u *)"MYVIMRC");
else if (is_vimrc == DOSO_GVIMRC)
vimrc_found(fname_exp, (char_u *)"MYGVIMRC");
#ifdef USE_CRNL
// If no automatic file format: Set default to CR-NL.
if (*p_ffs == NUL)
cookie.fileformat = EOL_DOS;
else
cookie.fileformat = EOL_UNKNOWN;
#endif
if (fname == NULL)
// When sourcing a range of lines from a buffer, use the buffer line
// number.
cookie.sourcing_lnum = eap->line1 - 1;
else
cookie.sourcing_lnum = 0;
#ifdef FEAT_EVAL
// Check if this script has a breakpoint.
cookie.breakpoint = dbg_find_breakpoint(TRUE, fname_exp, (linenr_T)0);
cookie.fname = fname_exp;
cookie.dbg_tick = debug_tick;
cookie.level = ex_nesting_level;
#endif
// Keep the sourcing name/lnum, for recursive calls.
estack_push(ETYPE_SCRIPT, fname_exp, 0);
ESTACK_CHECK_SETUP
#ifdef STARTUPTIME
if (time_fd != NULL)
time_push(&tv_rel, &tv_start);
#endif
// "legacy" does not apply to commands in the script
sticky_cmdmod_flags = 0;
save_current_sctx = current_sctx;
if (cmdmod.cmod_flags & CMOD_VIM9CMD)
// When the ":vim9cmd" command modifier is used, source the script as a
// Vim9 script.
current_sctx.sc_version = SCRIPT_VERSION_VIM9;
else
current_sctx.sc_version = 1; // default script version
#ifdef FEAT_EVAL
# ifdef FEAT_PROFILE
if (do_profiling == PROF_YES)
prof_child_enter(&wait_start); // entering a child now
# endif
// Don't use local function variables, if called from a function.
// Also starts profiling timer for nested script.
save_funccal(&funccalp_entry);
current_sctx.sc_lnum = 0;
// Check if this script was sourced before to find its SID.
// Always use a new sequence number.
current_sctx.sc_seq = ++last_current_SID_seq;
if (sid > 0)
{
hashtab_T *ht;
int todo;
hashitem_T *hi;
dictitem_T *di;
// loading the same script again
current_sctx.sc_sid = sid;
si = SCRIPT_ITEM(sid);
if (si->sn_state == SN_STATE_NOT_LOADED)
{
// this script was found but not loaded yet
si->sn_state = SN_STATE_NEW;
}
else
{
si->sn_state = SN_STATE_RELOAD;
if (!clearvars)
{
// Script-local variables remain but "const" can be set again.
// In Vim9 script variables will be cleared when "vim9script"
// is encountered without the "noclear" argument.
ht = &SCRIPT_VARS(sid);
todo = (int)ht->ht_used;
for (hi = ht->ht_array; todo > 0; ++hi)
if (!HASHITEM_EMPTY(hi))
{
--todo;
di = HI2DI(hi);
di->di_flags |= DI_FLAGS_RELOAD;
}
// imports can be redefined once
mark_imports_for_reload(sid);
}
else
clear_vim9_scriptlocal_vars(sid);
// reset version, "vim9script" may have been added or removed.
si->sn_version = 1;
}
}
else
{
int error = OK;
// It's new, generate a new SID and initialize the scriptitem.
current_sctx.sc_sid = get_new_scriptitem(&error);
if (error == FAIL)
goto almosttheend;
si = SCRIPT_ITEM(current_sctx.sc_sid);
si->sn_name = fname_exp;
fname_exp = vim_strsave(si->sn_name); // used for autocmd
if (ret_sid != NULL)
*ret_sid = current_sctx.sc_sid;
// Remember the "is_vimrc" flag for when the file is sourced again.
si->sn_is_vimrc = is_vimrc;
}
# ifdef FEAT_PROFILE
if (do_profiling == PROF_YES)
{
int forceit;
// Check if we do profiling for this script.
if (!si->sn_prof_on && has_profiling(TRUE, si->sn_name, &forceit))
{
script_do_profile(si);
si->sn_pr_force = forceit;
}
if (si->sn_prof_on)
{
++si->sn_pr_count;
profile_start(&si->sn_pr_start);
profile_zero(&si->sn_pr_children);
}
}
# endif
#endif
cookie.conv.vc_type = CONV_NONE; // no conversion
// Read the first line so we can check for a UTF-8 BOM.
firstline = getsourceline(0, (void *)&cookie, 0, TRUE);
if (firstline != NULL && STRLEN(firstline) >= 3 && firstline[0] == 0xef
&& firstline[1] == 0xbb && firstline[2] == 0xbf)
{
// Found BOM; setup conversion, skip over BOM and recode the line.
convert_setup(&cookie.conv, (char_u *)"utf-8", p_enc);
p = string_convert(&cookie.conv, firstline + 3, NULL);
if (p == NULL)
p = vim_strsave(firstline + 3);
if (p != NULL)
{
vim_free(firstline);
firstline = p;
}
}
// Call do_cmdline, which will call getsourceline() to get the lines.
do_cmdline(firstline, getsourceline, (void *)&cookie,
DOCMD_VERBOSE|DOCMD_NOWAIT|DOCMD_REPEAT);
retval = OK;
#ifdef FEAT_PROFILE
if (do_profiling == PROF_YES)
{
// Get "si" again, "script_items" may have been reallocated.
si = SCRIPT_ITEM(current_sctx.sc_sid);
if (si->sn_prof_on)
{
profile_end(&si->sn_pr_start);
profile_sub_wait(&wait_start, &si->sn_pr_start);
profile_add(&si->sn_pr_total, &si->sn_pr_start);
profile_self(&si->sn_pr_self, &si->sn_pr_start,
&si->sn_pr_children);
}
}
#endif
if (got_int)
emsg(_(e_interrupted));
ESTACK_CHECK_NOW
estack_pop();
if (p_verbose > 1)
{
verbose_enter();
smsg(_("finished sourcing %s"), fname);
if (SOURCING_NAME != NULL)
smsg(_("continuing in %s"), SOURCING_NAME);
verbose_leave();
}
#ifdef STARTUPTIME
if (time_fd != NULL)
{
vim_snprintf((char *)IObuff, IOSIZE, "sourcing %s", fname);
time_msg((char *)IObuff, &tv_start);
time_pop(&tv_rel);
}
#endif
if (!got_int)
trigger_source_post = TRUE;
#ifdef FEAT_EVAL
// After a "finish" in debug mode, need to break at first command of next
// sourced file.
if (save_debug_break_level > ex_nesting_level
&& debug_break_level == ex_nesting_level)
++debug_break_level;
#endif
#ifdef FEAT_EVAL
almosttheend:
// If "sn_save_cpo" is set that means we encountered "vim9script": restore
// 'cpoptions', unless in the main .vimrc file.
// Get "si" again, "script_items" may have been reallocated.
si = SCRIPT_ITEM(current_sctx.sc_sid);
if (si->sn_save_cpo != NULL && si->sn_is_vimrc == DOSO_NONE)
{
if (STRCMP(p_cpo, CPO_VIM) != 0)
{
char_u *f;
char_u *t;
// 'cpo' was changed in the script. Apply the same change to the
// saved value, if possible.
for (f = (char_u *)CPO_VIM; *f != NUL; ++f)
if (vim_strchr(p_cpo, *f) == NULL
&& (t = vim_strchr(si->sn_save_cpo, *f)) != NULL)
// flag was removed, also remove it from the saved 'cpo'
mch_memmove(t, t + 1, STRLEN(t));
for (f = p_cpo; *f != NUL; ++f)
if (vim_strchr((char_u *)CPO_VIM, *f) == NULL
&& vim_strchr(si->sn_save_cpo, *f) == NULL)
{
// flag was added, also add it to the saved 'cpo'
t = alloc(STRLEN(si->sn_save_cpo) + 2);
if (t != NULL)
{
*t = *f;
STRCPY(t + 1, si->sn_save_cpo);
vim_free(si->sn_save_cpo);
si->sn_save_cpo = t;
}
}
}
set_option_value_give_err((char_u *)"cpo",
0L, si->sn_save_cpo, OPT_NO_REDRAW);
}
VIM_CLEAR(si->sn_save_cpo);
restore_funccal();
# ifdef FEAT_PROFILE
if (do_profiling == PROF_YES)
prof_child_exit(&wait_start); // leaving a child now
# endif
#endif
current_sctx = save_current_sctx;
if (cookie.fp != NULL)
fclose(cookie.fp);
if (cookie.source_from_buf)
ga_clear_strings(&cookie.buflines);
vim_free(cookie.nextline);
vim_free(firstline);
convert_setup(&cookie.conv, NULL, NULL);
if (trigger_source_post)
apply_autocmds(EVENT_SOURCEPOST, fname_exp, fname_exp, FALSE, curbuf);
theend:
vim_free(fname_exp);
sticky_cmdmod_flags = save_sticky_cmdmod_flags;
#ifdef FEAT_EVAL
estack_compiling = save_estack_compiling;
#endif
return retval;
}
| 0
|
343,158
|
int esp6_output_head(struct xfrm_state *x, struct sk_buff *skb, struct esp_info *esp)
{
u8 *tail;
int nfrags;
int esph_offset;
struct page *page;
struct sk_buff *trailer;
int tailen = esp->tailen;
unsigned int allocsz;
if (x->encap) {
int err = esp6_output_encap(x, skb, esp);
if (err < 0)
return err;
}
allocsz = ALIGN(skb->data_len + tailen, L1_CACHE_BYTES);
if (allocsz > ESP_SKB_FRAG_MAXSIZE)
goto cow;
if (!skb_cloned(skb)) {
if (tailen <= skb_tailroom(skb)) {
nfrags = 1;
trailer = skb;
tail = skb_tail_pointer(trailer);
goto skip_cow;
} else if ((skb_shinfo(skb)->nr_frags < MAX_SKB_FRAGS)
&& !skb_has_frag_list(skb)) {
int allocsize;
struct sock *sk = skb->sk;
struct page_frag *pfrag = &x->xfrag;
esp->inplace = false;
allocsize = ALIGN(tailen, L1_CACHE_BYTES);
spin_lock_bh(&x->lock);
if (unlikely(!skb_page_frag_refill(allocsize, pfrag, GFP_ATOMIC))) {
spin_unlock_bh(&x->lock);
goto cow;
}
page = pfrag->page;
get_page(page);
tail = page_address(page) + pfrag->offset;
esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);
nfrags = skb_shinfo(skb)->nr_frags;
__skb_fill_page_desc(skb, nfrags, page, pfrag->offset,
tailen);
skb_shinfo(skb)->nr_frags = ++nfrags;
pfrag->offset = pfrag->offset + allocsize;
spin_unlock_bh(&x->lock);
nfrags++;
skb->len += tailen;
skb->data_len += tailen;
skb->truesize += tailen;
if (sk && sk_fullsock(sk))
refcount_add(tailen, &sk->sk_wmem_alloc);
goto out;
}
}
cow:
esph_offset = (unsigned char *)esp->esph - skb_transport_header(skb);
nfrags = skb_cow_data(skb, tailen, &trailer);
if (nfrags < 0)
goto out;
tail = skb_tail_pointer(trailer);
esp->esph = (struct ip_esp_hdr *)(skb_transport_header(skb) + esph_offset);
skip_cow:
esp_output_fill_trailer(tail, esp->tfclen, esp->plen, esp->proto);
pskb_put(skb, trailer, tailen);
out:
return nfrags;
}
| 0
|
427,244
|
static int funcname (LexState *ls, expdesc *v) {
/* funcname -> NAME {fieldsel} [':' NAME] */
int ismethod = 0;
singlevar(ls, v);
while (ls->t.token == '.')
fieldsel(ls, v);
if (ls->t.token == ':') {
ismethod = 1;
fieldsel(ls, v);
}
return ismethod;
}
| 0
|
230,632
|
void derive_spatial_luma_vector_prediction(base_context* ctx,
de265_image* img,
const slice_segment_header* shdr,
int xC,int yC,int nCS,int xP,int yP,
int nPbW,int nPbH, int X,
int refIdxLX, int partIdx,
uint8_t out_availableFlagLXN[2],
MotionVector out_mvLXN[2])
{
int isScaledFlagLX = 0;
const int A=0;
const int B=1;
out_availableFlagLXN[A] = 0;
out_availableFlagLXN[B] = 0;
// --- A ---
// 1.
int xA[2], yA[2];
xA[0] = xP-1;
yA[0] = yP + nPbH;
xA[1] = xA[0];
yA[1] = yA[0]-1;
// 2.
out_availableFlagLXN[A] = 0;
out_mvLXN[A].x = 0;
out_mvLXN[A].y = 0;
// 3. / 4.
bool availableA[2];
availableA[0] = img->available_pred_blk(xC,yC, nCS, xP,yP, nPbW,nPbH,partIdx, xA[0],yA[0]);
availableA[1] = img->available_pred_blk(xC,yC, nCS, xP,yP, nPbW,nPbH,partIdx, xA[1],yA[1]);
// 5.
if (availableA[0] || availableA[1]) {
isScaledFlagLX = 1;
}
// 6. test A0 and A1 (Ak)
int refIdxA=-1;
// the POC we want to reference in this PB
const de265_image* tmpimg = ctx->get_image(shdr->RefPicList[X][ refIdxLX ]);
if (tmpimg==NULL) { return; }
const int referenced_POC = tmpimg->PicOrderCntVal;
for (int k=0;k<=1;k++) {
if (availableA[k] &&
out_availableFlagLXN[A]==0 && // no A?-predictor so far
img->get_pred_mode(xA[k],yA[k]) != MODE_INTRA) {
int Y=1-X;
const PBMotion& vi = img->get_mv_info(xA[k],yA[k]);
logtrace(LogMotion,"MVP A%d=\n",k);
logmvcand(vi);
const de265_image* imgX = NULL;
if (vi.predFlag[X]) imgX = ctx->get_image(shdr->RefPicList[X][ vi.refIdx[X] ]);
const de265_image* imgY = NULL;
if (vi.predFlag[Y]) imgY = ctx->get_image(shdr->RefPicList[Y][ vi.refIdx[Y] ]);
// check whether the predictor X is available and references the same POC
if (vi.predFlag[X] && imgX && imgX->PicOrderCntVal == referenced_POC) {
logtrace(LogMotion,"take A%d/L%d as A candidate with same POC\n",k,X);
out_availableFlagLXN[A]=1;
out_mvLXN[A] = vi.mv[X];
refIdxA = vi.refIdx[X];
}
// check whether the other predictor (Y) is available and references the same POC
else if (vi.predFlag[Y] && imgY && imgY->PicOrderCntVal == referenced_POC) {
logtrace(LogMotion,"take A%d/L%d as A candidate with same POC\n",k,Y);
out_availableFlagLXN[A]=1;
out_mvLXN[A] = vi.mv[Y];
refIdxA = vi.refIdx[Y];
}
}
}
// 7. If there is no predictor referencing the same POC, we take any other reference as
// long as it is the same type of reference (long-term / short-term)
for (int k=0 ; k<=1 && out_availableFlagLXN[A]==0 ; k++) {
int refPicList=-1;
if (availableA[k] &&
// TODO: we could remove this call by storing the result of the similar computation above
img->get_pred_mode(xA[k],yA[k]) != MODE_INTRA) {
int Y=1-X;
const PBMotion& vi = img->get_mv_info(xA[k],yA[k]);
if (vi.predFlag[X]==1 &&
shdr->LongTermRefPic[X][refIdxLX] == shdr->LongTermRefPic[X][ vi.refIdx[X] ]) {
logtrace(LogMotion,"take A%D/L%d as A candidate with different POCs\n",k,X);
out_availableFlagLXN[A]=1;
out_mvLXN[A] = vi.mv[X];
refIdxA = vi.refIdx[X];
refPicList = X;
}
else if (vi.predFlag[Y]==1 &&
shdr->LongTermRefPic[X][refIdxLX] == shdr->LongTermRefPic[Y][ vi.refIdx[Y] ]) {
logtrace(LogMotion,"take A%d/L%d as A candidate with different POCs\n",k,Y);
out_availableFlagLXN[A]=1;
out_mvLXN[A] = vi.mv[Y];
refIdxA = vi.refIdx[Y];
refPicList = Y;
}
}
if (out_availableFlagLXN[A]==1) {
if (refIdxA<0) {
out_availableFlagLXN[0] = out_availableFlagLXN[1] = false;
return; // error
}
assert(refIdxA>=0);
assert(refPicList>=0);
const de265_image* refPicA = ctx->get_image(shdr->RefPicList[refPicList][refIdxA ]);
const de265_image* refPicX = ctx->get_image(shdr->RefPicList[X ][refIdxLX]);
//int picStateA = shdr->RefPicList_PicState[refPicList][refIdxA ];
//int picStateX = shdr->RefPicList_PicState[X ][refIdxLX];
int isLongTermA = shdr->LongTermRefPic[refPicList][refIdxA ];
int isLongTermX = shdr->LongTermRefPic[X ][refIdxLX];
logtrace(LogMotion,"scale MVP A: A-POC:%d X-POC:%d\n",
refPicA->PicOrderCntVal,refPicX->PicOrderCntVal);
if (!isLongTermA && !isLongTermX)
/*
if (picStateA == UsedForShortTermReference &&
picStateX == UsedForShortTermReference)
*/
{
int distA = img->PicOrderCntVal - refPicA->PicOrderCntVal;
int distX = img->PicOrderCntVal - referenced_POC;
if (!scale_mv(&out_mvLXN[A], out_mvLXN[A], distA, distX)) {
ctx->add_warning(DE265_WARNING_INCORRECT_MOTION_VECTOR_SCALING, false);
img->integrity = INTEGRITY_DECODING_ERRORS;
}
}
}
}
// --- B ---
// 1.
int xB[3], yB[3];
xB[0] = xP+nPbW;
yB[0] = yP-1;
xB[1] = xB[0]-1;
yB[1] = yP-1;
xB[2] = xP-1;
yB[2] = yP-1;
// 2.
out_availableFlagLXN[B] = 0;
out_mvLXN[B].x = 0;
out_mvLXN[B].y = 0;
// 3. test B0,B1,B2 (Bk)
int refIdxB=-1;
bool availableB[3];
for (int k=0;k<3;k++) {
availableB[k] = img->available_pred_blk(xC,yC, nCS, xP,yP, nPbW,nPbH,partIdx, xB[k],yB[k]);
if (availableB[k] && out_availableFlagLXN[B]==0) {
int Y=1-X;
const PBMotion& vi = img->get_mv_info(xB[k],yB[k]);
logtrace(LogMotion,"MVP B%d=\n",k);
logmvcand(vi);
const de265_image* imgX = NULL;
if (vi.predFlag[X]) imgX = ctx->get_image(shdr->RefPicList[X][ vi.refIdx[X] ]);
const de265_image* imgY = NULL;
if (vi.predFlag[Y]) imgY = ctx->get_image(shdr->RefPicList[Y][ vi.refIdx[Y] ]);
if (vi.predFlag[X] && imgX && imgX->PicOrderCntVal == referenced_POC) {
logtrace(LogMotion,"a) take B%d/L%d as B candidate with same POC\n",k,X);
out_availableFlagLXN[B]=1;
out_mvLXN[B] = vi.mv[X];
refIdxB = vi.refIdx[X];
}
else if (vi.predFlag[Y] && imgY && imgY->PicOrderCntVal == referenced_POC) {
logtrace(LogMotion,"b) take B%d/L%d as B candidate with same POC\n",k,Y);
out_availableFlagLXN[B]=1;
out_mvLXN[B] = vi.mv[Y];
refIdxB = vi.refIdx[Y];
}
}
}
// 4.
if (isScaledFlagLX==0 && // no A predictor,
out_availableFlagLXN[B]) // but an unscaled B predictor
{
// use unscaled B predictor as A predictor
logtrace(LogMotion,"copy the same-POC B candidate as additional A candidate\n");
out_availableFlagLXN[A]=1;
out_mvLXN[A] = out_mvLXN[B];
refIdxA = refIdxB;
}
// 5.
// If no A predictor, we output the unscaled B as the A predictor (above)
// and also add a scaled B predictor here.
// If there is (probably) an A predictor, no differing-POC B predictor is generated.
if (isScaledFlagLX==0) {
out_availableFlagLXN[B]=0;
for (int k=0 ; k<=2 && out_availableFlagLXN[B]==0 ; k++) {
int refPicList=-1;
if (availableB[k]) {
int Y=1-X;
const PBMotion& vi = img->get_mv_info(xB[k],yB[k]);
if (vi.predFlag[X]==1 &&
shdr->LongTermRefPic[X][refIdxLX] == shdr->LongTermRefPic[X][ vi.refIdx[X] ]) {
out_availableFlagLXN[B]=1;
out_mvLXN[B] = vi.mv[X];
refIdxB = vi.refIdx[X];
refPicList = X;
}
else if (vi.predFlag[Y]==1 &&
shdr->LongTermRefPic[X][refIdxLX] == shdr->LongTermRefPic[Y][ vi.refIdx[Y] ]) {
out_availableFlagLXN[B]=1;
out_mvLXN[B] = vi.mv[Y];
refIdxB = vi.refIdx[Y];
refPicList = Y;
}
}
if (out_availableFlagLXN[B]==1) {
if (refIdxB<0) {
out_availableFlagLXN[0] = out_availableFlagLXN[1] = false;
return; // error
}
assert(refPicList>=0);
assert(refIdxB>=0);
const de265_image* refPicB=ctx->get_image(shdr->RefPicList[refPicList][refIdxB ]);
const de265_image* refPicX=ctx->get_image(shdr->RefPicList[X ][refIdxLX]);
int isLongTermB = shdr->LongTermRefPic[refPicList][refIdxB ];
int isLongTermX = shdr->LongTermRefPic[X ][refIdxLX];
if (refPicB==NULL || refPicX==NULL) {
img->decctx->add_warning(DE265_WARNING_NONEXISTING_REFERENCE_PICTURE_ACCESSED,false);
img->integrity = INTEGRITY_DECODING_ERRORS;
}
else if (refPicB->PicOrderCntVal != refPicX->PicOrderCntVal &&
!isLongTermB && !isLongTermX) {
int distB = img->PicOrderCntVal - refPicB->PicOrderCntVal;
int distX = img->PicOrderCntVal - referenced_POC;
logtrace(LogMotion,"scale MVP B: B-POC:%d X-POC:%d\n",refPicB->PicOrderCntVal,refPicX->PicOrderCntVal);
if (!scale_mv(&out_mvLXN[B], out_mvLXN[B], distB, distX)) {
ctx->add_warning(DE265_WARNING_INCORRECT_MOTION_VECTOR_SCALING, false);
img->integrity = INTEGRITY_DECODING_ERRORS;
}
}
}
}
}
}
| 0
|
221,684
|
int Socket::getPort() {
return my_port;
}
| 0
|
376,339
|
add_signers (CamelCipherValidity *validity,
const GString *signers)
{
CamelInternetAddress *address;
gint i, count;
g_return_if_fail (validity != NULL);
if (!signers || !signers->str || !*signers->str)
return;
address = camel_internet_address_new ();
g_return_if_fail (address != NULL);
count = camel_address_decode (CAMEL_ADDRESS (address), signers->str);
for (i = 0; i < count; i++) {
const gchar *name = NULL, *email = NULL;
if (!camel_internet_address_get (address, i, &name, &email))
break;
camel_cipher_validity_add_certinfo (validity, CAMEL_CIPHER_VALIDITY_SIGN, name, email);
}
g_object_unref (address);
}
| 0
|
336,571
|
RedChannel *reds_find_channel(RedsState *reds, uint32_t type, uint32_t id)
{
for (auto channel: reds->channels) {
if (channel->type() == type && channel->id() == id) {
return channel.get();
}
}
return NULL;
}
| 0
|
245,709
|
static int add_xtinyproxy_header (struct conn_s *connptr)
{
assert (connptr && connptr->server_fd >= 0);
return write_message (connptr->server_fd,
"X-Tinyproxy: %s\r\n", connptr->client_ip_addr);
}
| 0
|
249,984
|
GF_Err DoWriteMeta(GF_ISOFile *file, GF_MetaBox *meta, GF_BitStream *bs, Bool Emulation, u64 baseOffset, u64 *mdatSize)
{
GF_ItemExtentEntry *entry;
u64 maxExtendOffset, maxExtendSize;
u32 i, j, count;
maxExtendOffset = 0;
maxExtendSize = 0;
if (mdatSize) *mdatSize = 0;
if (!meta->item_locations) return GF_OK;
count = gf_list_count(meta->item_locations->location_entries);
for (i=0; i<count; i++) {
u64 it_size;
GF_ItemLocationEntry *iloc = (GF_ItemLocationEntry *)gf_list_get(meta->item_locations->location_entries, i);
/*get item info*/
GF_ItemInfoEntryBox *iinf = NULL;
j=0;
while ((iinf = (GF_ItemInfoEntryBox *)gf_list_enum(meta->item_infos->item_infos, &j))) {
if (iinf->item_ID==iloc->item_ID) break;
iinf = NULL;
}
if (!iloc->base_offset && (gf_list_count(iloc->extent_entries)==1)) {
entry = (GF_ItemExtentEntry *)gf_list_get(iloc->extent_entries, 0);
if (!entry->extent_length && !entry->original_extent_offset && !entry->extent_index) {
entry->extent_offset = 0;
continue;
}
}
it_size = 0;
/*for self contained only*/
if (!iloc->data_reference_index) {
if (iloc->construction_method != 2) {
iloc->base_offset = baseOffset;
}
/*new resource*/
if (iinf && (iinf->full_path || (iinf->tk_id && iinf->sample_num))) {
FILE *src=NULL;
if (!iinf->data_len && iinf->full_path) {
src = gf_fopen(iinf->full_path, "rb");
if (!src) continue;
it_size = gf_fsize(src);
} else {
it_size = iinf->data_len;
}
if (maxExtendSize<it_size) maxExtendSize = it_size;
if (!gf_list_count(iloc->extent_entries)) {
GF_SAFEALLOC(entry, GF_ItemExtentEntry);
if (!entry) return GF_OUT_OF_MEM;
gf_list_add(iloc->extent_entries, entry);
}
entry = (GF_ItemExtentEntry *)gf_list_get(iloc->extent_entries, 0);
entry->extent_offset = 0;
entry->extent_length = it_size;
//shared data, do not count it
if (iinf->tk_id && iinf->sample_num) {
it_size = 0;
maxExtendOffset = 0xFFFFFFFFFFUL;
if (Emulation) {
meta->use_item_sample_sharing = GF_TRUE;
}
}
/*OK write to mdat*/
if (!Emulation) {
if (iinf->tk_id && iinf->sample_num) {
}
else if (src) {
char cache_data[4096];
u64 remain = entry->extent_length;
while (remain) {
u32 size_cache = (remain>4096) ? 4096 : (u32) remain;
size_t read = gf_fread(cache_data, size_cache, src);
if (read ==(size_t) -1) break;
gf_bs_write_data(bs, cache_data, (u32) read);
remain -= (u32) read;
}
} else {
gf_bs_write_data(bs, iinf->full_path, iinf->data_len);
}
}
if (src) gf_fclose(src);
}
else if (gf_list_count(iloc->extent_entries)) {
j=0;
while ((entry = (GF_ItemExtentEntry *)gf_list_enum(iloc->extent_entries, &j))) {
if (entry->extent_index) continue;
if (j && (maxExtendOffset<it_size) ) maxExtendOffset = it_size;
/*compute new offset*/
entry->extent_offset = baseOffset + it_size;
it_size += entry->extent_length;
if (maxExtendSize<entry->extent_length) maxExtendSize = entry->extent_length;
/*Reading from the input file*/
if (!Emulation) {
char cache_data[4096];
u64 remain = entry->extent_length;
gf_bs_seek(file->movieFileMap->bs, entry->original_extent_offset + iloc->original_base_offset);
while (remain) {
u32 size_cache = (remain>4096) ? 4096 : (u32) remain;
gf_bs_read_data(file->movieFileMap->bs, cache_data, size_cache);
/*Writing to the output file*/
gf_bs_write_data(bs, cache_data, size_cache);
remain -= size_cache;
}
}
}
}
baseOffset += it_size;
if (mdatSize)
*mdatSize += it_size;
} else {
/*we MUST have at least one extent for the dref data*/
if (!gf_list_count(iloc->extent_entries)) {
GF_SAFEALLOC(entry, GF_ItemExtentEntry);
if (!entry) return GF_OUT_OF_MEM;
gf_list_add(iloc->extent_entries, entry);
}
entry = (GF_ItemExtentEntry *)gf_list_get(iloc->extent_entries, 0);
entry->extent_offset = 0;
/*0 means full length of referenced file*/
entry->extent_length = 0;
}
}
/*update offset & size length fields*/
if (baseOffset>0xFFFFFFFF) meta->item_locations->base_offset_size = 8;
else if (baseOffset) meta->item_locations->base_offset_size = 4;
if (maxExtendSize>0xFFFFFFFF) meta->item_locations->length_size = 8;
else if (maxExtendSize) meta->item_locations->length_size = 4;
if (maxExtendOffset>0xFFFFFFFF) meta->item_locations->offset_size = 8;
else if (maxExtendOffset) meta->item_locations->offset_size = 4;
return GF_OK;
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.