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 |
|---|---|---|---|---|---|---|
newgame()
{
int i;
#ifdef MFLOPPY
gameDiskPrompt();
#endif
flags.ident = 1;
for (i = 0; i < NUMMONS; i++)
mvitals[i].mvflags = mons[i].geno & G_NOCORPSE;
init_objects(); /* must be before u_init() */
flags.pantheon = -1; /* role_init() will reset this */
role_init(); /* must be before init_dungeons(), u_init(),
* and init_artifacts() */
init_dungeons(); /* must be before u_init() to avoid rndmonst()
* creating odd monsters for any tins and eggs
* in hero's initial inventory */
init_artifacts(); /* before u_init() in case $WIZKIT specifies
* any artifacts */
u_init();
#ifndef NO_SIGNAL
(void) signal(SIGINT, (SIG_RET_TYPE) done1);
#endif
#ifdef NEWS
if(iflags.news) display_file(NEWS, FALSE);
#endif
load_qtlist(); /* load up the quest text info */
/* quest_init();*/ /* Now part of role_init() */
mklev();
u_on_upstairs();
vision_reset(); /* set up internals for level (after mklev) */
check_special_room(FALSE);
flags.botlx = 1;
/* Move the monster from under you or else
* makedog() will fail when it calls makemon().
* - ucsfcgl!kneller
*/
if(MON_AT(u.ux, u.uy)) mnexto(m_at(u.ux, u.uy));
(void) makedog();
docrt();
if (flags.legacy) {
flush_screen(1);
com_pager(1);
}
#ifdef INSURANCE
save_currentstate();
#endif
program_state.something_worth_saving++; /* useful data now exists */
/* Success! */
welcome(TRUE);
return;
} | false | false | false | false | false | 0 |
shell_exec_search(struct gnutella_shell *sh, int argc, const char *argv[])
{
shell_check(sh);
g_assert(argv);
g_assert(argc > 0);
if (argc < 2)
goto error;
if (0 == ascii_strcasecmp(argv[1], "add")) {
if (argc < 3) {
shell_set_msg(sh, _("Query string missing"));
goto error;
}
if (!utf8_is_valid_string(argv[2])) {
shell_set_msg(sh, _("Query string is not UTF-8 encoded"));
goto error;
}
if (gcu_search_gui_new_search(argv[2], 0)) {
shell_set_msg(sh, _("Search added"));
} else {
shell_set_msg(sh, _("The search could not be created"));
goto error;
}
} else {
shell_set_formatted(sh, _("Unknown operation \"%s\""), argv[1]);
goto error;
}
return REPLY_READY;
error:
return REPLY_ERROR;
} | false | false | false | false | false | 0 |
GetCellId( int displayPos[2] )
{
if (this->EnableVertexPicking)
{
return -1;
}
this->Update( displayPos );
return this->CellId;
} | false | false | false | false | false | 0 |
load_image_from_file_not_ply(int lp,
const char *file)
{
GdkPixbuf *impixfile;
#if GTK_MAJOR_VERSION < 2
impixfile= gdk_pixbuf_new_from_file(file);
if (impixfile ==NULL) {
showerr(file,_("\
the attempt to load the image file %s as produced error: %s"));
return FALSE;
}
#else
{
GError *err=NULL;
impixfile= gdk_pixbuf_new_from_file(file,&err);
if(err) {
show_error((err)->message);g_error_free (err);
return FALSE;
}
}
#endif
{
sp->im_width[lp]= gdk_pixbuf_get_width(impixfile);
sp->im_height[lp]= gdk_pixbuf_get_height(impixfile);
gtk_subimasel_reset( &(sp->subimasel[lp]) ,
sp->im_width[lp],
sp->im_height[lp]);
#ifndef RESCALE_RELOAD_LESS_MEM
destroy_pixbuf(lp,PIXLOADED );
#endif
destroy_pixmap(lp,PIXLOADED );
subimages_spinbuttons_set(lp);
subimage2affines(lp);
sp->im_loaded_pixbuf[lp]=impixfile;
create__pixmap(lp,PIXLOADED );
render_pixmap(lp, PIXLOADED);
scale_loaded_pixbuf_et_rrggbb(lp);
render_pixmap(lp, PIXSUBIMAGE);
//FIXME do we do this here?
//render_pixmap(lp, PIXWARPED);
#ifdef RESCALE_RELOAD_LESS_MEM
destroy_pixbuf(lp,PIXLOADED );
impixfile=NULL;
#endif
if(sp->im_filename_in[lp]!=NULL)
g_free(sp->im_filename_in[lp]);
sp->im_filename_in[lp]=g_strdup(file);
{
gchar * N = compute_title (lp);
gtk_window_set_title ( GTK_WINDOW(sp->im_widget[lp]), N);
g_free(N);
}
set_editview( lp, EDITVIEW_EYES);
drawingarea_configure(lp);
MY_GTK_DRAW( sp-> im_widget[lp]);
return TRUE;
}
} | false | false | false | false | false | 0 |
WildCardListMatch(wxString list, wxString name, bool strip)
{
if(list==_T("")) //any empty list matches everything by default
return true;
wxString wildlist=list;
wxString wild=list.BeforeFirst(';');
if(strip)
wild=wild.Strip(wxString::both);
while(wildlist!=_T(""))
{
if(wild!=_T("") && ::wxMatchWild(wild,name))
return true;
wildlist=wildlist.AfterFirst(';');
wild=wildlist.BeforeFirst(';');
if(strip)
wild=wild.Strip(wxString::both);
}
return false;
} | false | false | false | false | false | 0 |
propagate_block (basic_block bb, regset live, regset local_set,
regset cond_local_set, int flags)
{
struct propagate_block_info *pbi;
rtx insn, prev;
int changed;
pbi = init_propagate_block_info (bb, live, local_set, cond_local_set, flags);
if (flags & PROP_REG_INFO)
{
int i;
/* Process the regs live at the end of the block.
Mark them as not local to any one basic block. */
EXECUTE_IF_SET_IN_REG_SET (live, 0, i,
{ REG_BASIC_BLOCK (i) = REG_BLOCK_GLOBAL; });
}
/* Scan the block an insn at a time from end to beginning. */
changed = 0;
for (insn = BB_END (bb); ; insn = prev)
{
/* If this is a call to `setjmp' et al, warn if any
non-volatile datum is live. */
if ((flags & PROP_REG_INFO)
&& GET_CODE (insn) == CALL_INSN
&& find_reg_note (insn, REG_SETJMP, NULL))
IOR_REG_SET (regs_live_at_setjmp, pbi->reg_live);
prev = propagate_one_insn (pbi, insn);
if (!prev)
changed |= insn != get_insns ();
else
changed |= NEXT_INSN (prev) != insn;
if (insn == BB_HEAD (bb))
break;
}
free_propagate_block_info (pbi);
return changed;
} | false | false | false | true | true | 1 |
__readVertices()
{
std::set<size_t> references;
VerticesSet& V = *__vertices;
for (size_t i=0; i<V.numberOfVertices(); ++i) {
const double x = __getReal();
const double y = __getReal();
const double z = __getReal();
const size_t ref = __getInteger();
references.insert(ref);
V[i] = Vertex(x,y,z, ref);
}
this->__writeReferences(references, "Vertices");
} | false | false | false | false | false | 0 |
addICUPatterns(const Locale& locale, UErrorCode& status) {
UnicodeString dfPattern;
UnicodeString conflictingString;
UDateTimePatternConflict conflictingStatus;
DateFormat* df;
if (U_FAILURE(status)) {
return;
}
// Load with ICU patterns
for (int32_t i=DateFormat::kFull; i<=DateFormat::kShort; i++) {
DateFormat::EStyle style = (DateFormat::EStyle)i;
df = DateFormat::createDateInstance(style, locale);
if (df != NULL && df->getDynamicClassID() == SimpleDateFormat::getStaticClassID()) {
SimpleDateFormat* sdf = (SimpleDateFormat*)df;
conflictingStatus = addPattern(sdf->toPattern(dfPattern), FALSE, conflictingString, status);
}
// TODO Maybe we should return an error when the date format isn't simple.
delete df;
if (U_FAILURE(status)) {
return;
}
df = DateFormat::createTimeInstance(style, locale);
if (df != NULL && df->getDynamicClassID() == SimpleDateFormat::getStaticClassID()) {
SimpleDateFormat* sdf = (SimpleDateFormat*)df;
conflictingStatus = addPattern(sdf->toPattern(dfPattern), FALSE, conflictingString, status);
// HACK for hh:ss
if ( i==DateFormat::kMedium ) {
hackPattern = dfPattern;
}
}
// TODO Maybe we should return an error when the date format isn't simple.
delete df;
if (U_FAILURE(status)) {
return;
}
}
} | false | false | false | false | false | 0 |
bt_ctf_field_type_structure_get_type(
struct bt_ctf_field_type_structure *structure,
const char *name)
{
struct bt_ctf_field_type *type = NULL;
struct structure_field *field;
GQuark name_quark = g_quark_try_string(name);
size_t index;
if (!name_quark) {
goto end;
}
if (!g_hash_table_lookup_extended(structure->field_name_to_index,
GUINT_TO_POINTER(name_quark), NULL, (gpointer *)&index)) {
goto end;
}
field = structure->fields->pdata[index];
type = field->type;
end:
return type;
} | false | false | false | false | false | 0 |
aachar_to_num(ch)
char ch;
{
if (ch >= 97 && ch <= 122) ch = ch - 32; /* Make letters upper case */
switch (ch) {
case 'A': return(0);
case 'R': return(1);
case 'N': return(2);
case 'D': return(3);
case 'B': return(3);
case 'C': return(4);
case 'Q': return(5);
case 'E': return(6);
case 'Z': return(6);
case 'G': return(7);
case 'H': return(8);
case 'I': return(9);
case 'L': return(10);
case 'K': return(11);
case 'M': return(12);
case 'F': return(13);
case 'P': return(14);
case 'S': return(15);
case 'T': return(16);
case 'W': return(17);
case 'Y': return(18);
case 'V': return(19);
case 'J': return(20);
case 'O': return(20);
case 'X': return(20);
case '.': return(-1);
default: return(-1);
}
} | false | false | false | false | false | 0 |
login_write (struct logininfo *li)
{
#if !defined(HAVE_CYGWIN) && !defined(DONT_WARN_ON_NONROOT)
if ((int)geteuid() != 0) {
dropbear_log(LOG_WARNING,
"Attempt to write login records by non-root user (aborting)");
return 1;
}
#endif
/* set the timestamp */
login_set_current_time(li);
#ifdef USE_LOGIN
syslogin_write_entry(li);
#endif
#ifdef USE_LASTLOG
if (li->type == LTYPE_LOGIN) {
lastlog_write_entry(li);
}
#endif
#ifdef USE_UTMP
utmp_write_entry(li);
#endif
#ifdef USE_WTMP
wtmp_write_entry(li);
#endif
#ifdef USE_UTMPX
utmpx_write_entry(li);
#endif
#ifdef USE_WTMPX
wtmpx_write_entry(li);
#endif
return 0;
} | false | false | false | false | false | 0 |
fs2netd_update_valid_tables()
{
int rc;
int hacked = 0;
if ( !Logged_in ) {
return -1;
}
// if there are no tables to check with then bail
if ( Table_valid_status.empty() ) {
return -1;
}
// if we're a standalone, show a dialog saying "validating tables"
if (Game_mode & GM_STANDALONE_SERVER) {
std_create_gen_dialog("Validating tables");
std_gen_set_text("Querying FS2NetD:", 1);
}
do_full_packet = true;
In_process = true;
if (Is_standalone) {
do { rc = fs2netd_update_valid_tables_do(); } while (!rc);
} else {
rc = popup_till_condition(fs2netd_update_valid_tables_do, XSTR("&Cancel", 779), XSTR("Starting table validation", 1592));
}
In_process = false;
Local_timeout = -1;
switch (rc) {
// canceled by popup
case 0:
return -1;
// timed out
case 1: {
if ( !Is_standalone ) {
popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR("Table validation timed out!", 1593));
}
return -1;
}
// no tables
case 2: {
if ( !Is_standalone ) {
popup(PF_USE_AFFIRMATIVE_ICON, 1, POPUP_OK, XSTR("No tables are available from the server for validation!", 1594));
}
return -1;
}
}
// output the status of table validity to multi.log
for (SCP_vector<crc_valid_status>::iterator tvs = Table_valid_status.begin(); tvs != Table_valid_status.end(); ++tvs) {
if (tvs->valid) {
ml_printf("FS2NetD Table Check: '%s' -- Valid!", tvs->name);
} else {
ml_printf("FS2NetD Table Check: '%s' -- INVALID (0x%x)!", tvs->name, tvs->crc32);
hacked = 1;
}
}
// if we're a standalone, kill the validate dialog
if (Game_mode & GM_STANDALONE_SERVER) {
std_destroy_gen_dialog();
}
return hacked;
} | false | false | false | false | false | 0 |
SparseMatrix_exclude_submatrix(SparseMatrix A, int nrow, int ncol, int *rindices, int *cindices){
/* get a submatrix by excluding rows and columns */
int *r, *c, nr, nc, i;
SparseMatrix B;
if (nrow <= 0 && ncol <= 0) return A;
r = MALLOC(sizeof(int)*((size_t)A->m));
c = MALLOC(sizeof(int)*((size_t)A->n));
for (i = 0; i < A->m; i++) r[i] = i;
for (i = 0; i < A->n; i++) c[i] = i;
for (i = 0; i < nrow; i++) {
if (rindices[i] >= 0 && rindices[i] < A->m){
r[rindices[i]] = -1;
}
}
for (i = 0; i < ncol; i++) {
if (cindices[i] >= 0 && cindices[i] < A->n){
c[cindices[i]] = -1;
}
}
nr = nc = 0;
for (i = 0; i < A->m; i++) {
if (r[i] > 0) r[nr++] = r[i];
}
for (i = 0; i < A->n; i++) {
if (c[i] > 0) c[nc++] = c[i];
}
B = SparseMatrix_get_submatrix(A, nr, nc, r, c);
FREE(r);
FREE(c);
return B;
} | false | false | false | false | false | 0 |
orefdat_(fortint* ksec1) {
/*
// Fortran-callable:
//
// INTEGER OREFDAT
// EXTERNAL OREFDAT
//
// INDEX = OREFDAT(KSEC1)
//
// where KSEC1 contains GRIB section 1 after unpacking by GRIBEX.
//
// Returns the index of the reference date in the post-auxiliary array in
// ECMWF local definition 4 (ocean data).
//
// Returns -1 if
// - local definition 4 is not in use, or
// - the post-auxiliary array is empty, or
// - the post-auxiliary array does not contain a reference date.
*/
fortint offset;
if( ksec1[36] != 4 ) return -1;
offset = 74 + ksec1[70] + ksec1[71] + ksec1[72] + ksec1[73];
if( offset == 0 ) return -1;
if( ksec1[offset] < 5 )
return -1;
else
return (offset+5);
} | false | false | false | false | false | 0 |
config_rename_kids( CfEntryInfo *ce )
{
CfEntryInfo *ce2;
struct berval rdn, nrdn;
for (ce2 = ce->ce_kids; ce2; ce2 = ce2->ce_sibs) {
struct berval newdn, newndn;
dnRdn ( &ce2->ce_entry->e_name, &rdn );
dnRdn ( &ce2->ce_entry->e_nname, &nrdn );
build_new_dn( &newdn, &ce->ce_entry->e_name, &rdn, NULL );
build_new_dn( &newndn, &ce->ce_entry->e_nname, &nrdn, NULL );
free( ce2->ce_entry->e_name.bv_val );
free( ce2->ce_entry->e_nname.bv_val );
ce2->ce_entry->e_name = newdn;
ce2->ce_entry->e_nname = newndn;
config_rename_kids( ce2 );
}
} | false | false | false | false | false | 0 |
getUnitOrNull() const {
const DIE *p = this;
while (p) {
if (p->getTag() == dwarf::DW_TAG_compile_unit ||
p->getTag() == dwarf::DW_TAG_type_unit)
return p;
p = p->getParent();
}
return nullptr;
} | false | false | false | false | false | 0 |
ican3_handle_message(struct ican3_dev *mod, struct ican3_msg *msg)
{
netdev_dbg(mod->ndev, "%s: modno %d spec 0x%.2x len %d bytes\n", __func__,
mod->num, msg->spec, le16_to_cpu(msg->len));
switch (msg->spec) {
case MSG_IDVERS:
ican3_handle_idvers(mod, msg);
break;
case MSG_MSGLOST:
case MSG_FMSGLOST:
ican3_handle_msglost(mod, msg);
break;
case MSG_CEVTIND:
ican3_handle_cevtind(mod, msg);
break;
case MSG_INQUIRY:
ican3_handle_inquiry(mod, msg);
break;
default:
ican3_handle_unknown_message(mod, msg);
break;
}
} | false | false | false | false | false | 0 |
acl_get_permset(acl_entry_t entry_d, acl_permset_t *permset_p)
{
acl_entry_obj *entry_obj_p = ext2int(acl_entry, entry_d);
if (!entry_obj_p) {
if (permset_p)
*permset_p = NULL;
return -1;
}
if (!permset_p) {
errno = EINVAL;
return -1;
}
*permset_p = int2ext(&entry_obj_p->eperm);
return 0;
} | false | false | false | false | false | 0 |
usage() const
{
QString usage = fakeDevice()->property("usage").toString();
if (usage == "filesystem")
{
return Solid::StorageVolume::FileSystem;
}
else if (usage == "partitiontable")
{
return Solid::StorageVolume::PartitionTable;
}
else if (usage == "raid")
{
return Solid::StorageVolume::Raid;
}
else if (usage == "unused")
{
return Solid::StorageVolume::Unused;
}
else
{
return Solid::StorageVolume::Other;
}
} | false | false | false | false | false | 0 |
px_put_u(stream * s, uint i)
{
if (i <= 255)
px_put_ub(s, (byte)i);
else
px_put_us(s, i);
} | false | false | false | false | false | 0 |
__ecereMethod___ecereNameSpace__ecere__com__Container_Free(struct __ecereNameSpace__ecere__com__Instance * this)
{
struct __ecereNameSpace__ecere__com__IteratorPointer * i;
while(i = ((struct __ecereNameSpace__ecere__com__IteratorPointer * (*)(struct __ecereNameSpace__ecere__com__Instance *))__extension__ ({
struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = this;
__internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__com__Container->_vTbl;
})[__ecereVMethodID___ecereNameSpace__ecere__com__Container_GetFirst])(this))
((void (*)(struct __ecereNameSpace__ecere__com__Instance *, struct __ecereNameSpace__ecere__com__IteratorPointer * i))__extension__ ({
struct __ecereNameSpace__ecere__com__Instance * __internal_ClassInst = this;
__internal_ClassInst ? __internal_ClassInst->_vTbl : __ecereClass___ecereNameSpace__ecere__com__Container->_vTbl;
})[__ecereVMethodID___ecereNameSpace__ecere__com__Container_Delete])(this, i);
} | false | false | false | false | false | 0 |
part_at(int dx, int dy)
{
for (int i = 0; i < external_parts.size(); i++)
{
int p = external_parts[i];
if (parts[p].precalc_dx[0] == dx &&
parts[p].precalc_dy[0] == dy)
return p;
}
return -1;
} | false | false | false | false | false | 0 |
chmod (const char *path, mode_t mode)
{
if (!libc_chmod)
clickpreload_init (); /* also needed for package_path */
clickpreload_assert_path_in_instdir ("chmod", path);
mode |= S_IWUSR;
return (*libc_chmod) (path, mode);
} | false | false | false | false | false | 0 |
INET_rresolve(struct sockaddr_in *s_in, int numeric, uint32_t netmask)
{
/* addr-to-name cache */
struct addr {
struct addr *next;
struct sockaddr_in addr;
int host;
char name[1];
};
static struct addr *cache = NULL;
struct addr *pn;
char *name;
uint32_t ad, host_ad;
int host = 0;
if (s_in->sin_family != AF_INET) {
#ifdef DEBUG
bb_error_msg("rresolve: unsupported address family %d!",
s_in->sin_family);
#endif
errno = EAFNOSUPPORT;
return NULL;
}
ad = s_in->sin_addr.s_addr;
#ifdef DEBUG
bb_error_msg("rresolve: %08x, mask %08x, num %08x", (unsigned)ad, netmask, numeric);
#endif
if (ad == INADDR_ANY) {
if ((numeric & 0x0FFF) == 0) {
if (numeric & 0x8000)
return xstrdup("default");
return xstrdup("*");
}
}
if (numeric & 0x0FFF)
return xstrdup(inet_ntoa(s_in->sin_addr));
if ((ad & (~netmask)) != 0 || (numeric & 0x4000))
host = 1;
pn = cache;
while (pn) {
if (pn->addr.sin_addr.s_addr == ad && pn->host == host) {
#ifdef DEBUG
bb_error_msg("rresolve: found %s %08x in cache",
(host ? "host" : "net"), (unsigned)ad);
#endif
return xstrdup(pn->name);
}
pn = pn->next;
}
host_ad = ntohl(ad);
name = NULL;
if (host) {
struct hostent *ent;
#ifdef DEBUG
bb_error_msg("gethostbyaddr (%08x)", (unsigned)ad);
#endif
ent = gethostbyaddr((char *) &ad, 4, AF_INET);
if (ent)
name = xstrdup(ent->h_name);
} else if (ENABLE_FEATURE_ETC_NETWORKS) {
struct netent *np;
#ifdef DEBUG
bb_error_msg("getnetbyaddr (%08x)", (unsigned)host_ad);
#endif
np = getnetbyaddr(host_ad, AF_INET);
if (np)
name = xstrdup(np->n_name);
}
if (!name)
name = xstrdup(inet_ntoa(s_in->sin_addr));
pn = xmalloc(sizeof(*pn) + strlen(name)); /* no '+ 1', it's already accounted for */
pn->next = cache;
pn->addr = *s_in;
pn->host = host;
strcpy(pn->name, name);
cache = pn;
return name;
} | true | true | false | false | false | 1 |
gedit_document_get_metadata (GeditDocument *doc,
const gchar *key)
{
gchar *value = NULL;
g_return_val_if_fail (GEDIT_IS_DOCUMENT (doc), NULL);
g_return_val_if_fail (key != NULL, NULL);
if (doc->priv->metadata_info && g_file_info_has_attribute (doc->priv->metadata_info,
key))
{
value = g_strdup (g_file_info_get_attribute_string (doc->priv->metadata_info,
key));
}
return value;
} | false | false | false | false | false | 0 |
hexb(const char *s)
{
byte b=*(byte*)s;
b -= '0';
if (b > 9) b -= 'a'-'0'-10;
byte c = *(byte*)(s+1);
c -= '0';
if (c > 9) c -= 'a'-'0'-10;
return (b << 4) + c;
} | false | false | false | false | false | 0 |
edge_scc_exactly(struct isl_sched_edge *edge, int scc)
{
return edge->src->scc == scc && edge->dst->scc == scc;
} | false | false | false | false | false | 0 |
_hdb_find_master_key(uint32_t *mkvno, hdb_master_key mkey)
{
hdb_master_key ret = NULL;
while(mkey) {
if(ret == NULL && mkey->keytab.vno == 0)
ret = mkey;
if(mkvno == NULL) {
if(ret == NULL || mkey->keytab.vno > ret->keytab.vno)
ret = mkey;
} else if((uint32_t)mkey->keytab.vno == *mkvno)
return mkey;
mkey = mkey->next;
}
return ret;
} | false | false | false | false | false | 0 |
new_arena(void)
{
struct arena_object* arenaobj;
uint excess; /* number of bytes above pool alignment */
void *address;
#ifdef PYMALLOC_DEBUG
if (Py_GETENV("PYTHONMALLOCSTATS"))
_PyObject_DebugMallocStats(stderr);
#endif
if (unused_arena_objects == NULL) {
uint i;
uint numarenas;
size_t nbytes;
/* Double the number of arena objects on each allocation.
* Note that it's possible for `numarenas` to overflow.
*/
numarenas = maxarenas ? maxarenas << 1 : INITIAL_ARENA_OBJECTS;
if (numarenas <= maxarenas)
return NULL; /* overflow */
#if SIZEOF_SIZE_T <= SIZEOF_INT
if (numarenas > PY_SIZE_MAX / sizeof(*arenas))
return NULL; /* overflow */
#endif
nbytes = numarenas * sizeof(*arenas);
arenaobj = (struct arena_object *)PyMem_RawRealloc(arenas, nbytes);
if (arenaobj == NULL)
return NULL;
arenas = arenaobj;
/* We might need to fix pointers that were copied. However,
* new_arena only gets called when all the pages in the
* previous arenas are full. Thus, there are *no* pointers
* into the old array. Thus, we don't have to worry about
* invalid pointers. Just to be sure, some asserts:
*/
assert(usable_arenas == NULL);
assert(unused_arena_objects == NULL);
/* Put the new arenas on the unused_arena_objects list. */
for (i = maxarenas; i < numarenas; ++i) {
arenas[i].address = 0; /* mark as unassociated */
arenas[i].nextarena = i < numarenas - 1 ?
&arenas[i+1] : NULL;
}
/* Update globals. */
unused_arena_objects = &arenas[maxarenas];
maxarenas = numarenas;
}
/* Take the next available arena object off the head of the list. */
assert(unused_arena_objects != NULL);
arenaobj = unused_arena_objects;
unused_arena_objects = arenaobj->nextarena;
assert(arenaobj->address == 0);
address = _PyObject_Arena.alloc(_PyObject_Arena.ctx, ARENA_SIZE);
if (address == NULL) {
/* The allocation failed: return NULL after putting the
* arenaobj back.
*/
arenaobj->nextarena = unused_arena_objects;
unused_arena_objects = arenaobj;
return NULL;
}
arenaobj->address = (uptr)address;
++narenas_currently_allocated;
++ntimes_arena_allocated;
if (narenas_currently_allocated > narenas_highwater)
narenas_highwater = narenas_currently_allocated;
arenaobj->freepools = NULL;
/* pool_address <- first pool-aligned address in the arena
nfreepools <- number of whole pools that fit after alignment */
arenaobj->pool_address = (block*)arenaobj->address;
arenaobj->nfreepools = ARENA_SIZE / POOL_SIZE;
assert(POOL_SIZE * arenaobj->nfreepools == ARENA_SIZE);
excess = (uint)(arenaobj->address & POOL_SIZE_MASK);
if (excess != 0) {
--arenaobj->nfreepools;
arenaobj->pool_address += POOL_SIZE - excess;
}
arenaobj->ntotalpools = arenaobj->nfreepools;
return arenaobj;
} | false | false | false | false | false | 0 |
removeview ()
{
if ( !viewOnMap )
fatalError ("void Vehicle :: removeview - the vehicle is not viewing the map");
tcomputevehicleview bes ( gamemap );
bes.init( this, -1 );
bes.startsearch();
viewOnMap = false;
} | false | false | false | false | false | 0 |
clone_req_option_list (ReqOption *req_option)
{
ReqOption *new_req_option;
if (req_option == NULL)
return NULL;
new_req_option = (ReqOption *) xmalloc (sizeof (ReqOption));
new_req_option->or_option_terms = NULL;
new_req_option->next = NULL;
new_req_option->or_option_terms =
clone_req_or_option_list (req_option->or_option_terms);
new_req_option->next = clone_req_option_list (req_option->next);
return new_req_option;
} | false | false | false | false | false | 0 |
get_htc_epid_queue(struct ath9k_htc_priv *priv, u8 epid)
{
struct ath_common *common = ath9k_hw_common(priv->ah);
struct sk_buff_head *epid_queue = NULL;
if (epid == priv->mgmt_ep)
epid_queue = &priv->tx.mgmt_ep_queue;
else if (epid == priv->cab_ep)
epid_queue = &priv->tx.cab_ep_queue;
else if (epid == priv->data_be_ep)
epid_queue = &priv->tx.data_be_queue;
else if (epid == priv->data_bk_ep)
epid_queue = &priv->tx.data_bk_queue;
else if (epid == priv->data_vi_ep)
epid_queue = &priv->tx.data_vi_queue;
else if (epid == priv->data_vo_ep)
epid_queue = &priv->tx.data_vo_queue;
else
ath_err(common, "Invalid EPID: %d\n", epid);
return epid_queue;
} | false | false | false | false | false | 0 |
GC_initiate_gc()
{
if (GC_dirty_maintained) GC_read_dirty();
# ifdef STUBBORN_ALLOC
GC_read_changed();
# endif
# ifdef CHECKSUMS
{
extern void GC_check_dirty();
if (GC_dirty_maintained) GC_check_dirty();
}
# endif
GC_n_rescuing_pages = 0;
if (GC_mark_state == MS_NONE) {
GC_mark_state = MS_PUSH_RESCUERS;
} else if (GC_mark_state != MS_INVALID) {
ABORT("unexpected state");
} /* else this is really a full collection, and mark */
/* bits are invalid. */
scan_ptr = 0;
} | false | false | false | false | false | 0 |
vpd_macaddress_get(adapter_t *adapter, int index, u8 mac_addr[])
{
struct chelsio_vpd_t vpd;
if (t1_eeprom_vpd_get(adapter, &vpd))
return 1;
memcpy(mac_addr, vpd.mac_base_address, 5);
mac_addr[5] = vpd.mac_base_address[5] + index;
return 0;
} | false | true | false | false | false | 1 |
huge_ralloc(void *ptr, size_t oldsize, size_t size, size_t extra,
size_t alignment, bool zero)
{
void *ret;
size_t copysize;
/* Try to avoid moving the allocation. */
ret = huge_ralloc_no_move(ptr, oldsize, size, extra);
if (ret != NULL)
return (ret);
/*
* size and oldsize are different enough that we need to use a
* different size class. In that case, fall back to allocating new
* space and copying.
*/
if (alignment > chunksize)
ret = huge_palloc(size + extra, alignment, zero);
else
ret = huge_malloc(size + extra, zero);
if (ret == NULL) {
if (extra == 0)
return (NULL);
/* Try again, this time without extra. */
if (alignment > chunksize)
ret = huge_palloc(size, alignment, zero);
else
ret = huge_malloc(size, zero);
if (ret == NULL)
return (NULL);
}
/*
* Copy at most size bytes (not size+extra), since the caller has no
* expectation that the extra bytes will be reliably preserved.
*/
copysize = (size < oldsize) ? size : oldsize;
/*
* Use mremap(2) if this is a huge-->huge reallocation, and neither the
* source nor the destination are in swap or dss.
*/
#ifdef JEMALLOC_MREMAP_FIXED
if (oldsize >= chunksize
# ifdef JEMALLOC_SWAP
&& (swap_enabled == false || (chunk_in_swap(ptr) == false &&
chunk_in_swap(ret) == false))
# endif
# ifdef JEMALLOC_DSS
&& chunk_in_dss(ptr) == false && chunk_in_dss(ret) == false
# endif
) {
size_t newsize = huge_salloc(ret);
if (mremap(ptr, oldsize, newsize, MREMAP_MAYMOVE|MREMAP_FIXED,
ret) == MAP_FAILED) {
/*
* Assuming no chunk management bugs in the allocator,
* the only documented way an error can occur here is
* if the application changed the map type for a
* portion of the old allocation. This is firmly in
* undefined behavior territory, so write a diagnostic
* message, and optionally abort.
*/
char buf[BUFERROR_BUF];
buferror(errno, buf, sizeof(buf));
malloc_write("<jemalloc>: Error in mremap(): ");
malloc_write(buf);
malloc_write("\n");
if (opt_abort)
abort();
memcpy(ret, ptr, copysize);
idalloc(ptr);
} else
huge_dalloc(ptr, false);
} else
#endif
{
memcpy(ret, ptr, copysize);
idalloc(ptr);
}
return (ret);
} | false | false | false | false | false | 0 |
open_wave_file(lame_t gfp, char const *inPath, int *enc_delay, int *enc_padding)
{
FILE *musicin;
/* set the defaults from info incase we cannot determine them from file */
lame_set_num_samples(gfp, MAX_U_32_NUM);
if (!strcmp(inPath, "-")) {
lame_set_stream_binary_mode(musicin = stdin); /* Read from standard input. */
}
else {
if ((musicin = lame_fopen(inPath, "rb")) == NULL) {
if (global_ui_config.silent < 10) {
error_printf("Could not find \"%s\".\n", inPath);
}
exit(1);
}
}
if (global_reader.input_format == sf_ogg) {
if (global_ui_config.silent < 10) {
error_printf("sorry, vorbis support in LAME is deprecated.\n");
}
exit(1);
}
else if (global_reader.input_format == sf_raw) {
/* assume raw PCM */
if (global_ui_config.silent < 9) {
console_printf("Assuming raw pcm input file");
if (global_reader.swapbytes)
console_printf(" : Forcing byte-swapping\n");
else
console_printf("\n");
}
global. pcmswapbytes = global_reader.swapbytes;
}
else {
global_reader.input_format = parse_file_header(gfp, musicin);
}
if (global_reader.input_format == sf_mp123) {
if (open_mpeg_file_part2(gfp, musicin, inPath, enc_delay, enc_padding))
return musicin;
exit(2);
}
if (global_reader.input_format == sf_unknown) {
exit(1);
}
if (lame_get_num_samples(gfp) == MAX_U_32_NUM && musicin != stdin) {
double const flen = lame_get_file_size(musicin); /* try to figure out num_samples */
if (flen >= 0) {
/* try file size, assume 2 bytes per sample */
unsigned long fsize = (unsigned long) (flen / (2 * lame_get_num_channels(gfp)));
(void) lame_set_num_samples(gfp, fsize);
global. count_samples_carefully = 0;
}
}
return musicin;
} | false | false | false | false | false | 0 |
drive_ata_check (UDisksLinuxDriveObject *object)
{
gboolean ret;
UDisksLinuxDevice *device;
ret = FALSE;
if (object->devices == NULL)
goto out;
device = object->devices->data;
if (device->ata_identify_device_data != NULL || device->ata_identify_packet_device_data != NULL)
ret = TRUE;
out:
return ret;
} | false | false | false | false | false | 0 |
collection_table_move_focus(CollectTable *ct, gint row, gint col, gboolean relative)
{
gint new_row;
gint new_col;
if (relative)
{
new_row = ct->focus_row;
new_col = ct->focus_column;
new_row += row;
if (new_row < 0) new_row = 0;
if (new_row >= ct->rows) new_row = ct->rows - 1;
while (col != 0)
{
if (col < 0)
{
new_col--;
col++;
}
else
{
new_col++;
col--;
}
if (new_col < 0)
{
if (new_row > 0)
{
new_row--;
new_col = ct->columns - 1;
}
else
{
new_col = 0;
}
}
if (new_col >= ct->columns)
{
if (new_row < ct->rows - 1)
{
new_row++;
new_col = 0;
}
else
{
new_col = ct->columns - 1;
}
}
}
}
else
{
new_row = row;
new_col = col;
if (new_row >= ct->rows)
{
if (ct->rows > 0)
new_row = ct->rows - 1;
else
new_row = 0;
new_col = ct->columns - 1;
}
if (new_col >= ct->columns) new_col = ct->columns - 1;
}
if (new_row == ct->rows - 1)
{
gint l;
/* if we moved beyond the last image, go to the last image */
l = g_list_length(ct->cd->list);
if (ct->rows > 1) l -= (ct->rows - 1) * ct->columns;
if (new_col >= l) new_col = l - 1;
}
if (new_row == -1 || new_col == -1)
{
if (!ct->cd->list) return;
new_row = new_col = 0;
}
collection_table_set_focus(ct, collection_table_find_data(ct, new_row, new_col, NULL));
} | false | false | false | false | false | 0 |
e_ews_connection_get_free_busy (EEwsConnection *cnc,
gint pri,
EEwsRequestCreationCallback free_busy_cb,
gpointer free_busy_user_data,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
ESoapMessage *msg;
GSimpleAsyncResult *simple;
EwsAsyncData *async_data;
g_return_if_fail (cnc != NULL);
msg = e_ews_message_new_with_header (
cnc->priv->uri,
cnc->priv->impersonate_user,
"GetUserAvailabilityRequest",
NULL,
NULL,
cnc->priv->version,
E_EWS_EXCHANGE_2007_SP1,
FALSE);
free_busy_cb (msg, free_busy_user_data);
e_ews_message_write_footer (msg); /*GetUserAvailabilityRequest */
simple = g_simple_async_result_new (
G_OBJECT (cnc), callback, user_data,
e_ews_connection_get_free_busy);
async_data = g_new0 (EwsAsyncData, 1);
g_simple_async_result_set_op_res_gpointer (
simple, async_data, (GDestroyNotify) async_data_free);
e_ews_connection_queue_request (
cnc, msg, get_free_busy_response_cb,
pri, cancellable, simple);
g_object_unref (simple);
} | false | false | false | false | false | 0 |
insert(char *s, int token)
{
int len = strlen(s);
if (lastentry + 1 >= SYMMAX)
error("Symbol table full");
if (lastchar + len + 1 >= STRMAX)
error("Lexemes array full");
lastentry = lastentry + 1;
symtable[lastentry].token = token;
symtable[lastentry].lexptr = &lexemes[lastchar + 1];
lastchar = lastchar + len + 1;
strcpy(symtable[lastentry].lexptr, s);
return &symtable[lastentry];
} | false | false | false | false | false | 0 |
explain_buffer_in_addr(explain_string_buffer_t *sb,
const struct in_addr *addr)
{
explain_string_buffer_puts(sb, inet_ntoa(*addr));
if (ntohl(addr->s_addr) == INADDR_ANY)
{
explain_string_buffer_puts(sb, " INADDR_ANY");
}
else if (ntohl(addr->s_addr) == INADDR_BROADCAST)
{
explain_string_buffer_puts(sb, " INADDR_BROADCAST");
}
else if (explain_option_dialect_specific())
{
struct hostent *hep;
/*
* We make this dialect specific, because different systems will
* have different entries in their /etc/hosts file, or there
* could be transient DNS failures, and these could cause false
* negatives for automated testing.
*/
/* FIXME: gethostbyaddr_r if available */
hep = gethostbyaddr(addr, sizeof(addr), AF_INET);
if (hep)
{
explain_string_buffer_putc(sb, ' ');
explain_string_buffer_puts_quoted(sb, hep->h_name);
}
}
} | false | false | false | false | true | 1 |
load_provided(private_plugin_loader_t *this,
provided_feature_t *provided,
int level)
{
char *name, *provide;
int indent = level * 2;
if (provided->loaded || provided->failed)
{
return;
}
name = provided->entry->plugin->get_name(provided->entry->plugin);
provide = plugin_feature_get_string(provided->feature);
if (provided->loading)
{ /* prevent loop */
DBG3(DBG_LIB, "%*sloop detected while loading %s in plugin '%s'",
indent, "", provide, name);
free(provide);
return;
}
DBG3(DBG_LIB, "%*sloading feature %s in plugin '%s'",
indent, "", provide, name);
free(provide);
provided->loading = TRUE;
load_feature(this, provided, level + 1);
provided->loading = FALSE;
} | false | false | false | false | false | 0 |
travBFS(Gpr_t * state, Expr_t* prog, comp_block * xprog)
{
nodestream nodes;
queue *q;
ndata *nd;
Agnode_t *n;
Agedge_t *cure;
Agedge_t *nxte;
Agraph_t *g = state->curgraph;
q = mkQueue();
nodes.oldroot = 0;
nodes.prev = 0;
while ((n = nextNode(state, &nodes))) {
nd = nData(n);
if (MARKED(nd))
continue;
PUSH(nd, 0);
push(q, n);
while ((n = pull(q))) {
nd = nData(n);
MARK(nd);
POP(nd);
state->tvedge = nd->ine;
if (!evalNode(state, prog, xprog, n)) continue;
for (cure = agfstedge(g, n); cure; cure = nxte) {
nxte = agnxtedge(g, cure, n);
nd = nData(cure->node);
if (MARKED(nd))
continue;
if (!evalEdge(state, prog, xprog, cure)) continue;
if (!ONSTACK(nd)) {
push(q, cure->node);
PUSH(nd,cure);
}
}
}
}
state->tvedge = 0;
freeQ(q);
} | false | false | false | false | false | 0 |
flip_bold(int state)
{
extern char *_setbold, *_clearallattr;
if((pboldstate = state) == TRUE){
if(_setbold != NULL)
putpad(_setbold);
}
else{
if(_clearallattr != NULL){
if(!color_blasted_by_attrs)
color_blasted_by_attrs = pico_get_cur_color();
_force_fg_color_change = _force_bg_color_change = 1;
putpad(_clearallattr);
pinvstate = state;
pulstate = state;
rev_color_state = state;
}
}
} | false | false | false | false | false | 0 |
sync_delete_dir(const char *path)
{
hashtable *ht;
sync_store();
pthread_mutex_lock(&m_sync_ht);
/* remove basename ht from dirname ht */
ht = ht_remove_f(sync_ht, path, free);
pthread_mutex_unlock(&m_sync_ht);
/* no hashtable found */
if (!ht)
return -1;
/* ht should be empty (rmdir is only allowed on empty dirs)
if it isn't, nag a little and free it's content */
if (!ht_empty(ht))
{
ERROR("deleting non-empty dir hashtable");
ht_free_f(ht, NULL, sync_free);
}
if (db_sync_delete_path(path) != DB_OK)
return -1;
return 0;
} | false | false | false | false | false | 0 |
avl_inapply( Avlnode *root, IFP fn, caddr_t arg, int stopflag )
{
if ( root == 0 )
return( AVL_NOMORE );
if ( root->avl_left != 0 )
if ( avl_inapply( root->avl_left, fn, arg, stopflag )
== stopflag )
return( stopflag );
if ( (*fn)( root->avl_data, arg ) == stopflag )
return( stopflag );
if ( root->avl_right == 0 )
return( AVL_NOMORE );
else
return( avl_inapply( root->avl_right, fn, arg, stopflag ) );
} | false | false | false | false | false | 0 |
getSiftKp(
const cv::Mat& gray_img,
const cv::Mat1b& mask_img,
const cv::Mat& depth_img,
cv::Matx33f K,
float t,
std::vector<cv::KeyPoint3D>& keypoints,
cv::Mat1f& descriptors )
{
Lowe::SIFT sift;
sift.PeakThreshInit = 0.01 * t;
Lowe::SIFT::KeyList lowe_kps;
Lowe::SIFT::Image lowe_img(gray_img.rows, gray_img.cols);
for (int y = 0; y < gray_img.rows; y++) {
for (int x = 0; x < gray_img.cols; x++) {
lowe_img.pixels[y][x] = gray_img.at<uchar>(y, x) / 255.0;
}
}
lowe_kps = sift.getKeypoints(lowe_img);
if (lowe_kps.size() == 0) {
return;
}
int num_kp = lowe_kps.size();
std::vector<cv::KeyPoint> kps;
int desc_len = lowe_kps[0].ivec.size();
descriptors.create(num_kp, desc_len);
for (int i = 0; i < num_kp; i++) {
Lowe::SIFT::Key& lowe_kp = lowe_kps[i];
if ( mask_img.rows == 0 || mask_img(lowe_kp.row, lowe_kp.col) )
{
cv::KeyPoint kp;
kp.angle = 0;
kp.class_id = 0;
kp.octave = 0;
kp.pt = cv::Point2f(lowe_kp.col, lowe_kp.row);
kp.response = lowe_kp.strength;
kp.size = lowe_kp.scale * 6.14;
kps.push_back(kp);
for (int j = 0; j < desc_len; j++) {
descriptors[kps.size()-1][j] = lowe_kp.ivec[j];
}
}
}
descriptors = descriptors( cv::Rect( 0, 0, desc_len, kps.size() ) ).clone();
keypoints = makeKp3d(kps);
} | false | false | false | false | false | 0 |
opLineTo(Object args[], int numArgs) {
if (!state->isCurPt()) {
error(getPos(), "No current point in lineto");
return;
}
state->lineTo(args[0].getNum(), args[1].getNum());
} | false | false | false | false | false | 0 |
test_vcard_qp_2_1_parsing (const gchar *vcard_str,
const gchar *expected_text)
{
EVCard *vcard;
EVCardAttribute *attr;
gchar *value;
vcard = e_vcard_new_from_string (vcard_str);
g_return_val_if_fail (vcard != NULL, FALSE);
attr = e_vcard_get_attribute (vcard, "FN");
g_return_val_if_fail (attr != NULL, FALSE);
value = e_vcard_attribute_get_value (attr);
g_return_val_if_fail (value != NULL, FALSE);
g_return_val_if_fail (g_strcmp0 (value, expected_text) == 0, FALSE);
g_object_unref (vcard);
g_free (value);
return TRUE;
} | false | false | false | false | false | 0 |
pj_init_plus( const char *definition )
{
#define MAX_ARG 200
char *argv[MAX_ARG];
char *defn_copy;
int argc = 0, i;
PJ *result;
/* make a copy that we can manipulate */
defn_copy = (char *) pj_malloc( strlen(definition)+1 );
strcpy( defn_copy, definition );
/* split into arguments based on '+' and trim white space */
for( i = 0; defn_copy[i] != '\0'; i++ )
{
switch( defn_copy[i] )
{
case '+':
if( i == 0 || defn_copy[i-1] == '\0' )
{
if( argc+1 == MAX_ARG )
{
pj_errno = -44;
return NULL;
}
argv[argc++] = defn_copy + i + 1;
}
break;
case ' ':
case '\t':
case '\n':
defn_copy[i] = '\0';
break;
default:
/* do nothing */;
}
}
/* perform actual initialization */
result = pj_init( argc, argv );
pj_dalloc( defn_copy );
return result;
} | true | true | false | false | false | 1 |
profile_event_register(enum profile_type type, struct notifier_block *n)
{
int err = -EINVAL;
switch (type) {
case PROFILE_TASK_EXIT:
err = blocking_notifier_chain_register(
&task_exit_notifier, n);
break;
case PROFILE_MUNMAP:
err = blocking_notifier_chain_register(
&munmap_notifier, n);
break;
}
return err;
} | false | false | false | false | false | 0 |
mupdate_ready(void)
{
pthread_mutex_lock(&ready_for_connections_mutex);
if(ready_for_connections) {
syslog(LOG_CRIT, "mupdate_ready called when already ready");
fatal("mupdate_ready called when already ready", EC_TEMPFAIL);
}
ready_for_connections = 1;
pthread_cond_broadcast(&ready_for_connections_cond);
pthread_mutex_unlock(&ready_for_connections_mutex);
} | false | false | false | false | false | 0 |
vfs_getattr (const gchar *path, struct stat *sbuf)
{
GFile *file;
gint result = 0;
debug_print ("vfs_getattr: %s\n", path);
memset (sbuf, 0, sizeof (*sbuf));
sbuf->st_dev = 0; /* dev_t ID of device containing file */
sbuf->st_ino = 0; /* ino_t inode number */
sbuf->st_uid = 0; /* uid_t user ID of owner */
sbuf->st_gid = 0; /* gid_t group ID of owner */
sbuf->st_rdev = 0; /* dev_t device ID (if special file) */
sbuf->st_size = 0; /* off_t total size, in bytes */
sbuf->st_blocks = 0; /* blkcnt_t number of blocks allocated */
sbuf->st_atime = 0; /* time_t time of last access */
sbuf->st_mtime = 0; /* time_t time of last modification */
sbuf->st_ctime = 0; /* time_t time of last status change */
sbuf->st_blksize = 4096; /* blksize_t blocksize for filesystem I/O */
if (path_is_mount_list (path))
{
/* Mount list */
sbuf->st_mode = S_IFDIR | 0500; /* mode_t protection */
sbuf->st_nlink = 2 + g_list_length (mount_list); /* nlink_t number of hard links */
sbuf->st_atime = daemon_creation_time;
sbuf->st_mtime = daemon_creation_time;
sbuf->st_ctime = daemon_creation_time;
sbuf->st_uid = daemon_uid;
sbuf->st_gid = daemon_gid;
}
else if ((file = file_from_full_path (path)))
{
/* Submount */
result = getattr_for_file (file, sbuf);
if (result != 0)
{
FileHandle *fh = get_file_handle_for_path (path);
/* Some backends don't create new files until their stream has
* been closed. So, if the path doesn't exist, but we have a stream
* associated with it, pretend it's there. */
if (fh != NULL)
{
g_mutex_lock (&fh->mutex);
getattr_for_file_handle (fh, sbuf);
g_mutex_unlock (&fh->mutex);
file_handle_unref (fh);
result = 0;
}
}
g_object_unref (file);
}
else
{
result = -ENOENT;
}
debug_print ("vfs_getattr: -> %s\n", g_strerror (-result));
return result;
} | false | false | false | false | false | 0 |
gameport_destroy_port(struct gameport *gameport)
{
struct gameport *child;
child = gameport_get_pending_child(gameport);
if (child) {
gameport_remove_pending_events(child);
put_device(&child->dev);
}
if (gameport->parent) {
gameport->parent->child = NULL;
gameport->parent = NULL;
}
if (device_is_registered(&gameport->dev))
device_del(&gameport->dev);
list_del_init(&gameport->node);
gameport_remove_pending_events(gameport);
put_device(&gameport->dev);
} | false | false | false | false | false | 0 |
tcp_socket_state(int fd, thread_t * thread, char *ipaddress, uint16_t addr_port,
int (*func) (thread_t *))
{
int status;
socklen_t slen;
int ret = 0;
timeval_t timer_min;
/* Handle connection timeout */
if (thread->type == THREAD_WRITE_TIMEOUT) {
DBG("TCP connection timeout to [%s]:%d.\n",
ipaddress, ntohs(addr_port));
close(thread->u.fd);
return connect_timeout;
}
/* Check file descriptor */
slen = sizeof (status);
if (getsockopt
(thread->u.fd, SOL_SOCKET, SO_ERROR, (void *) &status, &slen) < 0)
ret = errno;
/* Connection failed !!! */
if (ret) {
DBG("TCP connection failed to [%s]:%d.\n",
ipaddress, ntohs(addr_port));
close(thread->u.fd);
return connect_error;
}
/* If status = 0, TCP connection to remote host is established.
* Otherwise register checker thread to handle connection in progress,
* and other error code until connection is established.
* Recompute the write timeout (or pending connection).
*/
if (status != 0) {
DBG("TCP connection to [%s]:%d still IN_PROGRESS.\n",
ipaddress, ntohs(addr_port));
timer_min = timer_sub_now(thread->sands);
thread_add_write(thread->master, func, THREAD_ARG(thread)
, thread->u.fd, timer_long(timer_min));
return connect_in_progress;
}
return connect_success;
} | false | false | false | false | false | 0 |
ajStrAssignS(AjPStr* Pstr, const AjPStr str)
{
AjBool ret = ajFalse;
AjPStr thys;
size_t size;
size_t roundsize = STRSIZE;
if(!*Pstr)
{
if(str)
{
size = str->Len + 1;
if(size >= LONGSTR)
roundsize = ajRound(size, LONGSTR);
else
roundsize = ajRound(size, STRSIZE);
}
*Pstr = ajStrNewResS(str,roundsize);
return ajTrue;
}
if(!str)
return ajStrAssignClear(Pstr);
thys = *Pstr;
if(thys->Use != 1 || thys->Res <= str->Len)
{
/* min. reserved size OR more */
ret = ajStrSetResRound(Pstr, str->Len+1);
thys = *Pstr;
}
thys->Len = str->Len;
memmove(thys->Ptr, str->Ptr, str->Len+1);
return ret;
} | false | false | false | false | false | 0 |
kvm_pv_enable_async_pf(struct kvm_vcpu *vcpu, u64 data)
{
gpa_t gpa = data & ~0x3f;
/* Bits 2:5 are reserved, Should be zero */
if (data & 0x3c)
return 1;
vcpu->arch.apf.msr_val = data;
if (!(data & KVM_ASYNC_PF_ENABLED)) {
kvm_clear_async_pf_completion_queue(vcpu);
kvm_async_pf_hash_reset(vcpu);
return 0;
}
if (kvm_gfn_to_hva_cache_init(vcpu->kvm, &vcpu->arch.apf.data, gpa,
sizeof(u32)))
return 1;
vcpu->arch.apf.send_user_only = !(data & KVM_ASYNC_PF_SEND_ALWAYS);
kvm_async_pf_wakeup_all(vcpu);
return 0;
} | false | false | false | false | false | 0 |
find_bind(int fd, const struct sockaddr *addr, socklen_t addrlen) {
anyfn_type *anyfn;
anyfn= find_any("bind"); if (!anyfn) return -1;
old_bind= (bindfn_type*)anyfn;
return old_bind(fd,addr,addrlen);
} | false | false | false | false | false | 0 |
is_null_interval() { return maybe_null && max_value[0] == 1; } | false | false | false | false | false | 0 |
Initialize(Handle<Object> target) {
HandleScope scope;
length_symbol = Persistent<String>::New(String::NewSymbol("length"));
chars_written_sym = Persistent<String>::New(String::NewSymbol("_charsWritten"));
Local<FunctionTemplate> t = FunctionTemplate::New(Buffer::New);
constructor_template = Persistent<FunctionTemplate>::New(t);
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
constructor_template->SetClassName(String::NewSymbol("SlowBuffer"));
// copy free
NODE_SET_PROTOTYPE_METHOD(constructor_template, "binarySlice", Buffer::BinarySlice);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "asciiSlice", Buffer::AsciiSlice);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "base64Slice", Buffer::Base64Slice);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "ucs2Slice", Buffer::Ucs2Slice);
// TODO NODE_SET_PROTOTYPE_METHOD(t, "utf16Slice", Utf16Slice);
// copy
NODE_SET_PROTOTYPE_METHOD(constructor_template, "utf8Slice", Buffer::Utf8Slice);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "utf8Write", Buffer::Utf8Write);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "asciiWrite", Buffer::AsciiWrite);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "binaryWrite", Buffer::BinaryWrite);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "base64Write", Buffer::Base64Write);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "ucs2Write", Buffer::Ucs2Write);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "fill", Buffer::Fill);
NODE_SET_PROTOTYPE_METHOD(constructor_template, "copy", Buffer::Copy);
NODE_SET_METHOD(constructor_template->GetFunction(),
"byteLength",
Buffer::ByteLength);
NODE_SET_METHOD(constructor_template->GetFunction(),
"makeFastBuffer",
Buffer::MakeFastBuffer);
target->Set(String::NewSymbol("SlowBuffer"), constructor_template->GetFunction());
} | false | false | false | false | false | 0 |
FindDir(const NameT &name)
{
DirMap::iterator di = g_dirmap.find(name);
return di == g_dirmap.end() ? 0 : di->second;
} | false | false | false | false | false | 0 |
warn_broken_mlsx(void)
{
static int flag;
if (flag++)
return;
warning(0,"working around malformed MLSx listing. For more information",0,0,0);
warning(0,"see http://www.ohse.de/uwe/ftpcopy/faq.html#brokenmlsx.",0,0,0);
} | false | false | false | false | false | 0 |
parseLodDistances(String& params, MaterialScriptContext& context)
{
// Set to distance strategy
context.material->setLodStrategy(DistanceLodSphereStrategy::getSingletonPtr());
StringVector vecparams = StringUtil::split(params, " \t");
// iterate over the parameters and parse values out of them
Material::LodValueList lodList;
StringVector::iterator i, iend;
iend = vecparams.end();
for (i = vecparams.begin(); i != iend; ++i)
{
lodList.push_back(StringConverter::parseReal(*i));
}
context.material->setLodLevels(lodList);
return false;
} | false | false | false | false | false | 0 |
PropertyOfSameObject(Expression* e1, Expression* e2) {
Property* p1 = e1->AsProperty();
Property* p2 = e2->AsProperty();
if ((p1 == NULL) || (p2 == NULL)) return false;
return SameObject(p1->obj(), p2->obj());
} | false | false | false | false | false | 0 |
init_vlc(VLC *vlc, int nb_bits, int nb_codes,
const void *bits, int bits_wrap, int bits_size,
const void *codes, int codes_wrap, int codes_size,
int flags)
{
vlc->bits = nb_bits;
vlc->table_size = 0;
#ifdef DEBUG_VLC
printf("build table nb_codes=%d\n", nb_codes);
#endif
if (build_table(vlc, nb_bits, nb_codes,
bits, bits_wrap, bits_size,
codes, codes_wrap, codes_size,
0, 0) < 0) {
//av_free(vlc->table);
return -1;
}
/* return flags to block gcc warning while allowing us to keep
* consistent with ffmpeg's function parameters
*/
return flags;
} | false | false | false | false | false | 0 |
StrStrip(string in_str) {
string temp;
unsigned int start, end;
start = 0;
end = in_str.length();
if (in_str[0] == '\n')
return "";
for (unsigned int x = 0; x < in_str.length(); x++) {
if (in_str[x] != ' ' && in_str[x] != '\t') {
start = x;
break;
}
}
for (unsigned int x = in_str.length(); x > 1; ) {
x--;
if (in_str[x] != ' ' && in_str[x] != '\t' && in_str[x] != '\n') {
end = x;
break;
}
}
return in_str.substr(start, end-start+1);
} | false | false | false | false | false | 0 |
readAndParse(){
gMutex->lock();
clearParsingFinished();
makeParser();
bool lSuccess=false;
char lBuffer[20];
string lLogString;
cerr << __FILE__ << ":"
<< __LINE__ << ":readAndParse before parse" << endl;
do {
cout //<< "-"
<< flush;
#ifdef _DEBUG
#endif
//was asyncReadChar
if(readChar(mSocket, lBuffer)) {
cout
//<< "<"
<< lBuffer[0]
//<< ">"
<< flush;
#ifdef _DEBUG
#endif
lBuffer[1]=0;
lLogString+=lBuffer;
if (!XML_Parse(mParser,
lBuffer,
1,
false)) {
cerr << "CCommunicationHandler.cc:"
<< __LINE__
<< ": XML ERROR "
<< XML_ErrorString(XML_GetErrorCode(mParser))
<< " at xml line "
<< XML_GetCurrentLineNumber(mParser)
<< endl;
lSuccess=false;
}else
lSuccess=true;// i read at least one character
}else{
cerr << "Stream broke down!"
<< XML_ErrorString(XML_GetErrorCode(mParser))
<< " at line "
<< XML_GetCurrentLineNumber(mParser)
<< endl
<< "The cstdio stream was " << mSocket
<< endl;
lSuccess=false;
}
} while (lSuccess &&
//!isParsingFinished() ex
!(mDocumentRoot->isSubtreeFinished())
);
XML_Parse(mParser,
lBuffer,
0,
true);
{
ofstream lInLogFile((gGIFTHome
+
string("/gift-last-in-message.mrml")).c_str());
lInLogFile << endl
<< "<!-- The following message was sent by " << endl
<< this->getPeerAddressString() << endl;
time_t lNow(time(0));
string lNowASCII=string(ctime(&lNow));
lInLogFile << "At: " << lNowASCII
<< " --> " << endl
<< lLogString
<< flush
<< endl;
}
if(lSuccess){
mLog << endl
<< "<!-- The following message was sent by " << endl
<< this->getPeerAddressString() << endl;
time_t lNow(time(0));
string lNowASCII=string(ctime(&lNow));
mLog << "At: " << lNowASCII
<< " --> " << endl
<< lLogString
<< flush
<< endl;
}
CXEVCommunication lVisitor(this);
gMutex->unlock();
cerr << __FILE__ << ":"
<< __LINE__ << ":readAndParse before visit" << endl;
mDocumentRoot->check();
cerr << __FILE__ << ":"
<< __LINE__ << ":readAndParse before check" << endl;
mDocumentRoot->traverse(lVisitor);
cerr << __FILE__ << ":"
<< __LINE__ << ":readAndParse after visit" << endl;
return lSuccess;
} | false | false | false | false | false | 0 |
wm5100_runtime_resume(struct device *dev)
{
struct wm5100_priv *wm5100 = dev_get_drvdata(dev);
int ret;
ret = regulator_bulk_enable(ARRAY_SIZE(wm5100->core_supplies),
wm5100->core_supplies);
if (ret != 0) {
dev_err(dev, "Failed to enable supplies: %d\n",
ret);
return ret;
}
if (wm5100->pdata.ldo_ena) {
gpio_set_value_cansleep(wm5100->pdata.ldo_ena, 1);
msleep(2);
}
regcache_cache_only(wm5100->regmap, false);
regcache_sync(wm5100->regmap);
return 0;
} | false | false | false | false | false | 0 |
KeccakF200OnWords(tKeccakLane *state)
{
unsigned int i;
displayStateAsLanes(3, "Same, with lanes as 8-bit words", state);
for(i=0; i<nrRounds; i++)
KeccakF200Round(state, i);
} | false | false | false | false | false | 0 |
get_do_element_name(xmlNodePtr node)
{
Octstr *name = NULL;
xmlAttrPtr attr;
if ((attr = node->properties) != NULL) {
while (attr != NULL) {
if (attr->name && strcmp((char *)attr->name, "name") == 0) {
name = create_octstr_from_node((char *)attr->children);
break;
}
attr = attr->next;
}
if (attr == NULL) {
attr = node->properties;
while (attr != NULL) {
if (attr->name && strcmp((char *)attr->name, "type") == 0) {
name = create_octstr_from_node((char *)attr->children);
break;
}
attr = attr->next;
}
}
}
return name;
} | false | false | false | false | false | 0 |
CreateRhombicosidodecahedron(double radius) {
return CreateIcosahedron(radius*sqrt(10.0/(35.0+9.0*sqrt(5.0))))->cantellate(1.5*(sqrt(5.0)-1));
} | false | false | false | false | false | 0 |
PyFF_Font_set_guide(PyFF_Font *self,PyObject *value,void *closure) {
SplineSet *ss = NULL, *newss;
int isquad = false;
SplineFont *sf;
Layer *guide;
if ( value==NULL ) {
PyErr_Format(PyExc_TypeError, "Cannot delete guide field" );
return( -1 );
}
if ( PyType_IsSubtype(&PyFF_LayerType,((PyObject *)value)->ob_type) ) {
isquad = ((PyFF_Layer *) value)->is_quadratic;
ss = SSFromLayer( (PyFF_Layer *) value);
} else if ( PyType_IsSubtype(&PyFF_ContourType,((PyObject *)value)->ob_type) ) {
isquad = ((PyFF_Contour *) value)->is_quadratic;
ss = SSFromContour( (PyFF_Contour *) value,NULL);
} else {
PyErr_Format( PyExc_TypeError, "Unexpected type" );
return( -1 );
}
sf = self->fv->sf;
guide = &sf->grid;
SplinePointListsFree(guide->splines);
if ( sf->grid.order2!=isquad ) {
if ( sf->grid.order2 )
newss = SplineSetsTTFApprox(ss);
else
newss = SplineSetsPSApprox(ss);
SplinePointListsFree(ss);
ss = newss;
}
guide->splines = ss;
return( 0 );
} | false | false | false | false | false | 0 |
unpack_search_buttons()
{
if( ! m_searchbar ) return;
std::list< Gtk::Widget* > lists = m_searchbar->get_children();
std::list< Gtk::Widget* >::iterator it = lists.begin();
for( ; it != lists.end(); ++it ){
m_searchbar->remove( *(*it) );
if( dynamic_cast< Gtk::SeparatorToolItem* >( *it ) ) delete *it;
}
} | false | false | false | false | false | 0 |
gw_menu_file_close_save_file_ok ( GtkWidget *bt, GtkWindow *dg) {
GWCatalogPlugin *plugin = NULL;
GWDBContext *context = gw_am_get_current_catalog_context ( );
GWDBCatalog *catalog = NULL;
gboolean result = FALSE;
#ifdef GW_DEBUG_GUI_CALLBACK_COMPONENT
g_print ( "*** GW - %s (%d) :: %s()\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
#endif
gtk_widget_destroy ( GTK_WIDGET ( dg));
if ( context != NULL ) {
plugin = (GWCatalogPlugin*)gw_db_context_get_plugin ( context);
catalog = plugin->gw_db_catalog_get_db_catalog ( context);
/* Checks if it's a new catalog (in this case his full name is "./[catalog_full_name]"). */
if ( gw_helper_db_catalog_is_new ( catalog)) {
/* If it's a new catalog, asks a file name. */
gw_file_selection_box_create ( _( "Save as catalog"), gw_helper_db_catalog_get_usefull_name ( catalog), (GtkSignalFunc)gw_menu_file_close_saveas_file_selection_ok, NULL);
} else {
/* Else save it directly and close it. */
gw_menu_file_save_click ( NULL, NULL);
gw_am_close_catalog ( FALSE);
}
gw_db_catalog_free ( catalog);
result = TRUE;
} else {
}
return result;
} | false | false | false | false | false | 0 |
cb_chime_entry(GtkWidget *widget, gpointer data)
{
gint which = (GPOINTER_TO_INT(data)) & 0x1;
gint activate = (GPOINTER_TO_INT(data)) & 0x10;
/* If editing the chime commands, block them until config is destroyed
| or we get a "activate".
*/
chime_block = activate ? FALSE : TRUE;
if (which)
gkrellm_dup_string(&hour_chime_command,
gkrellm_gtk_entry_get_text(&hour_chime_entry));
else
gkrellm_dup_string(&quarter_chime_command,
gkrellm_gtk_entry_get_text(&quarter_chime_entry));
} | false | false | false | false | false | 0 |
put(PopplerCacheKey *key, PopplerCacheItem *item)
{
int movingStartIndex = lastValidCacheIndex + 1;
if (lastValidCacheIndex == cacheSize - 1) {
delete keys[lastValidCacheIndex];
delete items[lastValidCacheIndex];
movingStartIndex = cacheSize - 1;
} else {
lastValidCacheIndex++;
}
for (int i = movingStartIndex; i > 0; i--) {
keys[i] = keys[i - 1];
items[i] = items[i - 1];
}
keys[0] = key;
items[0] = item;
} | false | false | false | false | false | 0 |
check_for_override (tree decl, tree ctype)
{
if (TREE_CODE (decl) == TEMPLATE_DECL)
/* In [temp.mem] we have:
A specialization of a member function template does not
override a virtual function from a base class. */
return;
if ((DECL_DESTRUCTOR_P (decl)
|| IDENTIFIER_VIRTUAL_P (DECL_NAME (decl))
|| DECL_CONV_FN_P (decl))
&& look_for_overrides (ctype, decl)
&& !DECL_STATIC_FUNCTION_P (decl))
/* Set DECL_VINDEX to a value that is neither an INTEGER_CST nor
the error_mark_node so that we know it is an overriding
function. */
DECL_VINDEX (decl) = decl;
if (DECL_VIRTUAL_P (decl))
{
if (!DECL_VINDEX (decl))
DECL_VINDEX (decl) = error_mark_node;
IDENTIFIER_VIRTUAL_P (DECL_NAME (decl)) = 1;
}
} | false | false | false | false | false | 0 |
RenameRelation(Oid myrelid, const char *newrelname, ObjectType reltype)
{
Relation targetrelation;
Oid namespaceId;
char relkind;
/*
* Grab an exclusive lock on the target table, index, sequence or view,
* which we will NOT release until end of transaction.
*/
targetrelation = relation_open(myrelid, AccessExclusiveLock);
namespaceId = RelationGetNamespace(targetrelation);
relkind = targetrelation->rd_rel->relkind;
/*
* For compatibility with prior releases, we don't complain if ALTER TABLE
* or ALTER INDEX is used to rename some other type of relation. But
* ALTER SEQUENCE/VIEW/FOREIGN TABLE are only to be used with relations of
* that type.
*/
if (reltype == OBJECT_SEQUENCE && relkind != RELKIND_SEQUENCE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a sequence",
RelationGetRelationName(targetrelation))));
if (reltype == OBJECT_VIEW && relkind != RELKIND_VIEW)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a view",
RelationGetRelationName(targetrelation))));
if (reltype == OBJECT_FOREIGN_TABLE && relkind != RELKIND_FOREIGN_TABLE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is not a foreign table",
RelationGetRelationName(targetrelation))));
/*
* Don't allow ALTER TABLE on composite types. We want people to use ALTER
* TYPE for that.
*/
if (relkind == RELKIND_COMPOSITE_TYPE)
ereport(ERROR,
(errcode(ERRCODE_WRONG_OBJECT_TYPE),
errmsg("\"%s\" is a composite type",
RelationGetRelationName(targetrelation)),
errhint("Use ALTER TYPE instead.")));
/* Do the work */
RenameRelationInternal(myrelid, newrelname, namespaceId);
/*
* Close rel, but keep exclusive lock!
*/
relation_close(targetrelation, NoLock);
} | false | false | false | false | false | 0 |
collectLeaves(QDomElement & element, QList<QDomElement> & leaves) {
if (element.hasChildNodes()) {
QDomElement c = element.firstChildElement();
while (!c.isNull()) {
collectLeaves(c, leaves);
c = c.nextSiblingElement();
}
}
else {
leaves.append(element);
}
} | false | false | false | false | false | 0 |
st_clear(st_table *table)
{
register st_table_entry *ptr, *next;
st_index_t i;
if (table->entries_packed) {
table->num_entries = 0;
return;
}
for(i = 0; i < table->num_bins; i++) {
ptr = table->bins[i];
table->bins[i] = 0;
while (ptr != 0) {
next = ptr->next;
free(ptr);
ptr = next;
}
}
table->num_entries = 0;
table->head = 0;
table->tail = 0;
} | false | false | false | false | false | 0 |
cvar_cbase()
{
NODE *cref = ruby_cref;
while (cref && cref->nd_next && (NIL_P(cref->nd_clss) || FL_TEST(cref->nd_clss, FL_SINGLETON))) {
cref = cref->nd_next;
if (!cref->nd_next) {
rb_warn("class variable access from toplevel singleton method");
}
}
if (NIL_P(cref->nd_clss)) {
rb_raise(rb_eTypeError, "no class variables available");
}
return cref->nd_clss;
} | false | false | false | false | false | 0 |
uri_worker_map_dump(jk_uri_worker_map_t *uw_map,
const char *reason, jk_logger_t *l)
{
JK_TRACE_ENTER(l);
if (uw_map) {
int i, off;
if (JK_IS_DEBUG_LEVEL(l)) {
jk_log(l, JK_LOG_DEBUG, "uri map dump %s: id=%d, index=%d file='%s' reject_unsafe=%d "
"reload=%d modified=%d checked=%d",
reason, uw_map->id, uw_map->index, STRNULL_FOR_NULL(uw_map->fname),
uw_map->reject_unsafe, uw_map->reload, uw_map->modified, uw_map->checked);
}
for (i = 0; i <= 1; i++) {
jk_log(l, JK_LOG_DEBUG, "generation %d: size=%d nosize=%d capacity=%d",
i, uw_map->size[i], uw_map->nosize[i], uw_map->capacity[i], uw_map->maps[i]);
}
off = uw_map->index;
for (i = 0; i <= 1; i++) {
char buf[32];
int k;
unsigned int j;
k = (i + off) % 2;
for (j = 0; j < uw_map->size[k]; j++) {
uri_worker_record_t *uwr = uw_map->maps[k][j];
if (uwr && JK_IS_DEBUG_LEVEL(l)) {
jk_log(l, JK_LOG_DEBUG, "%s (%d) map #%d: uri=%s worker=%s context=%s "
"source=%s type=%s len=%d",
i ? "NEXT" : "THIS", i, j,
STRNULL_FOR_NULL(uwr->uri), STRNULL_FOR_NULL(uwr->worker_name),
STRNULL_FOR_NULL(uwr->context), STRNULL_FOR_NULL(uri_worker_map_get_source(uwr,l)),
STRNULL_FOR_NULL(uri_worker_map_get_match(uwr,buf,l)), uwr->context_len);
}
}
}
}
JK_TRACE_EXIT(l);
} | false | false | false | false | false | 0 |
axi_spdif_startup(struct snd_pcm_substream *substream,
struct snd_soc_dai *dai)
{
struct axi_spdif *spdif = snd_soc_dai_get_drvdata(dai);
int ret;
ret = snd_pcm_hw_constraint_ratnums(substream->runtime, 0,
SNDRV_PCM_HW_PARAM_RATE,
&spdif->rate_constraints);
if (ret)
return ret;
ret = clk_prepare_enable(spdif->clk_ref);
if (ret)
return ret;
regmap_update_bits(spdif->regmap, AXI_SPDIF_REG_CTRL,
AXI_SPDIF_CTRL_TXEN, AXI_SPDIF_CTRL_TXEN);
return 0;
} | false | false | false | false | false | 0 |
dvb_id_bus_satellite_scanner_proxy_AddScanningData (DVBIDBusSatelliteScanner* self, guint frequency, const gchar* polarization, guint symbol_rate, GError** error) {
GDBusMessage *_message;
GVariant *_arguments;
GVariantBuilder _arguments_builder;
GDBusMessage *_reply_message;
G_DBUS_ERROR;
_message = g_dbus_message_new_method_call (g_dbus_proxy_get_name ((GDBusProxy *) self), g_dbus_proxy_get_object_path ((GDBusProxy *) self), "org.gnome.DVB.Scanner.Satellite", "AddScanningData");
g_variant_builder_init (&_arguments_builder, G_VARIANT_TYPE_TUPLE);
g_variant_builder_add_value (&_arguments_builder, g_variant_new_uint32 (frequency));
g_variant_builder_add_value (&_arguments_builder, g_variant_new_string (polarization));
g_variant_builder_add_value (&_arguments_builder, g_variant_new_uint32 (symbol_rate));
_arguments = g_variant_builder_end (&_arguments_builder);
g_dbus_message_set_body (_message, _arguments);
_reply_message = g_dbus_connection_send_message_with_reply_sync (g_dbus_proxy_get_connection ((GDBusProxy *) self), _message, G_DBUS_SEND_MESSAGE_FLAGS_NONE, g_dbus_proxy_get_default_timeout ((GDBusProxy *) self), NULL, NULL, error);
g_object_unref (_message);
if (!_reply_message) {
return;
}
if (g_dbus_message_to_gerror (_reply_message, error)) {
g_object_unref (_reply_message);
return;
}
g_object_unref (_reply_message);
} | false | false | false | false | false | 0 |
parser_scan_multipart_subparts (GMimeParser *parser, GMimeMultipart *multipart)
{
struct _GMimeParserPrivate *priv = parser->priv;
ContentType *content_type;
GMimeObject *subpart;
int found;
do {
/* skip over the boundary marker */
if (parser_skip_line (parser) == -1) {
found = FOUND_EOS;
break;
}
/* get the headers */
priv->state = GMIME_PARSER_STATE_HEADERS;
if (parser_step (parser) == GMIME_PARSER_STATE_ERROR) {
found = FOUND_EOS;
break;
}
if (priv->state == GMIME_PARSER_STATE_COMPLETE && priv->headers == NULL) {
found = FOUND_END_BOUNDARY;
break;
}
content_type = parser_content_type (parser, ((GMimeObject *) multipart)->content_type);
if (content_type_is_type (content_type, "multipart", "*"))
subpart = parser_construct_multipart (parser, content_type, FALSE, &found);
else
subpart = parser_construct_leaf_part (parser, content_type, FALSE, &found);
g_mime_multipart_add (multipart, subpart);
content_type_destroy (content_type);
g_object_unref (subpart);
} while (found == FOUND_BOUNDARY && found_immediate_boundary (priv, FALSE));
return found;
} | false | false | false | false | false | 0 |
ParseListOrder(char *s, int multiple_orders ) {
char *q;
uint32_t order_bits;
order_bits = 0;
while ( s ) {
int i;
q = strchr(s, '/');
if ( q && !multiple_orders ) {
return -1;
}
if ( q )
*q = 0;
i = 0;
while ( order_mode[i].string ) {
if ( strcasecmp(order_mode[i].string, s ) == 0 )
break;
i++;
}
if ( order_mode[i].string ) {
order_bits |= order_mode[i].val;
} else {
return 0;
}
if ( !q ) {
print_order_bits = order_bits;
return 1;
}
s = ++q;
}
// not reached
return 1;
} | false | false | false | false | false | 0 |
get_random_bytes(void *buf, int nbytes)
{
int i, n = nbytes, fd = get_random_fd();
int lose_counter = 0;
unsigned char *cp = (unsigned char *) buf;
if (fd >= 0) {
while (n > 0) {
i = read(fd, cp, n);
if (i <= 0) {
if (lose_counter++ > 16)
break;
continue;
}
n -= i;
cp += i;
lose_counter = 0;
}
}
/*
* We do this all the time, but this is the only source of
* randomness if /dev/random/urandom is out to lunch.
*/
for (cp = buf, i = 0; i < nbytes; i++)
*cp++ ^= (rand() >> 7) & 0xFF;
#ifdef DO_JRAND_MIX
{
unsigned short tmp_seed[3];
memcpy(tmp_seed, jrand_seed, sizeof(tmp_seed));
jrand_seed[2] = jrand_seed[2] ^ syscall(__NR_gettid);
for (cp = buf, i = 0; i < nbytes; i++)
*cp++ ^= (jrand48(tmp_seed) >> 7) & 0xFF;
memcpy(jrand_seed, tmp_seed,
sizeof(jrand_seed)-sizeof(unsigned short));
}
#endif
return;
} | false | false | false | false | false | 0 |
BTDM_IsWifiBusy(struct rtw_adapter *padapter)
{
/*PMGNT_INFO pMgntInfo = &GetDefaultAdapter(padapter)->MgntInfo; */
struct mlme_priv *pmlmepriv = &GetDefaultAdapter(padapter)->mlmepriv;
struct bt_30info *pBTInfo = GET_BT_INFO(padapter);
struct bt_traffic *pBtTraffic = &pBTInfo->BtTraffic;
if (pmlmepriv->LinkDetectInfo.bBusyTraffic ||
pBtTraffic->Bt30TrafficStatistics.bTxBusyTraffic ||
pBtTraffic->Bt30TrafficStatistics.bRxBusyTraffic)
return true;
else
return false;
} | false | false | false | false | false | 0 |
waypoint_add_list(const char *name, SCP_vector<vec3d> &vec_list)
{
Assert(name != NULL);
if (find_matching_waypoint_list(name) != NULL)
{
Warning(LOCATION, "Waypoint list '%s' already exists in this mission! Not adding the new list...");
return;
}
waypoint_list new_list(name);
Waypoint_lists.push_back(new_list);
waypoint_list *wp_list = &Waypoint_lists.back();
SCP_vector<vec3d>::iterator ii;
for (ii = vec_list.begin(); ii != vec_list.end(); ++ii)
{
waypoint new_waypoint(&(*ii), wp_list);
wp_list->get_waypoints().push_back(new_waypoint);
}
// so that masking in the other function works
// though if you actually hit this Assert, you have other problems
Assert(wp_list->get_waypoints().size() <= 0xffff);
} | false | false | false | false | false | 0 |
paramsMess (int argc, t_atom*argv) { // FUN
int i = (argc<FOG_ARRAY_LENGTH)?argc:FOG_ARRAY_LENGTH;
while(i--)params[i]=atom_getfloat(argv+i);
setModified();
} | false | false | false | false | false | 0 |
SelectLine(int line)
{
m_selectedLines.clear();
m_focusedLine = line;
if (line != -1)
m_selectedLines.insert(line);
Refresh();
} | false | false | false | false | false | 0 |
FCEU_DrawLagCounter(uint8 *XBuf)
{
if (lagCounterDisplay)
{
// If currently lagging - display red, else display green
uint8 color = (lagFlag) ? (0x16+0x80) : (0x2A+0x80);
sprintf(lagcounterbuf, "%d", lagCounter);
if(lagcounterbuf[0])
DrawTextTrans(ClipSidesOffset + XBuf + FCEU_TextScanlineOffsetFromBottom(40) + 1, 256, (uint8*)lagcounterbuf, color);
}
} | false | false | false | false | false | 0 |
mi_set_context(struct drm_i915_gem_request *req, u32 hw_flags)
{
struct intel_engine_cs *engine = req->engine;
u32 flags = hw_flags | MI_MM_SPACE_GTT;
const int num_rings =
/* Use an extended w/a on ivb+ if signalling from other rings */
i915_semaphore_is_enabled(engine->dev) ?
hweight32(INTEL_INFO(engine->dev)->ring_mask) - 1 :
0;
int len, ret;
/* w/a: If Flush TLB Invalidation Mode is enabled, driver must do a TLB
* invalidation prior to MI_SET_CONTEXT. On GEN6 we don't set the value
* explicitly, so we rely on the value at ring init, stored in
* itlb_before_ctx_switch.
*/
if (IS_GEN6(engine->dev)) {
ret = engine->flush(req, I915_GEM_GPU_DOMAINS, 0);
if (ret)
return ret;
}
/* These flags are for resource streamer on HSW+ */
if (IS_HASWELL(engine->dev) || INTEL_INFO(engine->dev)->gen >= 8)
flags |= (HSW_MI_RS_SAVE_STATE_EN | HSW_MI_RS_RESTORE_STATE_EN);
else if (INTEL_INFO(engine->dev)->gen < 8)
flags |= (MI_SAVE_EXT_STATE_EN | MI_RESTORE_EXT_STATE_EN);
len = 4;
if (INTEL_INFO(engine->dev)->gen >= 7)
len += 2 + (num_rings ? 4*num_rings + 6 : 0);
ret = intel_ring_begin(req, len);
if (ret)
return ret;
/* WaProgramMiArbOnOffAroundMiSetContext:ivb,vlv,hsw,bdw,chv */
if (INTEL_INFO(engine->dev)->gen >= 7) {
intel_ring_emit(engine, MI_ARB_ON_OFF | MI_ARB_DISABLE);
if (num_rings) {
struct intel_engine_cs *signaller;
intel_ring_emit(engine,
MI_LOAD_REGISTER_IMM(num_rings));
for_each_engine(signaller, to_i915(engine->dev)) {
if (signaller == engine)
continue;
intel_ring_emit_reg(engine,
RING_PSMI_CTL(signaller->mmio_base));
intel_ring_emit(engine,
_MASKED_BIT_ENABLE(GEN6_PSMI_SLEEP_MSG_DISABLE));
}
}
}
intel_ring_emit(engine, MI_NOOP);
intel_ring_emit(engine, MI_SET_CONTEXT);
intel_ring_emit(engine,
i915_gem_obj_ggtt_offset(req->ctx->legacy_hw_ctx.rcs_state) |
flags);
/*
* w/a: MI_SET_CONTEXT must always be followed by MI_NOOP
* WaMiSetContext_Hang:snb,ivb,vlv
*/
intel_ring_emit(engine, MI_NOOP);
if (INTEL_INFO(engine->dev)->gen >= 7) {
if (num_rings) {
struct intel_engine_cs *signaller;
i915_reg_t last_reg = {}; /* keep gcc quiet */
intel_ring_emit(engine,
MI_LOAD_REGISTER_IMM(num_rings));
for_each_engine(signaller, to_i915(engine->dev)) {
if (signaller == engine)
continue;
last_reg = RING_PSMI_CTL(signaller->mmio_base);
intel_ring_emit_reg(engine, last_reg);
intel_ring_emit(engine,
_MASKED_BIT_DISABLE(GEN6_PSMI_SLEEP_MSG_DISABLE));
}
/* Insert a delay before the next switch! */
intel_ring_emit(engine,
MI_STORE_REGISTER_MEM |
MI_SRM_LRM_GLOBAL_GTT);
intel_ring_emit_reg(engine, last_reg);
intel_ring_emit(engine, engine->scratch.gtt_offset);
intel_ring_emit(engine, MI_NOOP);
}
intel_ring_emit(engine, MI_ARB_ON_OFF | MI_ARB_ENABLE);
}
intel_ring_advance(engine);
return ret;
} | false | false | false | false | false | 0 |
DSO_free(DSO *dso)
{
int i;
if(dso == NULL)
{
DSOerr(DSO_F_DSO_FREE,ERR_R_PASSED_NULL_PARAMETER);
return(0);
}
i=CRYPTO_add(&dso->references,-1,CRYPTO_LOCK_DSO);
#ifdef REF_PRINT
REF_PRINT("DSO",dso);
#endif
if(i > 0) return(1);
#ifdef REF_CHECK
if(i < 0)
{
fprintf(stderr,"DSO_free, bad reference count\n");
abort();
}
#endif
if((dso->meth->dso_unload != NULL) && !dso->meth->dso_unload(dso))
{
DSOerr(DSO_F_DSO_FREE,DSO_R_UNLOAD_FAILED);
return(0);
}
if((dso->meth->finish != NULL) && !dso->meth->finish(dso))
{
DSOerr(DSO_F_DSO_FREE,DSO_R_FINISH_FAILED);
return(0);
}
sk_void_free(dso->meth_data);
if(dso->filename != NULL)
OPENSSL_free(dso->filename);
if(dso->loaded_filename != NULL)
OPENSSL_free(dso->loaded_filename);
OPENSSL_free(dso);
return(1);
} | false | false | false | false | false | 0 |
read_binary_matrix(Matrix& mres, ifstream& fs)
{
bool swapbytes = false;
unsigned int testval;
// test for byte swapping
fs.read((char*)&testval,sizeof(testval));
if (testval!=BINFLAG) {
swapbytes = true;
Swap_Nbytes(1,sizeof(testval),&testval);
if (testval!=BINFLAG) {
cerr << "Unrecognised binary matrix file format" << endl;
return 2;
}
}
// read matrix dimensions (num rows x num cols)
unsigned int ival,nx,ny;
fs.read((char*)&ival,sizeof(ival));
// ignore the padding (reserved for future use)
fs.read((char*)&ival,sizeof(ival));
if (swapbytes) Swap_Nbytes(1,sizeof(ival),&ival);
nx = ival;
fs.read((char*)&ival,sizeof(ival));
if (swapbytes) Swap_Nbytes(1,sizeof(ival),&ival);
ny = ival;
// set up and read matrix (rows fast, cols slow)
double val;
if ( (((unsigned int) mres.Ncols())<ny) || (((unsigned int) mres.Nrows())<nx) ) {
mres.ReSize(nx,ny);
}
for (unsigned int y=1; y<=ny; y++) {
for (unsigned int x=1; x<=nx; x++) {
fs.read((char*)&val,sizeof(val));
if (swapbytes) Swap_Nbytes(1,sizeof(val),&val);
mres(x,y)=val;
}
}
return 0;
} | false | false | false | false | false | 0 |
gw_db_file_set_rights_from_gchar ( GWDBFile *file, gchar *rights) {
mode_t mode = 000000; //TODO replace by hexa code
if ( (file != NULL) && (rights != NULL) && strlen ( rights)==10 ) {
switch (rights[0]) {
case 'b': mode|=S_IFBLK;
break;
case 'l': mode|=S_IFLNK;
break;
case 'd': mode|=S_IFDIR;
break;
case 'c': mode|=S_IFCHR;
break;
case 'p': mode|=S_IFIFO;
break;
case 's': mode|=S_IFSOCK;
break;
default: break;
}
if ( rights[1]=='r') {
mode|=S_IRUSR;
}
if ( rights[2]=='w') {
mode|=S_IWUSR;
}
switch (rights[3]) {
case 'x': mode|=S_IXUSR;
break;
case 's': mode|=S_ISUID;
mode|=S_IXUSR;
break;
case 'S': mode|=S_ISUID;
break;
default: break;
}
if ( rights[4]=='r') {
mode|=S_IRGRP;
}
if ( rights[5]=='w') {
mode|=S_IWGRP;
}
switch (rights[6]) {
case 'x': mode|=S_IXGRP;
break;
case 's': mode|=S_ISGID;
mode|=S_IXGRP;
break;
case 'S': mode|=S_ISGID;
break;
default: break;
}
if ( rights[7]=='r') {
mode|=S_IROTH;
}
if ( rights[8]=='w') {
mode|=S_IWOTH;
}
switch (rights[9]) {
case 'x': mode|=S_IXOTH;
break;
case 't': mode|=S_ISVTX;
mode|=S_IXOTH;
break;
case 'T': mode|=S_ISVTX;
break;
default: break;
}
file->rights = mode;
return 0;
}
return -1;
} | false | false | false | false | false | 0 |
Strsafe(y)
char *y;
{
char *z;
z = Strsafe_find(y);
if( z==0 && (z=malloc( strlen(y)+1 ))!=0 ){
strcpy(z,y);
Strsafe_insert(z);
}
MemoryCheck(z);
return z;
} | false | false | false | false | false | 0 |
file_get_contents(const char* fn, size_t* len, anbool addzero) {
struct stat st;
char* buf;
FILE* fid;
off_t size;
if (stat(fn, &st)) {
fprintf(stderr, "file_get_contents: failed to stat file \"%s\"", fn);
return NULL;
}
size = st.st_size;
fid = fopen(fn, "rb");
if (!fid) {
fprintf(stderr, "file_get_contents: failed to open file \"%s\": %s\n", fn, strerror(errno));
return NULL;
}
buf = malloc(size + (addzero ? 1 : 0));
if (!buf) {
fprintf(stderr, "file_get_contents: couldn't malloc %lu bytes.\n", (long)size);
return NULL;
}
if (fread(buf, 1, size, fid) != size) {
fprintf(stderr, "file_get_contents: failed to read %lu bytes: %s\n", (long)size, strerror(errno));
free(buf);
return NULL;
}
fclose(fid);
if (addzero)
buf[size] = '\0';
if (len)
*len = size;
return buf;
} | false | false | false | false | true | 1 |
calcBorderThickness(void)
{
calcLeftBorderThick();
calcRightBorderThick();
calcTopBorderThick();
calcBotBorderThick();
// set the boolean flags m_bIsAlongTopBorder and m_bIsAlongBotBorder
if (canDrawTopBorder())
{
if (isFirstLineInBlock())
{
m_bIsAlongTopBorder = true;
}
if (isSameYAsPrevious())
{
fp_Line * ppLine = static_cast<fp_Line *> (getPrev());
while(ppLine && ppLine->isSameYAsPrevious())
{
ppLine = static_cast<fp_Line *>(ppLine->getPrev());
}
if (ppLine && ppLine->isFirstLineInBlock())
{
m_bIsAlongTopBorder = true;
}
}
}
if(canDrawBotBorder())
{
if (isLastLineInBlock())
{
m_bIsAlongBotBorder = true;
}
if (isWrapped())
{
fp_Line * npLine = static_cast<fp_Line *>(getNext());;
if (npLine && isSameYAsPrevious())
{
do
{
if (npLine->isLastLineInBlock())
{
m_bIsAlongBotBorder = true;
break;
}
npLine = static_cast<fp_Line *>(npLine->getNext());
}
while(npLine && npLine->isSameYAsPrevious());
}
}
if (m_bIsAlongBotBorder)
{
fp_Line * ppLine =this;
while(ppLine && ppLine->isSameYAsPrevious())
{
ppLine = static_cast<fp_Line *>(ppLine->getPrev());
}
if(ppLine)
ppLine = static_cast<fp_Line *> (ppLine->getPrev());
while (ppLine && ppLine->isAlongBotBorder())
{
ppLine->setAlongBotBorder(false);
ppLine->recalcHeight();
}
}
}
if (isFirstLineInBlock() && !canDrawTopBorder())
{
fl_BlockLayout *pBl = static_cast < fl_BlockLayout * > (getBlock()->getPrev());
fp_Line *pLine = static_cast < fp_Line * > (pBl->getLastContainer());
if(pLine && pLine->isAlongBotBorder())
{
pBl->setLineHeightBlockWithBorders(-1);
}
}
} | false | false | false | false | false | 0 |
m_next(GtkWidget *, cchar *menu)
{
int err, Nth;
int nfiles = image_navi::nfiles;
if (menu) zfuncs::F1_help_topic = "open_image_file";
if (Fmenulock) return;
if (mod_keep()) return;
if (! curr_file) return;
for (Nth = curr_file_posn+1; Nth < nfiles; Nth++) // v.11.05
{
char *pp = image_gallery(0,"find",Nth);
if (! pp) continue;
err = f_open(pp,1,Nth);
zfree(pp);
if (! err) break;
}
return;
} | 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.