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
|
---|---|---|---|---|---|---|
tradspool_retrieve(const TOKEN token, const RETRTYPE amount) {
char *path;
ARTHANDLE *art;
static TOKEN ret_token;
if (token.type != TOKEN_TRADSPOOL) {
SMseterror(SMERR_INTERNAL, NULL);
return NULL;
}
if ((path = TokenToPath(token)) == NULL) {
SMseterror(SMERR_NOENT, NULL);
return NULL;
}
if ((art = OpenArticle(path, amount)) != (ARTHANDLE *)NULL) {
ret_token = token;
art->token = &ret_token;
}
free(path);
return art;
} | false | false | false | false | false | 0 |
gst_collect_pads2_set_flushing (GstCollectPads2 * pads, gboolean flushing)
{
g_return_if_fail (pads != NULL);
g_return_if_fail (GST_IS_COLLECT_PADS2 (pads));
/* NOTE since this eventually calls _pop, some (STREAM_)LOCK is needed here */
GST_COLLECT_PADS2_STREAM_LOCK (pads);
gst_collect_pads2_set_flushing_unlocked (pads, flushing);
GST_COLLECT_PADS2_STREAM_UNLOCK (pads);
} | false | false | false | false | false | 0 |
app_write_learn_status (app_t app, ctrl_t ctrl, unsigned int flags)
{
gpg_error_t err;
if (!app)
return gpg_error (GPG_ERR_INV_VALUE);
if (!app->ref_count)
return gpg_error (GPG_ERR_CARD_NOT_INITIALIZED);
if (!app->fnc.learn_status)
return gpg_error (GPG_ERR_UNSUPPORTED_OPERATION);
/* We do not send APPTYPE if only keypairinfo is requested. */
if (app->apptype && !(flags & 1))
send_status_info (ctrl, "APPTYPE",
app->apptype, strlen (app->apptype), NULL, 0);
err = lock_reader (app->slot, ctrl);
if (err)
return err;
err = app->fnc.learn_status (app, ctrl, flags);
unlock_reader (app->slot);
return err;
} | false | false | false | false | false | 0 |
getNextTransition(UDate base, UBool inclusive, TimeZoneTransition& result) /*const*/ {
UErrorCode status = U_ZERO_ERROR;
initTransitionRules(status);
if (U_FAILURE(status)) {
return FALSE;
}
if (finalZone != NULL) {
if (inclusive && base == firstFinalTZTransition->getTime()) {
result = *firstFinalTZTransition;
return TRUE;
} else if (base >= firstFinalTZTransition->getTime()) {
if (finalZone->useDaylightTime()) {
//return finalZone->getNextTransition(base, inclusive, result);
return finalZoneWithStartYear->getNextTransition(base, inclusive, result);
} else {
// No more transitions
return FALSE;
}
}
}
if (historicRules != NULL) {
// Find a historical transition
int16_t ttidx = transitionCount - 1;
for (; ttidx >= firstTZTransitionIdx; ttidx--) {
UDate t = ((UDate)transitionTimes[ttidx]) * U_MILLIS_PER_SECOND;
if (base > t || (!inclusive && base == t)) {
break;
}
}
if (ttidx == transitionCount - 1) {
if (firstFinalTZTransition != NULL) {
result = *firstFinalTZTransition;
return TRUE;
} else {
return FALSE;
}
} else if (ttidx < firstTZTransitionIdx) {
result = *firstTZTransition;
return TRUE;
} else {
// Create a TimeZoneTransition
TimeZoneRule *to = historicRules[typeData[ttidx + 1]];
TimeZoneRule *from = historicRules[typeData[ttidx]];
UDate startTime = ((UDate)transitionTimes[ttidx+1]) * U_MILLIS_PER_SECOND;
// The transitions loaded from zoneinfo.res may contain non-transition data
UnicodeString fromName, toName;
from->getName(fromName);
to->getName(toName);
if (fromName == toName && from->getRawOffset() == to->getRawOffset()
&& from->getDSTSavings() == to->getDSTSavings()) {
return getNextTransition(startTime, false, result);
}
result.setTime(startTime);
result.adoptFrom(from->clone());
result.adoptTo(to->clone());
return TRUE;
}
}
return FALSE;
} | false | false | false | false | false | 0 |
mgmt_disconnect(int index, bdaddr_t *bdaddr, uint8_t bdaddr_type)
{
char buf[MGMT_HDR_SIZE + sizeof(struct mgmt_cp_disconnect)];
struct mgmt_hdr *hdr = (void *) buf;
struct mgmt_cp_disconnect *cp = (void *) &buf[sizeof(*hdr)];
char addr[18];
ba2str(bdaddr, addr);
DBG("index %d %s", index, addr);
memset(buf, 0, sizeof(buf));
hdr->opcode = htobs(MGMT_OP_DISCONNECT);
hdr->len = htobs(sizeof(*cp));
hdr->index = htobs(index);
bacpy(&cp->addr.bdaddr, bdaddr);
cp->addr.type = bdaddr_type;
if (write(mgmt_sock, buf, sizeof(buf)) < 0)
error("write: %s (%d)", strerror(errno), errno);
return 0;
} | false | false | false | false | false | 0 |
ixgbe_get_rxfh(struct net_device *netdev, u32 *indir, u8 *key,
u8 *hfunc)
{
struct ixgbe_adapter *adapter = netdev_priv(netdev);
if (hfunc)
*hfunc = ETH_RSS_HASH_TOP;
if (indir)
ixgbe_get_reta(adapter, indir);
if (key)
memcpy(key, adapter->rss_key, ixgbe_get_rxfh_key_size(netdev));
return 0;
} | false | false | false | false | false | 0 |
pack_Y41B (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
const gpointer src, gint sstride, gpointer data[GST_VIDEO_MAX_PLANES],
const gint stride[GST_VIDEO_MAX_PLANES], GstVideoChromaSite chroma_site,
gint y, gint width)
{
int i;
guint8 *destY = GET_Y_LINE (y);
guint8 *destU = GET_U_LINE (y);
guint8 *destV = GET_V_LINE (y);
const guint8 *s = src;
for (i = 0; i < width - 3; i += 4) {
destY[i] = s[i * 4 + 1];
destY[i + 1] = s[i * 4 + 5];
destY[i + 2] = s[i * 4 + 9];
destY[i + 3] = s[i * 4 + 13];
destU[i >> 2] = s[i * 4 + 2];
destV[i >> 2] = s[i * 4 + 3];
}
if (i < width) {
destY[i] = s[i * 4 + 1];
destU[i >> 2] = s[i * 4 + 2];
destV[i >> 2] = s[i * 4 + 3];
if (i < width - 1)
destY[i + 1] = s[i * 4 + 5];
if (i < width - 2)
destY[i + 2] = s[i * 4 + 9];
}
} | false | false | false | false | false | 0 |
gmpc_meta_text_view_set_text_from_metadata (GmpcMetaTextView * self, MetaData * met)
{
#line 738 "gmpc-meta-text-view.c"
#define __GOB_FUNCTION__ "Gmpc:Meta:Text:View::set_text_from_metadata"
#line 313 "gmpc-meta-text-view.gob"
g_return_if_fail (self != NULL);
#line 313 "gmpc-meta-text-view.gob"
g_return_if_fail (GMPC_IS_META_TEXT_VIEW (self));
#line 744 "gmpc-meta-text-view.c"
{
#line 316 "gmpc-meta-text-view.gob"
if(met->content_type == META_DATA_CONTENT_URI) {
const gchar *path = meta_data_get_uri(met);
self_set_text_from_path(self, path);
}else if(met->content_type == META_DATA_CONTENT_TEXT) {
const gchar *text = meta_data_get_text(met);
self_set_text(self,text, -1, FALSE);
}else if (met->content_type == META_DATA_CONTENT_HTML) {
/* TODO: make utf-8 compatible */
gchar *text = meta_data_get_text_from_html(met);
if(text)
{
/* Get byte length */
self_set_text(self,text, -1, FALSE);
g_free(text);
}else{
self_set_text_na(self);
}
}
if(self->_priv->met) meta_data_free(self->_priv->met);
self->_priv->met = meta_data_dup(met);
}} | false | false | false | false | false | 0 |
get_udp_in_errors()
{
FILE* f = NULL;
u_int64_t errs = 0;
char buf[512], *p;
int len, i;
/* need to reopen /proc/net/snmp file each time, it won't update otherwise */
f = fopen("/proc/net/snmp", "r");
if (!f) {
// warn("could not open /proc/net/snmp");
return 0;
}
/* seek for header line currently with poor programming using poor /proc interface... */
while (!feof(f)) {
if (!fgets(buf, sizeof(buf)-1, f)) break;
if (strstr(buf, "Udp:") && strstr(buf, "InErrors") && !feof(f)) {
if(!fgets(buf, sizeof(buf)-1, f)) break;
len = strlen(buf);
/* Udp: InDatagrams NoPorts InErrors OutDatagrams
Udp: 62771599 31995 4244 63083342 */
p = buf;
for (i=0; (i<3) && (p!=NULL) && (p < buf+len-1); i++, p++) {
p = strchr(p, ' ');
}
if ((p != NULL) && (p < buf+len-1)) {
errs = atol(p--);
} else {
errs = 0;
}
break;
}
}
fclose(f);
return errs;
} | false | false | false | false | false | 0 |
instruct_serifs(InstrCt *ct, StemData *stem) {
int i, lcnt, rcnt;
struct dependent_serif *serif;
if ( stem->leftidx == -1 || stem->rightidx == -1 )
return;
lcnt = rcnt = 0;
for (i=0; i<stem->serif_cnt; i++) {
serif = &stem->serifs[i];
if ((serif->is_ball && !instruct_ball_terminals) ||
(!serif->is_ball && !instruct_serif_stems))
continue;
if ( serif->lbase )
lcnt++;
else if ( !serif->lbase )
rcnt++;
}
if (stem->ldone && lcnt > 0)
link_serifs_to_edge(ct, stem, true);
if (stem->rdone && rcnt > 0)
link_serifs_to_edge(ct, stem, false);
} | false | false | false | false | false | 0 |
UpdateStatusBar()
{
int x,y;
getmaxyx(stdscr, y, x);
char bar[cmCursesMainForm::MAX_WIDTH];
size_t size = strlen(this->Title.c_str());
if ( size >= cmCursesMainForm::MAX_WIDTH )
{
size = cmCursesMainForm::MAX_WIDTH-1;
}
strncpy(bar, this->Title.c_str(), size);
for(size_t i=size-1; i<cmCursesMainForm::MAX_WIDTH; i++) bar[i] = ' ';
int width;
if (x < cmCursesMainForm::MAX_WIDTH )
{
width = x;
}
else
{
width = cmCursesMainForm::MAX_WIDTH-1;
}
bar[width] = '\0';
char version[cmCursesMainForm::MAX_WIDTH];
char vertmp[128];
sprintf(vertmp,"CMake Version %s", cmVersion::GetCMakeVersion());
size_t sideSpace = (width-strlen(vertmp));
for(size_t i=0; i<sideSpace; i++) { version[i] = ' '; }
sprintf(version+sideSpace, "%s", vertmp);
version[width] = '\0';
curses_move(y-4,0);
attron(A_STANDOUT);
printw(bar);
attroff(A_STANDOUT);
curses_move(y-3,0);
printw(version);
pos_form_cursor(this->Form);
} | false | false | false | false | true | 1 |
insert( const gnSeqI offset, const gnSeqC *bases, const gnSeqI len){
STACK_TRACE_START
string str(bases, len);
gnStringSpec gpbs(str);
insert(offset, gpbs);
STACK_TRACE_END
} | false | false | false | false | false | 0 |
linkNamedMDNodes() {
const NamedMDNode *SrcModFlags = SrcM->getModuleFlagsMetadata();
for (const NamedMDNode &NMD : SrcM->named_metadata()) {
// Don't link module flags here. Do them separately.
if (&NMD == SrcModFlags)
continue;
NamedMDNode *DestNMD = DstM->getOrInsertNamedMetadata(NMD.getName());
// Add Src elements into Dest node.
for (const MDNode *op : NMD.operands())
DestNMD->addOperand(MapMetadata(op, ValueMap, RF_MoveDistinctMDs,
&TypeMap, &ValMaterializer));
}
} | false | false | false | false | false | 0 |
cpl_bivector_copy(cpl_bivector * self,
const cpl_bivector * other)
{
return cpl_vector_copy(cpl_bivector_get_x(self),
cpl_bivector_get_x_const(other)) ||
cpl_vector_copy(cpl_bivector_get_y(self),
cpl_bivector_get_y_const(other))
? cpl_error_set_where_() : CPL_ERROR_NONE;
} | false | false | false | false | false | 0 |
paintEvent( QPaintEvent *event )
{
Q_UNUSED( event )
QStyleOption op;
op.initFrom( this );
bool hovered = op.state & QStyle::State_MouseOver;
bool mover = mouseGrabber() == this;
if( !hovered || mover )
{
return;
}
QPainter p( this );
p.save();
KIcon icon( "transform-move" );
int iconSize;
QRect iconRect;
if( m_applet )
{ // it's possible m_applet is null if we just opened amarok and it failed to load the applet plugin
// so the user is seeing a big red X and trying to get rid of item
iconSize = qMin( qMin( height(), int( m_applet->size().width() ) ), 64 );
iconRect = QRect( rect().center() - QPoint( iconSize / 2, iconSize / 2 ), QSize( iconSize, iconSize ) );
p.drawPixmap( iconRect, icon.pixmap( iconSize, iconSize ) );
}
p.restore();
} | false | false | false | false | false | 0 |
xkobo_shot()
{
int i, j;
for(i = 0; i < game.bolts && boltst[i]; i++)
;
for(j = i + 1; j < game.bolts && boltst[j]; j++)
;
if(j >= game.bolts)
{
sound.g_player_overheat(1);
return 1;
}
shot_single(i, di, 0);
shot_single(j, (di > 4) ? (di - 4) : (di + 4), 0);
sound.g_player_fire();
return 0;
} | false | false | false | false | false | 0 |
getline() {
char linebuf[BUFSIZE];
int l = 0, eol = 0, left = 0, right = 0;
if (bufsiz == -1) return NULL;
while (l < bufsiz && !eol) {
linebuf[l++] = out[outc];
switch (out[outc]) {
case '\t': break;
case 31: { // escape
if (++outc == bufsiz) {
bufsiz = getbuf();
outc = 0;
}
linebuf[l - 1] = out[outc];
break;
}
case ' ': break;
default: if (((unsigned char) out[outc]) < 47) {
if (out[outc] > 32) {
right = out[outc] - 31;
if (++outc == bufsiz) {
bufsiz = getbuf();
outc = 0;
}
}
if (out[outc] == 30) left = 9; else left = out[outc];
linebuf[l-1] = '\n';
eol = 1;
}
}
if (++outc == bufsiz) {
outc = 0;
bufsiz = fin ? getbuf(): -1;
}
}
if (right) strcpy(linebuf + l - 1, line + strlen(line) - right - 1);
else linebuf[l] = '\0';
strcpy(line + left, linebuf);
return line;
} | false | false | false | false | false | 0 |
smc_detect_init (TCHAR **c)
{
int v, i;
ignore_ws (c);
v = readint (c);
smc_free ();
smc_size = 1 << 24;
if (currprefs.z3fastmem_size)
smc_size = currprefs.z3fastmem_start + currprefs.z3fastmem_size;
smc_size += 4;
smc_table = xmalloc (struct smc_item, smc_size);
if (!smc_table)
return;
for (i = 0; i < smc_size; i++) {
smc_table[i].addr = 0xffffffff;
smc_table[i].cnt = 0;
}
if (!memwatch_enabled)
initialize_memwatch (0);
if (v)
smc_mode = 1;
console_out_f (_T("SMCD enabled. Break=%d\n"), smc_mode);
} | false | false | false | false | false | 0 |
flmCurCSTestRec(
CURSOR * pCursor,
FLMUINT uiDrn,
FlmRecord * pTestRec,
FLMBOOL * pbIsMatchRV
)
{
RCODE rc = FERR_OK;
CS_CONTEXT * pCSContext = pCursor->pCSContext;
FCL_WIRE Wire( pCSContext);
// If there is no VALID id for the cursor, get one.
if (pCursor->uiCursorId == FCS_INVALID_ID)
{
if (RC_BAD( rc = flmInitCurCS( pCursor)))
{
goto Exit;
}
}
// Send a request to test the record or DRN.
if (RC_BAD( rc = Wire.sendOp(
FCS_OPCLASS_ITERATOR, FCS_OP_ITERATOR_TEST_REC)))
{
goto Exit;
}
if (RC_BAD( rc = Wire.sendNumber(
WIRE_VALUE_ITERATOR_ID, pCursor->uiCursorId)))
{
goto Transmission_Error;
}
if (pTestRec)
{
if (RC_BAD( rc = Wire.sendRecord( WIRE_VALUE_RECORD, pTestRec)))
{
goto Transmission_Error;
}
}
else
{
if (RC_BAD( rc = Wire.sendNumber( WIRE_VALUE_DRN, uiDrn)))
{
goto Transmission_Error;
}
}
if (RC_BAD( rc = Wire.sendTerminate()))
{
goto Transmission_Error;
}
// Read the response.
if (RC_BAD( rc = Wire.read()))
{
goto Transmission_Error;
}
*pbIsMatchRV = Wire.getBoolean();
rc = Wire.getRCode();
Exit:
return( rc);
Transmission_Error:
pCSContext->bConnectionGood = FALSE;
goto Exit;
} | false | false | false | false | false | 0 |
pn544_hci_i2c_irq_thread_fn(int irq, void *phy_id)
{
struct pn544_i2c_phy *phy = phy_id;
struct i2c_client *client;
struct sk_buff *skb = NULL;
int r;
if (!phy || irq != phy->i2c_dev->irq) {
WARN_ON_ONCE(1);
return IRQ_NONE;
}
client = phy->i2c_dev;
dev_dbg(&client->dev, "IRQ\n");
if (phy->hard_fault != 0)
return IRQ_HANDLED;
if (phy->run_mode == PN544_FW_MODE) {
phy->fw_cmd_result = pn544_hci_i2c_fw_read_status(phy);
schedule_work(&phy->fw_work);
} else {
r = pn544_hci_i2c_read(phy, &skb);
if (r == -EREMOTEIO) {
phy->hard_fault = r;
nfc_hci_recv_frame(phy->hdev, NULL);
return IRQ_HANDLED;
} else if ((r == -ENOMEM) || (r == -EBADMSG)) {
return IRQ_HANDLED;
}
nfc_hci_recv_frame(phy->hdev, skb);
}
return IRQ_HANDLED;
} | false | false | false | false | false | 0 |
test_threading(tst_case *tc, void *data)
{
int i;
pthread_t thread_id[NTHREADS];
Index *index = (Index *)data;
(void)data;
(void)tc;
for(i=0; i < NTHREADS; i++) {
pthread_create(&thread_id[i], NULL, &indexing_thread, index );
}
for(i=0; i < NTHREADS; i++) {
pthread_join(thread_id[i], NULL);
}
} | false | false | false | false | false | 0 |
ndmp_sxa_mover_listen (struct ndm_session *sess,
struct ndmp_xa_buf *xa, struct ndmconn *ref_conn)
{
#ifndef NDMOS_OPTION_NO_DATA_AGENT
struct ndm_data_agent * da = &sess->data_acb;
#endif /* !NDMOS_OPTION_NO_DATA_AGENT */
struct ndm_tape_agent * ta = &sess->tape_acb;
ndmp9_error error;
int will_write;
char reason[100];
NDMS_WITH(ndmp9_mover_listen)
ndmalogf (sess, 0, 6, "mover_listen_common() addr_type=%s mode=%s",
ndmp9_addr_type_to_str (request->addr_type),
ndmp9_mover_mode_to_str (request->mode));
/* Check args */
switch (request->mode) {
default:
NDMADR_RAISE_ILLEGAL_ARGS("mover_mode");
case NDMP9_MOVER_MODE_READ:
will_write = 1;
break;
case NDMP9_MOVER_MODE_WRITE:
will_write = 0;
break;
}
switch (request->addr_type) {
default:
NDMADR_RAISE_ILLEGAL_ARGS("mover_addr_type");
case NDMP9_ADDR_LOCAL:
#ifdef NDMOS_OPTION_NO_DATA_AGENT
NDMADR_RAISE_ILLEGAL_ARGS("mover LOCAL w/o local DATA agent");
#endif /* NDMOS_OPTION_NO_DATA_AGENT */
break;
case NDMP9_ADDR_TCP:
break;
}
/* Check states -- this should cover everything */
if (ta->mover_state.state != NDMP9_MOVER_STATE_IDLE) {
NDMADR_RAISE_ILLEGAL_STATE("mover_state !IDLE");
}
#ifndef NDMOS_OPTION_NO_DATA_AGENT
if (da->data_state.state != NDMP9_DATA_STATE_IDLE) {
NDMADR_RAISE_ILLEGAL_STATE("data_state !IDLE");
}
#endif /* !NDMOS_OPTION_NO_DATA_AGENT */
/* Check that the tape is ready to go */
error = mover_can_proceed (sess, will_write);
if (error != NDMP9_NO_ERR) {
NDMADR_RAISE(error, "!mover_can_proceed");
}
/*
* Check image stream state -- should already be reflected
* in the mover and data states. This extra check gives
* us an extra measure of robustness and sanity
* check on the implementation.
*/
error = ndmis_audit_tape_listen (sess, request->addr_type, reason);
if (error != NDMP9_NO_ERR) {
NDMADR_RAISE(error, reason);
}
error = ndmis_tape_listen (sess, request->addr_type,
&ta->mover_state.data_connection_addr,
reason);
if (error != NDMP9_NO_ERR) {
NDMADR_RAISE(error, reason);
}
error = ndmta_mover_listen(sess, request->mode);
if (error != NDMP9_NO_ERR) {
/* TODO: belay ndmis_tape_listen() */
NDMADR_RAISE(error, "!mover_listen");
}
reply->data_connection_addr = ta->mover_state.data_connection_addr;
return 0;
NDMS_ENDWITH
} | false | false | false | false | false | 0 |
SetOutputFormat(int format)
{
if (format == this->OutputFormat)
{
return;
}
this->OutputFormat = format;
// convert color format to number of scalar components
int numComponents = 1;
switch (this->OutputFormat)
{
case VTK_RGBA:
numComponents = 4;
break;
case VTK_RGB:
numComponents = 3;
break;
case VTK_LUMINANCE_ALPHA:
numComponents = 2;
break;
case VTK_LUMINANCE:
numComponents = 1;
break;
default:
vtkErrorMacro(<< "SetOutputFormat: Unrecognized color format.");
break;
}
this->NumberOfScalarComponents = numComponents;
if (this->FrameBufferBitsPerPixel != numComponents*8)
{
this->FrameBufferMutex->Lock();
this->FrameBufferBitsPerPixel = numComponents*8;
if (this->Initialized)
{
this->UpdateFrameBuffer();
}
this->FrameBufferMutex->Unlock();
}
this->Modified();
} | false | false | false | false | false | 0 |
add_button (int code, const gchar *hint, GtkSignalFunc cb, int show)
{
barpixwid[code] = gtk_pixmap_new(barpix[code], barmask[code]);
gtk_widget_show(barpixwid[code]);
mainbarbut[code] = gtk_toolbar_append_item(GTK_TOOLBAR(mainbar), NULL, hint,
NULL, barpixwid[code], cb, NULL);
if (show)
gtk_widget_show(mainbarbut[code]);
else
gtk_widget_hide(mainbarbut[code]);
} | false | false | false | false | false | 0 |
AdjustSpacingAndOrigin (int dimensions[3], double spacing[3],
double origin[3])
{
for (int i = 0; i < 3; i++)
{
if (spacing[i] < 0)
{
origin[i] = origin[i] + spacing[i] * dimensions[i];
spacing[i] = -spacing[i];
}
}
vtkDebugMacro("Adjusted Spacing " << spacing[0] << ", " << spacing[1] << ", " << spacing[2]);
vtkDebugMacro("Adjusted origin " << origin[0] << ", " << origin[1] << ", " << origin[2]);
} | false | false | false | false | false | 0 |
error_from_lstat_reply (GVfsBackendSftp *backend,
int reply_type,
GDataInputStream *reply,
guint32 len,
GVfsJob *job,
gpointer user_data)
{
ErrorFromStatData *data = user_data;
GFileInfo *info;
gint stat_error;
stat_error = 0;
info = NULL;
if (reply_type == SSH_FXP_STATUS)
stat_error = read_status_code (reply);
else if (reply_type == SSH_FXP_ATTRS)
{
info = g_file_info_new ();
parse_attributes (backend,
info,
NULL,
reply,
NULL);
}
else
{
g_vfs_job_failed (job, G_IO_ERROR, G_IO_ERROR_FAILED,
_("Invalid reply received"));
goto out;
}
data->callback (backend, job,
data->original_error,
stat_error,
info,
data->user_data);
out:
g_slice_free (ErrorFromStatData, data);
} | false | false | false | false | false | 0 |
CountArrayItems ( XMP_StringPtr schemaNS,
XMP_StringPtr arrayName ) const
{
XMP_Assert ( (schemaNS != 0) && (arrayName != 0) ); // Enforced by wrapper.
XMP_ExpandedXPath expPath;
ExpandXPath ( schemaNS, arrayName, &expPath );
const XMP_Node * arrayNode = FindConstNode ( &tree, expPath );
if ( arrayNode == 0 ) return 0;
if ( ! (arrayNode->options & kXMP_PropValueIsArray) ) XMP_Throw ( "The named property is not an array", kXMPErr_BadXPath );
return arrayNode->children.size();
} | false | false | false | false | false | 0 |
ComputeKeyedLoadOrStoreElement(
JSObject* receiver,
bool is_store,
StrictModeFlag strict_mode) {
Code::Flags flags =
Code::ComputeMonomorphicFlags(
is_store ? Code::KEYED_STORE_IC :
Code::KEYED_LOAD_IC,
NORMAL,
strict_mode);
String* name = is_store
? isolate()->heap()->KeyedStoreElementMonomorphic_symbol()
: isolate()->heap()->KeyedLoadElementMonomorphic_symbol();
Object* maybe_code = receiver->map()->FindInCodeCache(name, flags);
if (!maybe_code->IsUndefined()) return Code::cast(maybe_code);
MaybeObject* maybe_new_code = NULL;
Map* receiver_map = receiver->map();
if (is_store) {
KeyedStoreStubCompiler compiler(strict_mode);
maybe_new_code = compiler.CompileStoreElement(receiver_map);
} else {
KeyedLoadStubCompiler compiler;
maybe_new_code = compiler.CompileLoadElement(receiver_map);
}
Code* code;
if (!maybe_new_code->To(&code)) return maybe_new_code;
if (is_store) {
PROFILE(isolate_,
CodeCreateEvent(Logger::KEYED_STORE_IC_TAG,
Code::cast(code), 0));
} else {
PROFILE(isolate_,
CodeCreateEvent(Logger::KEYED_LOAD_IC_TAG,
Code::cast(code), 0));
}
ASSERT(code->IsCode());
Object* result;
{ MaybeObject* maybe_result =
receiver->UpdateMapCodeCache(name, Code::cast(code));
if (!maybe_result->ToObject(&result)) return maybe_result;
}
return code;
} | false | false | false | false | false | 0 |
combine_space(gs_ref_memory_t * mem)
{
alloc_save_t *saved = mem->saved;
gs_ref_memory_t *omem = &saved->state;
chunk_t *cp;
chunk_t *csucc;
alloc_close_chunk(mem);
for (cp = mem->cfirst; cp != 0; cp = csucc) {
csucc = cp->cnext; /* save before relinking */
if (cp->outer == 0)
alloc_link_chunk(cp, omem);
else {
chunk_t *outer = cp->outer;
outer->inner_count--;
if (mem->pcc == cp)
mem->pcc = outer;
if (mem->cfreed.cp == cp)
mem->cfreed.cp = outer;
/* "Free" the header of the inner chunk, */
/* and any immediately preceding gap left by */
/* the GC having compacted the outer chunk. */
{
obj_header_t *hp = (obj_header_t *) outer->cbot;
hp->o_pad = 0;
hp->o_alone = 0;
hp->o_size = (char *)(cp->chead + 1)
- (char *)(hp + 1);
hp->o_type = &st_bytes;
/* The following call is probably not safe. */
#if 0 /* **************** */
gs_free_object((gs_memory_t *) mem,
hp + 1, "combine_space(header)");
#endif /* **************** */
}
/* Update the outer chunk's allocation pointers. */
outer->cbot = cp->cbot;
outer->rcur = cp->rcur;
outer->rtop = cp->rtop;
outer->ctop = cp->ctop;
outer->has_refs |= cp->has_refs;
gs_free_object(mem->non_gc_memory, cp,
"combine_space(inner)");
}
}
/* Update relevant parts of allocator state. */
mem->cfirst = omem->cfirst;
mem->clast = omem->clast;
mem->allocated += omem->allocated;
mem->gc_allocated += omem->allocated;
mem->lost.objects += omem->lost.objects;
mem->lost.refs += omem->lost.refs;
mem->lost.strings += omem->lost.strings;
mem->saved = omem->saved;
mem->previous_status = omem->previous_status;
{ /* Concatenate free lists. */
int i;
for (i = 0; i < num_freelists; i++) {
obj_header_t *olist = omem->freelists[i];
obj_header_t *list = mem->freelists[i];
if (olist == 0);
else if (list == 0)
mem->freelists[i] = olist;
else {
while (*(obj_header_t **) list != 0)
list = *(obj_header_t **) list;
*(obj_header_t **) list = olist;
}
}
if (omem->largest_free_size > mem->largest_free_size)
mem->largest_free_size = omem->largest_free_size;
}
gs_free_object((gs_memory_t *) mem, saved, "combine_space(saved)");
alloc_open_chunk(mem);
} | false | false | false | false | false | 0 |
hx509_ca_sign(hx509_context context,
hx509_ca_tbs tbs,
hx509_cert signer,
hx509_cert *certificate)
{
const Certificate *signer_cert;
AuthorityKeyIdentifier ai;
int ret;
memset(&ai, 0, sizeof(ai));
signer_cert = _hx509_get_cert(signer);
ret = get_AuthorityKeyIdentifier(context, signer_cert, &ai);
if (ret)
goto out;
ret = ca_sign(context,
tbs,
_hx509_cert_private_key(signer),
&ai,
&signer_cert->tbsCertificate.subject,
certificate);
out:
free_AuthorityKeyIdentifier(&ai);
return ret;
} | false | false | false | false | false | 0 |
store_get_iter_for_tracklist(GtkTreeIter * store_iter,
GtkTreeIter * artist_iter,
GtkTreeIter * record_iter,
build_disc_t * disc, map_t ** artist_name_map) {
int i;
/* check if record already exists */
if (store_contains_disc(store_iter, artist_iter, record_iter, disc)) {
if (disc->artist.unknown) {
gtk_tree_store_set(music_store, artist_iter,
MS_COL_NAME, disc->artist.final,
MS_COL_SORT, disc->artist.sort,
-1);
}
return RECORD_EXISTS;
}
/* no such record -- check if the artist of the record exists */
i = 0;
while (gtk_tree_model_iter_nth_child(GTK_TREE_MODEL(music_store),
artist_iter, store_iter, i++)) {
char * artist_name;
gtk_tree_model_get(GTK_TREE_MODEL(music_store), artist_iter,
MS_COL_NAME, &artist_name, -1);
if (collate(disc->artist.final, artist_name)) {
g_free(artist_name);
continue;
}
/* artist found, create record */
create_record(artist_iter, record_iter, disc);
g_free(artist_name);
return RECORD_NEW;
}
/* no such artist -- create both artist and record */
create_artist(store_iter, artist_iter, disc);
create_record(artist_iter, record_iter, disc);
/* start contest for artist name */
map_put(artist_name_map, disc->artist.final);
return RECORD_NEW;
} | false | false | false | false | false | 0 |
ne_request_create(ne_session *sess,
const char *method, const char *path)
{
ne_request *req = ne_calloc(sizeof *req);
req->session = sess;
req->headers = ne_buffer_create();
/* Add in the fixed headers */
add_fixed_headers(req);
/* Set the standard stuff */
req->method = ne_strdup(method);
req->method_is_head = (strcmp(method, "HEAD") == 0);
/* Only use an absoluteURI here when absolutely necessary: some
* servers can't parse them. */
if (req->session->use_proxy && !req->session->use_ssl && path[0] == '/')
req->uri = ne_concat(req->session->scheme, "://",
req->session->server.hostport, path, NULL);
else
req->uri = ne_strdup(path);
{
struct hook *hk;
for (hk = sess->create_req_hooks; hk != NULL; hk = hk->next) {
ne_create_request_fn fn = (ne_create_request_fn)hk->fn;
fn(req, hk->userdata, method, req->uri);
}
}
return req;
} | false | false | false | false | false | 0 |
write(size_t size, const void* buf) {
if (size + fPos > fMax) {
size_t newSize = (fMax == 0) ? BLOCKSIZE : fMax * 2;
while (newSize < (size + fPos))
newSize *= 2;
resize(newSize);
}
memcpy(fData + fPos, buf, size);
fPos += size;
if (fPos > fSize)
fSize = fPos;
return size;
} | false | false | false | false | false | 0 |
hideBelow(VisuColorization *dt _U_,
const VisuColorizationNodeData *values, gpointer data)
{
struct _HideBelowData *st = (struct _HideBelowData*)data;
float *arr;
g_return_val_if_fail(st->column < values->data->len, FALSE);
arr = (float*)values->data->data;
return (arr[st->column] < st->value);
} | false | false | false | false | false | 0 |
extend_min5_a(EDGE *e1, EDGE *e2)
/* extends a graph in the way given by the type a extension for
5-connected triangulations. The edges e1, e2 start at the same
vertex and must have at least two edges on each of their sides.
It returns the edge characterizing this operation.
*/
{
register EDGE *e3, *e4, *start, *run, *e1i, *e2i, *work1, *work2;
int end1, end2, center, counter;
e3=e1->next;
e4=e2->prev;
e1i=e1->invers;
e2i=e2->invers;
work1=e1i->prev;
work2=e2i->next;
center=e1->start;
end1=e1->end;
end2=e2->end;
start=min5_a(nv);
firstedge[center]=start+2;
firstedge[nv]=start+1;
counter=1; run=e3; run->start=run->invers->end=nv;
do { run=run->next; run->start=run->invers->end=nv; counter++; }
while (run != e4);
degree[nv]=counter+3;
degree[center]-=(counter-1);
start->start=end1;
start->prev=work1;
start->next=e1i;
work1->next=e1i->prev=start;
(degree[end1])++;
run=start+1;
run->end=end1;
run->next=e3;
e3->prev=run;
run++; /*start+2*/
run->start=center;
run->next=e2;
run->prev=e1;
e1->next=e2->prev=run;
run++; /*start+3*/
run->end=center;
run++; /*start+4*/
run->start=end2;
run->prev=e2i;
run->next=work2;
e2i->next=work2->prev=run;
(degree[end2])++;
run++; /*start+5*/
run->end=end2;
run->prev=e4;
e4->next=run;
nv++; ne+=6;
return (start+2); /* It is the minimum of the two inverse edges */
} | false | false | false | false | false | 0 |
add_typedef_typeinfo(msft_typelib_t *typelib, type_t *tdef)
{
msft_typeinfo_t *msft_typeinfo;
int alignment;
if (-1 < tdef->typelib_idx)
return;
tdef->typelib_idx = typelib->typelib_header.nrtypeinfos;
msft_typeinfo = create_msft_typeinfo(typelib, TKIND_ALIAS, tdef->name, tdef->attrs);
encode_type(typelib, get_type_vt(type_alias_get_aliasee(tdef)),
type_alias_get_aliasee(tdef),
&msft_typeinfo->typeinfo->datatype1,
&msft_typeinfo->typeinfo->size,
&alignment, &msft_typeinfo->typeinfo->datatype2);
msft_typeinfo->typeinfo->typekind |= (alignment << 11 | alignment << 6);
} | false | false | false | false | false | 0 |
get_fields_for_table(const Document* document, const Glib::ustring& table_name, bool /* including_system_fields */)
{
//We could also get the field definitions from the database:
//But that is inefficient because this method is called so often,
//and that meta information is not even available if the user does not have SELECT rights.
//Therefore we just assume that the Document has been updated from the database already.
//type_vec_fields fieldsDatabase = get_fields_for_table_from_database(table_name, including_system_fields);
if(!document)
{
std::cerr << G_STRFUNC << ": document is null" << std::endl;
return type_vec_fields(); //This should never happen.
}
type_vec_fields result = document->get_table_fields(table_name);
//Look at each field in the database:
/*
for(type_vec_fields::iterator iter = fieldsDocument.begin(); iter != fieldsDocument.end(); ++iter)
{
sharedptr<Field> field = *iter;
const Glib::ustring field_name = field->get_name();
//Get the field info from the database:
//This is in the document as well, but it _might_ have changed.
type_vec_fields::const_iterator iterFindDatabase =
std::find_if(fieldsDatabase.begin(), fieldsDatabase.end(), predicate_FieldHasName<Field>(field_name));
if(iterFindDatabase != fieldsDatabase.end() ) //Ignore fields that don't exist in the database anymore.
{
Glib::RefPtr<Gnome::Gda::Column> field_info_document = field->get_field_info();
//Update the Field information that _might_ have changed in the database.
Glib::RefPtr<Gnome::Gda::Column> field_info = (*iterFindDatabase)->get_field_info();
//libgda does not tell us whether the field is auto_incremented, so we need to get that from the document.
field_info->set_auto_increment( field_info_document->get_auto_increment() );
//libgda does not tell us whether the field is auto_incremented, so we need to get that from the document.
//TODO_gda:field_info->set_primary_key( field_info_document->get_primary_key() );
//libgda does yet tell us correct default_value information so we need to get that from the document.
field_info->set_default_value( field_info_document->get_default_value() );
field->set_field_info(field_info);
result.push_back(*iter);
}
}
//Add any fields that are in the database, but not in the document:
for(type_vec_fields::iterator iter = fieldsDatabase.begin(); iter != fieldsDatabase.end(); ++iter)
{
const Glib::ustring field_name = (*iter)->get_name();
//Look in the result so far:
type_vec_fields::const_iterator iterFind = std::find_if(result.begin(), result.end(), predicate_FieldHasName<Field>(field_name));
//Add it if it is not there:
if(iterFind == result.end() )
result.push_back(*iter);
}
*/
return result;
} | false | false | false | false | false | 0 |
workio_thread(void *userdata) {
struct thr_info *mythr = userdata;
CURL *curl;
bool ok = true;
curl = curl_easy_init();
if (unlikely(!curl)) {
applog(LOG_ERR, "CURL initialization failed");
return NULL ;
}
if(jsonrpc_2) {
ok = workio_login(curl);
}
while (ok) {
struct workio_cmd *wc;
/* wait for workio_cmd sent to us, on our queue */
wc = tq_pop(mythr->q, NULL );
if (!wc) {
ok = false;
break;
}
/* process workio_cmd */
switch (wc->cmd) {
case WC_GET_WORK:
ok = workio_get_work(wc, curl);
break;
case WC_SUBMIT_WORK:
ok = workio_submit_work(wc, curl);
break;
default: /* should never happen */
ok = false;
break;
}
workio_cmd_free(wc);
}
tq_freeze(mythr->q);
curl_easy_cleanup(curl);
return NULL ;
} | false | false | false | false | false | 0 |
variantSet(enum VariantType type, void *value, unsigned long valueSize, void *userParam, void (*setter)(void *userParam, const char *string))
{
switch (type)
{
case VARIANT_TYPE_STRING:
setter(userParam, value);
break;
case VARIANT_TYPE_SIGNED_INTEGER:
if (valueSize >= sizeof(signed long))
{
char trans[32];
snprintf(trans, sizeof(trans) - 1, "%li", *(signed long *)value);
setter(userParam, trans);
}
break;
case VARIANT_TYPE_UNSIGNED_INTEGER:
if (valueSize >= sizeof(unsigned long))
{
char trans[32];
snprintf(trans, sizeof(trans) - 1, "%lu", *(unsigned long *)value);
setter(userParam, trans);
}
break;
case VARIANT_TYPE_SIGNED_SHORT:
if (valueSize >= sizeof(signed short))
{
char trans[16];
snprintf(trans, sizeof(trans) - 1, "%d", *(signed short *)value);
setter(userParam, trans);
}
break;
case VARIANT_TYPE_UNSIGNED_SHORT:
if (valueSize >= sizeof(signed short))
{
char trans[16];
snprintf(trans, sizeof(trans) - 1, "%u", *(unsigned short *)value);
setter(userParam, trans);
}
break;
case VARIANT_TYPE_FLOAT:
case VARIANT_TYPE_DOUBLE:
if ((valueSize >= sizeof(float)) || (valueSize >= sizeof(double)))
{
char trans[128];
snprintf(trans, sizeof(trans) - 1, "%f", *(float *)value);
setter(userParam, trans);
}
break;
case VARIANT_TYPE_CHAR:
if (valueSize >= sizeof(char))
{
char actual[2] = { *(char *)value, 0 };
setter(userParam, actual);
}
break;
case VARIANT_TYPE_BINARY_B64:
{
char *ret = _variantBase64Encode(value, valueSize);
setter(userParam, ret);
free(ret);
}
break;
default:
break;
}
} | true | true | false | false | false | 1 |
memChr(memBuf_t *mp, char c)
{
char *ret = strchr(mp->readptr, c);
if (ret)
mp->readptr = ret;
return ret;
} | false | false | false | false | false | 0 |
getChildNodeWithAttribute(XMLCSTR name,XMLCSTR attributeName,XMLCSTR attributeValue, int *k) const
{
int i=0,j;
if (k) i=*k;
XMLNode x;
XMLCSTR t;
do
{
x=getChildNode(name,&i);
if (!x.isEmpty())
{
if (attributeValue)
{
j=0;
do
{
t=x.getAttribute(attributeName,&j);
if (t&&(xstricmp(attributeValue,t)==0)) { if (k) *k=i; return x; }
} while (t);
} else
{
if (x.isAttributeSet(attributeName)) { if (k) *k=i; return x; }
}
}
} while (!x.isEmpty());
return emptyXMLNode;
} | false | false | false | false | false | 0 |
gtt_projects_tree_set_project_status (GttProjectsTree *gpt, GtkTreeStore *tree_model, GttProject *prj, GtkTreeIter *iter)
{
gchar *value;
switch (gtt_project_get_status (prj)) {
case GTT_NO_STATUS: value = "-"; break;
case GTT_NOT_STARTED: value = _("Not Started"); break;
case GTT_IN_PROGRESS: value = _("In Progress"); break;
case GTT_ON_HOLD: value = _("On Hold"); break;
case GTT_CANCELLED: value = _("Cancelled"); break;
case GTT_COMPLETED: value = _("Completed"); break;
default: value = "-"; break;
}
gtk_tree_store_set (tree_model,
iter,
STATUS_COLUMN, value,
-1);
} | false | false | false | false | false | 0 |
g_set_global_schema_csn(CSN *csn)
{
CSN *tmp = NULL;
if (NULL != global_schema_csn)
{
tmp = global_schema_csn;
}
global_schema_csn = csn;
if (NULL != tmp)
{
csn_free(&tmp);
}
} | false | false | false | false | false | 0 |
repl_sup_init_ext ()
{
int rc;
/* populate the extension list */
repl_sup_ext_list[REPL_SUP_EXT_OP].object_name = SLAPI_EXT_OPERATION;
rc = slapi_register_object_extension(repl_plugin_name,
SLAPI_EXT_OPERATION,
supplier_operation_extension_constructor,
supplier_operation_extension_destructor,
&repl_sup_ext_list[REPL_SUP_EXT_OP].object_type,
&repl_sup_ext_list[REPL_SUP_EXT_OP].handle);
if(rc!=0)
{
PR_ASSERT(0); /* JCMREPL Argh */
}
} | false | false | false | false | false | 0 |
dxf_ray_init
(
DxfRay *dxf_ray
/*!< DXF line entity. */
)
{
#if DEBUG
DXF_DEBUG_BEGIN
#endif
/* Do some basic checks. */
if (dxf_ray == NULL)
{
fprintf (stderr,
(_("Warning in %s () a NULL pointer was passed.\n")),
__FUNCTION__);
dxf_ray = dxf_ray_new ();
}
if (dxf_ray == NULL)
{
fprintf (stderr,
(_("Error in %s () could not allocate memory for a DxfRay struct.\n")),
__FUNCTION__);
return (NULL);
}
dxf_ray->id_code = 0;
dxf_ray->linetype = strdup (DXF_DEFAULT_LINETYPE);
dxf_ray->layer = strdup (DXF_DEFAULT_LAYER);
dxf_ray->x0 = 0.0;
dxf_ray->y0 = 0.0;
dxf_ray->z0 = 0.0;
dxf_ray->x1 = 0.0;
dxf_ray->y1 = 0.0;
dxf_ray->z1 = 0.0;
dxf_ray->elevation = 0.0;
dxf_ray->thickness = 0.0;
dxf_ray->linetype_scale = DXF_DEFAULT_LINETYPE_SCALE;
dxf_ray->visibility = DXF_DEFAULT_VISIBILITY;
dxf_ray->color = DXF_COLOR_BYLAYER;
dxf_ray->paperspace = DXF_MODELSPACE;
dxf_ray->dictionary_owner_soft = strdup ("");
dxf_ray->dictionary_owner_hard = strdup ("");
dxf_ray->next = NULL;
#if DEBUG
DXF_DEBUG_END
#endif
return (dxf_ray);
} | false | false | false | false | false | 0 |
rpz_get_zbits(ns_client_t *client,
dns_rdatatype_t ip_type, dns_rpz_type_t rpz_type)
{
dns_rpz_zones_t *rpzs;
dns_rpz_st_t *st;
dns_rpz_zbits_t zbits;
rpzs = client->view->rpzs;
switch (rpz_type) {
case DNS_RPZ_TYPE_CLIENT_IP:
zbits = rpzs->have.client_ip;
break;
case DNS_RPZ_TYPE_QNAME:
zbits = rpzs->have.qname;
break;
case DNS_RPZ_TYPE_IP:
if (ip_type == dns_rdatatype_a) {
zbits = rpzs->have.ipv4;
} else if (ip_type == dns_rdatatype_aaaa) {
zbits = rpzs->have.ipv6;
} else {
zbits = rpzs->have.ip;
}
break;
case DNS_RPZ_TYPE_NSDNAME:
zbits = rpzs->have.nsdname;
break;
case DNS_RPZ_TYPE_NSIP:
if (ip_type == dns_rdatatype_a) {
zbits = rpzs->have.nsipv4;
} else if (ip_type == dns_rdatatype_aaaa) {
zbits = rpzs->have.nsipv6;
} else {
zbits = rpzs->have.nsip;
}
break;
default:
INSIST(0);
break;
}
st = client->query.rpz_st;
/*
* Choose
* the earliest configured policy zone (rpz->num)
* QNAME over IP over NSDNAME over NSIP (rpz_type)
* the smallest name,
* the longest IP address prefix,
* the lexically smallest address.
*/
if (st->m.policy != DNS_RPZ_POLICY_MISS) {
if (st->m.type >= rpz_type) {
zbits &= DNS_RPZ_ZMASK(st->m.rpz->num);
} else{
zbits &= DNS_RPZ_ZMASK(st->m.rpz->num) >> 1;
}
}
/*
* If the client wants recursion, allow only compatible policies.
*/
if (!RECURSIONOK(client))
zbits &= rpzs->p.no_rd_ok;
return (zbits);
} | false | false | false | false | false | 0 |
add_code_page (uintptr_t *hash, uintptr_t hsize, uintptr_t page)
{
uintptr_t i;
uintptr_t start_pos;
start_pos = (page >> CPAGE_SHIFT) % hsize;
i = start_pos;
do {
if (hash [i] && CPAGE_ADDR (hash [i]) == CPAGE_ADDR (page)) {
return 0;
} else if (!hash [i]) {
hash [i] = page;
return 1;
}
/* wrap around */
if (++i == hsize)
i = 0;
} while (i != start_pos);
/* should not happen */
printf ("failed code page store\n");
return 0;
} | false | false | false | false | false | 0 |
ssl_sock_load_cert_chain_file(SSL_CTX *ctx, const char *file, struct bind_conf *s, char **sni_filter, int fcount)
{
BIO *in;
X509 *x = NULL, *ca;
int i, err;
int ret = -1;
int order = 0;
X509_NAME *xname;
char *str;
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
STACK_OF(GENERAL_NAME) *names;
#endif
in = BIO_new(BIO_s_file());
if (in == NULL)
goto end;
if (BIO_read_filename(in, file) <= 0)
goto end;
x = PEM_read_bio_X509_AUX(in, NULL, ctx->default_passwd_callback, ctx->default_passwd_callback_userdata);
if (x == NULL)
goto end;
if (fcount) {
while (fcount--)
order = ssl_sock_add_cert_sni(ctx, s, sni_filter[fcount], order);
}
else {
#ifdef SSL_CTRL_SET_TLSEXT_HOSTNAME
names = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL);
if (names) {
for (i = 0; i < sk_GENERAL_NAME_num(names); i++) {
GENERAL_NAME *name = sk_GENERAL_NAME_value(names, i);
if (name->type == GEN_DNS) {
if (ASN1_STRING_to_UTF8((unsigned char **)&str, name->d.dNSName) >= 0) {
order = ssl_sock_add_cert_sni(ctx, s, str, order);
OPENSSL_free(str);
}
}
}
sk_GENERAL_NAME_pop_free(names, GENERAL_NAME_free);
}
#endif /* SSL_CTRL_SET_TLSEXT_HOSTNAME */
xname = X509_get_subject_name(x);
i = -1;
while ((i = X509_NAME_get_index_by_NID(xname, NID_commonName, i)) != -1) {
X509_NAME_ENTRY *entry = X509_NAME_get_entry(xname, i);
if (ASN1_STRING_to_UTF8((unsigned char **)&str, entry->value) >= 0) {
order = ssl_sock_add_cert_sni(ctx, s, str, order);
OPENSSL_free(str);
}
}
}
ret = 0; /* the caller must not free the SSL_CTX argument anymore */
if (!SSL_CTX_use_certificate(ctx, x))
goto end;
if (ctx->extra_certs != NULL) {
sk_X509_pop_free(ctx->extra_certs, X509_free);
ctx->extra_certs = NULL;
}
while ((ca = PEM_read_bio_X509(in, NULL, ctx->default_passwd_callback, ctx->default_passwd_callback_userdata))) {
if (!SSL_CTX_add_extra_chain_cert(ctx, ca)) {
X509_free(ca);
goto end;
}
}
err = ERR_get_error();
if (!err || (ERR_GET_LIB(err) == ERR_LIB_PEM && ERR_GET_REASON(err) == PEM_R_NO_START_LINE)) {
/* we successfully reached the last cert in the file */
ret = 1;
}
ERR_clear_error();
end:
if (x)
X509_free(x);
if (in)
BIO_free(in);
return ret;
} | false | false | false | false | false | 0 |
vhost_signal(struct vhost_dev *dev, struct vhost_virtqueue *vq)
{
/* Signal the Guest tell them we used something up. */
if (vq->call_ctx && vhost_notify(dev, vq))
eventfd_signal(vq->call_ctx, 1);
} | false | false | false | false | false | 0 |
timeout_epilog(thread_t * thread, char *smtp_msg, char *debug_msg)
{
checker_t *checker = THREAD_ARG(thread);
log_message(LOG_INFO, "Timeout %s server %s."
, debug_msg
, FMT_HTTP_RS(checker));
/* check if server is currently alive */
if (svr_checker_up(checker->id, checker->rs)) {
smtp_alert(checker->rs, NULL, NULL,
"DOWN", smtp_msg);
update_svr_checker_state(DOWN, checker->id
, checker->vs
, checker->rs);
}
return epilog(thread, 1, 0, 0);
} | false | false | false | false | false | 0 |
openpgp_s2k (const void *passphrase, size_t passphraselen,
int algo, int hashalgo,
const void *salt, size_t saltlen,
unsigned long iterations,
size_t keysize, void *keybuffer)
{
gpg_err_code_t ec;
gcry_md_hd_t md;
char *key = keybuffer;
int pass, i;
int used = 0;
int secmode;
if ((algo == GCRY_KDF_SALTED_S2K || algo == GCRY_KDF_ITERSALTED_S2K)
&& (!salt || saltlen != 8))
return GPG_ERR_INV_VALUE;
secmode = gcry_is_secure (passphrase) || gcry_is_secure (keybuffer);
ec = gpg_err_code (gcry_md_open (&md, hashalgo,
secmode? GCRY_MD_FLAG_SECURE : 0));
if (ec)
return ec;
for (pass=0; used < keysize; pass++)
{
if (pass)
{
gcry_md_reset (md);
for (i=0; i < pass; i++) /* Preset the hash context. */
gcry_md_putc (md, 0);
}
if (algo == GCRY_KDF_SALTED_S2K || algo == GCRY_KDF_ITERSALTED_S2K)
{
int len2 = passphraselen + 8;
unsigned long count = len2;
if (algo == GCRY_KDF_ITERSALTED_S2K)
{
count = iterations;
if (count < len2)
count = len2;
}
while (count > len2)
{
gcry_md_write (md, salt, saltlen);
gcry_md_write (md, passphrase, passphraselen);
count -= len2;
}
if (count < saltlen)
gcry_md_write (md, salt, count);
else
{
gcry_md_write (md, salt, saltlen);
count -= saltlen;
gcry_md_write (md, passphrase, count);
}
}
else
gcry_md_write (md, passphrase, passphraselen);
gcry_md_final (md);
i = gcry_md_get_algo_dlen (hashalgo);
if (i > keysize - used)
i = keysize - used;
memcpy (key+used, gcry_md_read (md, hashalgo), i);
used += i;
}
gcry_md_close (md);
return 0;
} | false | true | false | false | true | 1 |
finish_function (void)
{
tree fndecl = current_function_decl;
if (c_dialect_objc ())
objc_finish_function ();
if (TREE_CODE (fndecl) == FUNCTION_DECL
&& targetm.calls.promote_prototypes (TREE_TYPE (fndecl)))
{
tree args = DECL_ARGUMENTS (fndecl);
for (; args; args = DECL_CHAIN (args))
{
tree type = TREE_TYPE (args);
if (INTEGRAL_TYPE_P (type)
&& TYPE_PRECISION (type) < TYPE_PRECISION (integer_type_node))
DECL_ARG_TYPE (args) = integer_type_node;
}
}
if (DECL_INITIAL (fndecl) && DECL_INITIAL (fndecl) != error_mark_node)
BLOCK_SUPERCONTEXT (DECL_INITIAL (fndecl)) = fndecl;
/* Must mark the RESULT_DECL as being in this function. */
if (DECL_RESULT (fndecl) && DECL_RESULT (fndecl) != error_mark_node)
DECL_CONTEXT (DECL_RESULT (fndecl)) = fndecl;
if (MAIN_NAME_P (DECL_NAME (fndecl)) && flag_hosted
&& TYPE_MAIN_VARIANT (TREE_TYPE (TREE_TYPE (fndecl)))
== integer_type_node && flag_isoc99)
{
/* Hack. We don't want the middle-end to warn that this return
is unreachable, so we mark its location as special. Using
UNKNOWN_LOCATION has the problem that it gets clobbered in
annotate_one_with_locus. A cleaner solution might be to
ensure ! should_carry_locus_p (stmt), but that needs a flag.
*/
c_finish_return (BUILTINS_LOCATION, integer_zero_node, NULL_TREE);
}
/* Tie off the statement tree for this function. */
DECL_SAVED_TREE (fndecl) = pop_stmt_list (DECL_SAVED_TREE (fndecl));
finish_fname_decls ();
/* Complain if there's just no return statement. */
if (warn_return_type
&& TREE_CODE (TREE_TYPE (TREE_TYPE (fndecl))) != VOID_TYPE
&& !current_function_returns_value && !current_function_returns_null
/* Don't complain if we are no-return. */
&& !current_function_returns_abnormally
/* Don't complain if we are declared noreturn. */
&& !TREE_THIS_VOLATILE (fndecl)
/* Don't warn for main(). */
&& !MAIN_NAME_P (DECL_NAME (fndecl))
/* Or if they didn't actually specify a return type. */
&& !C_FUNCTION_IMPLICIT_INT (fndecl)
/* Normally, with -Wreturn-type, flow will complain, but we might
optimize out static functions. */
&& !TREE_PUBLIC (fndecl))
{
warning (OPT_Wreturn_type,
"no return statement in function returning non-void");
TREE_NO_WARNING (fndecl) = 1;
}
/* Complain about parameters that are only set, but never otherwise used. */
if (warn_unused_but_set_parameter)
{
tree decl;
for (decl = DECL_ARGUMENTS (fndecl);
decl;
decl = DECL_CHAIN (decl))
if (TREE_USED (decl)
&& TREE_CODE (decl) == PARM_DECL
&& !DECL_READ_P (decl)
&& DECL_NAME (decl)
&& !DECL_ARTIFICIAL (decl)
&& !TREE_NO_WARNING (decl))
warning_at (DECL_SOURCE_LOCATION (decl),
OPT_Wunused_but_set_parameter,
"parameter %qD set but not used", decl);
}
/* Store the end of the function, so that we get good line number
info for the epilogue. */
cfun->function_end_locus = input_location;
/* Finalize the ELF visibility for the function. */
c_determine_visibility (fndecl);
/* For GNU C extern inline functions disregard inline limits. */
if (DECL_EXTERNAL (fndecl)
&& DECL_DECLARED_INLINE_P (fndecl))
DECL_DISREGARD_INLINE_LIMITS (fndecl) = 1;
/* Genericize before inlining. Delay genericizing nested functions
until their parent function is genericized. Since finalizing
requires GENERIC, delay that as well. */
if (DECL_INITIAL (fndecl) && DECL_INITIAL (fndecl) != error_mark_node
&& !undef_nested_function)
{
if (!decl_function_context (fndecl))
{
invoke_plugin_callbacks (PLUGIN_PRE_GENERICIZE, fndecl);
c_genericize (fndecl);
/* ??? Objc emits functions after finalizing the compilation unit.
This should be cleaned up later and this conditional removed. */
if (cgraph_global_info_ready)
{
cgraph_add_new_function (fndecl, false);
return;
}
cgraph_finalize_function (fndecl, false);
}
else
{
/* Register this function with cgraph just far enough to get it
added to our parent's nested function list. Handy, since the
C front end doesn't have such a list. */
(void) cgraph_node (fndecl);
}
}
if (!decl_function_context (fndecl))
undef_nested_function = false;
/* We're leaving the context of this function, so zap cfun.
It's still in DECL_STRUCT_FUNCTION, and we'll restore it in
tree_rest_of_compilation. */
set_cfun (NULL);
current_function_decl = NULL;
} | false | false | false | false | false | 0 |
operator<(const char *s1, const GStr& s2) {
if (s1==NULL) return !s2.is_empty();
return (strcmp(s1, s2.chars()) < 0);
} | false | false | false | false | false | 0 |
iwl_mvm_set_hw_rfkill_state(struct iwl_op_mode *op_mode, bool state)
{
struct iwl_mvm *mvm = IWL_OP_MODE_GET_MVM(op_mode);
bool calibrating = ACCESS_ONCE(mvm->calibrating);
if (state)
set_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status);
else
clear_bit(IWL_MVM_STATUS_HW_RFKILL, &mvm->status);
wiphy_rfkill_set_hw_state(mvm->hw->wiphy, iwl_mvm_is_radio_killed(mvm));
/* iwl_run_init_mvm_ucode is waiting for results, abort it */
if (calibrating)
iwl_abort_notification_waits(&mvm->notif_wait);
/*
* Stop the device if we run OPERATIONAL firmware or if we are in the
* middle of the calibrations.
*/
return state && (mvm->cur_ucode != IWL_UCODE_INIT || calibrating);
} | false | false | false | false | false | 0 |
prime_cache_tree(void)
{
struct tree *tree = (struct tree *)trees->item;
if (!tree)
return;
active_cache_tree = cache_tree();
prime_cache_tree_rec(active_cache_tree, tree);
} | false | false | false | false | false | 0 |
userException(cdrStream& stream, IOP_C* iop_c,
const char* repoId)
{
// Server side returns a user-defined exception, but we seem
// to think the operation has none. The IDL used on each side
// probably differs.
if( omniORB::trace(1) ) {
omniORB::logger l;
l << "WARNING -- server returned user-defined exception for an\n"
" operation which the client thinks has none declared. Could the\n"
" server and client have been compiled with different versions of\n"
" the IDL?\n"
" Exception repository id: " << repoId << "\n";
}
if (iop_c) iop_c->RequestCompleted(1);
OMNIORB_THROW(UNKNOWN,UNKNOWN_UserException,
(CORBA::CompletionStatus)stream.completion());
} | false | false | false | false | false | 0 |
update_av_offset (GstPlaySink * playsink)
{
gint64 av_offset;
GstPlayAudioChain *achain;
GstPlayVideoChain *vchain;
av_offset = playsink->av_offset;
achain = (GstPlayAudioChain *) playsink->audiochain;
vchain = (GstPlayVideoChain *) playsink->videochain;
if (achain && vchain && achain->ts_offset && vchain->ts_offset) {
g_object_set (achain->ts_offset, "ts-offset", MAX (0, -av_offset), NULL);
g_object_set (vchain->ts_offset, "ts-offset", MAX (0, av_offset), NULL);
} else {
GST_LOG_OBJECT (playsink, "no ts_offset elements");
}
} | false | false | false | false | false | 0 |
DXDelete(Object o)
{
int rc = 0, i, n;
Class class;
if (!o)
return OK;
if (o->count==PERMANENT)
return OK;
/* sanity checks - up thru dx 2.1.1, this was if DEBUGGED only */
if (o->count < 0)
DXErrorReturn(ERROR_DATA_INVALID,
"Object deleted too often! (or not an object)");
class = DXGetObjectClass(o);
if ((int)class<=(int)CLASS_MIN || (int)class>=(int)CLASS_MAX) {
DXSetError(ERROR_DATA_INVALID,
"Deleting object of unknown class %d! (or not an object)",
class);
return ERROR;
}
/* lock & decrement count */
if (DXfetch_and_add(&o->count, -1, &o->lock, ID) > 1)
return OK;
#if DEBUGGED
/* tracing */
if (trace>=2)
DXDebug("Q","deleting object class %s at 0x%x", CLASS_NAME(o->class), o);
if (trace>=1) {
int n = (int) CLASS_CLASS(o->class);
DXlock(&table->lock, 0);
table->counts[n].deleted += 1;
DXunlock(&table->lock, 0);
}
#endif
/*
* delete attributes
* XXX - this should by in an _DeleteObject to be called by subclass
* i.e. _Delete should be handled like New and DXCopy
*/
for (i=0, n=o->nattributes; i<n; i++)
if (o->count != PERMANENT)
DXDelete(o->attributes[i].value);
if (o->attributes!=o->local)
DXFree((Pointer)o->attributes);
/* user deletion */
rc = _dxfDelete(o);
/* in case we mistakenly delete this object again - same as above;
* was only if DEBUGGED up through dx 2.1.1
*/
o->class_id = CLASS_DELETED;
o->count = -1;
o->class = NULL;
/* finish deleting our stuff */
DXdestroy_lock(&o->lock);
DXFree((Pointer)o);
return rc;
} | false | false | false | false | false | 0 |
skip_whitespace()
{
while ( std::isspace( stream.peek() ) )
stream.get();
} | false | false | false | false | false | 0 |
dirvote_perform_vote(void)
{
crypto_pk_t *key = get_my_v3_authority_signing_key();
authority_cert_t *cert = get_my_v3_authority_cert();
networkstatus_t *ns;
char *contents;
pending_vote_t *pending_vote;
time_t now = time(NULL);
int status;
const char *msg = "";
if (!cert || !key) {
log_warn(LD_NET, "Didn't find key/certificate to generate v3 vote");
return -1;
} else if (cert->expires < now) {
log_warn(LD_NET, "Can't generate v3 vote with expired certificate");
return -1;
}
if (!(ns = dirserv_generate_networkstatus_vote_obj(key, cert)))
return -1;
contents = format_networkstatus_vote(key, ns);
networkstatus_vote_free(ns);
if (!contents)
return -1;
pending_vote = dirvote_add_vote(contents, &msg, &status);
tor_free(contents);
if (!pending_vote) {
log_warn(LD_DIR, "Couldn't store my own vote! (I told myself, '%s'.)",
msg);
return -1;
}
directory_post_to_dirservers(DIR_PURPOSE_UPLOAD_VOTE,
ROUTER_PURPOSE_GENERAL,
V3_DIRINFO,
pending_vote->vote_body->dir,
pending_vote->vote_body->dir_len, 0);
log_notice(LD_DIR, "Vote posted.");
return 0;
} | false | false | false | false | false | 0 |
changeKomi(But *but) {
CliMatch *m = but_packet(but);
char komiStr[10];
assert(MAGIC(m));
if (newKomi(m->komiIn, butTextin_get(m->komiIn)) & BUTOUT_ERR)
return(BUTOUT_ERR);
if (but == m->komiUp) {
m->komi += 1.0;
if (m->komi > 99.5)
m->komi = 99.5;
} else {
assert(but == m->komiDown);
m->komi -= 1.0;
if (m->komi < -99.5)
m->komi = -99.5;
}
sprintf(komiStr, "%g", m->komi);
butTextin_set(m->komiIn, komiStr, TRUE);
return(0);
} | true | true | false | false | false | 1 |
usr_string_list_create(UsrCategory category, gint id, gint *index)
{
GList *list = NULL, *iter;
g_hash_table_foreach(category == UIC_USER ? the_usr.dict_uname : the_usr.dict_gname, list_visit, &list);
if(index != NULL) /* Do we need to search? */
{
gint tmp, pos;
for(iter = list, pos = 0; iter != NULL; iter = g_list_next(iter), pos++)
{
if((sscanf(iter->data, "%d", &tmp) == 1) && (tmp == id))
*index = pos;
}
}
return list;
} | false | false | false | false | false | 0 |
ar9300_read_eeprom(struct ath_hw *ah, int address, u8 *buffer,
int count)
{
struct ath_common *common = ath9k_hw_common(ah);
int i;
if ((address < 0) || ((address + count) / 2 > AR9300_EEPROM_SIZE - 1)) {
ath_dbg(common, EEPROM, "eeprom address not in range\n");
return false;
}
/*
* Since we're reading the bytes in reverse order from a little-endian
* word stream, an even address means we only use the lower half of
* the 16-bit word at that address
*/
if (address % 2 == 0) {
if (!ar9300_eeprom_read_byte(ah, address--, buffer++))
goto error;
count--;
}
for (i = 0; i < count / 2; i++) {
if (!ar9300_eeprom_read_word(ah, address, buffer))
goto error;
address -= 2;
buffer += 2;
}
if (count % 2)
if (!ar9300_eeprom_read_byte(ah, address, buffer))
goto error;
return true;
error:
ath_dbg(common, EEPROM, "unable to read eeprom region at offset %d\n",
address);
return false;
} | false | false | false | false | false | 0 |
ldns_resolver_send_pkt(ldns_pkt **answer, ldns_resolver *r,
ldns_pkt *query_pkt)
{
ldns_pkt *answer_pkt = NULL;
ldns_status stat = LDNS_STATUS_OK;
size_t *rtt;
stat = ldns_send(&answer_pkt, (ldns_resolver *)r, query_pkt);
if (stat != LDNS_STATUS_OK) {
if(answer_pkt) {
ldns_pkt_free(answer_pkt);
answer_pkt = NULL;
}
} else {
/* if tc=1 fall back to EDNS and/or TCP */
/* check for tcp first (otherwise we don't care about tc=1) */
if (!ldns_resolver_usevc(r) && ldns_resolver_fallback(r)) {
if (ldns_pkt_tc(answer_pkt)) {
/* was EDNS0 set? */
if (ldns_pkt_edns_udp_size(query_pkt) == 0) {
ldns_pkt_set_edns_udp_size(query_pkt
, 4096);
ldns_pkt_free(answer_pkt);
/* Nameservers should not become
* unreachable because fragments are
* dropped (network error). We might
* still have success with TCP.
* Therefore maintain reachability
* statuses of the nameservers by
* backup and restore the rtt list.
*/
rtt = ldns_resolver_backup_rtt(r);
stat = ldns_send(&answer_pkt, r
, query_pkt);
ldns_resolver_restore_rtt(r, rtt);
}
/* either way, if it is still truncated, use TCP */
if (stat != LDNS_STATUS_OK ||
ldns_pkt_tc(answer_pkt)) {
ldns_resolver_set_usevc(r, true);
ldns_pkt_free(answer_pkt);
stat = ldns_send(&answer_pkt, r, query_pkt);
ldns_resolver_set_usevc(r, false);
}
}
}
}
if (answer) {
*answer = answer_pkt;
}
return stat;
} | false | false | false | false | false | 0 |
isc_file_splitpath(isc_mem_t *mctx, char *path, char **dirname, char **basename)
{
char *dir, *file, *slash;
if (path == NULL)
return (ISC_R_INVALIDFILE);
slash = strrchr(path, '/');
if (slash == path) {
file = ++slash;
dir = isc_mem_strdup(mctx, "/");
} else if (slash != NULL) {
file = ++slash;
dir = isc_mem_allocate(mctx, slash - path);
if (dir != NULL)
strlcpy(dir, path, slash - path);
} else {
file = path;
dir = isc_mem_strdup(mctx, ".");
}
if (dir == NULL)
return (ISC_R_NOMEMORY);
if (*file == '\0') {
isc_mem_free(mctx, dir);
return (ISC_R_INVALIDFILE);
}
*dirname = dir;
*basename = file;
return (ISC_R_SUCCESS);
} | false | false | false | false | false | 0 |
PyFF_ActiveGlyph(PyObject *self, PyObject *args) {
if ( sc_active_in_ui==NULL )
Py_RETURN_NONE;
return( PySC_From_SC_I( sc_active_in_ui ));
} | false | false | false | false | false | 0 |
TmNPolarDecomp(const TransformN *A, TransformN *Q)
{
HPtNCoord limit, g, f, pf;
TransformN *a;
Q = TmNCopy(A, Q);
limit = (1.0+EPS)*sqrt((float)(A->odim-1));
a = TmNInvert(Q, NULL);
g = sqrt(frob_norm(a)/frob_norm(Q));
axpbytNxN(0.5*g, Q, 0.5/g, a, Q);
f = frob_norm(Q);
pf = 1e8;
while (f > limit && f < pf) {
pf = f;
TmNInvert(Q, a);
g = sqrt(frob_norm(a) / f);
axpbytNxN(0.5*g, Q, 0.5/g, a, Q);
f = frob_norm(Q);
}
TmNDelete(a);
return Q;
} | false | false | false | false | false | 0 |
expand_acl(struct proc_acl *proc, struct role_acl *role)
{
char *tmpproc;
struct proc_acl *tmpp;
tmpproc = (char *)alloca(strlen(proc->filename) + 1);
strcpy(tmpproc, proc->filename);
while (parent_dir(proc->filename, &tmpproc)) {
tmpp = lookup_acl_subject_by_name(role, tmpproc);
if (tmpp) {
proc->parent_subject = tmpp;
return;
}
}
return;
} | false | true | false | false | false | 1 |
skipws(ScmPort *port, ScmReadContext *ctx)
{
ScmChar c0;
for (;;) {
int c = Scm_GetcUnsafe(port);
if (c == EOF) return c;
if (c <= 127) {
if (isspace(c)) continue;
if (c == ';') {
read_comment(port);
continue;
}
return c;
}
else if (!SCM_CHAR_EXTRA_WHITESPACE(c)) return c;
}
} | false | false | false | false | false | 0 |
pretty_process_dot(const char *infile, bool file_is_expr, const char *outfile,
ErrorHandler *errh)
{
RouterT *r = read_router(infile, file_is_expr, errh);
if (!r)
return;
// open output file
FILE *outf = open_output_file(outfile, errh);
if (!outf) {
delete r;
return;
}
// write dot configuration
fprintf(outf, "digraph clickrouter {\n\
node [shape=record,height=.1]\n\
edge [arrowhead=normal,arrowtail=none,tailclip=false]\n");
// print all nodes
for (RouterT::const_iterator n = r->begin_elements(); n != r->end_elements(); n++) {
fprintf(outf, " \"%s\" [label=\"", n->name_c_str());
if (n->ninputs() || n->noutputs())
fprintf(outf, "{");
if (n->ninputs()) {
fprintf(outf, "{");
for (int i = 0; i < n->ninputs(); i++)
fprintf(outf, (i ? "|<i%d>" : "<i%d>"), i);
fprintf(outf, "}|");
}
fputs(n->type_name_c_str(), outf);
if (n->noutputs()) {
fprintf(outf, "|{");
for (int i = 0; i < n->noutputs(); i++)
fprintf(outf, (i ? "|<o%d>" : "<o%d>"), i);
fprintf(outf, "}");
}
if (n->ninputs() || n->noutputs())
fprintf(outf, "}");
fprintf(outf, "\"];\n");
}
// print all connections
const Vector<ConnectionT> &conns = r->connections();
for (const ConnectionT *c = conns.begin(); c != conns.end(); c++)
fprintf(outf, " \"%s\":o%d -> \"%s\":i%d;\n",
c->from_element()->name_c_str(), c->from_port(),
c->to_element()->name_c_str(), c->to_port());
fprintf(outf, "}\n");
// close files, return
if (outf != stdout)
fclose(outf);
delete r;
} | false | false | false | false | false | 0 |
readChar(const XMLByte*& srcPtr, const XMLByte* srcEnd, XMLByte& firstByte, XMLCh& UTF8Char, const Charset::Tables& tables){
if(!srcPtr || !*srcPtr || srcPtr>=srcEnd)
return 0;
firstByte=*srcPtr++;
UTF8Char=tables.fromTable[firstByte];
if(UTF8Char<0x80)
return 1;
else if(UTF8Char<0x800)
return 2;
else if(UTF8Char<0x10000)
return 3;
else if(UTF8Char<0x200000)
return 4;
else if(UTF8Char<0x4000000)
return 5;
else if(UTF8Char<= 0x7FFFFFFF)
return 6;
// will use the replacement character '?'
firstByte=0;
return 1;
} | false | false | false | false | false | 0 |
test_slice(isl_ctx *ctx)
{
const char *str;
isl_map *map;
int equal;
str = "{ [i] -> [j] }";
map = isl_map_read_from_str(ctx, str);
map = isl_map_equate(map, isl_dim_in, 0, isl_dim_out, 0);
equal = map_check_equal(map, "{ [i] -> [i] }");
isl_map_free(map);
if (equal < 0)
return -1;
str = "{ [i] -> [j] }";
map = isl_map_read_from_str(ctx, str);
map = isl_map_equate(map, isl_dim_in, 0, isl_dim_in, 0);
equal = map_check_equal(map, "{ [i] -> [j] }");
isl_map_free(map);
if (equal < 0)
return -1;
str = "{ [i] -> [j] }";
map = isl_map_read_from_str(ctx, str);
map = isl_map_oppose(map, isl_dim_in, 0, isl_dim_out, 0);
equal = map_check_equal(map, "{ [i] -> [-i] }");
isl_map_free(map);
if (equal < 0)
return -1;
str = "{ [i] -> [j] }";
map = isl_map_read_from_str(ctx, str);
map = isl_map_oppose(map, isl_dim_in, 0, isl_dim_in, 0);
equal = map_check_equal(map, "{ [0] -> [j] }");
isl_map_free(map);
if (equal < 0)
return -1;
str = "{ [i] -> [j] }";
map = isl_map_read_from_str(ctx, str);
map = isl_map_order_gt(map, isl_dim_in, 0, isl_dim_out, 0);
equal = map_check_equal(map, "{ [i] -> [j] : i > j }");
isl_map_free(map);
if (equal < 0)
return -1;
str = "{ [i] -> [j] }";
map = isl_map_read_from_str(ctx, str);
map = isl_map_order_gt(map, isl_dim_in, 0, isl_dim_in, 0);
equal = map_check_equal(map, "{ [i] -> [j] : false }");
isl_map_free(map);
if (equal < 0)
return -1;
return 0;
} | false | false | false | false | false | 0 |
authenticateAuthUserRequestSetIp(auth_user_request_t * auth_user_request, struct in_addr ipaddr, request_t * request)
{
auth_user_ip_t *ipdata, *next;
auth_user_t *auth_user;
char *ip1;
int found = 0;
CBDATA_INIT_TYPE(auth_user_ip_t);
if (!auth_user_request->auth_user)
return;
auth_user = auth_user_request->auth_user;
next = (auth_user_ip_t *) auth_user->ip_list.head;
/*
* we walk the entire list to prevent the first item in the list
* preventing old entries being flushed and locking a user out after
* a timeout+reconfigure
*/
while ((ipdata = next) != NULL) {
next = (auth_user_ip_t *) ipdata->node.next;
/* walk the ip list */
if (ipdata->ipaddr.s_addr == ipaddr.s_addr) {
/* This ip has already been seen. */
found = 1;
/* update IP ttl */
ipdata->ip_expiretime = squid_curtime;
} else if (ipdata->ip_expiretime + Config.authenticateIpTTL < squid_curtime) {
/* This IP has expired - remove from the seen list */
authenticateAuthUserRemoveIpEntry(auth_user, ipdata);
}
}
authenticateAuthUserRequestLinkIp(auth_user_request, ipaddr, request);
if (found)
return;
/* This ip is not in the seen list */
ipdata = cbdataAlloc(auth_user_ip_t);
ipdata->ip_expiretime = squid_curtime;
ipdata->ipaddr = ipaddr;
dlinkAddTail(ipdata, &ipdata->node, &auth_user->ip_list);
auth_user->ipcount++;
ip1 = xstrdup(inet_ntoa(ipaddr));
debug(29, 2) ("authenticateAuthUserRequestSetIp: user '%s' has been seen at a new IP address (%s)\n", authenticateUserUsername(auth_user), ip1);
safe_free(ip1);
} | false | false | false | false | false | 0 |
LI17__LEFT_PARENTHESIS_READER__debug(V126,V127)
object V126;object V127;
{ VMB17 VMS17 VMV17
goto TTL;
TTL:;
{object V128;
register object V129;
V128= Cnil;
V129= symbol_value(((object)VV[29]));
if(!((symbol_value(((object)VV[29])))==(Ct))){
goto T402;}
setq(((object)VV[29]),Cnil);
goto T402;
T402:;
if(((V129))==Cnil){
goto T406;}
V129= (*(LnkLI132))((V126));
V128= structure_ref((V129),((object)VV[25]),(long)1);
goto T406;
T406:;
{object V130;
V130= (
(type_of(symbol_value(((object)VV[45]))) == t_sfun ?(*((symbol_value(((object)VV[45])))->sfn.sfn_self)):
(fcall.fun=(symbol_value(((object)VV[45]))),fcall.argd=2,fcalln))((V126),(V127)));
if(((V129))==Cnil){
goto T413;}
{object V132;
object V133;
V132= symbol_value(((object)VV[44]));
base[0]= (V129);
vs_top=(vs_base=base+0)+1;
(void) (*Lnk142)();
vs_top=sup;
V134= vs_base[0];
V133= make_cons(V134,(V128));
(void)((sethash_with_check(V130,(V132),(V133)),(V133)));}
goto T413;
T413:;
{object V135 = (V130);
VMR17(V135)}}}
base[0]=base[0];
return Cnil;
} | false | false | false | false | false | 0 |
png_colorspace_check_xy(png_XYZ *XYZ, const png_xy *xy)
{
int result;
png_xy xy_test;
/* As a side-effect this routine also returns the XYZ endpoints. */
result = png_XYZ_from_xy(XYZ, xy);
if (result) return result;
result = png_xy_from_XYZ(&xy_test, XYZ);
if (result) return result;
if (png_colorspace_endpoints_match(xy, &xy_test,
5/*actually, the math is pretty accurate*/))
return 0;
/* Too much slip */
return 1;
} | false | false | false | false | false | 0 |
unit_snprintf(char *s, int inLen,
double inNum, char inFormat)
{
int conv;
const char *suffix;
const char *format;
/* convert to bits for [bkmga] */
if (!isupper((int) inFormat))
{
inNum *= 8;
}
switch (toupper(inFormat))
{
case 'B':
conv = UNIT_CONV;
break;
case 'K':
conv = KILO_CONV;
break;
case 'M':
conv = MEGA_CONV;
break;
case 'G':
conv = GIGA_CONV;
break;
default:
case 'A':
{
double tmpNum = inNum;
conv = UNIT_CONV;
if (isupper((int) inFormat))
{
while (tmpNum >= 1024.0 && conv <= GIGA_CONV)
{
tmpNum /= 1024.0;
conv++;
}
} else
{
while (tmpNum >= 1000.0 && conv <= GIGA_CONV)
{
tmpNum /= 1000.0;
conv++;
}
}
break;
}
}
if (!isupper((int) inFormat))
{
inNum *= conversion_bits[conv];
suffix = label_bit[conv];
} else
{
inNum *= conversion_bytes[conv];
suffix = label_byte[conv];
}
/* print such that we always fit in 4 places */
if (inNum < 9.995)
{ /* 9.995 would be rounded to 10.0 */
format = "%4.2f %s";/* #.## */
} else if (inNum < 99.95)
{ /* 99.95 would be rounded to 100 */
format = "%4.1f %s";/* ##.# */
} else if (inNum < 999.5)
{ /* 999.5 would be rounded to 1000 */
format = "%4.0f %s";/* ### */
} else
{ /* 1000-1024 fits in 4 places If not using
* Adaptive sizes then this code will not
* control spaces */
format = "%4.0f %s";/* #### */
}
snprintf(s, inLen, format, inNum, suffix);
} | false | false | false | false | true | 1 |
delrdsdebug()
{
rdsdebug_list *DelDebug;
DelDebug = HEAD_RDSDEBUG;
if ( DelDebug != (rdsdebug_list *)NULL )
{
HEAD_RDSDEBUG = DelDebug->NEXT;
freerdsdebug( DelDebug );
}
} | false | false | false | false | false | 0 |
pixbuf_inline(const gchar *key)
{
gint i;
if (!key) return NULL;
i = 0;
while (inline_pixbuf_data[i].key)
{
if (strcmp(inline_pixbuf_data[i].key, key) == 0)
{
return gdk_pixbuf_new_from_inline(-1, inline_pixbuf_data[i].data, FALSE, NULL);
}
i++;
}
log_printf("warning: inline pixbuf key \"%s\" not found.\n", key);
return NULL;
} | false | false | false | false | false | 0 |
glp_ios_heur_sol(glp_tree *tree, const double x[])
{ glp_prob *mip = tree->mip;
int m = tree->orig_m;
int n = tree->n;
int i, j;
double obj;
xassert(mip->m >= m);
xassert(mip->n == n);
/* check values of integer variables and compute value of the
objective function */
obj = mip->c0;
for (j = 1; j <= n; j++)
{ GLPCOL *col = mip->col[j];
if (col->kind == GLP_IV)
{ /* provided value must be integral */
if (x[j] != floor(x[j])) return 1;
}
obj += col->coef * x[j];
}
/* check if the provided solution is better than the best known
integer feasible solution */
if (mip->mip_stat == GLP_FEAS)
{ switch (mip->dir)
{ case GLP_MIN:
if (obj >= tree->mip->mip_obj) return 1;
break;
case GLP_MAX:
if (obj <= tree->mip->mip_obj) return 1;
break;
default:
xassert(mip != mip);
}
}
/* it is better; store it in the problem object */
if (tree->parm->msg_lev >= GLP_MSG_ON)
xprintf("Solution found by heuristic: %.12g\n", obj);
mip->mip_stat = GLP_FEAS;
mip->mip_obj = obj;
for (j = 1; j <= n; j++)
mip->col[j]->mipx = x[j];
for (i = 1; i <= m; i++)
{ GLPROW *row = mip->row[i];
GLPAIJ *aij;
row->mipx = 0.0;
for (aij = row->ptr; aij != NULL; aij = aij->r_next)
row->mipx += aij->val * aij->col->mipx;
}
#if 1 /* 11/VII-2013 */
ios_process_sol(tree);
#endif
return 0;
} | false | false | false | false | false | 0 |
set_quote_source_name( gpointer pObject, gpointer pValue )
{
gnc_commodity* pCommodity;
const gchar* quote_source_name = (const gchar*)pValue;
gnc_quote_source* quote_source;
g_return_if_fail( pObject != NULL );
g_return_if_fail( GNC_IS_COMMODITY(pObject) );
if ( pValue == NULL ) return;
pCommodity = GNC_COMMODITY(pObject);
quote_source = gnc_quote_source_lookup_by_internal( quote_source_name );
gnc_commodity_set_quote_source( pCommodity, quote_source );
} | false | false | false | false | false | 0 |
yuyv_to_yuv_soa(struct gallivm_state *gallivm,
unsigned n,
LLVMValueRef packed,
LLVMValueRef i,
LLVMValueRef *y,
LLVMValueRef *u,
LLVMValueRef *v)
{
LLVMBuilderRef builder = gallivm->builder;
struct lp_type type;
LLVMValueRef mask;
memset(&type, 0, sizeof type);
type.width = 32;
type.length = n;
assert(lp_check_value(type, packed));
assert(lp_check_value(type, i));
/*
* Little endian:
* y = (yuyv >> 16*i) & 0xff
* u = (yuyv >> 8 ) & 0xff
* v = (yuyv >> 24 ) & 0xff
*
* Big endian:
* y = (yuyv >> (-16*i + 24) & 0xff
* u = (yuyv >> 16) & 0xff
* v = (yuyv) & 0xff
*/
#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64)
/*
* Avoid shift with per-element count.
* No support on x86, gets translated to roughly 5 instructions
* per element. Didn't measure performance but cuts shader size
* by quite a bit (less difference if cpu has no sse4.1 support).
*/
if (util_cpu_caps.has_sse2 && n > 1) {
LLVMValueRef sel, tmp;
struct lp_build_context bld32;
lp_build_context_init(&bld32, gallivm, type);
tmp = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(gallivm, type, 16), "");
sel = lp_build_compare(gallivm, type, PIPE_FUNC_EQUAL, i, lp_build_const_int_vec(gallivm, type, 0));
*y = lp_build_select(&bld32, sel, packed, tmp);
} else
#endif
{
LLVMValueRef shift;
#ifdef PIPE_ARCH_LITTLE_ENDIAN
shift = LLVMBuildMul(builder, i, lp_build_const_int_vec(gallivm, type, 16), "");
#else
shift = LLVMBuildMul(builder, i, lp_build_const_int_vec(gallivm, type, -16), "");
shift = LLVMBuildAdd(builder, shift, lp_build_const_int_vec(gallivm, type, 24), "");
#endif
*y = LLVMBuildLShr(builder, packed, shift, "");
}
#ifdef PIPE_ARCH_LITTLE_ENDIAN
*u = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(gallivm, type, 8), "");
*v = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(gallivm, type, 24), "");
#else
*u = LLVMBuildLShr(builder, packed, lp_build_const_int_vec(gallivm, type, 16), "");
*v = packed;
#endif
mask = lp_build_const_int_vec(gallivm, type, 0xff);
*y = LLVMBuildAnd(builder, *y, mask, "y");
*u = LLVMBuildAnd(builder, *u, mask, "u");
*v = LLVMBuildAnd(builder, *v, mask, "v");
} | false | false | false | false | false | 0 |
setContent(GooString* new_content)
{
if (isReadOnly()) {
error(-1, "FormWidgetText::setContentCopy called on a read only field\n");
return;
}
modified = gTrue;
if (new_content == NULL) {
parent->setContentCopy(NULL);
} else {
//append the unicode marker <FE FF> if needed
if (!new_content->hasUnicodeMarker()) {
new_content->insert(0, 0xff);
new_content->insert(0, 0xfe);
}
GooString *cont = new GooString(new_content);
parent->setContentCopy(cont);
Object obj1;
obj1.initString(cont);
updateField ("V", &obj1);
}
} | false | false | false | false | false | 0 |
setCharProperty(GWEN_DIALOG_PROPERTY prop,
int index,
const char *value,
int doSignal) {
if (_setCharPropertyFn)
return _setCharPropertyFn(_widget, prop, index, value, doSignal);
else
return GWEN_ERROR_NOT_SUPPORTED;
} | false | false | false | false | false | 0 |
dump_tree (gchar *current_key, xmms_config_property_t *prop,
dump_tree_data_t *data)
{
gchar *prop_name, section[256];
gchar *dot = NULL, *current_last_dot, *start = current_key;
prop_name = strrchr (current_key, '.');
/* check whether we need to open a new section.
* this is always the case if data->prev_key == NULL.
* but if the sections of the last key and the current key differ,
* we also need to do that.
*/
if (data->prev_key) {
gchar *c = current_key, *o = data->prev_key;
gsize dots = 0;
/* position c and o at the respective ends of the common
* prefixes of the previous and the current key.
*/
while (*c && *o && *c == *o) {
c++;
o++;
if (*c == '.')
start = c + 1;
};
/* from this position on, count the number of dots in the
* previous key (= number of dots that are present in the
* previous key, but no the current key).
*/
while (*o) {
if (*o == '.')
dots++;
o++;
};
/* we'll close the previous key's sections now, so we don't
* have to worry about it next time this function is called.
*/
if (dots)
data->prev_key = NULL;
while (dots--) {
/* decrease indent level */
data->indent[--data->indent_level] = '\0';
fprintf (data->fp, "%s</section>\n", data->indent);
}
}
/* open section tags */
dot = strchr (start, '.');
current_last_dot = start - 1;
while (dot) {
strncpy (section, current_last_dot + 1, dot - current_last_dot + 1);
section[dot - current_last_dot - 1] = 0;
fprintf (data->fp, "%s<section name=\"%s\">\n",
data->indent, section);
/* increase indent level */
g_assert (data->indent_level < 127);
data->indent[data->indent_level] = '\t';
data->indent[++data->indent_level] = '\0';
current_last_dot = dot;
dot = strchr (dot + 1, '.');
};
data->prev_key = current_key;
fprintf (data->fp, "%s<property name=\"%s\">%s</property>\n",
data->indent, prop_name + 1,
xmms_config_property_get_string (prop));
return FALSE; /* keep going */
} | false | false | false | false | false | 0 |
snd_rme32_playback_getrate(struct rme32 * rme32)
{
int rate;
rate = ((rme32->wcreg >> RME32_WCR_BITPOS_FREQ_0) & 1) +
(((rme32->wcreg >> RME32_WCR_BITPOS_FREQ_1) & 1) << 1);
switch (rate) {
case 1:
rate = 32000;
break;
case 2:
rate = 44100;
break;
case 3:
rate = 48000;
break;
default:
return -1;
}
return (rme32->wcreg & RME32_WCR_DS_BM) ? rate << 1 : rate;
} | false | false | false | false | false | 0 |
nautilus_file_get_string_attribute_with_default_q (NautilusFile *file, GQuark attribute_q)
{
char *result;
guint item_count;
gboolean count_unreadable;
NautilusRequestStatus status;
result = nautilus_file_get_string_attribute_q (file, attribute_q);
if (result != NULL) {
return result;
}
/* Supply default values for the ones we know about. */
/* FIXME bugzilla.gnome.org 40646:
* Use hash table and switch statement or function pointers for speed?
*/
if (attribute_q == attribute_size_q) {
if (!nautilus_file_should_show_directory_item_count (file)) {
return g_strdup ("--");
}
count_unreadable = FALSE;
if (nautilus_file_is_directory (file)) {
nautilus_file_get_directory_item_count (file, &item_count, &count_unreadable);
}
return g_strdup (count_unreadable ? _("? items") : "...");
}
if (attribute_q == attribute_deep_size_q) {
status = nautilus_file_get_deep_counts (file, NULL, NULL, NULL, NULL, FALSE);
if (status == NAUTILUS_REQUEST_DONE) {
/* This means no contents at all were readable */
return g_strdup (_("? bytes"));
}
return g_strdup ("...");
}
if (attribute_q == attribute_deep_file_count_q
|| attribute_q == attribute_deep_directory_count_q
|| attribute_q == attribute_deep_total_count_q) {
status = nautilus_file_get_deep_counts (file, NULL, NULL, NULL, NULL, FALSE);
if (status == NAUTILUS_REQUEST_DONE) {
/* This means no contents at all were readable */
return g_strdup (_("? items"));
}
return g_strdup ("...");
}
if (attribute_q == attribute_type_q
|| attribute_q == attribute_detailed_type_q
|| attribute_q == attribute_mime_type_q) {
return g_strdup (_("Unknown"));
}
if (attribute_q == attribute_trashed_on_q) {
/* If n/a */
return g_strdup ("");
}
if (attribute_q == attribute_trash_orig_path_q) {
/* If n/a */
return g_strdup ("");
}
/* Fallback, use for both unknown attributes and attributes
* for which we have no more appropriate default.
*/
return g_strdup (_("unknown"));
} | false | false | false | false | false | 0 |
H5C_get_evictions_enabled(const H5C_t *cache_ptr,
hbool_t * evictions_enabled_ptr)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
if ( ( cache_ptr == NULL ) || ( cache_ptr->magic != H5C__H5C_T_MAGIC ) ) {
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "Bad cache_ptr on entry.")
}
if ( evictions_enabled_ptr == NULL ) {
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, \
"Bad evictions_enabled_ptr on entry.")
}
*evictions_enabled_ptr = cache_ptr->evictions_enabled;
done:
FUNC_LEAVE_NOAPI(ret_value)
} | false | false | false | false | false | 0 |
td_tx_submit(struct dma_async_tx_descriptor *txd)
{
struct timb_dma_desc *td_desc = container_of(txd, struct timb_dma_desc,
txd);
struct timb_dma_chan *td_chan = container_of(txd->chan,
struct timb_dma_chan, chan);
dma_cookie_t cookie;
spin_lock_bh(&td_chan->lock);
cookie = dma_cookie_assign(txd);
if (list_empty(&td_chan->active_list)) {
dev_dbg(chan2dev(txd->chan), "%s: started %u\n", __func__,
txd->cookie);
list_add_tail(&td_desc->desc_node, &td_chan->active_list);
__td_start_dma(td_chan);
} else {
dev_dbg(chan2dev(txd->chan), "tx_submit: queued %u\n",
txd->cookie);
list_add_tail(&td_desc->desc_node, &td_chan->queue);
}
spin_unlock_bh(&td_chan->lock);
return cookie;
} | false | false | false | false | false | 0 |
tp_base_contact_list_channel_dispose (GObject *object)
{
TpBaseContactListChannel *self = TP_BASE_CONTACT_LIST_CHANNEL (object);
void (*dispose) (GObject *) =
G_OBJECT_CLASS (_tp_base_contact_list_channel_parent_class)->dispose;
_tp_base_contact_list_channel_close (self);
if (dispose != NULL)
dispose (object);
} | false | false | false | false | false | 0 |
end_test_iterator_result (CutStreamParser *parser, CutStreamParserPrivate *priv,
GMarkupParseContext *context,
const gchar *element_name, GError **error)
{
if (!priv->test_iterator_result)
return;
if (priv->run_context) {
CutTestResult *result;
CutTestResultStatus status;
const gchar *signal_name;
gchar *full_signal_name;
result = priv->test_iterator_result->result;
status = cut_test_result_get_status(result);
signal_name = cut_test_result_status_to_signal_name(status);
full_signal_name = g_strdup_printf("%s-test-iterator", signal_name);
g_signal_emit_by_name(priv->run_context, full_signal_name,
priv->test_iterator_result->test_iterator,
priv->test_iterator_result->result);
g_free(full_signal_name);
}
if (priv->test_iterator_result->test_iterator)
DROP_TEST_ITERATOR(priv);
test_iterator_result_free(priv->test_iterator_result);
priv->test_iterator_result = NULL;
g_object_unref(priv->result);
priv->result = NULL;
} | false | false | false | false | false | 0 |
acquire_group(struct mcast_port *port,
union ib_gid *mgid, gfp_t gfp_mask)
{
struct mcast_group *group, *cur_group;
unsigned long flags;
int is_mgid0;
is_mgid0 = !memcmp(&mgid0, mgid, sizeof mgid0);
if (!is_mgid0) {
spin_lock_irqsave(&port->lock, flags);
group = mcast_find(port, mgid);
if (group)
goto found;
spin_unlock_irqrestore(&port->lock, flags);
}
group = kzalloc(sizeof *group, gfp_mask);
if (!group)
return NULL;
group->retries = 3;
group->port = port;
group->rec.mgid = *mgid;
group->pkey_index = MCAST_INVALID_PKEY_INDEX;
INIT_LIST_HEAD(&group->pending_list);
INIT_LIST_HEAD(&group->active_list);
INIT_WORK(&group->work, mcast_work_handler);
spin_lock_init(&group->lock);
spin_lock_irqsave(&port->lock, flags);
cur_group = mcast_insert(port, group, is_mgid0);
if (cur_group) {
kfree(group);
group = cur_group;
} else
atomic_inc(&port->refcount);
found:
atomic_inc(&group->refcount);
spin_unlock_irqrestore(&port->lock, flags);
return group;
} | false | false | false | false | false | 0 |
PyvtkTransform_GetOrientation_s3(PyObject *, PyObject *args)
{
vtkPythonArgs ap(args, "GetOrientation");
double temp0[3];
double save0[3];
const int size0 = 3;
vtkMatrix4x4 *temp1 = NULL;
PyObject *result = NULL;
if (ap.CheckArgCount(2) &&
ap.GetArray(temp0, size0) &&
ap.GetVTKObject(temp1, "vtkMatrix4x4"))
{
ap.SaveArray(temp0, save0, size0);
vtkTransform::GetOrientation(temp0, temp1);
if (ap.ArrayHasChanged(temp0, save0, size0) &&
!ap.ErrorOccurred())
{
ap.SetArray(0, temp0, size0);
}
if (!ap.ErrorOccurred())
{
result = ap.BuildNone();
}
}
return result;
} | false | false | false | false | false | 0 |
gst_video_calculate_display_ratio (guint * dar_n, guint * dar_d,
guint video_width, guint video_height,
guint video_par_n, guint video_par_d,
guint display_par_n, guint display_par_d)
{
gint num, den;
gint tmp_n, tmp_d;
g_return_val_if_fail (dar_n != NULL, FALSE);
g_return_val_if_fail (dar_d != NULL, FALSE);
/* Calculate (video_width * video_par_n * display_par_d) /
* (video_height * video_par_d * display_par_n) */
if (!gst_util_fraction_multiply (video_width, video_height, video_par_n,
video_par_d, &tmp_n, &tmp_d))
goto error_overflow;
if (!gst_util_fraction_multiply (tmp_n, tmp_d, display_par_d, display_par_n,
&num, &den))
goto error_overflow;
g_return_val_if_fail (num > 0, FALSE);
g_return_val_if_fail (den > 0, FALSE);
*dar_n = num;
*dar_d = den;
return TRUE;
error_overflow:
return FALSE;
} | false | false | false | false | false | 0 |
move_win_sym()
{
#if 0
dbg("move_win_sym %d\n", current_CS->in_method);
#endif
if (!gwin_sym)
return;
int wx, wy;
#if 0
if (hime_pop_up_win) {
wx = dpy_xl;
} else
#endif
{
// dbg("win_y: %d %d\n", win_y, win_yl);
update_active_in_win_geom();
wx = win_x; wy = win_y + win_yl;
}
int winsym_xl, winsym_yl;
get_win_size(gwin_sym, &winsym_xl, &winsym_yl);
if (wx + winsym_xl > dpy_xl)
wx = dpy_xl - winsym_xl;
if (wx < 0)
wx = 0;
#if 0
if (hime_pop_up_win) {
wy = win_status_y - winsym_yl;
} else
#endif
{
if (wy + winsym_yl > dpy_yl)
wy = win_y - winsym_yl;
if (wy < 0)
wy = 0;
}
gtk_window_move(GTK_WINDOW(gwin_sym), wx, wy);
} | false | false | false | false | false | 0 |
dfx_ctl_update_filters(DFX_board_t *bp)
{
int i = 0; /* used as index */
/* Fill in command request information */
bp->cmd_req_virt->cmd_type = PI_CMD_K_FILTERS_SET;
/* Initialize Broadcast filter - * ALWAYS ENABLED * */
bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_BROADCAST;
bp->cmd_req_virt->filter_set.item[i++].value = PI_FSTATE_K_PASS;
/* Initialize LLC Individual/Group Promiscuous filter */
bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_IND_GROUP_PROM;
bp->cmd_req_virt->filter_set.item[i++].value = bp->ind_group_prom;
/* Initialize LLC Group Promiscuous filter */
bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_GROUP_PROM;
bp->cmd_req_virt->filter_set.item[i++].value = bp->group_prom;
/* Terminate the item code list */
bp->cmd_req_virt->filter_set.item[i].item_code = PI_ITEM_K_EOL;
/* Issue command to update adapter filters, then return */
if (dfx_hw_dma_cmd_req(bp) != DFX_K_SUCCESS)
return DFX_K_FAILURE;
return DFX_K_SUCCESS;
} | false | false | false | false | false | 0 |
gnac_profiles_utils_init_raw_audioconvert(XMLDoc *doc)
{
if (G_UNLIKELY(!raw)) {
raw = gnac_profiles_xml_engine_get_text_node(doc,
"//process[@id='gstreamer-audio']");
}
if (G_UNLIKELY(!audioconvert)) {
audioconvert = gnac_profiles_xml_engine_get_text_node(doc,
"//process[@id='audioconvert']");
}
} | false | false | false | false | false | 0 |
mono_set_assemblies_path (const char* path)
{
char **splitted, **dest;
splitted = g_strsplit (path, G_SEARCHPATH_SEPARATOR_S, 1000);
if (assemblies_path)
g_strfreev (assemblies_path);
assemblies_path = dest = splitted;
while (*splitted) {
char *tmp = *splitted;
if (*tmp)
*dest++ = mono_path_canonicalize (tmp);
g_free (tmp);
splitted++;
}
*dest = *splitted;
if (g_getenv ("MONO_DEBUG") == NULL)
return;
splitted = assemblies_path;
while (*splitted) {
if (**splitted && !g_file_test (*splitted, G_FILE_TEST_IS_DIR))
g_warning ("'%s' in MONO_PATH doesn't exist or has wrong permissions.", *splitted);
splitted++;
}
} | false | false | false | false | false | 0 |
estPairRemember( ajint col, ajint row )
{
EstOSavePair rp;
ajint left;
ajint right;
ajint middle;
ajint d;
ajint bad;
if(!rpairs_sorted)
{
qsort(rpair, rpairs, sizeof(EstOSavePair), estSavePairCmp);
rpairs_sorted = 1;
}
rp.col = col;
rp.row = row;
left = 0;
right = rpairs-1;
if(debug)
ajDebug("estPairRemember left: %d right: %d rp rp.col rp.row\n",
left, right, rp, rp.col, rp.row);
/*
** MATHOG, changed flow somewhat, added "bad" variable, inverted some
** tests ( PLEASE CHECK THEM! I did this because the original version
** had two ways to drop into the failure code, but one of them was only
** evident after careful reading of the code.
*/
if((estSavePairCmp(&rpair[left],&rp ) > 0 ) ||
(estSavePairCmp(&rpair[right],&rp ) < 0 ))
bad = 1; /*MATHOG, preceding test's logic was inverted */
else
{
bad = 0;
while(right-left > 1)
{
/* binary check for row/col */
middle = (left+right)/2;
d = estSavePairCmp( &rpair[middle], &rp );
if( d < 0 )
left = middle;
else if( d >= 0 )
right = middle;
}
if(debug)
ajDebug("col %d row %d right: col %d row %d left: col %d row %d\n",
col, row, rpair[right].col, rpair[right].row,
rpair[left].col,
rpair[left].row );
/*
** any of these fail indicates failure
** MATHOG, next test's logic was inverted
*/
if( estSavePairCmp( &rpair[right], &rp ) < 0 ||
rpair[left].col != col ||
rpair[left].row >= row )
{
if(debug)
{
ajDebug("estPairRemember => bad2\n");
ajDebug("estSavePairCmp( %d+%d, %d+%d) %d\n",
rpair[right].col, rpair[right].row,
rp.col, rp.row,
estSavePairCmp( &rpair[right], &rp ));
ajDebug("rpair[left].col %d %d\n", rpair[left].col, col);
ajDebug("rpair[left].row %d %d\n", rpair[left].row, row);
}
bad = 2;
}
}
/* error - this should never happen */
if(bad != 0)
ajFatal("ERROR in estPairRemember() "
"left: %d (%d %d) right: %d (%d %d) "
"col: %d row: %d, bad: %d\n",
left, rpair[left].col, rpair[left].row, right,
rpair[right].col, rpair[right].row, col, row, bad);
return rpair[left].row;
} | false | false | false | false | false | 0 |
CDB___log_flush(dblp, lsn)
DB_LOG *dblp;
const DB_LSN *lsn;
{
DB_LSN t_lsn;
LOG *lp;
int current, ret;
ret = 0;
lp = dblp->reginfo.primary;
/*
* If no LSN specified, flush the entire log by setting the flush LSN
* to the last LSN written in the log. Otherwise, check that the LSN
* isn't a non-existent record for the log.
*/
if (lsn == NULL) {
t_lsn.file = lp->lsn.file;
t_lsn.offset = lp->lsn.offset - lp->len;
lsn = &t_lsn;
} else
if (lsn->file > lp->lsn.file ||
(lsn->file == lp->lsn.file &&
lsn->offset > lp->lsn.offset - lp->len)) {
CDB___db_err(dblp->dbenv,
"CDB_log_flush: LSN past current end-of-log");
return (EINVAL);
}
/*
* If the LSN is less than or equal to the last-sync'd LSN, we're
* done. Note, the last-sync LSN saved in s_lsn is the LSN of the
* first byte we absolutely know has been written to disk, so the
* test is <=.
*/
if (lsn->file < lp->s_lsn.file ||
(lsn->file == lp->s_lsn.file && lsn->offset <= lp->s_lsn.offset))
return (0);
/*
* We may need to write the current buffer. We have to write the
* current buffer if the flush LSN is greater than or equal to the
* buffer's starting LSN.
*/
current = 0;
if (lp->b_off != 0 && CDB_log_compare(lsn, &lp->f_lsn) >= 0) {
if ((ret = CDB___log_write(dblp, dblp->bufp, lp->b_off)) != 0)
return (ret);
lp->b_off = 0;
current = 1;
}
/*
* It's possible that this thread may never have written to this log
* file. Acquire a file descriptor if we don't already have one.
* One last check -- if we're not writing anything from the current
* buffer, don't bother. We have nothing to write and nothing to
* sync.
*/
if (dblp->lfname != lp->lsn.file) {
if (!current)
return (0);
if ((ret = CDB___log_newfh(dblp)) != 0)
return (ret);
}
/* Sync all writes to disk. */
if ((ret = CDB___os_fsync(&dblp->lfh)) != 0) {
CDB___db_panic(dblp->dbenv, ret);
return (ret);
}
++lp->stat.st_scount;
/*
* Set the last-synced LSN, using the LSN of the current buffer. If
* the current buffer was flushed, we know the LSN of the first byte
* of the buffer is on disk, otherwise, we only know that the LSN of
* the record before the one beginning the current buffer is on disk.
*
* Check to be sure the saved lsn isn't 0 before decrementing it. If
* DB_CHECKPOINT was called before we wrote any log records, you can
* end up here without ever having written anything to a log file, and
* decrementing s_lsn.file or s_lsn.offset will cause much sadness.
*/
lp->s_lsn = lp->f_lsn;
if (!current && lp->s_lsn.file != 0) {
if (lp->s_lsn.offset == 0) {
--lp->s_lsn.file;
lp->s_lsn.offset = lp->persist.lg_max;
} else
--lp->s_lsn.offset;
}
return (0);
} | false | false | false | false | false | 0 |
stop( KDirLister *lister, bool silent )
{
#ifdef DEBUG_CACHE
//printDebug();
#endif
//kDebug(7004) << "lister:" << lister << "silent=" << silent;
const KUrl::List urls = lister->d->lstDirs;
Q_FOREACH(const KUrl& url, urls) {
stopListingUrl(lister, url, silent);
}
#if 0 // test code
QHash<QString,KDirListerCacheDirectoryData>::iterator dirit = directoryData.begin();
const QHash<QString,KDirListerCacheDirectoryData>::iterator dirend = directoryData.end();
for( ; dirit != dirend ; ++dirit ) {
KDirListerCacheDirectoryData& dirData = dirit.value();
if (dirData.listersCurrentlyListing.contains(lister)) {
kDebug(7004) << "ERROR: found lister" << lister << "in list - for" << dirit.key();
Q_ASSERT(false);
}
}
#endif
} | false | false | false | false | false | 0 |