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 |
|---|---|---|---|---|---|---|
handler (int signum_)
{
trace_with_mask("SigHandler::handler", SIGHAND);
if ( in_range (signum_) == -1 )
return 0;
return m_signal_handlers[signum_];
} | false | false | false | false | false | 0 |
exif_content_free (ExifContent *content)
{
ExifMem *mem = (content && content->priv) ? content->priv->mem : NULL;
unsigned int i;
if (!content) return;
for (i = 0; i < content->count; i++)
exif_entry_unref (content->entries[i]);
exif_mem_free (mem, content->entries);
if (content->priv) {
exif_log_unref (content->priv->log);
}
exif_mem_free (mem, content->priv);
exif_mem_free (mem, content);
exif_mem_unref (mem);
} | false | false | false | false | false | 0 |
AddRotamers(unsigned char *arr,int nrotamers)
{
unsigned int size;
int i;
size = (unsigned int)_vrotor.size()+1;
for (i = 0;i < nrotamers;++i)
{
unsigned char *rot = new unsigned char [size];
memcpy(rot,&arr[i*size],sizeof(char)*size);
_vrotamer.push_back(rot);
}
} | false | false | false | false | false | 0 |
ast_calendar_event_alloc(struct ast_calendar *cal)
{
struct ast_calendar_event *event;
if (!(event = ao2_alloc(sizeof(*event), calendar_event_destructor))) {
return NULL;
}
if (ast_string_field_init(event, 32)) {
event = ast_calendar_unref_event(event);
return NULL;
}
event->owner = cal;
event->notify_sched = -1;
event->bs_start_sched = -1;
event->bs_end_sched = -1;
AST_LIST_HEAD_INIT_NOLOCK(&event->attendees);
return event;
} | false | false | false | false | false | 0 |
gwy_delaunay_point_on_simplex(GwyDelaunayVertex *p, simplex *s)
{
if (!s) return 0;
if (p == s->p[0] || p == s->p[1] || p == s->p[2] || p == s->p[3])
return 1;
return 0;
} | false | false | false | false | false | 0 |
hash(ulong *nr, ulong *nr2)
{
if (is_null())
{
*nr^= (*nr << 1) | 1;
}
else
{
uint len= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr);
CHARSET_INFO *cs= charset();
cs->coll->hash_sort(cs, ptr + length_bytes, len, nr, nr2);
}
} | false | false | false | false | false | 0 |
AcpiNsOpensScope (
ACPI_OBJECT_TYPE Type)
{
ACPI_FUNCTION_ENTRY ();
if (Type > ACPI_TYPE_LOCAL_MAX)
{
/* type code out of range */
ACPI_WARNING ((AE_INFO, "Invalid Object Type 0x%X", Type));
return (ACPI_NS_NORMAL);
}
return (((UINT32) AcpiGbl_NsProperties[Type]) & ACPI_NS_NEWSCOPE);
} | false | false | false | false | false | 0 |
js_InflateString(JSContext *cx, const char *bytes, size_t *lengthp)
{
size_t nbytes, nchars, i;
jschar *chars;
#ifdef DEBUG
JSBool ok;
#endif
nbytes = *lengthp;
if (js_CStringsAreUTF8) {
if (!js_InflateStringToBuffer(cx, bytes, nbytes, NULL, &nchars))
goto bad;
chars = (jschar *) cx->malloc((nchars + 1) * sizeof (jschar));
if (!chars)
goto bad;
#ifdef DEBUG
ok =
#endif
js_InflateStringToBuffer(cx, bytes, nbytes, chars, &nchars);
JS_ASSERT(ok);
} else {
nchars = nbytes;
chars = (jschar *) cx->malloc((nchars + 1) * sizeof(jschar));
if (!chars)
goto bad;
for (i = 0; i < nchars; i++)
chars[i] = (unsigned char) bytes[i];
}
*lengthp = nchars;
chars[nchars] = 0;
return chars;
bad:
/*
* For compatibility with callers of JS_DecodeBytes we must zero lengthp
* on errors.
*/
*lengthp = 0;
return NULL;
} | false | true | false | false | false | 1 |
operator==(const Format& other) const {
// This protected comparison operator should only be called by subclasses
// which have confirmed that the other object being compared against is
// an instance of a sublcass of PluralFormat. THIS IS IMPORTANT.
// Format::operator== guarantees that this cast is safe
PluralFormat* fmt = (PluralFormat*)&other;
return ((*pluralRules == *(fmt->pluralRules)) &&
(*numberFormat == *(fmt->numberFormat)));
} | false | false | false | false | false | 0 |
dumpenv(flaglist, fp)
CONST char *flaglist;
XFILE *fp;
{
char *cp;
int i, n;
for (i = n = 0; i < ENVLISTSIZ; i++) {
if ((!flaglist || !(flaglist[i] & 2))
&& (cp = getshellvar(env_str(i), -1))
&& (env_type(i) != T_CHARP || strenvcmp(cp, def_str(i))))
n++;
if ((!flaglist || !(flaglist[i] & 1))
&& getshellvar(fdenv_str(i), -1))
n++;
}
if (!n || !fp) return(n);
VOID_C fputnl(fp);
Xfputs("# shell variables definition\n", fp);
for (i = 0; i < ENVLISTSIZ; i++) {
if ((!flaglist || !(flaglist[i] & 2))
&& (cp = getshellvar(env_str(i), -1))
&& (env_type(i) != T_CHARP || strenvcmp(cp, def_str(i)))) {
cp = killmeta(cp);
VOID_C Xfprintf(fp, "%s=%s\n", env_str(i), cp);
Xfree(cp);
}
if ((!flaglist || !(flaglist[i] & 1))
&& (cp = getshellvar(fdenv_str(i), -1))) {
cp = killmeta(cp);
VOID_C Xfprintf(fp, "%s=%s\n", fdenv_str(i), cp);
Xfree(cp);
}
}
return(n);
} | false | false | false | false | false | 0 |
gnc_lot_is_closed (GNCLot *lot)
{
LotPrivate* priv;
if (!lot) return TRUE;
priv = GET_PRIVATE(lot);
if (0 > priv->is_closed) gnc_lot_get_balance (lot);
return priv->is_closed;
} | false | false | false | false | false | 0 |
ncx_pad_getn_schar_float(const void **xpp, size_t nelems, float *tp)
{
size_t rndup = nelems % X_ALIGN;
schar *xp = (schar *) *xpp;
if(rndup)
rndup = X_ALIGN - rndup;
while(nelems-- != 0)
{
*tp++ = *xp++;
}
*xpp = (void *)(xp + rndup);
return ENOERR;
} | false | false | false | false | false | 0 |
ocfs2_dlm_shutdown_debug(struct ocfs2_super *osb)
{
struct ocfs2_dlm_debug *dlm_debug = osb->osb_dlm_debug;
if (dlm_debug) {
debugfs_remove(dlm_debug->d_locking_state);
ocfs2_put_dlm_debug(dlm_debug);
}
} | false | false | false | false | false | 0 |
CTEXTAREA_set_foreground(void *_object)
{
THIS->no_change = TRUE;
QTextCursor oldCursor = WIDGET->textCursor();
WIDGET->selectAll();
WIDGET->setTextColor(Qt::black);
set_text_color(THIS);
WIDGET->setTextCursor(oldCursor);
set_text_color(THIS);
THIS->no_change = FALSE;
} | false | false | false | false | false | 0 |
intelx_check_link ( struct net_device *netdev ) {
struct intel_nic *intel = netdev->priv;
uint32_t links;
/* Read link status */
links = readl ( intel->regs + INTELX_LINKS );
DBGC ( intel, "INTEL %p link status is %08x\n", intel, links );
/* Update network device */
if ( links & INTELX_LINKS_UP ) {
netdev_link_up ( netdev );
} else {
netdev_link_down ( netdev );
}
} | false | false | false | false | false | 0 |
received_test( struct sip_msg *msg )
{
int rcvd;
if(msg->via1->received !=NULL)
return 1;
if(msg->via1->maddr){
rcvd = check_ip_address(&msg->rcv.src_ip, &msg->via1->maddr->value,
msg->via1->port, msg->via1->proto, received_dns);
} else {
rcvd = check_ip_address(&msg->rcv.src_ip,
&msg->via1->host, msg->via1->port, msg->via1->proto, received_dns);
}
return rcvd;
} | false | false | false | false | false | 0 |
exif_tag_get_name_in_ifd (ExifTag tag, ExifIfd ifd)
{
unsigned int i;
int first;
if (ifd >= EXIF_IFD_COUNT)
return NULL;
first = exif_tag_table_first(tag);
if (first < 0)
return NULL;
for (i = first; ExifTagTable[i].name; i++) {
if (ExifTagTable[i].tag == tag) {
if (RECORDED)
break;
} else
return NULL; /* Recorded tag not found in the table */
}
return ExifTagTable[i].name;
} | false | false | false | false | false | 0 |
Write(const wxString& name, const ConfigManagerContainer::SerializableObjectMap* map)
{
wxString key(name);
TiXmlElement* e = AssertPath(key);
TiXmlElement *leaf = GetUniqElement(e, key);
TiXmlElement *mNode;
mNode = GetUniqElement(leaf, _T("objmap"));
leaf->RemoveChild(mNode);
mNode = GetUniqElement(leaf, _T("objmap"));
for (ConfigManagerContainer::SerializableObjectMap::const_iterator it = map->begin(); it != map->end(); ++it)
{
TiXmlElement s(cbU2C(it->first));
s.InsertEndChild(TiXmlText(cbU2C(wxBase64::Encode(it->second->SerializeOut()))));
mNode->InsertEndChild(s);
}
} | false | false | false | false | false | 0 |
pg_db_free_savepoints_to (pTHX_ imp_dbh_t * imp_dbh, const char *savepoint)
{
I32 i;
if (TSTART_slow) TRC(DBILOGFP, "%sBegin pg_db_free_savepoints_to\n", THEADER_slow);
for (i = av_len(imp_dbh->savepoints); i >= 0; i--) {
SV * const elem = av_pop(imp_dbh->savepoints);
if (strEQ(SvPV_nolen(elem), savepoint)) {
sv_2mortal(elem);
break;
}
sv_2mortal(elem);
}
if (TEND_slow) TRC(DBILOGFP, "%sEnd pg_db_free_savepoints_to\n", THEADER_slow);
} | false | false | false | false | false | 0 |
e1000_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,
u32 usec_interval, bool *success)
{
s32 ret_val = E1000_SUCCESS;
u16 i, phy_status;
DEBUGFUNC("e1000_phy_has_link_generic");
if (!(hw->phy.ops.read_reg))
return E1000_SUCCESS;
for (i = 0; i < iterations; i++) {
/*
* Some PHYs require the PHY_STATUS register to be read
* twice due to the link bit being sticky. No harm doing
* it across the board.
*/
ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status);
if (ret_val) {
/*
* If the first read fails, another entity may have
* ownership of the resources, wait and try again to
* see if they have relinquished the resources yet.
*/
usec_delay(usec_interval);
}
ret_val = hw->phy.ops.read_reg(hw, PHY_STATUS, &phy_status);
if (ret_val)
break;
if (phy_status & MII_SR_LINK_STATUS)
break;
if (usec_interval >= 1000)
msec_delay_irq(usec_interval/1000);
else
usec_delay(usec_interval);
}
*success = (i < iterations) ? true : false;
return ret_val;
} | false | false | false | false | false | 0 |
privateUserCallback(void *callbackData, unsigned long bytes)
{
DIMSE_PrivateUserContext *ctx;
ctx = (DIMSE_PrivateUserContext*)callbackData;
ctx->progress->state = DIMSE_StoreProgressing;
ctx->progress->progressBytes = bytes;
ctx->progress->callbackCount++;
if (ctx->callback) {
ctx->callback(ctx->callbackData, ctx->progress, ctx->request);
}
} | false | false | false | false | false | 0 |
setCellRowAlignment( Symbol alignment ) {
switch( alignment ) {
case symbolEnd: nextFormat.PgfCellAlignment = MifDoc::sBottom; break;
case symbolCenter: nextFormat.PgfCellAlignment = MifDoc::sMiddle; break;
default: nextFormat.PgfCellAlignment = MifDoc::sTop; break;
}
} | false | false | false | false | false | 0 |
update_system_secrets_cache (NMSettingsConnection *self)
{
NMSettingsConnectionPrivate *priv = NM_SETTINGS_CONNECTION_GET_PRIVATE (self);
if (priv->system_secrets)
g_object_unref (priv->system_secrets);
priv->system_secrets = nm_connection_duplicate (NM_CONNECTION (self));
/* Clear out non-system-owned and not-saved secrets */
nm_connection_clear_secrets_with_flags (priv->system_secrets,
secrets_filter_cb,
GUINT_TO_POINTER (NM_SETTING_SECRET_FLAG_NONE));
} | false | false | false | false | false | 0 |
instance (ACE_Service_Repository *s)
{
ACE_TRACE ("ACE_Service_Repository::instance");
ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
*ACE_Static_Object_Lock::instance (), 0));
ACE_Service_Repository *t = ACE_Service_Repository::svc_rep_;
// We can't safely delete it since we don't know who created it!
ACE_Service_Repository::delete_svc_rep_ = false;
ACE_Service_Repository::svc_rep_ = s;
return t;
} | false | false | false | false | false | 0 |
record_start(char *outfile, int *nr)
{
int wav;
do {
sprintf(outfile,"%s%03d.wav",filename,(*nr)++);
wav = open(outfile, O_WRONLY | O_EXCL | O_CREAT, 0666);
} while ((-1 == wav) && (EEXIST == errno));
if (-1 == wav) {
perror("open");
exit(1);
}
wav_start_write(wav,rate);
return wav;
} | false | false | false | false | false | 0 |
setElementPrefix(Plasma::Location location)
{
switch (location) {
case TopEdge:
setElementPrefix("north");
break;
case BottomEdge:
setElementPrefix("south");
break;
case LeftEdge:
setElementPrefix("west");
break;
case RightEdge:
setElementPrefix("east");
break;
default:
setElementPrefix(QString());
break;
}
d->location = location;
} | false | false | false | false | false | 0 |
rtw_alloc_stainfo23a(struct sta_priv *pstapriv, const u8 *hwaddr, gfp_t gfp)
{
struct list_head *phash_list;
struct sta_info *psta;
struct recv_reorder_ctrl *preorder_ctrl;
s32 index;
int i = 0;
u16 wRxSeqInitialValue = 0xffff;
psta = kmalloc(sizeof(struct sta_info), gfp);
if (!psta)
return NULL;
spin_lock_bh(&pstapriv->sta_hash_lock);
_rtw_init_stainfo(psta);
psta->padapter = pstapriv->padapter;
ether_addr_copy(psta->hwaddr, hwaddr);
index = wifi_mac_hash(hwaddr);
RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_,
"rtw_alloc_stainfo23a: index = %x\n", index);
if (index >= NUM_STA) {
RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_err_,
"ERROR => rtw_alloc_stainfo23a: index >= NUM_STA\n");
psta = NULL;
goto exit;
}
phash_list = &pstapriv->sta_hash[index];
list_add_tail(&psta->hash_list, phash_list);
pstapriv->asoc_sta_count++;
/* For the SMC router, the sequence number of first packet of WPS
handshake will be 0. */
/* In this case, this packet will be dropped by recv_decache function
if we use the 0x00 as the default value for tid_rxseq variable. */
/* So, we initialize the tid_rxseq variable as the 0xffff. */
for (i = 0; i < 16; i++)
memcpy(&psta->sta_recvpriv.rxcache.tid_rxseq[i],
&wRxSeqInitialValue, 2);
RT_TRACE(_module_rtl871x_sta_mgt_c_, _drv_info_,
"alloc number_%d stainfo with hwaddr = %pM\n",
pstapriv->asoc_sta_count, hwaddr);
init_addba_retry_timer23a(psta);
/* for A-MPDU Rx reordering buffer control */
for (i = 0; i < 16; i++) {
preorder_ctrl = &psta->recvreorder_ctrl[i];
preorder_ctrl->padapter = pstapriv->padapter;
preorder_ctrl->enable = false;
preorder_ctrl->indicate_seq = 0xffff;
preorder_ctrl->wend_b = 0xffff;
/* preorder_ctrl->wsize_b = (NR_RECVBUFF-2); */
preorder_ctrl->wsize_b = 64;/* 64; */
_rtw_init_queue23a(&preorder_ctrl->pending_recvframe_queue);
rtw_init_recv_timer23a(preorder_ctrl);
}
/* init for DM */
psta->rssi_stat.UndecoratedSmoothedPWDB = (-1);
psta->rssi_stat.UndecoratedSmoothedCCK = (-1);
/* init for the sequence number of received management frame */
psta->RxMgmtFrameSeqNum = 0xffff;
exit:
spin_unlock_bh(&pstapriv->sta_hash_lock);
return psta;
} | false | false | false | false | false | 0 |
get_color_code(int idx)
{
if (showbranch_use_color)
return column_colors_ansi[idx % column_colors_ansi_max];
return "";
} | false | false | false | false | false | 0 |
convertTagCaseType( const QString &tag, int type )
{
if( tag.isEmpty() )
return tag;
switch( type )
{
case 0:
return tag;
case 1:
return tag.toLower().replace( 0, 1, tag.left( 1 ).toUpper() );
case 2:
{
QString complete;
QStringList splitted = tag.toLower().split( " ", QString::SkipEmptyParts );
foreach( QString word, splitted )
{
if( word.length() > 1 )
word.replace( 0, 1, word.left( 1 ).toUpper() );
complete += word + " ";
}
complete.truncate( complete.length() - 1 );
return complete;
}
case 3:
return tag.toUpper();
case 4:
return tag.toLower();
default:
return tag;
}
} | false | false | false | false | false | 0 |
load_dup(UnpicklerObject *self)
{
PyObject *last;
Py_ssize_t len;
if ((len = Py_SIZE(self->stack)) <= 0)
return stack_underflow();
last = self->stack->data[len - 1];
PDATA_APPEND(self->stack, last, -1);
return 0;
} | false | false | false | false | false | 0 |
av_get_config(const char *param)
{
const char *val;
val = NULL;
if(strcmp(param, "moduledir") == 0)
val = MODULE_DIR;
else if(strcmp(param, "compiledate") == 0)
val = COMPILE_DATE;
else if(strcmp(param, "compilesystem") == 0)
val = COMPILE_SYSTEM;
if(val == NULL)
return NULL;
return av_strdup(val);
} | false | false | false | false | false | 0 |
nv_crtc_prepare(struct drm_crtc *crtc)
{
struct drm_device *dev = crtc->dev;
struct nouveau_drm *drm = nouveau_drm(dev);
struct nouveau_crtc *nv_crtc = nouveau_crtc(crtc);
const struct drm_crtc_helper_funcs *funcs = crtc->helper_private;
if (nv_two_heads(dev))
NVSetOwner(dev, nv_crtc->index);
drm_vblank_pre_modeset(dev, nv_crtc->index);
funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
NVBlankScreen(dev, nv_crtc->index, true);
/* Some more preparation. */
NVWriteCRTC(dev, nv_crtc->index, NV_PCRTC_CONFIG, NV_PCRTC_CONFIG_START_ADDRESS_NON_VGA);
if (drm->device.info.family == NV_DEVICE_INFO_V0_CURIE) {
uint32_t reg900 = NVReadRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900);
NVWriteRAMDAC(dev, nv_crtc->index, NV_PRAMDAC_900, reg900 & ~0x10000);
}
} | false | false | false | false | false | 0 |
lunar_date_init (LunarDate *date)
{
gchar *cfgfile;
LunarDatePrivate *priv;
priv = LUNAR_DATE_GET_PRIVATE (date);
lunar_date_init_i18n();
priv->keyfile = g_key_file_new();
priv->solar = g_new0 (CLDate, 1);
priv->lunar = g_new0 (CLDate, 1);
priv->lunar2 = g_new0 (CLDate, 1);
priv->gan = g_new0 (CLDate, 1);
priv->zhi = g_new0 (CLDate, 1);
priv->gan2 = g_new0 (CLDate, 1);
priv->zhi2 = g_new0 (CLDate, 1);
cfgfile = g_build_filename(g_get_user_config_dir() , "liblunar", "holiday.dat", NULL);
if (!g_file_test(cfgfile, G_FILE_TEST_EXISTS |G_FILE_TEST_IS_REGULAR))
{
const gchar* const * langs = g_get_language_names();
int i = 0;
while(langs[i] && langs[i][0] != '\0')
{
if (g_str_has_prefix(langs[i], "zh_") && (strlen(langs[i])>= 5))
{
gchar *lang = g_strconcat("holiday.", g_strndup(langs[i], 5), NULL);
g_free(cfgfile);
#ifdef RUN_IN_SOURCE_TREE
cfgfile = g_build_filename("..", "data", lang, NULL);
if ( !g_file_test(cfgfile, G_FILE_TEST_EXISTS |G_FILE_TEST_IS_REGULAR))
{
g_free(cfgfile);
cfgfile = g_build_filename("date", lang, NULL);
}
#else
cfgfile = g_build_filename(LUNAR_HOLIDAYDIR, lang, NULL);
#endif
if (g_file_test(cfgfile, G_FILE_TEST_EXISTS |G_FILE_TEST_IS_REGULAR))
{
break;
}
g_free(lang);
}
i++;
}
}
if (!g_key_file_load_from_file(priv->keyfile, cfgfile, G_KEY_FILE_KEEP_COMMENTS, NULL))
{
g_critical("Format error \"%s\" !!!\n", cfgfile);
}
g_free(cfgfile);
_cl_date_make_all_lunar_data(date);
} | false | false | false | false | false | 0 |
_insert_config_node(struct dm_config_node **cn1,
struct dm_config_node *cn2)
{
if (!*cn1) {
*cn1 = cn2;
cn2->sib = NULL;
} else {
cn2->sib = (*cn1)->sib;
(*cn1)->sib = cn2;
}
} | false | false | false | false | false | 0 |
db_open_local(const char *zDbName){
int i, n;
char zPwd[2000];
static const char aDbName[][10] = { "_FOSSIL_", ".fslckout", ".fos" };
if( g.localOpen) return 1;
file_getcwd(zPwd, sizeof(zPwd)-20);
n = strlen(zPwd);
if( n==1 && zPwd[0]=='/' ) zPwd[0] = '.';
while( n>0 ){
for(i=0; i<count(aDbName); i++){
sqlite3_snprintf(sizeof(zPwd)-n, &zPwd[n], "/%s", aDbName[i]);
if( isValidLocalDb(zPwd) ){
/* Found a valid checkout database file */
zPwd[n] = 0;
while( n>1 && zPwd[n-1]=='/' ){
n--;
zPwd[n] = 0;
}
g.zLocalRoot = mprintf("%s/", zPwd);
g.localOpen = 1;
db_open_config(0);
db_open_repository(zDbName);
return 1;
}
}
n--;
while( n>0 && zPwd[n]!='/' ){ n--; }
while( n>0 && zPwd[n-1]=='/' ){ n--; }
zPwd[n] = 0;
}
/* A checkout database file could not be found */
return 0;
} | false | false | false | false | false | 0 |
set_dads(struct pval *dad, struct pval *child_list)
{
struct pval *t;
for(t=child_list;t;t=t->next) /* simple stuff */
t->dad = dad;
} | false | false | false | false | false | 0 |
mdb_sql_dump_node(MdbSargNode *node, int level)
{
int i;
int mylevel = level+1;
if (!level)
printf("root ");
for (i=0;i<mylevel;i++) printf("--->");
switch (node->op) {
case MDB_OR:
printf(" or\n");
break;
case MDB_AND:
printf(" and\n");
break;
case MDB_NOT:
printf(" not\n");
break;
case MDB_LT:
printf(" < %d\n", node->value.i);
break;
case MDB_GT:
printf(" < %d\n", node->value.i);
break;
case MDB_LIKE:
printf(" like %s\n", node->value.s);
break;
case MDB_EQUAL:
printf(" = %d\n", node->value.i);
break;
}
if (node->left) {
printf("left ");
mdb_sql_dump_node(node->left, mylevel);
}
if (node->right) {
printf("right ");
mdb_sql_dump_node(node->right, mylevel);
}
} | false | false | false | false | false | 0 |
logfs_mtd_can_write_buf(struct super_block *sb, u64 ofs)
{
struct logfs_super *super = logfs_super(sb);
void *buf;
int err;
buf = kmalloc(super->s_writesize, GFP_KERNEL);
if (!buf)
return -ENOMEM;
err = logfs_mtd_read(sb, ofs, super->s_writesize, buf);
if (err)
goto out;
if (memchr_inv(buf, 0xff, super->s_writesize))
err = -EIO;
kfree(buf);
out:
return err;
} | false | false | false | false | false | 0 |
php_plain_files_unlink(php_stream_wrapper *wrapper, char *url, int options, php_stream_context *context TSRMLS_DC)
{
char *p;
int ret;
if ((p = strstr(url, "://")) != NULL) {
url = p + 3;
}
if (php_check_open_basedir(url TSRMLS_CC)) {
return 0;
}
ret = VCWD_UNLINK(url);
if (ret == -1) {
if (options & REPORT_ERRORS) {
php_error_docref1(NULL TSRMLS_CC, url, E_WARNING, "%s", strerror(errno));
}
return 0;
}
/* Clear stat cache (and realpath cache) */
php_clear_stat_cache(1, NULL, 0 TSRMLS_CC);
return 1;
} | false | false | false | false | false | 0 |
ext2_has_free_blocks(struct ext2_sb_info *sbi)
{
ext2_fsblk_t free_blocks, root_blocks;
free_blocks = percpu_counter_read_positive(&sbi->s_freeblocks_counter);
root_blocks = le32_to_cpu(sbi->s_es->s_r_blocks_count);
if (free_blocks < root_blocks + 1 && !capable(CAP_SYS_RESOURCE) &&
!uid_eq(sbi->s_resuid, current_fsuid()) &&
(gid_eq(sbi->s_resgid, GLOBAL_ROOT_GID) ||
!in_group_p (sbi->s_resgid))) {
return 0;
}
return 1;
} | false | false | false | false | false | 0 |
FoldBinaryNumeric(JSContext *cx, JSOp op, JSParseNode *pn1, JSParseNode *pn2,
JSParseNode *pn, JSTreeContext *tc)
{
jsdouble d, d2;
int32 i, j;
JS_ASSERT(pn1->pn_type == TOK_NUMBER && pn2->pn_type == TOK_NUMBER);
d = pn1->pn_dval;
d2 = pn2->pn_dval;
switch (op) {
case JSOP_LSH:
case JSOP_RSH:
i = js_DoubleToECMAInt32(d);
j = js_DoubleToECMAInt32(d2);
j &= 31;
d = (op == JSOP_LSH) ? i << j : i >> j;
break;
case JSOP_URSH:
j = js_DoubleToECMAInt32(d2);
j &= 31;
d = js_DoubleToECMAUint32(d) >> j;
break;
case JSOP_ADD:
d += d2;
break;
case JSOP_SUB:
d -= d2;
break;
case JSOP_MUL:
d *= d2;
break;
case JSOP_DIV:
if (d2 == 0) {
#if defined(XP_WIN)
/* XXX MSVC miscompiles such that (NaN == 0) */
if (JSDOUBLE_IS_NaN(d2))
d = *cx->runtime->jsNaN;
else
#endif
if (d == 0 || JSDOUBLE_IS_NaN(d))
d = *cx->runtime->jsNaN;
else if (JSDOUBLE_IS_NEG(d) != JSDOUBLE_IS_NEG(d2))
d = *cx->runtime->jsNegativeInfinity;
else
d = *cx->runtime->jsPositiveInfinity;
} else {
d /= d2;
}
break;
case JSOP_MOD:
if (d2 == 0) {
d = *cx->runtime->jsNaN;
} else {
d = js_fmod(d, d2);
}
break;
default:;
}
/* Take care to allow pn1 or pn2 to alias pn. */
if (pn1 != pn)
RecycleTree(pn1, tc);
if (pn2 != pn)
RecycleTree(pn2, tc);
pn->pn_type = TOK_NUMBER;
pn->pn_op = JSOP_DOUBLE;
pn->pn_arity = PN_NULLARY;
pn->pn_dval = d;
return JS_TRUE;
} | false | false | false | false | false | 0 |
php_html_entities(INTERNAL_FUNCTION_PARAMETERS, int all)
{
char *str, *hint_charset = NULL;
int str_len, hint_charset_len = 0;
int len;
long quote_style = ENT_COMPAT;
char *replaced;
zend_bool double_encode = 1;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|ls!b", &str, &str_len, "e_style, &hint_charset, &hint_charset_len, &double_encode) == FAILURE) {
return;
}
replaced = php_escape_html_entities_ex(str, str_len, &len, all, quote_style, hint_charset, double_encode TSRMLS_CC);
RETVAL_STRINGL(replaced, len, 0);
} | false | false | false | false | false | 0 |
bcm5600_reg_free(struct nm_16esw_data *d)
{
struct bcm5600_reg *reg,*next;
int i;
for(i=0;i<BCM5600_REG_HASH_SIZE;i++)
for(reg=d->reg_hash_table[i];reg;reg=next) {
next = reg->next;
free(reg);
}
} | false | false | false | false | false | 0 |
agxbinit(agxbuf * xb, unsigned int hint, unsigned char *init)
{
if (init) {
xb->buf = init;
xb->dyna = 0;
} else {
if (hint == 0)
hint = BUFSIZ;
xb->dyna = 1;
xb->buf = N_GNEW(hint, unsigned char);
}
xb->eptr = xb->buf + hint;
xb->ptr = xb->buf;
*xb->ptr = '\0';
} | false | true | false | false | false | 1 |
SetStringValue( char *String,
char **SavedString,
unsigned int linenum )
{
char *fn = "SetStringValue()";
unsigned int Size;
Size = strlen( String ) + 1;
/*
* Do some reasonable bounds checking before we malloc()
*/
if ( ( Size < 1 ) || ( Size > 4096 ) )
{
syslog( LOG_ERR, "%s: Length of string value at line %d of config file is not within size boundaries -- Exiting.", fn, linenum );
exit( 1 );
}
*SavedString = malloc( Size );
if ( ! *SavedString )
{
syslog( LOG_ERR, "%s: malloc() failed: %s -- Exiting.", fn,
strerror( errno ) );
exit( 1 );
}
memcpy( *SavedString, String, Size );
return;
} | false | false | false | false | false | 0 |
UTF16toUTF8(FILE *fp)
{
FILE *fp8;
unsigned short t16[512];
unsigned char t8[2048];
const UTF16 *p16,*p16a;
UTF8 *p8;
if((fp8=tmpfile()) == NULL) return NULL;
#ifdef _WIN32
_setmode(_fileno(fp),_O_BINARY);
#endif
fseek(fp,2,SEEK_SET);
while(fread(t16,2,1,fp))
{
p16 = t16; p8 = t8; p16a = p16+1;
if(IConvertUTF16toUTF8(&p16,p16a,&p8,t8+2047) == 0)
{
if (fwrite(t8,1,(size_t)(p8-t8),fp8) == 0)
fail(1, "unable to write to temporary file %s", fp8);
}
else
fail(1,"unable to convert Unicode file, illegal or malformed UTF16 sequence");
}
fseek(fp8,0,SEEK_SET);
return fp8;
} | false | false | false | false | true | 1 |
genTempFilename(const char *dir,
const char *segment,
const char *extension)
{
char buf[256];
char *name, *outname;
l_int32 pid, nseg, next;
PROCNAME("genTempFilename");
if (!dir)
return (char *)ERROR_PTR("dir not defined", procName, NULL);
#if COMPILER_MSVC
pid=GetCurrentProcessId();
#else
pid = getpid();
#endif
if (segment)
nseg = strlen(segment);
else
nseg = 0;
if (extension)
next = strlen(extension);
else
next = 0;
#if COMPILER_MSVC
snprintf(buf, 255 - nseg - next, "%s\\%d_", dir, pid);
#else
snprintf(buf, 255 - nseg - next, "%s/%d_", dir, pid);
#endif
name = stringJoin(buf, segment);
outname = stringJoin(name, extension);
FREE(name);
return outname;
} | false | false | false | false | false | 0 |
cb_entry(GtkWidget *widget, gpointer data)
{
gchar *empty_line[] = { "","" };
GtkWidget *clist;
const char *entry_text;
int count = 0;
jp_logf(JP_LOG_DEBUG, "enter cb_entry\n");
entry_text = gtk_entry_get_text(GTK_ENTRY(widget));
if (!entry_text || !strlen(entry_text)) {
return;
}
jp_logf(JP_LOG_DEBUG, "entry text = %s\n", entry_text);
clist = data;
gtk_clist_clear(GTK_CLIST(clist));
count += search_address_or_contacts(entry_text, clist);
count += search_todo(entry_text, clist);
count += search_memo(entry_text, clist);
#ifdef ENABLE_PLUGINS
count += search_plugins(entry_text, clist);
#endif
/* sort the results */
gtk_clist_set_sort_column(GTK_CLIST(clist), 1);
gtk_clist_sort(GTK_CLIST(clist));
/* the datebook events are already sorted by date */
count += search_datebook(entry_text, clist);
if (count == 0) {
gtk_clist_prepend(GTK_CLIST(clist), empty_line);
gtk_clist_set_text(GTK_CLIST(clist), 0, 1, _("No records found"));
}
/* Highlight the first row in the list of returned items.
* This does NOT cause the main window to jump to the selected record. */
clist_select_row(GTK_CLIST(clist), 0, 0);
/* select the first record found */
cb_clist_selection(clist, 0, 0, (GdkEventButton *)1, NULL);
return;
} | false | false | false | false | false | 0 |
profiler_exit( unsigned int index ) {
/* Stop the current timer */
timer_stop( &profiles[index].time_in );
/* Pop the stack */
stack_size--;
/* Start the timer, if needed */
if( (stack_size > 0) && profiles[stack[stack_size-1]].timed ) {
timer_start( &profiles[stack[stack_size-1]].time_in );
}
} | false | false | false | false | false | 0 |
sign_prepare (GMimeObject *mime_part)
{
GMimeContentEncoding encoding;
GMimeMultipart *multipart;
GMimeObject *subpart;
int i, n;
if (GMIME_IS_MULTIPART (mime_part)) {
multipart = (GMimeMultipart *) mime_part;
if (GMIME_IS_MULTIPART_SIGNED (multipart) ||
GMIME_IS_MULTIPART_ENCRYPTED (multipart)) {
/* must not modify these parts as they must be treated as opaque */
return;
}
n = g_mime_multipart_get_count (multipart);
for (i = 0; i < n; i++) {
subpart = g_mime_multipart_get_part (multipart, i);
sign_prepare (subpart);
}
} else if (GMIME_IS_MESSAGE_PART (mime_part)) {
subpart = GMIME_MESSAGE_PART (mime_part)->message->mime_part;
sign_prepare (subpart);
} else {
encoding = g_mime_part_get_content_encoding (GMIME_PART (mime_part));
if (encoding != GMIME_CONTENT_ENCODING_BASE64)
g_mime_part_set_content_encoding (GMIME_PART (mime_part),
GMIME_CONTENT_ENCODING_QUOTEDPRINTABLE);
}
} | false | false | false | false | false | 0 |
SetClippingPlanes(vtkPlanes *planes)
{
vtkPlane *plane;
if (!planes)
{
return;
}
int numPlanes = planes->GetNumberOfPlanes();
this->RemoveAllClippingPlanes();
for (int i=0; i<numPlanes && i<6; i++)
{
plane = vtkPlane::New();
planes->GetPlane(i, plane);
this->AddClippingPlane(plane);
plane->Delete();
}
} | false | false | false | false | false | 0 |
word_read_macro_info(int fd, macro_info_t *macro_info)
{
if(!read_uint16(fd, ¯o_info->count, FALSE)) {
cli_dbgmsg("read macro_info failed\n");
macro_info->count = 0;
return NULL;
}
cli_dbgmsg("macro count: %d\n", macro_info->count);
if(macro_info->count == 0)
return NULL;
macro_info->entries = (macro_entry_t *)cli_malloc(sizeof(macro_entry_t) * macro_info->count);
if(macro_info->entries == NULL) {
macro_info->count = 0;
cli_errmsg("word_read_macro_info: Unable to allocate memory for macro_info->entries\n");
return NULL;
}
if(!word_read_macro_entry(fd, macro_info)) {
free(macro_info->entries);
macro_info->count = 0;
return NULL;
}
return macro_info;
} | false | false | false | false | false | 0 |
fieldMatrixToIntegerMatrix(FieldMatrix const &m)
{
IntegerMatrix ret(m.getHeight(),m.getWidth());
for(int i=0;i<m.getHeight();i++)
ret[i]=fieldVectorToIntegerVector(m[i]);
return ret;
} | false | false | false | false | false | 0 |
evaluate_from_tenzor(const gs_function_Sd_t *pfn, int *I, double *T, int offset, int ii, double *y)
{
int s = pfn->params.array_step[ii], k, l, code;
if (ii < 0) {
for (k = 0; k < pfn->params.n; k++)
y[k] = *(pfn->params.pole + offset + k);
} else if (T[ii] == 0) {
return evaluate_from_tenzor(pfn, I, T, offset + s * I[ii], ii - 1, y);
} else {
double t0 = T[ii], t1 = 1 - t0;
double p[4][max_Sd_n];
for (l = 0; l < 4; l++) {
code = evaluate_from_tenzor(pfn, I, T, offset + s * I[ii] + l * (s / 3), ii - 1, p[l]);
if (code < 0)
return code;
}
for (k = 0; k < pfn->params.n; k++)
y[k] = p[0][k] * t1 * t1 * t1 +
p[1][k] * t1 * t1 * t0 * 3 +
p[2][k] * t1 * t0 * t0 * 3 +
p[3][k] * t0 * t0 * t0;
}
return 0;
} | false | false | false | false | false | 0 |
print_rate(const struct ap_session *ses, char *buf)
{
struct shaper_pd_t *pd = find_pd((struct ap_session *)ses, 0);
if (pd && (pd->down_speed || pd->up_speed))
sprintf(buf, "%i/%i", pd->down_speed, pd->up_speed);
else
*buf = 0;
} | false | false | false | false | false | 0 |
source_dispose (GObject *object)
{
ESourcePrivate *priv;
priv = E_SOURCE_GET_PRIVATE (object);
if (priv->dbus_object != NULL) {
EDBusObject *dbus_object;
EDBusSource *dbus_source;
dbus_object = E_DBUS_OBJECT (priv->dbus_object);
dbus_source = e_dbus_object_get_source (dbus_object);
if (dbus_source != NULL) {
g_signal_handlers_disconnect_matched (
dbus_source, G_SIGNAL_MATCH_DATA,
0, 0, NULL, NULL, object);
g_object_unref (dbus_source);
}
g_object_unref (priv->dbus_object);
priv->dbus_object = NULL;
}
if (priv->main_context != NULL) {
g_main_context_unref (priv->main_context);
priv->main_context = NULL;
}
/* XXX Maybe not necessary to acquire the lock? */
g_mutex_lock (&priv->changed_lock);
if (priv->changed != NULL) {
g_source_destroy (priv->changed);
g_source_unref (priv->changed);
priv->changed = NULL;
}
g_mutex_unlock (&priv->changed_lock);
g_hash_table_remove_all (priv->extensions);
/* Chain up to parent's dispose() method. */
G_OBJECT_CLASS (e_source_parent_class)->dispose (object);
} | false | false | false | false | false | 0 |
evbuffer_remove(struct evbuffer *buf, void *data, size_t datlen)
{
size_t nread = datlen;
if (nread >= buf->off)
nread = buf->off;
memcpy(data, buf->buffer, nread);
evbuffer_drain(buf, nread);
return (nread);
} | false | false | false | false | false | 0 |
unlock()
{
bool fRet(false);
if (isOpen())
{
if (isLocked())
{
struct flock fl;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
fl.l_type = F_UNLCK;
if (::fcntl(handle(), F_SETLKW, &fl) != -1)
{
m_LockMode = NoLock;
fRet = true;
}
else
qWarning("LockedFile::lock(): fcntl: %s", ::strerror(errno));
}
else
fRet = true;
}
else
qWarning("LockedFile::unlock(): file is not opened");
return(fRet);
} | false | false | false | false | false | 0 |
getFunctionName(const DISubprogram *SP) {
if (!SP->getLinkageName().empty())
return SP->getLinkageName();
return SP->getName();
} | false | false | false | false | false | 0 |
fuse_dev_fasync(int fd, struct file *file, int on)
{
struct fuse_dev *fud = fuse_get_dev(file);
if (!fud)
return -EPERM;
/* No locking - fasync_helper does its own locking */
return fasync_helper(fd, file, on, &fud->fc->iq.fasync);
} | false | false | false | false | false | 0 |
cache_remove(struct cache *cache, void *ptr)
{
int ret = 0;
struct backcommon *e;
if (NULL == ptr)
{
LOG("=> lru_remove\n<= lru_remove (null entry)\n", 0, 0, 0);
return ret;
}
e = (struct backcommon *)ptr;
PR_Lock(cache->c_mutex);
if (CACHE_TYPE_ENTRY == e->ep_type) {
ASSERT(e->ep_refcnt > 0);
ret = entrycache_remove_int(cache, (struct backentry *)e);
} else if (CACHE_TYPE_DN == e->ep_type) {
ret = dncache_remove_int(cache, (struct backdn *)e);
}
PR_Unlock(cache->c_mutex);
return ret;
} | false | false | false | false | false | 0 |
load_firmware(struct hfi1_devdata *dd)
{
int ret;
if (fw_fabric_serdes_load) {
ret = acquire_hw_mutex(dd);
if (ret)
return ret;
set_sbus_fast_mode(dd);
set_serdes_broadcast(dd, all_fabric_serdes_broadcast,
fabric_serdes_broadcast[dd->hfi1_id],
fabric_serdes_addrs[dd->hfi1_id],
NUM_FABRIC_SERDES);
turn_off_spicos(dd, SPICO_FABRIC);
ret = load_fabric_serdes_firmware(dd, &fw_fabric);
clear_sbus_fast_mode(dd);
release_hw_mutex(dd);
if (ret)
return ret;
}
if (fw_8051_load) {
ret = load_8051_firmware(dd, &fw_8051);
if (ret)
return ret;
}
return 0;
} | false | false | false | false | false | 0 |
first_available(list_number)
int list_number;
{
int index;
if (list_size[list_number] == 0) return (0);
//printf("--- looking for next object in list\n");
for (index = 0; index < max_size[list_number]; index++) {
if (object_list[list_number][index] != 0) {
//printf("--- returning object %s\n", object[object_list[list_number][index]]->label);
return (object_list[list_number][index]);
}
}
//printf("--- no objects left in list\n");
/* NO OBJECTS LEFT IN THE LIST */
return (0);
} | false | false | false | false | false | 0 |
elm_diskselector_smart_class_get(void)
{
static Elm_Diskselector_Smart_Class _sc =
ELM_DISKSELECTOR_SMART_CLASS_INIT_NAME_VERSION
(ELM_DISKSELECTOR_SMART_NAME);
static const Elm_Diskselector_Smart_Class *class = NULL;
Evas_Smart_Class *esc = (Evas_Smart_Class *)&_sc;
if (class) return class;
_elm_diskselector_smart_set(&_sc);
esc->callbacks = _smart_callbacks;
class = &_sc;
return class;
} | false | false | false | false | false | 0 |
profile_path_perm(const char *op, struct aa_profile *profile,
const struct path *path, char *buffer, u32 request,
struct path_cond *cond, int flags,
struct aa_perms *perms)
{
const char *name;
int error;
if (profile_unconfined(profile))
return 0;
error = path_name(op, &profile->label, path,
flags | profile->path_flags, buffer, &name, cond,
request);
if (error)
return error;
return __aa_path_perm(op, profile, name, request, cond, flags,
perms);
} | false | false | false | false | false | 0 |
rv40_parse_slice_header(RV34DecContext *r, GetBitContext *gb, SliceInfo *si)
{
int mb_bits;
int w = r->s.width, h = r->s.height;
int mb_size;
memset(si, 0, sizeof(SliceInfo));
if(get_bits1(gb))
return -1;
si->type = get_bits(gb, 2);
if(si->type == 1) si->type = 0;
si->quant = get_bits(gb, 5);
if(get_bits(gb, 2))
return -1;
si->vlc_set = get_bits(gb, 2);
skip_bits1(gb);
si->pts = get_bits(gb, 13);
if(!si->type || !get_bits1(gb))
rv40_parse_picture_size(gb, &w, &h);
if(avcodec_check_dimensions(r->s.avctx, w, h) < 0)
return -1;
si->width = w;
si->height = h;
mb_size = ((w + 15) >> 4) * ((h + 15) >> 4);
mb_bits = ff_rv34_get_start_offset(gb, mb_size);
si->start = get_bits(gb, mb_bits);
return 0;
} | false | false | false | false | false | 0 |
getext(ext, flagsp)
CONST char *ext;
u_char *flagsp;
{
char *tmp;
*flagsp = 0;
# ifndef OLDPARSE
if (*ext == '/') {
ext++;
*flagsp |= LF_IGNORECASE;
}
# endif
if (*ext == '*') tmp = Xstrdup(ext);
else {
tmp = Xmalloc(strlen(ext) + 2);
*tmp = '*';
Xstrcpy(&(tmp[1]), ext);
}
return(tmp);
} | false | false | false | false | false | 0 |
openUrl( const KUrl &url )
{
setUrl(url);
m_lineParser->reset();
startHeader();
//m_mimeType = arguments().mimeType();
// Hmm, args.reload is set to true when reloading, but this doesn't seem to be enough...
// I get "HOLD: Reusing held slave for <url>", and the old data
m_job = KIO::get( url,
arguments().reload() ? KIO::Reload : KIO::NoReload,
KIO::HideProgressInfo );
emit started( 0 /*m_job*/ ); // don't pass the job, it would interfere with our own infoMessage
connect( m_job, SIGNAL(result(KJob*)),
this, SLOT(slotJobFinished(KJob*)) );
connect( m_job, SIGNAL(data(KIO::Job*,QByteArray)),
this, SLOT(slotData(KIO::Job*,QByteArray)) );
m_numberOfFrames = 0;
m_numberOfFramesSkipped = 0;
m_totalNumberOfFrames = 0;
m_qtime.start();
m_timer->start( 1000 ); //1s
return true;
} | false | false | false | false | false | 0 |
metric_init(void)
{
g_val_t rval;
char * dummy;
struct stat struct_stat;
num_cpustates = num_cpustates_func();
/* scaling_max_freq will contain the max CPU speed if available */
cpufreq = 0;
if ( stat(SCALING_MAX_FREQ, &struct_stat) == 0 ) {
cpufreq = 1;
dummy = sys_devices_system_cpu;
slurpfile(SCALING_MAX_FREQ, &dummy, 32);
}
dummy = proc_cpuinfo;
rval.int32 = slurpfile("/proc/cpuinfo", &dummy, BUFFSIZE);
if (proc_cpuinfo == NULL)
proc_cpuinfo = dummy;
if ( rval.int32 == SLURP_FAILURE )
{
err_msg("metric_init() got an error from slurpfile() /proc/cpuinfo");
rval.int32 = SYNAPSE_FAILURE;
return rval;
}
dummy = proc_sys_kernel_osrelease;
rval.int32 = slurpfile("/proc/sys/kernel/osrelease", &dummy,
MAX_G_STRING_SIZE);
if ( rval.int32 == SLURP_FAILURE )
{
err_msg("metric_init() got an error from slurpfile()");
rval.int32 = SYNAPSE_FAILURE;
return rval;
}
/* Get rid of pesky \n in osrelease */
proc_sys_kernel_osrelease[rval.int32-1] = '\0';
dummy = update_file(&proc_net_dev);
if ( dummy == NULL )
{
err_msg("metric_init() got an error from update_file()");
rval.int32 = SYNAPSE_FAILURE;
return rval;
}
update_ifdata("metric_inint");
rval.int32 = SYNAPSE_SUCCESS;
return rval;
} | false | false | false | false | false | 0 |
frame_init()
{
/* setup position of extra info */
info_x = stk_display->w - BRICK_WIDTH;
if ( game->game_type == GT_NETWORK ) {
/* general */
info_y = 178;
info_offsets[EX_METAL] = 26;
info_offsets[EX_WEAK_BALL] = 26;
info_offsets[EX_EXPL_BALL] = 26;
info_offsets[EX_FAST] = 52;
info_offsets[EX_SLOW] = 52;
info_offsets[EX_CHAOS] = 78;
/* paddles */
paddle_info_y[0] = 271;
paddle_info_y[1] = 7;
paddle_info_offsets[EX_SLIME] = 26;
paddle_info_offsets[EX_WEAPON] = 52;
paddle_info_offsets[EX_WALL] = 78;
paddle_info_offsets[EX_GOLDSHOWER] = 104;
paddle_info_offsets[EX_GHOST_PADDLE] = 130;
paddle_info_offsets[EX_BONUS_MAGNET] = 156;
paddle_info_offsets[EX_MALUS_MAGNET] = 156;
}
else {
/* in single player we ignore the second paddle
and model general and paddle0 extras so that
they result in the old layout */
info_y = 48; paddle_info_y[0] = 48;
paddle_info_offsets[EX_GOLDSHOWER] = 30;
paddle_info_offsets[EX_SLIME] = 60;
info_offsets[EX_METAL] = 90;
info_offsets[EX_WEAK_BALL] = 90;
info_offsets[EX_EXPL_BALL] = 90;
paddle_info_offsets[EX_WALL] = 120;
paddle_info_offsets[EX_WEAPON] = 150;
info_offsets[EX_FAST] = 180;
info_offsets[EX_SLOW] = 180;
info_offsets[EX_CHAOS] = 210;
paddle_info_offsets[EX_GHOST_PADDLE] = 240;
paddle_info_offsets[EX_BONUS_MAGNET] = 270;
paddle_info_offsets[EX_MALUS_MAGNET] = 270;
}
} | false | false | false | false | false | 0 |
qib_eeprom_read(struct qib_devdata *dd, u8 eeprom_offset,
void *buff, int len)
{
int ret;
ret = mutex_lock_interruptible(&dd->eep_lock);
if (!ret) {
ret = qib_twsi_reset(dd);
if (ret)
qib_dev_err(dd, "EEPROM Reset for read failed\n");
else
ret = qib_twsi_blk_rd(dd, dd->twsi_eeprom_dev,
eeprom_offset, buff, len);
mutex_unlock(&dd->eep_lock);
}
return ret;
} | false | false | false | false | false | 0 |
strextcmp(const char *s1, const char *s2)
{
// sanity check
Assert( (s1 != NULL) && (s2 != NULL) );
// find last '.' in both strings
char *s1_end = (char *)strrchr(s1, '.');
char *s2_end = (char *)strrchr(s2, '.');
// get length
size_t s1_len, s2_len;
if (s1_end != NULL)
s1_len = (s1_end - s1);
else
s1_len = strlen(s1);
if (s2_end != NULL)
s2_len = (s2_end - s2);
else
s2_len = strlen(s2);
// if the lengths aren't the same then it's deffinitely not the same name
if (s2_len != s1_len)
return 1;
return strnicmp(s1, s2, s1_len);
} | false | false | false | false | false | 0 |
hfs_ext_lastblock(struct hfs_extent *ext)
{
int i;
ext += 2;
for (i = 0; i < 2; ext--, i++)
if (ext->count)
break;
return be16_to_cpu(ext->block) + be16_to_cpu(ext->count);
} | false | false | false | false | false | 0 |
HandShake(RTMP * r, bool FP9HandShake)
{
int i;
char clientbuf[RTMP_SIG_SIZE + 1], *clientsig = clientbuf+1;
char serversig[RTMP_SIG_SIZE];
clientbuf[0] = 0x03; // not encrypted
uint32_t uptime = htonl(RTMP_GetTime());
memcpy(clientsig, &uptime, 4);
memset(&clientsig[4], 0, 4);
#ifdef _DEBUG
for (i = 8; i < RTMP_SIG_SIZE; i++)
clientsig[i] = 0xff;
#else
for (i = 8; i < RTMP_SIG_SIZE; i++)
clientsig[i] = (char) (rand() % 256);
#endif
if (!WriteN(r, clientbuf, RTMP_SIG_SIZE + 1))
return false;
char type;
if (ReadN(r, &type, 1) != 1) // 0x03 or 0x06
return false;
Log(LOGDEBUG, "%s: Type Answer : %02X", __FUNCTION__, type);
if (type != clientbuf[0])
Log(LOGWARNING, "%s: Type mismatch: client sent %d, server answered %d",
__FUNCTION__, clientbuf[0], type);
if (ReadN(r, serversig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE)
return false;
// decode server response
uint32_t suptime;
memcpy(&suptime, serversig, 4);
suptime = ntohl(suptime);
Log(LOGDEBUG, "%s: Server Uptime : %d", __FUNCTION__, suptime);
Log(LOGDEBUG, "%s: FMS Version : %d.%d.%d.%d", __FUNCTION__, serversig[4],
serversig[5], serversig[6], serversig[7]);
// 2nd part of handshake
if (!WriteN(r, serversig, RTMP_SIG_SIZE))
return false;
if (ReadN(r, serversig, RTMP_SIG_SIZE) != RTMP_SIG_SIZE)
return false;
bool bMatch = (memcmp(serversig, clientsig, RTMP_SIG_SIZE) == 0);
if (!bMatch)
{
Log(LOGWARNING, "%s, client signature does not match!", __FUNCTION__);
}
return true;
} | false | false | false | false | false | 0 |
emit_conv_gpr_to_fpu(struct insn *insn, struct buffer *buf, struct basic_block *bb)
{
enum machine_reg src, dest;
unsigned char opc[3];
int rex_w;
src = mach_reg(&insn->src.reg);
dest = mach_reg(&insn->dest.reg);
if (!is_64bit_reg(&insn->dest))
opc[0] = 0xF3;
else
opc[0] = 0xF2;
opc[1] = 0x0F;
opc[2] = 0x2A;
rex_w = is_64bit_reg(&insn->src);
__emit_lopc_reg_reg(buf, rex_w, opc, 3, dest, src);
} | true | true | false | false | false | 1 |
hybrid_pref_tab_add_section(GtkWidget *tab, const gchar *name)
{
GtkWidget *child;
GtkWidget *frame;
frame = gtk_frame_new(name ? name : "");
gtk_container_set_border_width(GTK_CONTAINER(frame), 10);
child = gtk_table_new(1, 2, FALSE);
gtk_table_set_row_spacings(GTK_TABLE(child), 6);
gtk_table_set_col_spacings(GTK_TABLE(child), 10);
gtk_container_add(GTK_CONTAINER(frame), child);
gtk_container_add(GTK_CONTAINER(tab), frame);
return child;
} | false | false | false | false | false | 0 |
worker_flush_part(worker_t *worker, int from, int to,
apr_pool_t *ptmp) {
int i;
int len;
int nocrlf = 0;
apr_status_t status = APR_SUCCESS;
apr_table_entry_t *e =
(apr_table_entry_t *) apr_table_elts(worker->cache)->elts;
/* iterate through all cached lines and send them */
for (i = from; i < to; ++i) {
line_t line;
line.info = e[i].key;
line.buf = e[i].val;
/* use in this case the copied key */
if (strstr(line.info, "resolve")) {
int unresolved;
/* do only local var resolve the only var pool which could have new vars
* with values
*/
/* replace all vars */
line.buf = worker_replace_vars(worker, line.buf, &unresolved, ptmp);
}
if((status = htt_run_line_flush(worker, &line)) != APR_SUCCESS) {
return status;
}
if (strncasecmp(line.info, "NOCRLF:", 7) == 0) {
line.len = apr_atoi64(&line.info[7]);
if (nocrlf) {
worker_log_buf(worker, LOG_INFO, '+', line.buf, line.len);
}
else {
worker_log_buf(worker, LOG_INFO, '>', line.buf, line.len);
}
nocrlf = 1;
}
else if (strcasecmp(line.info, "NOCRLF") == 0) {
line.len = strlen(line.buf);
if (nocrlf) {
worker_log_buf(worker, LOG_INFO, '+', line.buf, line.len);
}
else {
worker_log_buf(worker, LOG_INFO, '>', line.buf, line.len);
}
nocrlf = 1;
}
else {
line.len = strlen(line.buf);
if (nocrlf) {
worker_log_buf(worker, LOG_INFO, '+', line.buf, line.len);
}
else {
worker_log_buf(worker, LOG_INFO, '>', line.buf, line.len);
}
nocrlf = 0;
}
if ((status = worker_socket_send(worker, line.buf, line.len))
!= APR_SUCCESS) {
goto error;
}
if((status = htt_run_line_sent(worker, &line)) != APR_SUCCESS) {
return status;
}
worker->sent += line.len;
if (strncasecmp(line.info, "NOCRLF", 6) != 0) {
len = 2;
if ((status = worker_socket_send(worker, "\r\n", len)) != APR_SUCCESS) {
goto error;
}
worker->sent += len;
}
}
error:
return status;
} | false | false | false | false | false | 0 |
find_pid_index(gint pid)
{
gint i;
for (i = psarray->len - 1; i >= 0 && g_array_index(psarray, struct task_pak, i).pid != pid; i--);
return(i);
} | false | false | false | false | false | 0 |
_ov_open1(void *f,OggVorbis_File *vf,char *initial,
long ibytes, ov_callbacks callbacks){
int offsettest=((f && callbacks.seek_func)?callbacks.seek_func(f,0,SEEK_CUR):-1);
int ret;
memset(vf,0,sizeof(*vf));
vf->datasource=f;
vf->callbacks = callbacks;
/* init the framing state */
ogg_sync_init(&vf->oy);
/* perhaps some data was previously read into a buffer for testing
against other stream types. Allow initialization from this
previously read data (as we may be reading from a non-seekable
stream) */
if(initial){
char *buffer=ogg_sync_buffer(&vf->oy,ibytes);
memcpy(buffer,initial,ibytes);
ogg_sync_wrote(&vf->oy,ibytes);
}
/* can we seek? Stevens suggests the seek test was portable */
if(offsettest!=-1)vf->seekable=1;
/* No seeking yet; Set up a 'single' (current) logical bitstream
entry for partial open */
vf->links=1;
vf->vi=_ogg_calloc(vf->links,sizeof(*vf->vi));
vf->vc=_ogg_calloc(vf->links,sizeof(*vf->vc));
ogg_stream_init(&vf->os,-1); /* fill in the serialno later */
/* Try to fetch the headers, maintaining all the storage */
if((ret=_fetch_headers(vf,vf->vi,vf->vc,&vf->current_serialno,NULL))<0){
vf->datasource=NULL;
ov_clear(vf);
}else
vf->ready_state=PARTOPEN;
return(ret);
} | false | false | false | false | false | 0 |
WeekDay(jsdouble t)
{
jsint result;
result = (jsint) Day(t) + 4;
result = result % 7;
if (result < 0)
result += 7;
return (intN) result;
} | false | false | false | false | false | 0 |
mdread(SMgrRelation reln, BlockNumber blocknum, char *buffer)
{
bool status;
long seekpos;
int nbytes;
MdfdVec *v;
v = _mdfd_getseg(reln, blocknum, false);
#ifndef LET_OS_MANAGE_FILESIZE
seekpos = (long) (BLCKSZ * (blocknum % ((BlockNumber) RELSEG_SIZE)));
Assert(seekpos < BLCKSZ * RELSEG_SIZE);
#else
seekpos = (long) (BLCKSZ * (blocknum));
#endif
if (FileSeek(v->mdfd_vfd, seekpos, SEEK_SET) != seekpos)
return false;
status = true;
if ((nbytes = FileRead(v->mdfd_vfd, buffer, BLCKSZ)) != BLCKSZ)
{
/*
* If we are at or past EOF, return zeroes without complaining. Also
* substitute zeroes if we found a partial block at EOF.
*
* XXX this is really ugly, bad design. However the current
* implementation of hash indexes requires it, because hash index
* pages are initialized out-of-order.
*/
if (nbytes == 0 ||
(nbytes > 0 && mdnblocks(reln) == blocknum))
MemSet(buffer, 0, BLCKSZ);
else
status = false;
}
return status;
} | false | false | false | false | false | 0 |
_dxfComputeCheckSameTypeSpecReturn (PTreeNode *pt, ObjStruct *os, OperBinding *binding)
{
PTreeNode *subTree;
int listElement;
int items = pt->metaType.items;
int count;
/* Count number of arguments (ensure match) */
if (binding->numArgs != -1) {
for (count = 0, subTree = pt->args;
subTree != NULL;
++count, subTree = subTree->next)
;
if (count != binding->numArgs) {
DXSetError(ERROR_BAD_TYPE, "#11945", binding->numArgs);
return (ERROR);
}
}
else if (pt->args == NULL) {
return (ERROR);
}
/* Ensure that all elements of a vector are the same type.
* Result is same type with rank and shape adjusted.
* Number of elements is same as largest (if any != 0).
*/
pt->metaType = pt->args->metaType;
pt->metaType.items = items;
listElement = 0;
subTree = pt->args;
/* Resolve types of subtree */
while (subTree != NULL) {
if (subTree->metaType.type != binding->inTypes[0].type ||
_dxfComputeCompareType (&pt->metaType, &subTree->metaType) == ERROR) {
return (ERROR);
}
subTree = subTree->next;
++listElement;
}
pt->metaType = binding->outType;
pt->metaType.items = items;
pt->impl = binding->impl;
return (OK);
} | false | false | false | true | false | 1 |
git_reference__set_name(
git_reference *ref, const char *name)
{
size_t namelen = strlen(name);
size_t reflen;
git_reference *rewrite = NULL;
if (!GIT_ADD_SIZET_OVERFLOW(&reflen, sizeof(git_reference), namelen) &&
!GIT_ADD_SIZET_OVERFLOW(&reflen, reflen, 1) &&
(rewrite = git__realloc(ref, reflen)) != NULL)
memcpy(rewrite->name, name, namelen + 1);
return rewrite;
} | false | false | false | false | false | 0 |
get_prealloc(Window win, Atom prop, Atom type, gint size,
guchar *data, gulong num)
{
gboolean ret = FALSE;
gint res;
guchar *xdata = NULL;
Atom ret_type;
gint ret_size;
gulong ret_items, bytes_left;
glong num32 = 32 / size * num; /* num in 32-bit elements */
res = XGetWindowProperty(obt_display, win, prop, 0l, num32,
FALSE, type, &ret_type, &ret_size,
&ret_items, &bytes_left, &xdata);
if (res == Success && ret_items && xdata) {
if (ret_size == size && ret_items >= num) {
guint i;
for (i = 0; i < num; ++i)
switch (size) {
case 8:
data[i] = xdata[i];
break;
case 16:
((guint16*)data)[i] = ((gushort*)xdata)[i];
break;
case 32:
((guint32*)data)[i] = ((gulong*)xdata)[i];
break;
default:
g_assert_not_reached(); /* unhandled size */
}
ret = TRUE;
}
XFree(xdata);
}
return ret;
} | false | false | false | false | false | 0 |
talloc_reparent(const void *old_parent, const void *new_parent, const void *ptr)
{
struct talloc_chunk *tc;
struct talloc_reference_handle *h;
if (unlikely(ptr == NULL)) {
return NULL;
}
if (old_parent == talloc_parent(ptr)) {
return _talloc_steal_internal(new_parent, ptr);
}
tc = talloc_chunk_from_ptr(ptr);
for (h=tc->refs;h;h=h->next) {
if (talloc_parent(h) == old_parent) {
if (_talloc_steal_internal(new_parent, h) != h) {
return NULL;
}
return discard_const_p(void, ptr);
}
}
/* it wasn't a parent */
return NULL;
} | false | false | false | false | false | 0 |
writeToFile(HttpQueue *q, char *data, ssize len)
{
HttpConn *conn;
HttpUploadFile *file;
HttpLimits *limits;
Upload *up;
ssize rc;
conn = q->conn;
limits = conn->limits;
up = q->queueData;
file = up->currentFile;
if ((file->size + len) > limits->uploadSize) {
httpError(conn, HTTP_CODE_REQUEST_TOO_LARGE, "Uploaded file exceeds maximum %,Ld", limits->uploadSize);
return MPR_ERR_CANT_WRITE;
}
if (len > 0) {
/*
File upload. Write the file data.
*/
rc = mprWriteFile(up->file, data, len);
if (rc != len) {
httpError(conn, HTTP_CODE_INTERNAL_SERVER_ERROR,
"Can't write to upload temp file %s, rc %d, errno %d", up->tmpPath, rc, mprGetOsError(up));
return MPR_ERR_CANT_WRITE;
}
file->size += len;
mprLog(7, "uploadFilter: Wrote %d bytes to %s", len, up->tmpPath);
}
return 0;
} | false | false | false | false | false | 0 |
pt_Send(
PRFileDesc *fd, const void *buf, PRInt32 amount,
PRIntn flags, PRIntervalTime timeout)
{
PRInt32 syserrno, bytes = -1;
PRBool fNeedContinue = PR_FALSE;
#if defined(SOLARIS)
PRInt32 tmp_amount = amount;
#endif
/*
* Under HP-UX DCE threads, pthread.h includes dce/cma_ux.h,
* which has the following:
* # define send cma_send
* extern int cma_send (int , void *, int, int );
* So we need to cast away the 'const' of argument #2 for send().
*/
#if defined (HPUX) && defined(_PR_DCETHREADS)
#define PT_SENDBUF_CAST (void *)
#else
#define PT_SENDBUF_CAST
#endif
if (pt_TestAbort()) return bytes;
/*
* On pre-2.6 Solaris, send() is much slower than write().
* On 2.6 and beyond, with in-kernel sockets, send() and
* write() are fairly equivalent in performance.
*/
#if defined(SOLARIS)
PR_ASSERT(0 == flags);
retry:
bytes = write(fd->secret->md.osfd, PT_SENDBUF_CAST buf, tmp_amount);
#else
bytes = send(fd->secret->md.osfd, PT_SENDBUF_CAST buf, amount, flags);
#endif
syserrno = errno;
#if defined(SOLARIS)
/*
* The write system call has been reported to return the ERANGE error
* on occasion. Try to write in smaller chunks to workaround this bug.
*/
if ((bytes == -1) && (syserrno == ERANGE))
{
if (tmp_amount > 1)
{
tmp_amount = tmp_amount/2; /* half the bytes */
goto retry;
}
}
#endif
if ( (bytes >= 0) && (bytes < amount) && (!fd->secret->nonblocking) )
{
if (PR_INTERVAL_NO_WAIT == timeout)
{
bytes = -1;
syserrno = ETIMEDOUT;
}
else
{
buf = (char *) buf + bytes;
amount -= bytes;
fNeedContinue = PR_TRUE;
}
}
if ( (bytes == -1) && (syserrno == EWOULDBLOCK || syserrno == EAGAIN)
&& (!fd->secret->nonblocking) )
{
if (PR_INTERVAL_NO_WAIT == timeout) syserrno = ETIMEDOUT;
else
{
bytes = 0;
fNeedContinue = PR_TRUE;
}
}
if (fNeedContinue == PR_TRUE)
{
pt_Continuation op;
op.arg1.osfd = fd->secret->md.osfd;
op.arg2.buffer = (void*)buf;
op.arg3.amount = amount;
op.arg4.flags = flags;
op.timeout = timeout;
op.result.code = bytes; /* initialize the number sent */
op.function = pt_send_cont;
op.event = POLLOUT | POLLPRI;
bytes = pt_Continue(&op);
syserrno = op.syserrno;
}
if (bytes == -1)
pt_MapError(_PR_MD_MAP_SEND_ERROR, syserrno);
return bytes;
} | false | false | false | false | false | 0 |
replaceSubWithSub(unsigned OldR, unsigned OldSR,
unsigned NewR, unsigned NewSR, MachineRegisterInfo &MRI) {
if (!TargetRegisterInfo::isVirtualRegister(OldR) ||
!TargetRegisterInfo::isVirtualRegister(NewR))
return false;
auto Begin = MRI.use_begin(OldR), End = MRI.use_end();
decltype(End) NextI;
for (auto I = Begin; I != End; I = NextI) {
NextI = std::next(I);
if (I->getSubReg() != OldSR)
continue;
I->setReg(NewR);
I->setSubReg(NewSR);
}
return Begin != End;
} | false | false | false | false | false | 0 |
httpServerUnpipeline(HTTPRequestPtr request)
{
HTTPConnectionPtr connection = request->connection;
HTTPServerPtr server = connection->server;
request->flags &= ~REQUEST_PERSISTENT;
if(request->next) {
HTTPRequestPtr req;
do_log(L_WARN,
"Restarting pipeline to %s:%d.\n",
scrub(connection->server->name), connection->server->port);
req = request->next;
while(req) {
req->connection = NULL;
req = req->next;
}
if(server->request)
connection->request_last->next = server->request;
else
server->request_last = connection->request_last;
server->request = request->next;
request->next = NULL;
connection->request_last = request;
}
connection->pipelined = httpConnectionPipelined(connection);
} | false | false | false | false | false | 0 |
elm_win_screen_size_get(const Evas_Object *obj,
int *x,
int *y,
int *w,
int *h)
{
ELM_WIN_CHECK(obj);
ELM_WIN_DATA_GET_OR_RETURN(obj, sd);
ecore_evas_screen_geometry_get(sd->ee, x, y, w, h);
} | false | false | false | false | false | 0 |
kvm_arch_async_page_ready(struct kvm_vcpu *vcpu, struct kvm_async_pf *work)
{
int r;
if ((vcpu->arch.mmu.direct_map != work->arch.direct_map) ||
work->wakeup_all)
return;
r = kvm_mmu_reload(vcpu);
if (unlikely(r))
return;
if (!vcpu->arch.mmu.direct_map &&
work->arch.cr3 != vcpu->arch.mmu.get_cr3(vcpu))
return;
vcpu->arch.mmu.page_fault(vcpu, work->gva, 0, true);
} | false | false | false | false | false | 0 |
brcms_ops_ampdu_action(struct ieee80211_hw *hw,
struct ieee80211_vif *vif,
struct ieee80211_ampdu_params *params)
{
struct brcms_info *wl = hw->priv;
struct scb *scb = &wl->wlc->pri_scb;
int status;
struct ieee80211_sta *sta = params->sta;
enum ieee80211_ampdu_mlme_action action = params->action;
u16 tid = params->tid;
u8 buf_size = params->buf_size;
if (WARN_ON(scb->magic != SCB_MAGIC))
return -EIDRM;
switch (action) {
case IEEE80211_AMPDU_RX_START:
break;
case IEEE80211_AMPDU_RX_STOP:
break;
case IEEE80211_AMPDU_TX_START:
spin_lock_bh(&wl->lock);
status = brcms_c_aggregatable(wl->wlc, tid);
spin_unlock_bh(&wl->lock);
if (!status) {
brcms_err(wl->wlc->hw->d11core,
"START: tid %d is not agg\'able\n", tid);
return -EINVAL;
}
ieee80211_start_tx_ba_cb_irqsafe(vif, sta->addr, tid);
break;
case IEEE80211_AMPDU_TX_STOP_CONT:
case IEEE80211_AMPDU_TX_STOP_FLUSH:
case IEEE80211_AMPDU_TX_STOP_FLUSH_CONT:
spin_lock_bh(&wl->lock);
brcms_c_ampdu_flush(wl->wlc, sta, tid);
spin_unlock_bh(&wl->lock);
ieee80211_stop_tx_ba_cb_irqsafe(vif, sta->addr, tid);
break;
case IEEE80211_AMPDU_TX_OPERATIONAL:
/*
* BA window size from ADDBA response ('buf_size') defines how
* many outstanding MPDUs are allowed for the BA stream by
* recipient and traffic class. 'ampdu_factor' gives maximum
* AMPDU size.
*/
spin_lock_bh(&wl->lock);
brcms_c_ampdu_tx_operational(wl->wlc, tid, buf_size,
(1 << (IEEE80211_HT_MAX_AMPDU_FACTOR +
sta->ht_cap.ampdu_factor)) - 1);
spin_unlock_bh(&wl->lock);
/* Power save wakeup */
break;
default:
brcms_err(wl->wlc->hw->d11core,
"%s: Invalid command, ignoring\n", __func__);
}
return 0;
} | false | false | false | false | false | 0 |
FindNonWhitespace(const char *str)
{
assert(str != NULL);
while(*str != NUL)
{
if(!isspace(*str))
{
break;
}
str++;
}
return str;
} | false | false | false | false | false | 0 |
newPf(const string& name)
{ return Proof(Expr(d_pfOp, d_em->newVarExpr(name))); } | false | false | false | false | false | 0 |
onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
size_t *retlen, u_char *buf,
otp_op_t action, int mode)
{
struct onenand_chip *this = mtd->priv;
int otp_pages;
int density;
int ret = 0;
*retlen = 0;
density = onenand_get_density(this->device_id);
if (density < ONENAND_DEVICE_DENSITY_512Mb)
otp_pages = 20;
else
otp_pages = 50;
if (mode == MTD_OTP_FACTORY) {
from += mtd->writesize * otp_pages;
otp_pages = ONENAND_PAGES_PER_BLOCK - otp_pages;
}
/* Check User/Factory boundary */
if (mode == MTD_OTP_USER) {
if (mtd->writesize * otp_pages < from + len)
return 0;
} else {
if (mtd->writesize * otp_pages < len)
return 0;
}
onenand_get_device(mtd, FL_OTPING);
while (len > 0 && otp_pages > 0) {
if (!action) { /* OTP Info functions */
struct otp_info *otpinfo;
len -= sizeof(struct otp_info);
if (len <= 0) {
ret = -ENOSPC;
break;
}
otpinfo = (struct otp_info *) buf;
otpinfo->start = from;
otpinfo->length = mtd->writesize;
otpinfo->locked = 0;
from += mtd->writesize;
buf += sizeof(struct otp_info);
*retlen += sizeof(struct otp_info);
} else {
size_t tmp_retlen;
ret = action(mtd, from, len, &tmp_retlen, buf);
buf += tmp_retlen;
len -= tmp_retlen;
*retlen += tmp_retlen;
if (ret)
break;
}
otp_pages--;
}
onenand_release_device(mtd);
return ret;
} | false | false | false | false | false | 0 |
UnRegisterAllFactories()
{
// do not do anything if this is null
if( ! vtkObjectFactory::RegisteredFactories )
{
return;
}
int num = vtkObjectFactory::RegisteredFactories->GetNumberOfItems();
// collect up all the library handles so they can be closed
// AFTER the factory has been deleted.
void** libs = new void*[num+1];
vtkObjectFactory* factory;
vtkCollectionSimpleIterator osit;
vtkObjectFactory::RegisteredFactories->InitTraversal(osit);
int index = 0;
while((factory =
vtkObjectFactory::RegisteredFactories->GetNextObjectFactory(osit)))
{
libs[index++] = factory->LibraryHandle;
}
// delete the factory list and its factories
vtkObjectFactory::RegisteredFactories->Delete();
vtkObjectFactory::RegisteredFactories = 0;
// now close the libraries
for(int i = 0; i < num; i++)
{
void* lib = libs[i];
if(lib)
{
vtkDynamicLoader::CloseLibrary(reinterpret_cast<vtkLibHandle>(lib));
}
}
delete [] libs;
} | false | false | false | false | false | 0 |
vnc_connection_pointer_type_change(VncConnection *conn, gboolean absPointer)
{
VncConnectionPrivate *priv = conn->priv;
struct signal_data sigdata;
VNC_DEBUG("Pointer mode %s", absPointer ? "absolute" : "relative");
if (priv->absPointer == absPointer)
return;
priv->absPointer = absPointer;
if (priv->has_error)
return;
sigdata.params.absPointer = absPointer;
vnc_connection_emit_main_context(conn, VNC_POINTER_MODE_CHANGED, &sigdata);
} | false | false | false | false | false | 0 |
readImageSize() {
m_BitsPerComponent = fgetc(m_In);
m_Height = read16BE();
m_Width = read16BE();
m_Components = fgetc(m_In);
if (m_Components == 1) {
setMode(GLE_BITMAP_GRAYSCALE);
} else {
setMode(GLE_BITMAP_RGB);
}
return GLE_IMAGE_ERROR_NONE;
} | false | false | false | false | false | 0 |
dispose(omniIdentity* id)
{
ASSERT_OMNI_TRACEDMUTEX_HELD(boa_lock, 1);
ASSERT_OMNI_TRACEDMUTEX_HELD(*omni::internalLock, 1);
if( pd_state == DESTROYED ) {
omni::internalLock->unlock();
boa_lock.unlock();
OMNIORB_THROW(OBJECT_NOT_EXIST,OBJECT_NOT_EXIST_NoMatch,
CORBA::COMPLETED_NO);
}
omniObjTableEntry* entry = omniObjTableEntry::downcast(id);
if( !entry || entry->state() != omniObjTableEntry::ACTIVE ) {
omni::internalLock->unlock();
boa_lock.unlock();
return;
}
entry->setDeactivating();
entry->removeFromOAObjList();
if( entry->is_idle() ) {
detached_object();
boa_lock.unlock();
lastInvocationHasCompleted(entry);
}
else {
// When outstanding requests have completed the object
// will be etherealised.
omni::internalLock->unlock();
detached_object();
boa_lock.unlock();
omniORB::logs(15, "Object is still busy -- etherealise later.");
}
} | false | false | false | false | false | 0 |
on_testConnectivity_clicked()
{
QNetworkProxy proxy;
switch(proxyMode())
{
case ActionTools::Settings::PROXY_NONE:
proxy.setType(QNetworkProxy::NoProxy);
break;
case ActionTools::Settings::PROXY_SYSTEM:
{
QUrl url(Global::CONNECTIVITY_URL);
QNetworkProxyQuery networkProxyQuery(url);
QList<QNetworkProxy> listOfProxies = QNetworkProxyFactory::systemProxyForQuery(networkProxyQuery);
if(!listOfProxies.isEmpty())
proxy = listOfProxies.first();
else
proxy.setType(QNetworkProxy::NoProxy);
}
break;
case ActionTools::Settings::PROXY_CUSTOM:
if(ui->proxyType->currentIndex() == ActionTools::Settings::PROXY_TYPE_HTTP)
proxy.setType(QNetworkProxy::HttpProxy);
else
proxy.setType(QNetworkProxy::Socks5Proxy);
proxy.setHostName(ui->proxyHost->text());
proxy.setPort(ui->proxyPort->text().toInt());
proxy.setUser(ui->proxyUser->text());
proxy.setPassword(ui->proxyPassword->text());
break;
}
QNetworkProxy::setApplicationProxy(proxy);
mNetworkReply = mNetworkAccessManager->get(QNetworkRequest(QUrl(Global::CONNECTIVITY_URL)));
connect(mNetworkReply, SIGNAL(finished()), this, SLOT(proxyTestFinished()));
setEnabled(false);
mTimeoutTimer->start(5000);
} | 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.