functionSource stringlengths 20 97.4k | CWE-119 bool 2
classes | CWE-120 bool 2
classes | CWE-469 bool 2
classes | CWE-476 bool 2
classes | CWE-other bool 2
classes | combine int64 0 1 |
|---|---|---|---|---|---|---|
sfmtv(cchar *fmt, va_list arg)
{
mprAssert(fmt);
return mprAsprintfv(fmt, arg);
} | false | false | false | false | false | 0 |
testing_util_engine_free (PeasEngine *engine_)
{
/* In case a test needs to free the engine */
if (engine != NULL)
{
g_object_unref (engine_);
/* Make sure that at the end of every test the engine is freed */
g_assert (engine == NULL);
}
/* Pop the log hooks so the test cases don't have to */
testing_util_pop_log_hooks ();
} | false | false | false | false | false | 0 |
js_alloc_sftbl_entry(void *priv, const void *key)
{
size_t nbytes = offsetof(ScriptFilenameEntry, filename) +
strlen((const char *) key) + 1;
return (JSHashEntry *) js_malloc(JS_MAX(nbytes, sizeof(JSHashEntry)));
} | false | false | false | false | false | 0 |
alberta_calloc(size_t size, size_t elsize, const char *fct,
const char *file, int line)
{
FUNCNAME("alberta_calloc");
void *mem;
if (size <= 0 || elsize <= 0)
{
ERROR("one of size = %d or data size = %d is zero\n", size, elsize);
ALLOC_ERR(fct, file, line);
}
if (!(mem = CALLOC(size,elsize)))
{
ERROR("can not allocate %s\n", size_as_string(size*elsize));
ALLOC_ERR(fct, file, line);
}
size_used += (double)size * (double)elsize;
return(mem);
} | false | false | false | false | true | 1 |
optimize_code6(FILE *lf)
{
unsigned i, j;
int changed = 0;
code_t *c0, *c1, *c2;
char *s;
for(i = 0; i < code_size; i++) {
c0 = code + i;
c1 = code + (j = next_code(i));
c2 = code + (j = next_code(j));
if(
c0->type == t_int && c0->value.u == 0 &&
c1->type == t_int && (c1->value.u == t_none || c1->value.u == t_end) &&
c2->type == t_prim &&
c2->value.u == p_settype
) {
c0->type = c1->value.u;
c0->value.u = 0;
asprintf(&s, "%s # %s", c0->type ? ".end" : ".undef", c0->name);
free(c0->name);
c0->name = s;
if(verbose && lf) fprintf(lf, "# constant expression: %s (at %d)\n", c0->name, i);
if(verbose && lf) fprintf(lf, "# deleting code: %d - %d\n", i + 1, j);
c1->type = c2->type = t_skip;
changed = 1;
}
}
return changed;
} | false | false | false | false | false | 0 |
ShiftBreakpoint(cb::shared_ptr<DebuggerBreakpoint> bp, int nroflines)
{
// notify driver if it is active
if (m_pDriver)
{
m_pDriver->RemoveBreakpoint(bp);
bp->line += nroflines;
m_pDriver->AddBreakpoint(bp);
}
else
bp->line += nroflines;
} | false | false | false | false | false | 0 |
gee_set_base_init (GeeSetIface * iface) {
static gboolean initialized = FALSE;
if (!initialized) {
initialized = TRUE;
/**
* The read-only view of this set.
*/
g_object_interface_install_property (iface, g_param_spec_object ("read-only-view", "read-only-view", "read-only-view", GEE_TYPE_SET, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_READABLE));
}
} | false | false | false | false | false | 0 |
build_dentry_path(struct dentry *dentry,
const char **ppath, int *ppathlen, u64 *pino,
int *pfreepath)
{
char *path;
struct inode *dir;
rcu_read_lock();
dir = d_inode_rcu(dentry->d_parent);
if (dir && ceph_snap(dir) == CEPH_NOSNAP) {
*pino = ceph_ino(dir);
rcu_read_unlock();
*ppath = dentry->d_name.name;
*ppathlen = dentry->d_name.len;
return 0;
}
rcu_read_unlock();
path = ceph_mdsc_build_path(dentry, ppathlen, pino, 1);
if (IS_ERR(path))
return PTR_ERR(path);
*ppath = path;
*pfreepath = 1;
return 0;
} | false | false | false | false | false | 0 |
FileEditComment(char * TempFileName, char * Comment, int CommentSize)
{
FILE * file;
int a;
char QuotedPath[PATH_MAX+10];
file = fopen(TempFileName, "w");
if (file == NULL){
fprintf(stderr, "Can't create file '%s'\n",TempFileName);
ErrFatal("could not create temporary file");
}
fwrite(Comment, CommentSize, 1, file);
fclose(file);
fflush(stdout); // So logs are contiguous.
{
char * Editor;
Editor = getenv("EDITOR");
if (Editor == NULL){
#ifdef _WIN32
Editor = "notepad";
#else
Editor = "vi";
#endif
}
if (strlen(Editor) > PATH_MAX) ErrFatal("env too long");
sprintf(QuotedPath, "%s \"%s\"",Editor, TempFileName);
a = system(QuotedPath);
}
if (a != 0){
perror("Editor failed to launch");
exit(-1);
}
file = fopen(TempFileName, "r");
if (file == NULL){
ErrFatal("could not open temp file for read");
}
// Read the file back in.
CommentSize = fread(Comment, 1, 999, file);
fclose(file);
unlink(TempFileName);
return CommentSize;
} | true | true | false | false | true | 1 |
alloc_root(struct super_block *sb)
{
int err;
struct inode *inode;
struct dentry *root;
err = -ENOMEM;
inode = au_iget_locked(sb, AUFS_ROOT_INO);
err = PTR_ERR(inode);
if (IS_ERR(inode))
goto out;
inode->i_op = aufs_iop + AuIop_DIR; /* with getattr by default */
inode->i_fop = &aufs_dir_fop;
inode->i_mode = S_IFDIR;
set_nlink(inode, 2);
unlock_new_inode(inode);
root = d_make_root(inode);
if (unlikely(!root))
goto out;
err = PTR_ERR(root);
if (IS_ERR(root))
goto out;
err = au_di_init(root);
if (!err) {
sb->s_root = root;
return 0; /* success */
}
dput(root);
out:
return err;
} | false | false | false | false | false | 0 |
compiler_listcomp(struct compiler *c, expr_ty e)
{
assert(e->kind == ListComp_kind);
ADDOP_I(c, BUILD_LIST, 0);
return compiler_listcomp_generator(c, e->v.ListComp.generators, 0,
e->v.ListComp.elt);
} | false | false | false | false | false | 0 |
gtk_combo_box_get_active_text( GtkComboBox *psComboBox ) {
GtkTreeIter sIter;
gchar *pnText = NULL;
GtkTreeModel *psModel = gtk_combo_box_get_model( psComboBox );
if ( gtk_combo_box_get_active_iter( psComboBox, &sIter ) ) {
gtk_tree_model_get( psModel, &sIter, 0, &pnText, -1 );
}
return pnText;
} | false | false | false | false | false | 0 |
draw_chars(struct view *view, enum line_type type, const char *string,
int max_len, bool use_tilde)
{
static char out_buffer[BUFSIZ * 2];
int len = 0;
int col = 0;
int trimmed = FALSE;
size_t skip = view->yoffset > view->col ? view->yoffset - view->col : 0;
if (max_len <= 0)
return 0;
len = utf8_length(&string, skip, &col, max_len, &trimmed, use_tilde, opt_tab_size);
set_view_attr(view, type);
if (len > 0) {
if (opt_iconv_out != ICONV_NONE) {
ICONV_CONST char *inbuf = (ICONV_CONST char *) string;
size_t inlen = len + 1;
char *outbuf = out_buffer;
size_t outlen = sizeof(out_buffer);
size_t ret;
ret = iconv(opt_iconv_out, &inbuf, &inlen, &outbuf, &outlen);
if (ret != (size_t) -1) {
string = out_buffer;
len = sizeof(out_buffer) - outlen;
}
}
waddnstr(view->win, string, len);
}
if (trimmed && use_tilde) {
set_view_attr(view, LINE_DELIMITER);
waddch(view->win, '~');
col++;
}
return col;
} | false | false | false | false | false | 0 |
cfile_init(char *exe_dir, char *cdrom_dir)
{
int i;
// initialize encryption
encrypt_init();
if ( !cfile_inited ) {
char buf[CFILE_ROOT_DIRECTORY_LEN];
cfile_inited = 1;
memset(buf, 0, CFILE_ROOT_DIRECTORY_LEN);
strncpy(buf, exe_dir, CFILE_ROOT_DIRECTORY_LEN - 1);
i = strlen(buf);
// are we in a root directory?
if(cfile_in_root_dir(buf)){
MessageBox((HWND)NULL, "FreeSpace2/Fred2 cannot be run from a drive root directory!", "Error", MB_OK);
return 1;
}
while (i--) {
if (buf[i] == DIR_SEPARATOR_CHAR){
break;
}
}
if (i >= 2) {
buf[i] = 0;
cfile_chdir(buf);
} else {
MessageBox((HWND)NULL, "Error trying to determine executable root directory!", "Error", MB_OK);
return 1;
}
// set root directory
strncpy(Cfile_root_dir, buf, CFILE_ROOT_DIRECTORY_LEN-1);
#ifdef SCP_UNIX
snprintf(Cfile_user_dir, CFILE_ROOT_DIRECTORY_LEN-1, "%s/%s/", detect_home(), Osreg_user_dir);
#endif
for ( i = 0; i < MAX_CFILE_BLOCKS; i++ ) {
Cfile_block_list[i].type = CFILE_BLOCK_UNUSED;
}
// 32 bit CRC table init
cf_chksum_long_init();
Cfile_cdrom_dir = cdrom_dir;
cf_build_secondary_filelist(Cfile_cdrom_dir);
atexit( cfile_close );
}
return 0;
} | false | false | false | false | false | 0 |
_gdk_pixbuf_load_module (GdkPixbufModule *image_module,
GError **error)
{
gboolean ret;
gboolean locked = FALSE;
/* be extra careful, maybe the module initializes
* the thread system
*/
if (g_threads_got_initialized) {
G_LOCK (init_lock);
locked = TRUE;
}
ret = gdk_pixbuf_load_module_unlocked (image_module, error);
if (locked)
G_UNLOCK (init_lock);
return ret;
} | false | false | false | false | false | 0 |
reader_process ( void *data ) /* executed as a child process */
{
int status;
FILE *fp;
Pie_Scanner * scanner;
sigset_t ignore_set;
struct SIGACTION act;
scanner = (Pie_Scanner *)data;
if (sanei_thread_is_forked ()) {
close ( scanner->pipe );
sigfillset (&ignore_set);
sigdelset (&ignore_set, SIGTERM);
#if defined (__APPLE__) && defined (__MACH__)
sigdelset (&ignore_set, SIGUSR2);
#endif
sigprocmask (SIG_SETMASK, &ignore_set, 0);
memset (&act, 0, sizeof (act));
sigaction (SIGTERM, &act, 0);
}
DBG (DBG_sane_proc, "reader_process started\n");
memset (&act, 0, sizeof (act)); /* define SIGTERM-handler */
act.sa_handler = reader_process_sigterm_handler;
sigaction (SIGTERM, &act, 0);
fp = fdopen (scanner->reader_fds, "w");
if (!fp)
{
return SANE_STATUS_IO_ERROR;
}
DBG (DBG_sane_info, "reader_process: starting to READ data\n");
if (scanner->device->inquiry_color_format & INQ_COLOR_FORMAT_LINE)
status = pie_reader_process (scanner, fp);
else if (scanner->device->inquiry_color_format & INQ_COLOR_FORMAT_INDEX)
status = pie_reader_process_indexed (scanner, fp);
else
status = SANE_STATUS_UNSUPPORTED;
fclose (fp);
DBG (DBG_sane_info, "reader_process: finished reading data\n");
return status;
} | false | false | false | false | false | 0 |
subj_hash_table_clear(SUBJECT **subj_ht) {
SUBJECT *loop, *next;
long i;
for (i = 0 ; i < HASH_SIZE ; i++) {
for (loop = subj_ht[i] ; loop ; loop = next) {
next = loop->hash_next;
XtFree(loop->subject);
XtFree((char *)loop);
}
subj_ht[i] = NULL;
}
} | false | false | false | false | false | 0 |
applicable_action(int action, const State* s) {
assert(s);
assert(action >=0 && action < gnum_op_conn);
assert(gop_conn[action].num_E == 1);
int ef = gop_conn[action].E[0];
// Only check if all known preconditions present in the state
for (int j=0;j<gef_conn[ef].num_PC;j++) {
int p = gef_conn[ef].PC[j];
if (!is_in_state(p, s)) {
return false;
}
}
return true;
} | false | false | false | false | false | 0 |
Pk11Install_Pair_Print(Pk11Install_Pair* _this, int pad)
{
while (_this) {
/*PAD(pad); printf("**Pair\n");
PAD(pad); printf("***Key====\n");*/
PAD(pad); printf("%s {\n", _this->key);
/*PAD(pad); printf("====\n");*/
/*PAD(pad); printf("***ValueList\n");*/
Pk11Install_ValueList_Print(_this->list,pad+PADINC);
PAD(pad); printf("}\n");
}
} | false | false | false | false | false | 0 |
FetchParent()
{
int id = m_Community->GetParentId();
if(id)
{
mdo::Community* parent = new mdo::Community;
m_Community->SetParentCommunity(parent);
parent->SetId(m_Community->GetParentId());
mws::Community remote;
remote.SetWebAPI(mws::WebAPI::Instance());
remote.SetObject(parent);
return remote.Fetch();
}
return true;
} | false | false | false | false | false | 0 |
ToUpper(std::string s)
{
std::string u;
for (std::string::size_type i = 0; i < s.length(); i++)
{
u.append(1, static_cast<char>(toupper(s[i])));
}
return u;
} | false | false | false | false | false | 0 |
httpCreateStage(Http *http, cchar *name, int flags, MprModule *module)
{
HttpStage *stage;
mprAssert(http);
mprAssert(name && *name);
if ((stage = httpLookupStage(http, name)) != 0) {
if (!(stage->flags & HTTP_STAGE_UNLOADED)) {
mprError("Stage %s already exists", name);
return 0;
}
} else if ((stage = mprAllocObj(HttpStage, manageStage)) == 0) {
return 0;
}
if ((flags & HTTP_METHOD_MASK) == 0) {
flags |= HTTP_STAGE_METHODS;
}
stage->flags = flags;
stage->name = sclone(name);
stage->open = defaultOpen;
stage->close = defaultClose;
stage->incomingData = incomingData;
stage->incomingService = incomingService;
stage->outgoingData = outgoingData;
stage->outgoingService = httpDefaultOutgoingServiceStage;
stage->module = module;
httpAddStage(http, stage);
return stage;
} | false | false | false | false | false | 0 |
GetSliceSize(void)
{
int limit;
int n;
limit = (pcsound_sample_rate * MAX_SOUND_SLICE_TIME) / 1000;
// Try all powers of two, not exceeding the limit.
for (n=0;; ++n)
{
// 2^n <= limit < 2^n+1 ?
if ((1 << (n + 1)) > limit)
{
return (1 << n);
}
}
// Should never happen?
return 1024;
} | false | false | false | false | false | 0 |
inlineScan(InlineScanState *iss)
{
aggr = aggr->inlineScan(iss);
if (body)
body = body->inlineScan(iss);
return this;
} | false | false | false | false | false | 0 |
LUKS_PBKDF2_performance_check(const char *hashSpec,
uint64_t *PBKDF2_per_sec,
struct crypt_device *ctx)
{
if (!*PBKDF2_per_sec) {
if (PBKDF2_performance_check(hashSpec, PBKDF2_per_sec) < 0) {
log_err(ctx, _("Not compatible PBKDF2 options (using hash algorithm %s).\n"), hashSpec);
return -EINVAL;
}
log_dbg("PBKDF2: %" PRIu64 " iterations per second using hash %s.", *PBKDF2_per_sec, hashSpec);
}
return 0;
} | false | false | false | false | false | 0 |
__log_inmem_lsnoff(dblp, lsnp, offsetp)
DB_LOG *dblp;
DB_LSN *lsnp;
size_t *offsetp;
{
LOG *lp;
struct __db_filestart *filestart;
lp = (LOG *)dblp->reginfo.primary;
SH_TAILQ_FOREACH(filestart, &lp->logfiles, links, __db_filestart)
if (filestart->file == lsnp->file) {
*offsetp = (u_int32_t)
(filestart->b_off + lsnp->offset) % lp->buffer_size;
return (0);
}
return (DB_NOTFOUND);
} | false | false | false | false | false | 0 |
gigaset_m10x_input(struct inbuf_t *inbuf)
{
struct cardstate *cs = inbuf->cs;
unsigned numbytes, procbytes;
gig_dbg(DEBUG_INTR, "buffer state: %u -> %u", inbuf->head, inbuf->tail);
while (inbuf->head != inbuf->tail) {
/* check for DLE escape */
handle_dle(inbuf);
/* process a contiguous block of bytes */
numbytes = (inbuf->head > inbuf->tail ?
RBUFSIZE : inbuf->tail) - inbuf->head;
gig_dbg(DEBUG_INTR, "processing %u bytes", numbytes);
/*
* numbytes may be 0 if handle_dle() ate the last byte.
* This does no harm, *_loop() will just return 0 immediately.
*/
if (cs->mstate == MS_LOCKED)
procbytes = lock_loop(numbytes, inbuf);
else if (inbuf->inputstate & INS_command)
procbytes = cmd_loop(numbytes, inbuf);
else if (cs->bcs->proto2 == L2_HDLC)
procbytes = hdlc_loop(numbytes, inbuf);
else
procbytes = iraw_loop(numbytes, inbuf);
inbuf->head += procbytes;
/* check for buffer wraparound */
if (inbuf->head >= RBUFSIZE)
inbuf->head = 0;
gig_dbg(DEBUG_INTR, "head set to %u", inbuf->head);
}
} | false | false | false | false | false | 0 |
decode(Char *to, const char *s,
size_t slen, const char **rest)
{
size_t n = decoder_->decode(to, s, slen, rest);
for (size_t i = 0; i < n; i++)
to[i] = (*map_)[to[i]];
return n;
} | false | false | false | false | false | 0 |
transform (guint32 * src, guint32 * dest, gint video_area,
gint edge_a, gint edge_b)
{
guint32 in, red, green, blue;
gint x;
for (x = 0; x < video_area; x++) {
in = *src++;
red = (in >> 16) & 0xff;
green = (in >> 8) & 0xff;
blue = (in) & 0xff;
red = abs_int (cos_from_table ((red + edge_a) + ((red * edge_b) / 2)));
green = abs_int (cos_from_table (
(green + edge_a) + ((green * edge_b) / 2)));
blue = abs_int (cos_from_table ((blue + edge_a) + ((blue * edge_b) / 2)));
red = gate_int (red, 0, 255);
green = gate_int (green, 0, 255);
blue = gate_int (blue, 0, 255);
*dest++ = (red << 16) | (green << 8) | blue;
}
} | false | false | false | false | false | 0 |
radeon_miptree_create(radeonContextPtr rmesa,
GLenum target, mesa_format mesaFormat, GLuint baseLevel, GLuint numLevels,
GLuint width0, GLuint height0, GLuint depth0, GLuint tilebits)
{
radeon_mipmap_tree *mt = CALLOC_STRUCT(_radeon_mipmap_tree);
radeon_print(RADEON_TEXTURE, RADEON_NORMAL,
"%s(%p) new tree is %p.\n",
__func__, rmesa, mt);
mt->mesaFormat = mesaFormat;
mt->refcount = 1;
mt->target = target;
mt->faces = _mesa_num_tex_faces(target);
mt->baseLevel = baseLevel;
mt->numLevels = numLevels;
mt->width0 = width0;
mt->height0 = height0;
mt->depth0 = depth0;
mt->tilebits = tilebits;
calculate_miptree_layout(rmesa, mt);
mt->bo = radeon_bo_open(rmesa->radeonScreen->bom,
0, mt->totalsize, 1024,
RADEON_GEM_DOMAIN_VRAM,
0);
return mt;
} | false | false | false | false | false | 0 |
init_perdim(struct perdim **pdp, int dim)
{
/* allocate zero so uninitialized pointers are NULL.
*/
*pdp = (struct perdim *)DXAllocateZero(sizeof(struct perdim));
if (! *pdp)
return ERROR;
if (((*pdp)->binsplus1 = (int *)DXAllocate(dim * sizeof(int))) == NULL)
goto error;
if (((*pdp)->binsize = (float *)DXAllocate(dim * sizeof(float))) == NULL)
goto error;
if (((*pdp)->thisbin = (int *)DXAllocate(dim * sizeof(int))) == NULL)
goto error;
if (((*pdp)->dminlist = (float *)DXAllocate(dim * sizeof(float))) == NULL)
goto error;
if (((*pdp)->dmaxlist = (float *)DXAllocate(dim * sizeof(float))) == NULL)
goto error;
if (((*pdp)->slicecnt = (int **)DXAllocateZero(dim * sizeof(int *))) == NULL)
goto error;
if (((*pdp)->deltas = (float *)DXAllocate(dim * dim * sizeof(float))) == NULL)
goto error;
return OK;
error:
free_perdim(*pdp, dim);
return ERROR;
} | false | false | false | false | false | 0 |
wsm_channel_switch_indication(struct cw1200_common *priv,
struct wsm_buf *buf)
{
WARN_ON(WSM_GET32(buf));
priv->channel_switch_in_progress = 0;
wake_up(&priv->channel_switch_done);
wsm_unlock_tx(priv);
return 0;
underflow:
return -EINVAL;
} | false | false | false | false | false | 0 |
Perl_op_scope(pTHX_ OP *o)
{
dVAR;
if (o) {
if (o->op_flags & OPf_PARENS || PERLDB_NOOPT || TAINTING_get) {
o = op_prepend_elem(OP_LINESEQ, newOP(OP_ENTER, 0), o);
o->op_type = OP_LEAVE;
o->op_ppaddr = PL_ppaddr[OP_LEAVE];
}
else if (o->op_type == OP_LINESEQ) {
OP *kid;
o->op_type = OP_SCOPE;
o->op_ppaddr = PL_ppaddr[OP_SCOPE];
kid = ((LISTOP*)o)->op_first;
if (kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE) {
op_null(kid);
/* The following deals with things like 'do {1 for 1}' */
kid = kid->op_sibling;
if (kid &&
(kid->op_type == OP_NEXTSTATE || kid->op_type == OP_DBSTATE))
op_null(kid);
}
}
else
o = newLISTOP(OP_SCOPE, 0, o, NULL);
}
return o;
} | false | false | false | false | false | 0 |
check_surface_consistency(EncaSurface surface)
{
return count_bits((unsigned long int)surface & ENCA_SURFACE_MASK_EOL) <= 1
&& count_bits((unsigned long int)surface & ENCA_SURFACE_MASK_PERM) <= 1
&& (surface & ENCA_SURFACE_REMOVE) == 0
&& (surface & ENCA_SURFACE_UNKNOWN) == 0;
} | false | false | false | false | false | 0 |
ebitset_resize (bitset src, bitset_bindex n_bits)
{
bitset_windex oldsize;
bitset_windex newsize;
if (n_bits == BITSET_NBITS_ (src))
return n_bits;
oldsize = EBITSET_SIZE (src);
newsize = EBITSET_N_ELTS (n_bits);
if (oldsize < newsize)
{
bitset_windex size;
/* The bitset needs to grow. If we already have enough memory
allocated, then just zero what we need. */
if (newsize > EBITSET_ASIZE (src))
{
/* We need to allocate more memory. When oldsize is
non-zero this means that we are changing the size, so
grow the bitset 25% larger than requested to reduce
number of reallocations. */
if (oldsize == 0)
size = newsize;
else
size = newsize + newsize / 4;
EBITSET_ELTS (src)
= realloc (EBITSET_ELTS (src), size * sizeof (ebitset_elt *));
EBITSET_ASIZE (src) = size;
}
memset (EBITSET_ELTS (src) + oldsize, 0,
(newsize - oldsize) * sizeof (ebitset_elt *));
}
else
{
/* The bitset needs to shrink. There's no point deallocating
the memory unless it is shrinking by a reasonable amount. */
if ((oldsize - newsize) >= oldsize / 2)
{
EBITSET_ELTS (src)
= realloc (EBITSET_ELTS (src), newsize * sizeof (ebitset_elt *));
EBITSET_ASIZE (src) = newsize;
}
/* Need to prune any excess bits. FIXME. */
}
BITSET_NBITS_ (src) = n_bits;
return n_bits;
} | false | true | false | false | false | 1 |
r600_wait_for_power_level_unequal(struct radeon_device *rdev,
enum r600_power_level index)
{
int i;
for (i = 0; i < rdev->usec_timeout; i++) {
if (r600_power_level_get_target_index(rdev) != index)
break;
udelay(1);
}
for (i = 0; i < rdev->usec_timeout; i++) {
if (r600_power_level_get_current_index(rdev) != index)
break;
udelay(1);
}
} | false | false | false | false | false | 0 |
messageAnimatedImage(gchar* format)
{
if(strcmp(format,"pov")==0) return messagePovray();
gchar* t = g_strdup_printf(
_(" You can create an animated file using convert software :\n"
" convert -delay 10 -loop 1000 gab*.%s imageAnim.gif (for a gif animated file)\n"
" or\n"
" convert -delay 10 -loop 1000 gab*.%s imageAnim.mng (for a png animated file)\n\n"
"convert is a free software. You can download this(for any system) from http://www.imagemagick.org\n"
"(in Linux convert is probably installed)\n\n"),
format, format
);
return t;
} | false | false | false | false | false | 0 |
replace_all(string& str,const string&old_value,const string& new_value)
{
string::size_type pos;
if (str.length()<1)
return str;
for(pos=0; pos!=string::npos; pos+=new_value.length())
{
if( (pos=str.find(old_value,pos))!=string::npos )
{
str.replace(pos,old_value.length(),new_value);
}
else
break;
}
return str;
} | false | false | false | false | false | 0 |
gst_asf_mux_audio_set_caps (GstPad * pad, GstCaps * caps)
{
GstAsfMux *asfmux;
GstAsfAudioPad *audiopad;
GstStructure *structure;
const gchar *caps_name;
gint channels, rate;
gchar *aux;
const GValue *codec_data;
asfmux = GST_ASF_MUX (gst_pad_get_parent (pad));
audiopad = (GstAsfAudioPad *) gst_pad_get_element_private (pad);
g_assert (audiopad);
aux = gst_caps_to_string (caps);
GST_DEBUG_OBJECT (asfmux, "%s:%s, caps=%s", GST_DEBUG_PAD_NAME (pad), aux);
g_free (aux);
structure = gst_caps_get_structure (caps, 0);
caps_name = gst_structure_get_name (structure);
if (!gst_structure_get_int (structure, "channels", &channels) ||
!gst_structure_get_int (structure, "rate", &rate))
goto refuse_caps;
audiopad->audioinfo.channels = (guint16) channels;
audiopad->audioinfo.rate = (guint32) rate;
/* taken from avimux
* codec initialization data, if any
*/
codec_data = gst_structure_get_value (structure, "codec_data");
if (codec_data) {
audiopad->pad.codec_data = gst_value_get_buffer (codec_data);
gst_buffer_ref (audiopad->pad.codec_data);
}
if (strcmp (caps_name, "audio/x-wma") == 0) {
gint version;
gint block_align = 0;
gint bitrate = 0;
if (!gst_structure_get_int (structure, "wmaversion", &version)) {
goto refuse_caps;
}
if (gst_structure_get_int (structure, "block_align", &block_align)) {
audiopad->audioinfo.blockalign = (guint16) block_align;
}
if (gst_structure_get_int (structure, "bitrate", &bitrate)) {
audiopad->pad.bitrate = (guint32) bitrate;
audiopad->audioinfo.av_bps = bitrate / 8;
}
if (version == 1) {
audiopad->audioinfo.format = GST_RIFF_WAVE_FORMAT_WMAV1;
} else if (version == 2) {
audiopad->audioinfo.format = GST_RIFF_WAVE_FORMAT_WMAV2;
} else if (version == 3) {
audiopad->audioinfo.format = GST_RIFF_WAVE_FORMAT_WMAV3;
} else {
goto refuse_caps;
}
} else if (strcmp (caps_name, "audio/mpeg") == 0) {
gint version;
gint layer;
if (!gst_structure_get_int (structure, "mpegversion", &version) ||
!gst_structure_get_int (structure, "layer", &layer)) {
goto refuse_caps;
}
if (version != 1 || layer != 3) {
goto refuse_caps;
}
audiopad->audioinfo.format = GST_RIFF_WAVE_FORMAT_MPEGL3;
} else {
goto refuse_caps;
}
gst_object_unref (asfmux);
return TRUE;
refuse_caps:
GST_WARNING_OBJECT (asfmux, "pad %s refused caps %" GST_PTR_FORMAT,
GST_PAD_NAME (pad), caps);
gst_object_unref (asfmux);
return FALSE;
} | false | false | false | false | false | 0 |
move_to_close_lru(struct nfs4_ol_stateid *s, struct net *net)
{
struct nfs4_ol_stateid *last;
struct nfs4_openowner *oo = openowner(s->st_stateowner);
struct nfsd_net *nn = net_generic(s->st_stid.sc_client->net,
nfsd_net_id);
dprintk("NFSD: move_to_close_lru nfs4_openowner %p\n", oo);
/*
* We know that we hold one reference via nfsd4_close, and another
* "persistent" reference for the client. If the refcount is higher
* than 2, then there are still calls in progress that are using this
* stateid. We can't put the sc_file reference until they are finished.
* Wait for the refcount to drop to 2. Since it has been unhashed,
* there should be no danger of the refcount going back up again at
* this point.
*/
wait_event(close_wq, atomic_read(&s->st_stid.sc_count) == 2);
release_all_access(s);
if (s->st_stid.sc_file) {
put_nfs4_file(s->st_stid.sc_file);
s->st_stid.sc_file = NULL;
}
spin_lock(&nn->client_lock);
last = oo->oo_last_closed_stid;
oo->oo_last_closed_stid = s;
list_move_tail(&oo->oo_close_lru, &nn->close_lru);
oo->oo_time = get_seconds();
spin_unlock(&nn->client_lock);
if (last)
nfs4_put_stid(&last->st_stid);
} | false | false | false | false | false | 0 |
read(hsStream* S, plResManager* mgr) {
plSingleModifier::read(S, mgr);
setEnterMsg(S->readBool() ? plMessage::Convert(mgr->ReadCreatable(S)) : NULL);
setExitMsg(S->readBool() ? plMessage::Convert(mgr->ReadCreatable(S)) : NULL);
} | false | false | false | false | false | 0 |
dp_set_link_config(struct dp_state *dp)
{
struct nvkm_output_dp *outp = dp->outp;
struct nvkm_disp *disp = outp->base.disp;
struct nvkm_subdev *subdev = &disp->engine.subdev;
struct nvkm_bios *bios = subdev->device->bios;
struct nvbios_init init = {
.subdev = subdev,
.bios = bios,
.offset = 0x0000,
.outp = &outp->base.info,
.crtc = -1,
.execute = 1,
};
u32 lnkcmp;
u8 sink[2];
int ret;
OUTP_DBG(&outp->base, "%d lanes at %d KB/s", dp->link_nr, dp->link_bw);
/* set desired link configuration on the source */
if ((lnkcmp = dp->outp->info.lnkcmp)) {
if (outp->version < 0x30) {
while ((dp->link_bw / 10) < nvbios_rd16(bios, lnkcmp))
lnkcmp += 4;
init.offset = nvbios_rd16(bios, lnkcmp + 2);
} else {
while ((dp->link_bw / 27000) < nvbios_rd08(bios, lnkcmp))
lnkcmp += 3;
init.offset = nvbios_rd16(bios, lnkcmp + 1);
}
nvbios_exec(&init);
}
ret = outp->func->lnk_ctl(outp, dp->link_nr, dp->link_bw / 27000,
outp->dpcd[DPCD_RC02] &
DPCD_RC02_ENHANCED_FRAME_CAP);
if (ret) {
if (ret < 0)
OUTP_ERR(&outp->base, "lnk_ctl failed with %d", ret);
return ret;
}
outp->func->lnk_pwr(outp, dp->link_nr);
/* set desired link configuration on the sink */
sink[0] = dp->link_bw / 27000;
sink[1] = dp->link_nr;
if (outp->dpcd[DPCD_RC02] & DPCD_RC02_ENHANCED_FRAME_CAP)
sink[1] |= DPCD_LC01_ENHANCED_FRAME_EN;
return nvkm_wraux(outp->aux, DPCD_LC00_LINK_BW_SET, sink, 2);
} | false | false | false | false | false | 0 |
getArgv(int *pargc, char ***pargv, int originalArgc, char **originalArgv)
{
char *switches, *next, sbuf[1024];
int i;
*pargc = 0;
if (getQueryString(&queryBuf, &queryLen) < 0) {
return -1;
}
numQueryKeys = getVars(&queryKeys, queryBuf, queryLen);
switches = 0;
for (i = 0; i < numQueryKeys; i += 2) {
if (strcmp(queryKeys[i], "HTTP_SWITCHES") == 0) {
switches = queryKeys[i+1];
break;
}
}
if (switches == 0) {
switches = getenv("HTTP_SWITCHES");
}
if (switches) {
strncpy(sbuf, switches, sizeof(sbuf) - 1);
descape(sbuf);
next = strtok(sbuf, " \t\n");
i = 1;
for (i = 1; next && i < (MAX_ARGV - 1); i++) {
argvList[i] = next;
next = strtok(0, " \t\n");
}
argvList[0] = originalArgv[0];
*pargv = argvList;
*pargc = i;
} else {
*pargc = originalArgc;
*pargv = originalArgv;
}
return 0;
} | true | true | false | false | true | 1 |
JustReachedHome() override
{
if (m_pInstance)
{
if (!(m_pInstance->GetData(TYPE_MOGRAINE_AND_WHITE_EVENT) == NOT_STARTED) || !(m_pInstance->GetData(TYPE_MOGRAINE_AND_WHITE_EVENT) == FAIL))
{
m_pInstance->SetData(TYPE_MOGRAINE_AND_WHITE_EVENT, FAIL);
}
}
} | false | false | false | false | false | 0 |
button_widget_button_press (GtkWidget *widget, GdkEventButton *event)
{
g_return_val_if_fail (BUTTON_IS_WIDGET (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
if (event->button == 1 && BUTTON_WIDGET (widget)->priv->activatable &&
/* we don't want to have two/three "click" events for double/triple
* clicks. FIXME: this is only a workaround, waiting for bug 159101 */
event->type == GDK_BUTTON_PRESS)
return GTK_WIDGET_CLASS (button_widget_parent_class)->button_press_event (widget, event);
return FALSE;
} | false | false | false | false | false | 0 |
binsearch (gint64 targ, const gint64 *vals, int n, int offset)
{
int m = n/2;
if (targ == vals[m]) {
return m + offset;
} else if (targ < vals[0] || targ > vals[n-1]) {
return -1;
} else if (targ < vals[m]) {
return binsearch(targ, vals, m, offset);
} else {
return binsearch(targ, vals + m, n - m, offset + m);
}
} | false | false | false | false | false | 0 |
toAgentItem() const
{
AgentItem ai;
ai.setJid( jid() );
ai.setName( name() );
Identity id;
if ( !identities().isEmpty() )
id = identities().first();
ai.setCategory( id.category );
ai.setType( id.type );
ai.setFeatures( d->features );
return ai;
} | false | false | false | false | false | 0 |
FindConstant(const char* F) const
{
if(data->Constants.size())
{
unsigned ind = 0;
while(isalnum(F[ind]) || F[ind] == '_') ++ind;
if(ind)
{
string name(F, ind);
return data->Constants.find(name);
}
}
return data->Constants.end();
} | false | false | false | false | false | 0 |
PyvtkMedicalImageProperties_GetDateAsFields(PyObject *, PyObject *args)
{
vtkPythonArgs ap(args, "GetDateAsFields");
char *temp0 = NULL;
int temp1;
int temp2;
int temp3;
PyObject *result = NULL;
if (ap.CheckArgCount(4) &&
ap.GetValue(temp0) &&
ap.GetValue(temp1) &&
ap.GetValue(temp2) &&
ap.GetValue(temp3))
{
int tempr = vtkMedicalImageProperties::GetDateAsFields(temp0, temp1, temp2, temp3);
if (!ap.ErrorOccurred())
{
ap.SetArgValue(1, temp1);
}
if (!ap.ErrorOccurred())
{
ap.SetArgValue(2, temp2);
}
if (!ap.ErrorOccurred())
{
ap.SetArgValue(3, temp3);
}
if (!ap.ErrorOccurred())
{
result = ap.BuildValue(tempr);
}
}
return result;
} | false | false | false | false | false | 0 |
join_search_one_level(PlannerInfo *root, int level, List **joinrels)
{
List *result_rels = NIL;
List *new_rels;
ListCell *r;
int k;
/*
* First, consider left-sided and right-sided plans, in which rels of
* exactly level-1 member relations are joined against initial relations.
* We prefer to join using join clauses, but if we find a rel of level-1
* members that has no join clauses, we will generate Cartesian-product
* joins against all initial rels not already contained in it.
*
* In the first pass (level == 2), we try to join each initial rel to each
* initial rel that appears later in joinrels[1]. (The mirror-image joins
* are handled automatically by make_join_rel.) In later passes, we try
* to join rels of size level-1 from joinrels[level-1] to each initial rel
* in joinrels[1].
*/
foreach(r, joinrels[level - 1])
{
RelOptInfo *old_rel = (RelOptInfo *) lfirst(r);
ListCell *other_rels;
if (level == 2)
other_rels = lnext(r); /* only consider remaining initial
* rels */
else
other_rels = list_head(joinrels[1]); /* consider all initial
* rels */
if (old_rel->joininfo != NIL || old_rel->has_eclass_joins ||
has_join_restriction(root, old_rel))
{
/*
* Note that if all available join clauses for this rel require
* more than one other rel, we will fail to make any joins against
* it here. In most cases that's OK; it'll be considered by
* "bushy plan" join code in a higher-level pass where we have
* those other rels collected into a join rel.
*
* See also the last-ditch case below.
*/
new_rels = make_rels_by_clause_joins(root,
old_rel,
other_rels);
}
else
{
/*
* Oops, we have a relation that is not joined to any other
* relation, either directly or by join-order restrictions.
* Cartesian product time.
*/
new_rels = make_rels_by_clauseless_joins(root,
old_rel,
other_rels);
}
/*
* At levels above 2 we will generate the same joined relation in
* multiple ways --- for example (a join b) join c is the same
* RelOptInfo as (b join c) join a, though the second case will add a
* different set of Paths to it. To avoid making extra work for
* subsequent passes, do not enter the same RelOptInfo into our output
* list multiple times.
*/
result_rels = list_concat_unique_ptr(result_rels, new_rels);
}
/*
* Now, consider "bushy plans" in which relations of k initial rels are
* joined to relations of level-k initial rels, for 2 <= k <= level-2.
*
* We only consider bushy-plan joins for pairs of rels where there is a
* suitable join clause (or join order restriction), in order to avoid
* unreasonable growth of planning time.
*/
for (k = 2;; k++)
{
int other_level = level - k;
/*
* Since make_join_rel(x, y) handles both x,y and y,x cases, we only
* need to go as far as the halfway point.
*/
if (k > other_level)
break;
foreach(r, joinrels[k])
{
RelOptInfo *old_rel = (RelOptInfo *) lfirst(r);
ListCell *other_rels;
ListCell *r2;
/*
* We can ignore clauseless joins here, *except* when they
* participate in join-order restrictions --- then we might have
* to force a bushy join plan.
*/
if (old_rel->joininfo == NIL && !old_rel->has_eclass_joins &&
!has_join_restriction(root, old_rel))
continue;
if (k == other_level)
other_rels = lnext(r); /* only consider remaining rels */
else
other_rels = list_head(joinrels[other_level]);
for_each_cell(r2, other_rels)
{
RelOptInfo *new_rel = (RelOptInfo *) lfirst(r2);
if (!bms_overlap(old_rel->relids, new_rel->relids))
{
/*
* OK, we can build a rel of the right level from this
* pair of rels. Do so if there is at least one usable
* join clause or a relevant join restriction.
*/
if (have_relevant_joinclause(root, old_rel, new_rel) ||
have_join_order_restriction(root, old_rel, new_rel))
{
RelOptInfo *jrel;
jrel = make_join_rel(root, old_rel, new_rel);
/* Avoid making duplicate entries ... */
if (jrel)
result_rels = list_append_unique_ptr(result_rels,
jrel);
}
}
}
}
}
/*
* Last-ditch effort: if we failed to find any usable joins so far, force
* a set of cartesian-product joins to be generated. This handles the
* special case where all the available rels have join clauses but we
* cannot use any of the joins yet. An example is
*
* SELECT * FROM a,b,c WHERE (a.f1 + b.f2 + c.f3) = 0;
*
* The join clause will be usable at level 3, but at level 2 we have no
* choice but to make cartesian joins. We consider only left-sided and
* right-sided cartesian joins in this case (no bushy).
*/
if (result_rels == NIL)
{
/*
* This loop is just like the first one, except we always call
* make_rels_by_clauseless_joins().
*/
foreach(r, joinrels[level - 1])
{
RelOptInfo *old_rel = (RelOptInfo *) lfirst(r);
ListCell *other_rels;
if (level == 2)
other_rels = lnext(r); /* only consider remaining initial
* rels */
else
other_rels = list_head(joinrels[1]); /* consider all initial
* rels */
new_rels = make_rels_by_clauseless_joins(root,
old_rel,
other_rels);
result_rels = list_concat_unique_ptr(result_rels, new_rels);
}
/*----------
* When OJs or IN clauses are involved, there may be no legal way
* to make an N-way join for some values of N. For example consider
*
* SELECT ... FROM t1 WHERE
* x IN (SELECT ... FROM t2,t3 WHERE ...) AND
* y IN (SELECT ... FROM t4,t5 WHERE ...)
*
* We will flatten this query to a 5-way join problem, but there are
* no 4-way joins that join_is_legal() will consider legal. We have
* to accept failure at level 4 and go on to discover a workable
* bushy plan at level 5.
*
* However, if there are no such clauses then join_is_legal() should
* never fail, and so the following sanity check is useful.
*----------
*/
if (result_rels == NIL &&
root->oj_info_list == NIL && root->in_info_list == NIL)
elog(ERROR, "failed to build any %d-way joins", level);
}
return result_rels;
} | false | false | false | false | false | 0 |
AlterTableGetRelOptionsLockLevel(List *defList)
{
LOCKMODE lockmode = NoLock;
ListCell *cell;
if (defList == NIL)
return AccessExclusiveLock;
if (need_initialization)
initialize_reloptions();
foreach(cell, defList)
{
DefElem *def = (DefElem *) lfirst(cell);
int i;
for (i = 0; relOpts[i]; i++)
{
if (pg_strncasecmp(relOpts[i]->name,
def->defname,
relOpts[i]->namelen + 1) == 0)
{
if (lockmode < relOpts[i]->lockmode)
lockmode = relOpts[i]->lockmode;
}
}
}
return lockmode;
} | false | false | false | false | false | 0 |
inPaths(string const& path, string const& list)
{
std::istringstream s(list + ":");
string buf;
while (getline(s, buf, ':') && buf.size()) {
if (buf == "/" || !fnmatch(buf.c_str(), path.c_str(), 0) || !path.find(buf + "/"))
return true;
}
return false;
} | false | false | false | false | false | 0 |
put(ostream& s) const {
// Too lazy to implement all the const_iterator stuff, so cast const away
ConfigFile* self = const_cast<ConfigFile*>(this);
for (iterator i = self->begin(), e = self->end(); i != e; ++i)
s << *i << '\n';
return s;
} | false | false | false | false | false | 0 |
syck_map_initialize(VALUE self, VALUE type_id, VALUE val, VALUE style)
{
SyckNode *node;
Data_Get_Struct( self, SyckNode, node );
if ( !NIL_P( val ) )
{
VALUE hsh = rb_check_convert_type(val, T_HASH, "Hash", "to_hash");
VALUE keys;
int i;
if ( NIL_P(hsh) )
{
rb_raise( rb_eTypeError, "wrong argument type" );
}
keys = rb_funcall( hsh, s_keys, 0 );
for ( i = 0; i < RARRAY_LEN(keys); i++ )
{
VALUE key = rb_ary_entry(keys, i);
syck_map_add( node, key, rb_hash_aref(hsh, key) );
}
}
rb_iv_set( self, "@kind", sym_seq );
rb_funcall( self, s_type_id_set, 1, type_id );
rb_funcall( self, s_value_set, 1, val );
rb_funcall( self, s_style_set, 1, style );
return self;
} | false | false | false | false | false | 0 |
Keyboard_configure( const char * filename )
{
struct stat statbuf;
int fd, devmajor, devminor;
linux_keyboard * keyboard;
unsigned char relcaps[(REL_MAX / 8) + 1];
unsigned char abscaps[(ABS_MAX / 8) + 1];
unsigned char keycaps[(KEY_MAX / 8) + 1];
if( stat( filename, &statbuf ) == -1 )
return;
if( S_ISCHR( statbuf.st_mode ) == 0 )
return; /* not a character device... */
devmajor = ( statbuf.st_rdev & 0xFF00 ) >> 8;
devminor = ( statbuf.st_rdev & 0x00FF );
if ( ( devmajor != 13 ) || ( devminor < 64 ) || ( devminor > 96 ) )
return; /* not an evdev. */
if( ( fd = open( filename, O_RDONLY | O_NONBLOCK ) ) < 0 )
return;
memset( relcaps, 0, sizeof( relcaps ) );
memset( abscaps, 0, sizeof( abscaps ) );
memset( keycaps, 0, sizeof( keycaps ) );
int num_keys = 0;
if( ioctl( fd, EVIOCGBIT( EV_KEY, sizeof( keycaps ) ), keycaps ) == -1 )
return;
if( ioctl( fd, EVIOCGBIT( EV_REL, sizeof( relcaps ) ), relcaps ) != -1 )
{
for( int i = 0; i < sizeof( relcaps ); i++ )
if( relcaps[i] )
return;
}
if( ioctl( fd, EVIOCGBIT( EV_ABS, sizeof( abscaps ) ), abscaps ) != -1 )
{
for( int i = 0; i < sizeof( abscaps ); i++ )
if( abscaps[i] )
return;
}
for( int i = 0; i < sizeof( keycaps ); i++ )
{
for( int j = 0; j < 8; j++ )
{
if( keycaps[i] & ( 1 << j ) )
num_keys++;
}
}
keyboard = new linux_keyboard;
keyboard->num = keyboards->size();
ioctl( fd, EVIOCGNAME( CK_HID_NAMESIZE ), keyboard->name );
if( fd >= 0 )
close( fd ); // no need to keep the file open
strncpy( keyboard->filename, filename, CK_HID_STRBUFSIZE );
keyboards->push_back( keyboard );
EM_log( CK_LOG_INFO, "keyboard: found device %s", keyboard->name );
} | false | false | false | false | false | 0 |
rfio_dircleanup(s) /* cleanup rfio dir. descriptor */
int s;
{
int s_index;
INIT_TRACE("RFIO_TRACE");
TRACE(1, "rfio", "rfio_dircleanup(%d)", s);
if ((s_index = rfio_rdirfdt_findentry(s,FINDRDIR_WITHOUT_SCAN)) != -1) {
if (rdirfdt[s_index] != NULL) {
if (rdirfdt[s_index]->magic != RFIO_MAGIC && rdirfdt[s_index]->magic != B_RFIO_MAGIC) {
serrno = SEBADVERSION ;
END_TRACE();
return(-1);
}
TRACE(2, "rfio", "freeing RFIO directory descriptor at 0X%X", rdirfdt[s_index]);
(void) free((char *)rdirfdt[s_index]->dp.dd_buf);
rfio_rdirfdt_freeentry(s_index);
TRACE(2, "rfio", "closing %d",s) ;
(void) close(s) ;
}
}
END_TRACE();
return(0);
} | false | false | false | false | false | 0 |
writeAsDX()
{
//generate filename
string fn=makeFilename();
// write header
ofstream out_file(fn.c_str());
out_file << "points = " << m_data.size() << endl;
out_file << "format = ascii" << endl;
out_file << "dependency = positions, positions" << endl;
out_file << "interleaving = field" << endl;
out_file << "field = locations, " << m_field_name << endl;
out_file << "structure = 3-vector, 3-vector" << endl;
out_file << "type = float, float " << endl;
out_file << "header = marker \"Start\\n\"" << endl;
out_file << endl << "end" << endl;
out_file << "Start" << endl;
// write data
for(vector<pair<Vec3,Vec3> >::iterator iter=m_data.begin();
iter!=m_data.end();
iter++){
out_file << iter->first << " " << iter->second << endl;
}
out_file.close();
m_data.erase(m_data.begin(),m_data.end());
} | false | false | false | false | false | 0 |
fso_framework_inotifier_handleEvent (FsoFrameworkINotifier* self, struct inotify_event* event) {
INotifyDelegateHolder* holder = NULL;
GHashTable* _tmp0_ = NULL;
struct inotify_event _tmp1_ = {0};
gint _tmp2_ = 0;
gconstpointer _tmp3_ = NULL;
INotifyDelegateHolder* _tmp4_ = NULL;
const gchar* _tmp5_ = NULL;
struct inotify_event _tmp6_ = {0};
guint32 _tmp7_ = 0U;
INotifyDelegateHolder* _tmp10_ = NULL;
FsoFrameworkINotifyNotifierFunc _tmp11_ = NULL;
void* _tmp11__target = NULL;
struct inotify_event _tmp12_ = {0};
guint32 _tmp13_ = 0U;
struct inotify_event _tmp14_ = {0};
guint32 _tmp15_ = 0U;
const gchar* _tmp16_ = NULL;
g_return_if_fail (self != NULL);
g_return_if_fail (event != NULL);
_tmp0_ = self->priv->delegates;
_tmp1_ = *event;
_tmp2_ = _tmp1_.wd;
_tmp3_ = g_hash_table_lookup (_tmp0_, (gpointer) ((gintptr) _tmp2_));
holder = (INotifyDelegateHolder*) _tmp3_;
_tmp4_ = holder;
_vala_assert (_tmp4_ != NULL, "holder != null");
_tmp6_ = *event;
_tmp7_ = _tmp6_.len;
if (_tmp7_ > ((guint32) 0)) {
struct inotify_event _tmp8_ = {0};
const gchar* _tmp9_ = NULL;
_tmp8_ = *event;
_tmp9_ = _tmp8_.name;
_tmp5_ = _tmp9_;
} else {
_tmp5_ = NULL;
}
_tmp10_ = holder;
_tmp11_ = _tmp10_->func;
_tmp11__target = _tmp10_->func_target;
_tmp12_ = *event;
_tmp13_ = _tmp12_.mask;
_tmp14_ = *event;
_tmp15_ = _tmp14_.cookie;
_tmp16_ = _tmp5_;
_tmp11_ ((int) _tmp13_, _tmp15_, _tmp16_, _tmp11__target);
} | false | false | false | false | false | 0 |
parse_port(cfg_parser_t *pctx, cfg_obj_t **ret) {
isc_result_t result;
CHECK(cfg_parse_uint32(pctx, NULL, ret));
if ((*ret)->value.uint32 > 0xffff) {
cfg_parser_error(pctx, CFG_LOG_NEAR, "invalid port");
cfg_obj_destroy(pctx, ret);
result = ISC_R_RANGE;
}
cleanup:
return (result);
} | false | false | false | false | false | 0 |
ena_update_on_link_change(void *adapter_data,
struct ena_admin_aenq_entry *aenq_e)
{
struct ena_adapter *adapter = (struct ena_adapter *)adapter_data;
struct ena_admin_aenq_link_change_desc *aenq_desc =
(struct ena_admin_aenq_link_change_desc *)aenq_e;
int status = aenq_desc->flags &
ENA_ADMIN_AENQ_LINK_CHANGE_DESC_LINK_STATUS_MASK;
if (status) {
netdev_dbg(adapter->netdev, "%s\n", __func__);
set_bit(ENA_FLAG_LINK_UP, &adapter->flags);
netif_carrier_on(adapter->netdev);
} else {
clear_bit(ENA_FLAG_LINK_UP, &adapter->flags);
netif_carrier_off(adapter->netdev);
}
} | false | false | false | false | false | 0 |
gss_inquire_cred (OM_uint32 * minor_status,
const gss_cred_id_t cred_handle,
gss_name_t * name,
OM_uint32 * lifetime,
gss_cred_usage_t * cred_usage, gss_OID_set * mechanisms)
{
gss_cred_id_t credh = cred_handle;
_gss_mech_api_t mech;
OM_uint32 maj_stat;
if (cred_handle == GSS_C_NO_CREDENTIAL)
{
maj_stat = gss_acquire_cred (minor_status, GSS_C_NO_NAME,
GSS_C_INDEFINITE, GSS_C_NO_OID_SET,
GSS_C_INITIATE, &credh, NULL, NULL);
if (GSS_ERROR (maj_stat))
return maj_stat;
}
mech = _gss_find_mech (credh->mech);
if (mech == NULL)
{
if (minor_status)
*minor_status = 0;
return GSS_S_BAD_MECH;
}
maj_stat = mech->inquire_cred (minor_status, credh, name, lifetime,
cred_usage, mechanisms);
if (cred_handle == GSS_C_NO_CREDENTIAL)
gss_release_cred (NULL, &credh);
return maj_stat;
} | false | false | false | false | false | 0 |
try_rich_compare(PyObject *v, PyObject *w, int op)
{
richcmpfunc f;
PyObject *res;
if (v->ob_type != w->ob_type &&
PyType_IsSubtype(w->ob_type, v->ob_type) &&
(f = RICHCOMPARE(w->ob_type)) != NULL) {
res = (*f)(w, v, _Py_SwappedOp[op]);
if (res != Py_NotImplemented)
return res;
Py_DECREF(res);
}
if ((f = RICHCOMPARE(v->ob_type)) != NULL) {
res = (*f)(v, w, op);
if (res != Py_NotImplemented)
return res;
Py_DECREF(res);
}
if ((f = RICHCOMPARE(w->ob_type)) != NULL) {
return (*f)(w, v, _Py_SwappedOp[op]);
}
res = Py_NotImplemented;
Py_INCREF(res);
return res;
} | false | false | false | false | false | 0 |
isDevelopmentVersion( const QString &version )
{
return version.indexOf( "alpha", 0, Qt::CaseInsensitive ) != -1 ||
version.indexOf( "beta", 0, Qt::CaseInsensitive ) != -1 ||
version.indexOf( "rc", 0, Qt::CaseInsensitive ) != -1 ||
version.indexOf( "svn", 0, Qt::CaseInsensitive ) != -1 ||
version.indexOf( "cvs", 0, Qt::CaseInsensitive ) != -1;
} | false | false | false | false | false | 0 |
readlinkname(s, len)
CONST char *s;
int len;
{
int i;
for (i = 0; i < LINKLISTSIZ; i++) {
if (linklist[i].len > len) continue;
if (!strncmp(s, linklist[i].name, linklist[i].len)) {
s += linklist[i].len;
return(skipspace(s));
}
}
return(NULL);
} | false | false | false | false | false | 0 |
poll_sensor(struct gspca_dev *gspca_dev)
{
static const u8 poll1[] =
{0x67, 0x05, 0x68, 0x81, 0x69, 0x80, 0x6a, 0x82,
0x6b, 0x68, 0x6c, 0x69, 0x72, 0xd9, 0x73, 0x34,
0x74, 0x32, 0x75, 0x92, 0x76, 0x00, 0x09, 0x01,
0x60, 0x14};
static const u8 poll2[] =
{0x67, 0x02, 0x68, 0x71, 0x69, 0x72, 0x72, 0xa9,
0x73, 0x02, 0x73, 0x02, 0x60, 0x14};
static const u8 noise03[] = /* (some differences / ms-drv) */
{0xa6, 0x0a, 0xea, 0xcf, 0xbe, 0x26, 0xb1, 0x5f,
0xa1, 0xb1, 0xda, 0x6b, 0xdb, 0x98, 0xdf, 0x0c,
0xc2, 0x80, 0xc3, 0x10};
PDEBUG(D_STREAM, "[Sensor requires polling]");
reg_w_buf(gspca_dev, poll1, sizeof poll1);
reg_w_buf(gspca_dev, poll2, sizeof poll2);
reg_w_buf(gspca_dev, noise03, sizeof noise03);
} | false | false | false | false | false | 0 |
ncio_spx_init2(ncio *const nciop, const size_t *const sizehintp)
{
ncio_spx *const pxp = (ncio_spx *)nciop->pvt;
assert(nciop->fd >= 0);
pxp->bf_extent = *sizehintp;
assert(pxp->bf_base == NULL);
/* this is separate allocation because it may grow */
pxp->bf_base = malloc(pxp->bf_extent);
if(pxp->bf_base == NULL)
{
pxp->bf_extent = 0;
return ENOMEM;
}
/* else */
return ENOERR;
} | false | false | false | false | false | 0 |
value_destroy(struct value_obj *vo)
{
TRACE_FLOW_ENTRY();
if (vo) {
/* Free arrays if any */
value_destroy_arrays(vo->raw_lines,
vo->raw_lengths);
/* Free the simple buffer if any */
simplebuffer_free(vo->unfolded);
/* Function checks validity inside */
ini_comment_destroy(vo->ic);
free(vo);
}
TRACE_FLOW_EXIT();
} | false | false | false | false | true | 1 |
gst_y4m_dec_sink_event (GstPad * pad, GstEvent * event)
{
gboolean res;
GstY4mDec *y4mdec;
y4mdec = GST_Y4M_DEC (gst_pad_get_parent (pad));
GST_DEBUG_OBJECT (y4mdec, "event");
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_FLUSH_START:
res = gst_pad_push_event (y4mdec->srcpad, event);
break;
case GST_EVENT_FLUSH_STOP:
res = gst_pad_push_event (y4mdec->srcpad, event);
break;
case GST_EVENT_NEWSEGMENT:
{
gboolean update;
gdouble rate;
gdouble applied_rate;
GstFormat format;
gint64 start;
gint64 stop;
gint64 position;
gst_event_parse_new_segment_full (event, &update, &rate,
&applied_rate, &format, &start, &stop, &position);
GST_DEBUG ("new_segment: update: %d rate: %g applied_rate: %g "
"format: %d start: %" G_GUINT64_FORMAT " stop: %" G_GUINT64_FORMAT
" position %" G_GUINT64_FORMAT,
update, rate, applied_rate, format, start, stop, position);
if (format == GST_FORMAT_BYTES) {
y4mdec->segment_start = start;
y4mdec->segment_stop = stop;
y4mdec->segment_position = position;
y4mdec->have_new_segment = TRUE;
}
res = TRUE;
/* not sure why it's not forwarded, but let's unref it so it
doesn't leak, remove the unref if it gets forwarded again */
gst_event_unref (event);
//res = gst_pad_push_event (y4mdec->srcpad, event);
}
break;
case GST_EVENT_EOS:
res = gst_pad_push_event (y4mdec->srcpad, event);
break;
default:
res = gst_pad_push_event (y4mdec->srcpad, event);
break;
}
gst_object_unref (y4mdec);
return res;
} | false | false | false | false | false | 0 |
bfa_fcport_cfg_speed(struct bfa_s *bfa, enum bfa_port_speed speed)
{
struct bfa_fcport_s *fcport = BFA_FCPORT_MOD(bfa);
bfa_trc(bfa, speed);
if (fcport->cfg.trunked == BFA_TRUE)
return BFA_STATUS_TRUNK_ENABLED;
if ((fcport->cfg.topology == BFA_PORT_TOPOLOGY_LOOP) &&
(speed == BFA_PORT_SPEED_16GBPS))
return BFA_STATUS_UNSUPP_SPEED;
if ((speed != BFA_PORT_SPEED_AUTO) && (speed > fcport->speed_sup)) {
bfa_trc(bfa, fcport->speed_sup);
return BFA_STATUS_UNSUPP_SPEED;
}
/* Port speed entered needs to be checked */
if (bfa_ioc_get_type(&fcport->bfa->ioc) == BFA_IOC_TYPE_FC) {
/* For CT2, 1G is not supported */
if ((speed == BFA_PORT_SPEED_1GBPS) &&
(bfa_asic_id_ct2(bfa->ioc.pcidev.device_id)))
return BFA_STATUS_UNSUPP_SPEED;
/* Already checked for Auto Speed and Max Speed supp */
if (!(speed == BFA_PORT_SPEED_1GBPS ||
speed == BFA_PORT_SPEED_2GBPS ||
speed == BFA_PORT_SPEED_4GBPS ||
speed == BFA_PORT_SPEED_8GBPS ||
speed == BFA_PORT_SPEED_16GBPS ||
speed == BFA_PORT_SPEED_AUTO))
return BFA_STATUS_UNSUPP_SPEED;
} else {
if (speed != BFA_PORT_SPEED_10GBPS)
return BFA_STATUS_UNSUPP_SPEED;
}
fcport->cfg.speed = speed;
return BFA_STATUS_OK;
} | false | false | false | false | false | 0 |
PlaceTileLower(wxUint32 x, wxUint32 y, Tile tile, bool enablemonster) {
if(x >= 32 || y >= 32)
return tile == TILE_FLOOR;
if(enablemonster && IsTileMonster(tile))
AddMonster(x, y);
else if(!IsTileMonster(upper[x + 32 * y]))
RemoveMonster(x, y);
#if 0
if(lower[x + 32 * y] == tile)
return true;
if(upper[x + 32 * y] != lower[x + 32 * y])
RemoveWire(x, y, lower[x + 32 * y]);
#endif
Tile old = lower[x + 32 * y];
lower[x + 32 * y] = tile;
RemoveInvalidWire(x, y);
if(tile != old && monitor != NULL)
monitor->OnLevelChange(this, new LevelChangeTile(LevelChange::LOWER, x, y, old, tile));
return true;
} | false | false | false | false | false | 0 |
gmpc_profiles_set_db_update_time (GmpcProfiles * self, const gchar * id, int value)
{
#line 1217 "gmpc-profiles.c"
#define __GOB_FUNCTION__ "Gmpc:Profiles::set_db_update_time"
#line 606 "gmpc-profiles.gob"
g_return_if_fail (self != NULL);
#line 606 "gmpc-profiles.gob"
g_return_if_fail (GMPC_IS_PROFILES (self));
#line 606 "gmpc-profiles.gob"
g_return_if_fail (id != NULL);
#line 1225 "gmpc-profiles.c"
{
#line 609 "gmpc-profiles.gob"
Profile *prof = self_get_profile(self, id);
if(!prof)
return ;
if(value == prof->db_update_time) return;
cfg_set_single_value_as_int(self->_priv->profiles, (char *)id, "db update time",(int)value);
self_changed(self,PROFILE_COL_CHANGED, PROFILE_COL_DB_UPDATE_TIME,id);
}} | false | false | false | false | false | 0 |
scontrol_print_job (char * job_id_str)
{
int error_code = SLURM_SUCCESS, i, print_cnt = 0;
uint32_t job_id = 0;
job_info_msg_t * job_buffer_ptr = NULL;
job_info_t *job_ptr = NULL;
if (job_id_str)
job_id = (uint32_t) strtol (job_id_str, (char **)NULL, 10);
error_code = _scontrol_load_jobs(&job_buffer_ptr, job_id);
if (error_code) {
exit_code = 1;
if (quiet_flag != 1)
slurm_perror ("slurm_load_jobs error");
return;
}
if (quiet_flag == -1) {
char time_str[32];
slurm_make_time_str ((time_t *)&job_buffer_ptr->last_update,
time_str, sizeof(time_str));
printf ("last_update_time=%s, records=%d\n",
time_str, job_buffer_ptr->record_count);
}
job_ptr = job_buffer_ptr->job_array ;
for (i = 0; i < job_buffer_ptr->record_count; i++) {
print_cnt++;
slurm_print_job_info (stdout, & job_ptr[i], one_liner ) ;
}
if (print_cnt == 0) {
if (job_id_str) {
exit_code = 1;
if (quiet_flag != 1)
printf ("Job %u not found\n", job_id);
} else if (quiet_flag != 1)
printf ("No jobs in the system\n");
}
} | true | true | false | false | false | 1 |
rhkspm32_detect(const GwyFileDetectInfo *fileinfo,
gboolean only_name)
{
gint score = 0;
if (only_name)
return g_str_has_suffix(fileinfo->name_lowercase, EXTENSION) ? 20 : 0;
if (fileinfo->buffer_len > MAGIC_SIZE
&& memcmp(fileinfo->head, MAGIC, MAGIC_SIZE) == 0)
score = 100;
return score;
} | false | false | false | false | false | 0 |
start_redo_ins()
{
register int c;
if (read_redo(TRUE) == FAIL)
return FAIL;
start_stuff();
/* skip the count and the command character */
while ((c = read_redo(FALSE)) != NUL)
{
c = TO_UPPER(c);
if (strchr("AIRO", c) != NULL)
{
if (c == 'O')
stuffReadbuff(NL_STR);
break;
}
}
/* copy the typed text from the redo buffer into the stuff buffer */
copy_redo();
block_redo = TRUE;
return OK;
} | false | false | false | false | false | 0 |
iwl_dealloc_bcast_stations(struct iwl_priv *priv)
{
int i;
spin_lock_bh(&priv->sta_lock);
for (i = 0; i < IWLAGN_STATION_COUNT; i++) {
if (!(priv->stations[i].used & IWL_STA_BCAST))
continue;
priv->stations[i].used &= ~IWL_STA_UCODE_ACTIVE;
priv->num_stations--;
if (WARN_ON(priv->num_stations < 0))
priv->num_stations = 0;
kfree(priv->stations[i].lq);
priv->stations[i].lq = NULL;
}
spin_unlock_bh(&priv->sta_lock);
} | false | false | false | false | false | 0 |
display_what_to_do(GooCanvasItem *parent)
{
gint base_Y = 90;
gint base_X = 570;
/* Load the text to find */
textToFind = get_random_word(NULL);
g_assert(textToFind != NULL);
/* Decide now if this time we will display the text to find */
/* Use this formula to have a better random number see 'man 3 rand' */
if(g_random_boolean())
textToFindIndex = g_random_int_range(0, numberOfLine);
else
textToFindIndex = NOT_THERE;
goo_canvas_text_new (parent,
_("Please, check if the word"),
(double) base_X,
(double) base_Y,
-1,
GTK_ANCHOR_CENTER,
"font", gc_skin_font_board_medium,
"fill-color", "black",
NULL);
goo_canvas_text_new (parent,
textToFind,
(double) base_X,
(double) base_Y + 30,
-1,
GTK_ANCHOR_CENTER,
"font", gc_skin_font_board_big,
"fill-color", "blue",
NULL);
goo_canvas_text_new (parent,
_("is being displayed"),
(double) base_X,
(double) base_Y + 60,
-1,
GTK_ANCHOR_CENTER,
"font", gc_skin_font_board_medium,
"fill-color", "black",
NULL);
return NULL;
} | false | false | false | false | false | 0 |
check_fileending(struct dirent const *entry, char *fileending) {
struct stat buf;
char *end;
/* get stats for the file */
if(stat(entry->d_name,&buf)) {
perror("couldn't get stats for file");
}
/* check if file is a regular file and if it has and ending (.*) */
if(S_ISREG(buf.st_mode) && (end=strrchr(entry->d_name,'.'))!=NULL){
/* check if the ending is .txt (configure via config.h?) */
if(!strcmp(end,fileending)) {
return -1;
}
}
return 0;
} | false | false | false | false | false | 0 |
sgen_hash_table_replace (SgenHashTable *hash_table, gpointer key, gpointer new_value, gpointer old_value)
{
guint hash;
SgenHashTableEntry *entry;
rehash_if_necessary (hash_table);
entry = lookup (hash_table, key, &hash);
if (entry) {
if (old_value)
memcpy (old_value, entry->data, hash_table->data_size);
memcpy (entry->data, new_value, hash_table->data_size);
return FALSE;
}
entry = (SgenHashTableEntry *)sgen_alloc_internal (hash_table->entry_mem_type);
entry->key = key;
memcpy (entry->data, new_value, hash_table->data_size);
entry->next = hash_table->table [hash];
hash_table->table [hash] = entry;
hash_table->num_entries++;
return TRUE;
} | false | false | false | false | false | 0 |
_lt_ext_ldml_t_get_tag(lt_ext_module_data_t *data)
{
lt_ext_ldml_t_data_t *d = (lt_ext_ldml_t_data_t *)data;
lt_string_t *s = lt_string_new(lt_tag_get_string(d->tag));
lt_list_t *l;
if (d->fields) {
for (l = d->fields; l != NULL; l = lt_list_next(l)) {
const lt_string_t *t = lt_list_value(l);
char *ts = strdup(lt_string_value(t));
if (lt_string_length(s) > 0)
lt_string_append_c(s, '-');
if (lt_string_length(t) == 2) {
/* XXX: do we need to auto-complete the clipped type here? */
}
lt_string_append(s, lt_strlower(ts));
free(ts);
}
}
return lt_string_free(s, FALSE);
} | false | false | false | false | false | 0 |
mkflatdtype(MPI_Datatype dtype, int dtlabel, char **pbuf, int *psize)
{
int nrec; /* # records available */
struct trsrc *psrc; /* ptr src header */
struct trdtype *pdhdr; /* ptr trace datatype header */
struct trdtype *p; /* favourite pointer */
/*
* Initialize.
*/
if (dtbuf == 0) {
dtbufrec = TRDTINITBUFSIZE;
dtbufsize = sizeof(struct trsrc) + sizeof(struct trdtype) +
(dtbufrec * sizeof(struct trdtype));
dtbuf = malloc((unsigned) dtbufsize);
if (dtbuf == 0) return(LAMERROR);
#if LAM_DISINFECT
memset(dtbuf, 0, dtbufsize);
#endif
}
psrc = (struct trsrc *) dtbuf;
psrc->trs_node = getnodeid();
psrc->trs_pid = lam_getpid();
psrc->trs_listno = TRDTYPE;
pdhdr = (struct trdtype *) (psrc + 1);
pdhdr->trd_dtype = dtlabel;
/*
* Recursively (depth-first) flatten datatype.
*/
p = (struct trdtype *) (pdhdr + 1);
nrec = dtbufrec;
if (flat_dtype(dtype, &p, &nrec)) return(LAMERROR);
*pbuf = dtbuf;
*psize = ((long) p) - ((long) dtbuf);
pdhdr = (struct trdtype *) (dtbuf + sizeof(struct trsrc));
pdhdr->trd_length = *psize - sizeof(struct trsrc);
return(0);
} | false | false | false | false | false | 0 |
check_password(struct ast_vm_user *vmu, char *password)
{
/* check minimum length */
if (strlen(password) < minpassword)
return 1;
/* check that password does not contain '*' character */
if (!ast_strlen_zero(password) && password[0] == '*')
return 1;
if (!ast_strlen_zero(ext_pass_check_cmd)) {
char cmd[255], buf[255];
ast_debug(1, "Verify password policies for %s\n", password);
snprintf(cmd, sizeof(cmd), "%s %s %s %s %s", ext_pass_check_cmd, vmu->mailbox, vmu->context, vmu->password, password);
if (vm_check_password_shell(cmd, buf, sizeof(buf))) {
ast_debug(5, "Result: %s\n", buf);
if (!strncasecmp(buf, "VALID", 5)) {
ast_debug(3, "Passed password check: '%s'\n", buf);
return 0;
} else if (!strncasecmp(buf, "FAILURE", 7)) {
ast_log(AST_LOG_WARNING, "Unable to execute password validation script: '%s'.\n", buf);
return 0;
} else {
ast_log(AST_LOG_NOTICE, "Password doesn't match policies for user %s %s\n", vmu->mailbox, password);
return 1;
}
}
}
return 0;
} | false | false | false | false | false | 0 |
precompute(void)
{
G_message(_("Precomputing: e/w distances"));
precompute_ew_dists();
G_message(_("Precomputing: quantization tolerances"));
precompute_epsilons();
if (parm.up) {
G_message(_("Precomputing: inverted elevations"));
upslope_correction();
}
if (!parm.aspin) {
G_message(_("Precomputing: interpolated border elevations"));
interpolate_border();
}
if (!parm.mem) {
if (parm.aspin) {
G_message(_("Precomputing: re-oriented aspects"));
reflect_and_sentinel();
}
else {
G_message(_("Precomputing: aspects"));
precompute_aspects();
}
}
} | false | false | false | false | false | 0 |
on_link_clicked(GObject * ignored, DhLink * dhlink, DevhelpPlugin *self)
{
gchar *uri;
g_return_if_fail(DEVHELP_IS_PLUGIN(self));
uri = dh_link_get_uri(dhlink);
devhelp_plugin_set_webview_uri(self, uri);
devhelp_plugin_activate_webview_tab(self);
g_free(uri);
} | false | false | false | false | false | 0 |
pwm_lpss_probe(struct device *dev, struct resource *r,
const struct pwm_lpss_boardinfo *info)
{
struct pwm_lpss_chip *lpwm;
int ret;
lpwm = devm_kzalloc(dev, sizeof(*lpwm), GFP_KERNEL);
if (!lpwm)
return ERR_PTR(-ENOMEM);
lpwm->regs = devm_ioremap_resource(dev, r);
if (IS_ERR(lpwm->regs))
return ERR_CAST(lpwm->regs);
lpwm->info = info;
lpwm->chip.dev = dev;
lpwm->chip.ops = &pwm_lpss_ops;
lpwm->chip.base = -1;
lpwm->chip.npwm = info->npwm;
ret = pwmchip_add(&lpwm->chip);
if (ret) {
dev_err(dev, "failed to add PWM chip: %d\n", ret);
return ERR_PTR(ret);
}
return lpwm;
} | false | false | false | false | false | 0 |
ves_icall_System_Reflection_Assembly_GetEntryAssembly (void)
{
MonoDomain* domain = mono_domain_get ();
MONO_ARCH_SAVE_REGS;
if (!domain->entry_assembly)
return NULL;
return mono_assembly_get_object (domain, domain->entry_assembly);
} | false | false | false | false | false | 0 |
remove_all_edges() {
//not calling remove_edge because this would take O ( e*ln(e)*ln(e) )
//doing it this way takes only O(e * ln(e))
for(EdgeIterator it = _edges.begin(); it != _edges.end(); it ++) {
(*it)->remove_self();
delete *it;
}
_edges.clear();
} | false | false | false | false | false | 0 |
tile_move_cost_ptrs(const struct unit *punit,
const struct player *pplayer,
const struct tile *t1, const struct tile *t2)
{
bool cardinal_move;
struct unit_class *pclass = NULL;
bool native = TRUE;
if (punit) {
pclass = unit_class(punit);
native = is_native_tile(unit_type(punit), t2);
}
if (game.info.slow_invasions
&& punit
&& tile_city(t1) == NULL
&& !is_native_tile(unit_type(punit), t1)
&& is_native_tile(unit_type(punit), t2)) {
/* If "slowinvasions" option is turned on, units moving from
* non-native terrain (from transport) to native terrain lose all their
* movement.
* e.g. ground units moving from sea to land */
return punit->moves_left;
}
if (punit && !uclass_has_flag(pclass, UCF_TERRAIN_SPEED)) {
return SINGLE_MOVE;
}
/* Railroad check has to be before F_IGTER check so that F_IGTER
* units are not penalized. F_IGTER affects also entering and
* leaving ships, so F_IGTER check has to be before native terrain
* check. We want to give railroad bonus only to native units. */
if (tile_has_special(t1, S_RAILROAD) && tile_has_special(t2, S_RAILROAD)
&& native && !restrict_infra(pplayer, t1, t2)) {
return MOVE_COST_RAIL;
}
if (punit && unit_has_type_flag(punit, F_IGTER)) {
return SINGLE_MOVE/3;
}
if (!native) {
/* Loading to transport or entering port */
return SINGLE_MOVE;
}
if (tile_has_special(t1, S_ROAD) && tile_has_special(t2, S_ROAD)
&& !restrict_infra(pplayer, t1, t2)) {
return MOVE_COST_ROAD;
}
if (tile_has_special(t1, S_RIVER) && tile_has_special(t2, S_RIVER)) {
cardinal_move = is_move_cardinal(t1, t2);
switch (terrain_control.river_move_mode) {
case RMV_NORMAL:
break;
case RMV_FAST_STRICT:
if (cardinal_move)
return MOVE_COST_RIVER;
break;
case RMV_FAST_RELAXED:
if (cardinal_move)
return MOVE_COST_RIVER;
else
return 2 * MOVE_COST_RIVER;
case RMV_FAST_ALWAYS:
return MOVE_COST_RIVER;
default:
break;
}
}
return tile_terrain(t2)->movement_cost * SINGLE_MOVE;
} | false | false | false | true | false | 1 |
findfilendir(argvars, rettv, find_what)
typval_T *argvars UNUSED;
typval_T *rettv;
int find_what UNUSED;
{
#ifdef FEAT_SEARCHPATH
char_u *fname;
char_u *fresult = NULL;
char_u *path = *curbuf->b_p_path == NUL ? p_path : curbuf->b_p_path;
char_u *p;
char_u pathbuf[NUMBUFLEN];
int count = 1;
int first = TRUE;
int error = FALSE;
#endif
rettv->vval.v_string = NULL;
rettv->v_type = VAR_STRING;
#ifdef FEAT_SEARCHPATH
fname = get_tv_string(&argvars[0]);
if (argvars[1].v_type != VAR_UNKNOWN)
{
p = get_tv_string_buf_chk(&argvars[1], pathbuf);
if (p == NULL)
error = TRUE;
else
{
if (*p != NUL)
path = p;
if (argvars[2].v_type != VAR_UNKNOWN)
count = get_tv_number_chk(&argvars[2], &error);
}
}
if (count < 0 && rettv_list_alloc(rettv) == FAIL)
error = TRUE;
if (*fname != NUL && !error)
{
do
{
if (rettv->v_type == VAR_STRING || rettv->v_type == VAR_LIST)
vim_free(fresult);
fresult = find_file_in_path_option(first ? fname : NULL,
first ? (int)STRLEN(fname) : 0,
0, first, path,
find_what,
curbuf->b_ffname,
find_what == FINDFILE_DIR
? (char_u *)"" : curbuf->b_p_sua);
first = FALSE;
if (fresult != NULL && rettv->v_type == VAR_LIST)
list_append_string(rettv->vval.v_list, fresult, -1);
} while ((rettv->v_type == VAR_LIST || --count > 0) && fresult != NULL);
}
if (rettv->v_type == VAR_STRING)
rettv->vval.v_string = fresult;
#endif
} | false | false | false | false | false | 0 |
Print( const wxString & rosPrefix )
{
CmdBase::Print( rosPrefix + wxT("CmdBase::") );
cout << rosPrefix.mb_str( ) << "m_osStart : "
<< m_osStart.mb_str( ) << '\n';
cout << rosPrefix.mb_str( ) << "m_osStop : "
<< m_osStop .mb_str( ) << '\n';
cout << rosPrefix.mb_str( ) << "m_osStep : "
<< m_osStep .mb_str( ) << '\n';
cout << rosPrefix.mb_str( ) << "m_eInitC : ";
switch( m_eInitC )
{
case eINITC_WARM : cout << "eINITC_COLD\n"; break;
case eINITC_UICS : cout << "eINITC_UICS\n"; break;
case eINITC_COLD : cout << "eINITC_COLD\n"; break;
case eINITC_NONE : cout << "eINITC_NONE\n"; break;
default : cout << "Invalid\n"; break;
}
} | false | false | false | false | false | 0 |
replaceIfDefined(const std::string &str) const
{
std::string ret(str);
std::string::size_type pos;
pos = 0;
while ((pos = ret.find("#if defined(", pos)) != std::string::npos) {
std::string::size_type pos2 = ret.find(")", pos + 9);
if (pos2 > ret.length() - 1)
break;
if (ret[pos2+1] == '\n') {
ret.erase(pos2, 1);
ret.erase(pos + 3, 9);
ret.insert(pos + 3, "def ");
}
++pos;
if (_settings && _settings->terminated())
return "";
}
pos = 0;
while ((pos = ret.find("#if !defined(", pos)) != std::string::npos) {
std::string::size_type pos2 = ret.find(")", pos + 9);
if (pos2 > ret.length() - 1)
break;
if (ret[pos2+1] == '\n') {
ret.erase(pos2, 1);
ret.erase(pos + 3, 10);
ret.insert(pos + 3, "ndef ");
}
++pos;
if (_settings && _settings->terminated())
return "";
}
pos = 0;
while ((pos = ret.find("#elif defined(", pos)) != std::string::npos) {
std::string::size_type pos2 = ret.find(")", pos + 9);
if (pos2 > ret.length() - 1)
break;
if (ret[pos2+1] == '\n') {
ret.erase(pos2, 1);
ret.erase(pos + 6, 8);
}
++pos;
if (_settings && _settings->terminated())
return "";
}
return ret;
} | false | false | false | false | false | 0 |
csc_next(Scorer *self)
{
ConjunctionScorer *csc = CSc(self);
if (csc->first_time) {
csc_init(self, true);
}
else if (csc->more) {
/* trigger further scanning */
const int last_idx = PREV_NUM(csc->first_idx, csc->ss_cnt);
Scorer *sub_scorer = csc->sub_scorers[last_idx];
csc->more = sub_scorer->next(sub_scorer);
}
return csc_do_next(self);
} | false | false | false | false | false | 0 |
read_reuc(git_index *index, const char *buffer, size_t size)
{
const char *endptr;
size_t len;
int i;
/* If called multiple times, the vector might already be initialized */
if (index->reuc._alloc_size == 0 &&
git_vector_init(&index->reuc, 16, reuc_cmp) < 0)
return -1;
while (size) {
git_index_reuc_entry *lost;
len = p_strnlen(buffer, size) + 1;
if (size <= len)
return index_error_invalid("reading reuc entries");
lost = reuc_entry_alloc(buffer);
GITERR_CHECK_ALLOC(lost);
size -= len;
buffer += len;
/* read 3 ASCII octal numbers for stage entries */
for (i = 0; i < 3; i++) {
int tmp;
if (git__strtol32(&tmp, buffer, &endptr, 8) < 0 ||
!endptr || endptr == buffer || *endptr ||
(unsigned)tmp > UINT_MAX) {
index_entry_reuc_free(lost);
return index_error_invalid("reading reuc entry stage");
}
lost->mode[i] = tmp;
len = (endptr + 1) - buffer;
if (size <= len) {
index_entry_reuc_free(lost);
return index_error_invalid("reading reuc entry stage");
}
size -= len;
buffer += len;
}
/* read up to 3 OIDs for stage entries */
for (i = 0; i < 3; i++) {
if (!lost->mode[i])
continue;
if (size < 20) {
index_entry_reuc_free(lost);
return index_error_invalid("reading reuc entry oid");
}
git_oid_fromraw(&lost->oid[i], (const unsigned char *) buffer);
size -= 20;
buffer += 20;
}
/* entry was read successfully - insert into reuc vector */
if (git_vector_insert(&index->reuc, lost) < 0)
return -1;
}
/* entries are guaranteed to be sorted on-disk */
git_vector_set_sorted(&index->reuc, true);
return 0;
} | false | false | false | false | false | 0 |
indicator_ranges(const struct indicator *indicators)
{
int i;
GString *gstr;
gstr = g_string_new("\r\n+CIND: ");
for (i = 0; indicators[i].desc != NULL; i++) {
if (i == 0)
g_string_append_printf(gstr, "(\"%s\",(%s))",
indicators[i].desc,
indicators[i].range);
else
g_string_append_printf(gstr, ",(\"%s\",(%s))",
indicators[i].desc,
indicators[i].range);
}
g_string_append(gstr, "\r\n");
return g_string_free(gstr, FALSE);
} | false | false | false | false | false | 0 |
btmrvl_tx_pkt(struct btmrvl_private *priv, struct sk_buff *skb)
{
int ret = 0;
if (!skb || !skb->data)
return -EINVAL;
if (!skb->len || ((skb->len + BTM_HEADER_LEN) > BTM_UPLD_SIZE)) {
BT_ERR("Tx Error: Bad skb length %d : %d",
skb->len, BTM_UPLD_SIZE);
return -EINVAL;
}
skb_push(skb, BTM_HEADER_LEN);
/* header type: byte[3]
* HCI_COMMAND = 1, ACL_DATA = 2, SCO_DATA = 3, 0xFE = Vendor
* header length: byte[2][1][0]
*/
skb->data[0] = (skb->len & 0x0000ff);
skb->data[1] = (skb->len & 0x00ff00) >> 8;
skb->data[2] = (skb->len & 0xff0000) >> 16;
skb->data[3] = bt_cb(skb)->pkt_type;
if (priv->hw_host_to_card)
ret = priv->hw_host_to_card(priv, skb->data, skb->len);
return ret;
} | false | false | false | false | false | 0 |
gt_sain_incrementfirstSstar(GtSainseq *sainseq,
unsigned long *suftab)
{
unsigned long charidx, sum = 0;
for (charidx = 0; charidx < sainseq->numofchars; charidx++)
{
sum += sainseq->bucketsize[charidx];
gt_assert(sainseq->bucketfillptr[charidx] <= sum);
if (sainseq->bucketfillptr[charidx] < sum)
{
suftab[sainseq->bucketfillptr[charidx]] += sainseq->totallength;
}
sainseq->roundtable[charidx] = 0;
sainseq->roundtable[charidx+sainseq->numofchars] = 0;
}
} | false | false | false | false | false | 0 |
jbig2_decode_generic_template0_TPGDON(Jbig2Ctx *ctx,
Jbig2Segment *segment,
const Jbig2GenericRegionParams *params,
Jbig2ArithState *as,
Jbig2Image *image,
Jbig2ArithCx *GB_stats)
{
const int GBW = image->width;
const int GBH = image->height;
uint32_t CONTEXT;
int x, y;
bool bit;
int LTP = 0;
for (y = 0; y < GBH; y++)
{
LTP ^= jbig2_arith_decode(as, &GB_stats[0x9B25]);
if (!LTP) {
for (x = 0; x < GBW; x++) {
CONTEXT = jbig2_image_get_pixel(image, x - 1, y);
CONTEXT |= jbig2_image_get_pixel(image, x - 2, y) << 1;
CONTEXT |= jbig2_image_get_pixel(image, x - 3, y) << 2;
CONTEXT |= jbig2_image_get_pixel(image, x - 4, y) << 3;
CONTEXT |= jbig2_image_get_pixel(image, x + params->gbat[0],
y + params->gbat[1]) << 4;
CONTEXT |= jbig2_image_get_pixel(image, x + 2, y - 1) << 5;
CONTEXT |= jbig2_image_get_pixel(image, x + 1, y - 1) << 6;
CONTEXT |= jbig2_image_get_pixel(image, x , y - 1) << 7;
CONTEXT |= jbig2_image_get_pixel(image, x - 1, y - 1) << 8;
CONTEXT |= jbig2_image_get_pixel(image, x - 2, y - 1) << 9;
CONTEXT |= jbig2_image_get_pixel(image, x + params->gbat[2],
y + params->gbat[3]) << 10;
CONTEXT |= jbig2_image_get_pixel(image, x + params->gbat[4],
y + params->gbat[5]) << 11;
CONTEXT |= jbig2_image_get_pixel(image, x + 1, y - 2) << 12;
CONTEXT |= jbig2_image_get_pixel(image, x , y - 2) << 13;
CONTEXT |= jbig2_image_get_pixel(image, x - 1, y - 2) << 14;
CONTEXT |= jbig2_image_get_pixel(image, x + params->gbat[6],
y + params->gbat[7]) << 15;
bit = jbig2_arith_decode(as, &GB_stats[CONTEXT]);
jbig2_image_set_pixel(image, x, y, bit);
}
} else {
copy_prev_row(image, y);
}
}
return 0;
} | false | false | false | false | false | 0 |
_idn2_contexto_rule (const uint32_t * label, size_t llen, size_t pos)
{
uint32_t cp = label[pos];
if (!_idn2_contexto_p (cp))
return IDN2_OK;
switch (cp)
{
case 0x00B7:
/* MIDDLE DOT */
if (llen < 3)
return IDN2_CONTEXTO;
if (pos == 0 || pos == llen - 1)
return IDN2_CONTEXTO;
if (label[pos - 1] == 0x006C && label[pos + 1] == 0x006C)
return IDN2_OK;
return IDN2_CONTEXTO;
break;
case 0x0375:
/* GREEK LOWER NUMERAL SIGN (KERAIA) */
if (pos == llen - 1)
return IDN2_CONTEXTO;
if (strcmp (uc_script (label[pos + 1])->name, "Greek") == 0)
return IDN2_OK;
return IDN2_CONTEXTO;
break;
case 0x05F3:
/* HEBREW PUNCTUATION GERESH */
case 0x05F4:
/* HEBREW PUNCTUATION GERSHAYIM */
if (pos == 0)
return IDN2_CONTEXTO;
if (strcmp (uc_script (label[pos - 1])->name, "Hebrew") == 0)
return IDN2_OK;
return IDN2_CONTEXTO;
break;
case 0x0660:
case 0x0661:
case 0x0662:
case 0x0663:
case 0x0664:
case 0x0665:
case 0x0666:
case 0x0667:
case 0x0668:
case 0x0669:
{
/* ARABIC-INDIC DIGITS */
size_t i;
for (i = 0; i < llen; i++)
if (label[i] >= 0x6F0 && label[i] <= 0x06F9)
return IDN2_CONTEXTO;
return IDN2_OK;
break;
}
case 0x06F0:
case 0x06F1:
case 0x06F2:
case 0x06F3:
case 0x06F4:
case 0x06F5:
case 0x06F6:
case 0x06F7:
case 0x06F8:
case 0x06F9:
{
/* EXTENDED ARABIC-INDIC DIGITS */
size_t i;
for (i = 0; i < llen; i++)
if (label[i] >= 0x660 && label[i] <= 0x0669)
return IDN2_CONTEXTO;
return IDN2_OK;
break;
}
case 0x30FB:
{
/* KATAKANA MIDDLE DOT */
size_t i;
bool script_ok = false;
for (i = 0; !script_ok && i < llen; i++)
if (strcmp (uc_script (label[i])->name, "Hiragana") == 0
|| strcmp (uc_script (label[i])->name, "Katakana") == 0
|| strcmp (uc_script (label[i])->name, "Han") == 0)
script_ok = true;
if (script_ok)
return IDN2_OK;
return IDN2_CONTEXTO;
break;
}
}
return IDN2_CONTEXTO_NO_RULE;
} | false | false | false | false | false | 0 |
replace_jmp(Statement *spt, void *param)
{
Label_table **buf = param;
Quadruple *qpt;
for (qpt = spt->qr_head; qpt != NULL; qpt = qpt->next) {
if (qpt->ope == OPE_LABEL) continue;
int i;
for (i = 0; i < 4; i++) {
Operand *op = qpt->op[i];
if (op == NULL) break;
if (op->kind == KIND_LABEL) {
if (buf[op->entry] != NULL) {
Label_table *new_label = buf[op->entry];
op->entry = new_label->label_no;
op->tbl.l = new_label;
}
}
}
}
} | false | false | false | false | false | 0 |
list_select(GtkWidget *w, gint row, gint column, GdkEventButton *eb, gpointer data)
{
struct gui_object *obj;
GdkPixmap *pm = NULL;
GdkBitmap *bm = NULL;
char *text;
guint8 spacing;
obj = gtk_clist_get_row_data(GTK_CLIST(w), row);
if (!eb)
return;
current = obj;
if (eb->button == 1) {
gtk_clist_get_pixtext(GTK_CLIST(w), row, 0, &text, &spacing, &pm, &bm);
gtk_drag_set_default_icon(gdk_colormap_get_system(), pm, bm, 10, 10);
gastman_object_select(obj->pvt);
} else if (eb->button == 3) {
bbutton = eb->button;
btime = eb->time;
gastman_right_click(obj->pvt);
}
} | false | false | false | false | false | 0 |
initialize_basics(void)
{
static int initialized;
int err;
if (!initialized)
{
initialized = 1;
err = ath_mutex_init (&pool_lock);
if (err)
log_fatal ("failed to create the pool lock: %s\n", strerror (err) );
err = ath_mutex_init (&nonce_buffer_lock);
if (err)
log_fatal ("failed to create the nonce buffer lock: %s\n",
strerror (err) );
#ifdef USE_RANDOM_DAEMON
_gcry_daemon_initialize_basics ();
#endif /*USE_RANDOM_DAEMON*/
/* Make sure that we are still using the values we have
traditionally used for the random levels. */
gcry_assert (GCRY_WEAK_RANDOM == 0
&& GCRY_STRONG_RANDOM == 1
&& GCRY_VERY_STRONG_RANDOM == 2);
}
} | false | false | false | false | false | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.