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 |
|---|---|---|---|---|---|---|
elf_xtensa_action_discarded (asection *sec)
{
if (strcmp (".xt_except_table", sec->name) == 0)
return 0;
if (strcmp (".xt_except_desc", sec->name) == 0)
return 0;
return _bfd_elf_default_action_discarded (sec);
} | false | false | false | false | false | 0 |
focus(Fl_Widget *o) {
if (o && !o->visible_focus()) return;
if (grab()) return; // don't do anything while grab is on
Fl_Widget *p = focus_;
if (o != p) {
Fl::compose_reset();
focus_ = o;
// make sure that fl_xfocus is set to the top level window
// of this widget, or fl_fix_focus will clear our focus again
if (o) {
Fl_Window *win = 0, *w1 = o->as_window();
if (!w1) w1 = o->window();
while (w1) { win=w1; w1=win->window(); }
if (win) {
#ifdef __APPLE__
if (fl_xfocus != win) {
Fl_X *x = Fl_X::i(win);
if (x) x->set_key_window();
}
#endif
fl_xfocus = win;
}
}
// take focus from the old focused window
fl_oldfocus = 0;
int old_event = e_number;
e_number = FL_UNFOCUS;
for (; p; p = p->parent()) {
p->handle(FL_UNFOCUS);
fl_oldfocus = p;
}
e_number = old_event;
}
} | false | false | false | false | false | 0 |
GetUnrollMetadataForLoop(const Loop *L, StringRef Name) {
if (MDNode *LoopID = L->getLoopID())
return GetUnrollMetadata(LoopID, Name);
return nullptr;
} | false | false | false | false | false | 0 |
doublePixels(const QImage &src) const
{
int w = src.width();
int h = src.height();
QImage dst( w*2, h*2, src.format() );
if (src.depth() == 1)
{
kDebug(265) << "image depth 1 not supported\n";
return QImage();
}
int x, y;
if (src.depth() == 32)
{
QRgb* l1, *l2;
for (y=0; y<h; ++y)
{
l1 = (QRgb*)src.scanLine(y);
l2 = (QRgb*)dst.scanLine(y*2);
for (x=0; x<w; ++x)
{
l2[x*2] = l2[x*2+1] = l1[x];
}
memcpy(dst.scanLine(y*2+1), l2, dst.bytesPerLine());
}
} else
{
for (x=0; x<src.numColors(); ++x)
dst.setColor(x, src.color(x));
const unsigned char *l1;
unsigned char *l2;
for (y=0; y<h; ++y)
{
l1 = src.scanLine(y);
l2 = dst.scanLine(y*2);
for (x=0; x<w; ++x)
{
l2[x*2] = l1[x];
l2[x*2+1] = l1[x];
}
memcpy(dst.scanLine(y*2+1), l2, dst.bytesPerLine());
}
}
return dst;
} | false | false | false | false | false | 0 |
NDT_V2_GetNodeType(u32 NDT_Tag, u32 NodeTag)
{
if(!NDT_Tag || !NodeTag) return 0;
switch(NDT_Tag) {
case NDT_SFWorldNode:
return ALL_GetNodeType(SFWorldNode_V2_TypeToTag, SFWorldNode_V2_Count, NodeTag, GF_BIFS_V2);
case NDT_SF3DNode:
return ALL_GetNodeType(SF3DNode_V2_TypeToTag, SF3DNode_V2_Count, NodeTag, GF_BIFS_V2);
case NDT_SF2DNode:
return ALL_GetNodeType(SF2DNode_V2_TypeToTag, SF2DNode_V2_Count, NodeTag, GF_BIFS_V2);
case NDT_SFGeometryNode:
return ALL_GetNodeType(SFGeometryNode_V2_TypeToTag, SFGeometryNode_V2_Count, NodeTag, GF_BIFS_V2);
case NDT_SFMaterialNode:
return ALL_GetNodeType(SFMaterialNode_V2_TypeToTag, SFMaterialNode_V2_Count, NodeTag, GF_BIFS_V2);
case NDT_SFBAPNode:
return ALL_GetNodeType(SFBAPNode_V2_TypeToTag, SFBAPNode_V2_Count, NodeTag, GF_BIFS_V2);
case NDT_SFBDPNode:
return ALL_GetNodeType(SFBDPNode_V2_TypeToTag, SFBDPNode_V2_Count, NodeTag, GF_BIFS_V2);
case NDT_SFBodyDefTableNode:
return ALL_GetNodeType(SFBodyDefTableNode_V2_TypeToTag, SFBodyDefTableNode_V2_Count, NodeTag, GF_BIFS_V2);
case NDT_SFBodySegmentConnectionHintNode:
return ALL_GetNodeType(SFBodySegmentConnectionHintNode_V2_TypeToTag, SFBodySegmentConnectionHintNode_V2_Count, NodeTag, GF_BIFS_V2);
case NDT_SFPerceptualParameterNode:
return ALL_GetNodeType(SFPerceptualParameterNode_V2_TypeToTag, SFPerceptualParameterNode_V2_Count, NodeTag, GF_BIFS_V2);
default:
return 0;
}
} | false | false | false | false | false | 0 |
ath10k_mac_vif_tx_lock(struct ath10k_vif *arvif, int reason)
{
struct ath10k *ar = arvif->ar;
lockdep_assert_held(&ar->htt.tx_lock);
WARN_ON(reason >= BITS_PER_LONG);
arvif->tx_paused |= BIT(reason);
ieee80211_stop_queue(ar->hw, arvif->vdev_id);
} | false | false | false | false | false | 0 |
mt312_get_symbol_rate(struct mt312_state *state, u32 *sr)
{
int ret;
u8 sym_rate_h;
u8 dec_ratio;
u16 sym_rat_op;
u16 monitor;
u8 buf[2];
ret = mt312_readreg(state, SYM_RATE_H, &sym_rate_h);
if (ret < 0)
return ret;
if (sym_rate_h & 0x80) {
/* symbol rate search was used */
ret = mt312_writereg(state, MON_CTRL, 0x03);
if (ret < 0)
return ret;
ret = mt312_read(state, MONITOR_H, buf, sizeof(buf));
if (ret < 0)
return ret;
monitor = (buf[0] << 8) | buf[1];
dprintk("sr(auto) = %u\n",
mt312_div(monitor * 15625, 4));
} else {
ret = mt312_writereg(state, MON_CTRL, 0x05);
if (ret < 0)
return ret;
ret = mt312_read(state, MONITOR_H, buf, sizeof(buf));
if (ret < 0)
return ret;
dec_ratio = ((buf[0] >> 5) & 0x07) * 32;
ret = mt312_read(state, SYM_RAT_OP_H, buf, sizeof(buf));
if (ret < 0)
return ret;
sym_rat_op = (buf[0] << 8) | buf[1];
dprintk("sym_rat_op=%d dec_ratio=%d\n",
sym_rat_op, dec_ratio);
dprintk("*sr(manual) = %lu\n",
(((state->xtal * 8192) / (sym_rat_op + 8192)) *
2) - dec_ratio);
}
return 0;
} | false | false | false | false | false | 0 |
read(const Filename &fn, MetricsFinder *finder, ErrorHandler *errh)
{
Slurper slurper(fn);
return read(slurper, finder, errh);
} | false | false | false | false | false | 0 |
select_p_update_node_config (int index)
{
if (index >= select_node_cnt) {
error("select_p_update_node_config: index too large %d>%d",
index, select_node_cnt);
return SLURM_ERROR;
}
if (select_fast_schedule)
return SLURM_SUCCESS;
select_node_record[index].real_memory = select_node_record[index].
node_ptr->real_memory;
return SLURM_SUCCESS;
} | false | false | false | false | false | 0 |
filetypes_index(gint idx)
{
return (idx >= 0 && idx < (gint) filetypes_array->len) ? filetypes[idx] : NULL;
} | false | false | false | false | false | 0 |
return_channel(int channel, CSOUND *sound)
{
CCHANNEL *ch = NULL;
if (channel < 0 || channel >= channel_count)
{
if (sound)
GB.Unref(POINTER(&sound));
GB.ReturnNull();
return;
}
ch = channel_cache[channel];
if (!ch)
{
ch = GB.New(GB.FindClass("Channel"), NULL, NULL);
channel_cache[channel] = ch;
ch->channel = channel;
GB.Ref(ch);
}
free_channel(ch);
if (sound)
ch->sound = sound;
GB.ReturnObject(ch);
} | false | false | false | false | false | 0 |
GVL_isosurf_get_att(int id, int isosurf_id,
int att, int *set, float *constant, char *mapname)
{
int src;
geovol_isosurf *isosurf;
G_debug(3, "GVL_isosurf_get_att");
isosurf = gvl_isosurf_get_isosurf(id, isosurf_id);
if (isosurf) {
if (-1 != (src = gvl_isosurf_get_att_src(isosurf, att))) {
*set = src;
if (src == CONST_ATT) {
*constant = isosurf->att[att].constant;
}
else if (src == MAP_ATT) {
G_strcpy(mapname, gvl_file_get_name(isosurf->att[att].hfile));
}
return (1);
}
return (-1);
}
return (-1);
} | false | false | false | false | false | 0 |
cycle(double index, double loRange, double hiRange)
{
int lo = int(loRange);
int hi = int(hiRange);
int range = hi - lo + 1;
if (range <= 0) return lo;
int result = int(index) % range;
if (result < 0) result += range;
return lo + result;
} | false | false | false | false | false | 0 |
totem_pl_parser_save_m3u (TotemPlParser *parser,
TotemPlPlaylist *playlist,
GFile *output,
gboolean dos_compatible,
GError **error)
{
TotemPlPlaylistIter iter;
GFileOutputStream *stream;
gboolean valid, success;
char *buf;
const char *cr;
stream = g_file_replace (output, NULL, FALSE, G_FILE_CREATE_NONE, NULL, error);
if (stream == NULL)
return FALSE;
cr = dos_compatible ? "\r\n" : "\n";
buf = g_strdup_printf ("#EXTM3U%s", cr);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
g_free (buf);
if (success == FALSE)
return FALSE;
valid = totem_pl_playlist_iter_first (playlist, &iter);
while (valid) {
char *uri, *title, *path2;
GFile *file;
totem_pl_playlist_get (playlist, &iter,
TOTEM_PL_PARSER_FIELD_URI, &uri,
TOTEM_PL_PARSER_FIELD_TITLE, &title,
NULL);
valid = totem_pl_playlist_iter_next (playlist, &iter);
if (!uri) {
g_free (title);
continue;
}
file = g_file_new_for_uri (uri);
if (totem_pl_parser_scheme_is_ignored (parser, file) != FALSE) {
g_object_unref (file);
g_free (uri);
g_free (title);
continue;
}
g_object_unref (file);
if (title) {
buf = g_strdup_printf (EXTINF",%s%s", title, cr);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
g_free (buf);
if (success == FALSE) {
g_free (title);
g_free (uri);
return FALSE;
}
}
g_free (title);
if (dos_compatible == FALSE) {
char *tmp;
tmp = totem_pl_parser_relative (output, uri);
if (tmp == NULL && g_str_has_prefix (uri, "file:")) {
path2 = g_filename_from_uri (uri, NULL, NULL);
} else {
path2 = tmp;
}
} else {
path2 = totem_pl_parser_uri_to_dos (uri, output);
}
buf = g_strdup_printf ("%s%s", path2 ? path2 : uri, cr);
g_free (path2);
g_free (uri);
success = totem_pl_parser_write_string (G_OUTPUT_STREAM (stream), buf, error);
g_free (buf);
if (success == FALSE)
return FALSE;
}
g_object_unref (stream);
return TRUE;
} | false | false | false | false | false | 0 |
goto_tabpage_tp(tp, trigger_enter_autocmds, trigger_leave_autocmds)
tabpage_T *tp;
int trigger_enter_autocmds;
int trigger_leave_autocmds;
{
/* Don't repeat a message in another tab page. */
set_keep_msg(NULL, 0);
if (tp != curtab && leave_tabpage(tp->tp_curwin->w_buffer,
trigger_leave_autocmds) == OK)
{
if (valid_tabpage(tp))
enter_tabpage(tp, curbuf, trigger_enter_autocmds,
trigger_leave_autocmds);
else
enter_tabpage(curtab, curbuf, trigger_enter_autocmds,
trigger_leave_autocmds);
}
} | false | false | false | false | false | 0 |
command_dispose_test_stream(char * token, Channel * c) {
char id[256];
int err = 0;
json_read_string(&c->inp, id, sizeof(id));
if (read_stream(&c->inp) != 0) exception(ERR_JSON_SYNTAX);
if (read_stream(&c->inp) != MARKER_EOM) exception(ERR_JSON_SYNTAX);
#if SERVICE_Streams
if (!err) {
VirtualStream * stream = virtual_stream_find(id);
if (stream == NULL) err = errno;
else virtual_stream_delete(stream);
}
#else
err = ERR_UNSUPPORTED;
#endif
write_stringz(&c->out, "R");
write_stringz(&c->out, token);
write_errno(&c->out, err);
write_stream(&c->out, MARKER_EOM);
} | true | true | false | false | false | 1 |
GMT_init_track (double y[], GMT_LONG n, struct GMT_XSEGMENT **S)
{
/* GMT_init_track accepts the y components of an x-y track of length n and returns an array of
* line segments that have been sorted on the minimum y-coordinate
*/
GMT_LONG a, b, nl = n - 1;
struct GMT_XSEGMENT *L = NULL;
int GMT_ysort (const void *p1, const void *p2);
if (nl <= 0) {
fprintf (stderr, "GMT: ERROR in GMT_init_track; nl = %ld\n", nl);
GMT_exit (EXIT_FAILURE);
}
L = (struct GMT_XSEGMENT *) GMT_memory (VNULL, nl, sizeof (struct GMT_XSEGMENT), "GMT_init_track");
for (a = 0, b = 1; b < n; a++, b++) {
if (y[b] < y[a]) {
L[a].start = b;
L[a].stop = a;
}
else {
L[a].start = a;
L[a].stop = b;
}
}
/* Sort on minimum y-coordinate, if tie then on 2nd coordinate */
GMT_x2sys_Y = y; /* Sort routine needs this pointer */
qsort ((void *)L, (size_t)nl, sizeof (struct GMT_XSEGMENT), GMT_ysort);
GMT_x2sys_Y = (double *)NULL;
*S = L;
return (GMT_NOERROR);
} | false | false | false | false | false | 0 |
print_block(const uint8_t *b, int size) {
int i=0;
fprintf(stderr,"BEGIN OF %d BYTES---\n", size);
for(i=0; i<size; i++) {
fprintf(stderr,"%d ", *(b+i));
}
fprintf(stderr,"END OF %d BYTES---\n", size);
} | false | false | false | false | false | 0 |
Definition (ostream& out) {
if (idraw_format()) {
ArrowMultiLineOvComp* comp = (ArrowMultiLineOvComp*) GetSubject();
ArrowMultiLine* aml = comp->GetArrowMultiLine();
const Coord* x, *y;
int n = aml->GetOriginal(x, y);
float arrow_scale = aml->ArrowScale();
out << "Begin " << MARK << " " << Name() << "\n";
MinGS(out);
out << MARK << " " << n << "\n";
for (int i = 0; i < n; i++) {
out << x[i] << " " << y[i] << "\n";
}
out << n << " " << Name() << "\n";
out << MARK << " " << arrow_scale << "\n";
out << "End\n\n";
return out.good();
}
ArrowMultiLine* aml = (ArrowMultiLine*) GetGraphicComp()->GetGraphic();
const Coord* x, *y;
int numverts = aml->GetOriginal(x, y);
float arrow_scale = aml->ArrowScale();
boolean head = aml->Head();
boolean tail = aml->Tail();
const int limit = 32;
int cnt = 0;
for (int v=0; v<numverts; v+=limit-1) {
int n = min(numverts-cnt,limit);
if (v==0)
aml->SetArrows(head, false);
else if ( v+limit>=numverts)
aml->SetArrows(false, tail);
else
aml->SetArrows(false, false);
out << "Begin " << MARK << " " << Name() << "\n";
MinGS(out);
out << MARK << " " << n << "\n";
for (int i=0; i < n; i++, cnt++) {
out << x[cnt] << " " << y[cnt] << "\n";
}
out << n << " " << Name() << "\n";
out << MARK << " " << arrow_scale << "\n";
out << "End\n\n";
cnt--; /* back up so that split lines share a vertex */
}
aml->SetArrows(head, tail);
return out.good();
} | false | false | false | false | false | 0 |
drawGL (CVector3 *z1, CVector3 *z2, CVector3 *tl, float alpha2, float lum2, bool drawlight2, bool istextured2)
{
int i;
CVector3 tl1;
tl1.x = tl->x + this->tl->x;
tl1.y = tl->y + this->tl->y;
tl1.z = tl->z + this->tl->z;
if (draw == 0) return;
if (draw == 2 || gl->isSphereInFrustum (tl1.x, tl1.y, tl1.z, this->zoom * 1.5))
{
if (drawlight && drawlight2)
{
glEnable (GL_LIGHTING);
o->draw (tl, this->tl, this->rot, this->zoom, lum * lum2, explode);
if (refmodel != NULL)
{
glPushMatrix ();
glTranslatef (tl1.x, tl1.y - 0.001 * explode * explode / timestep / timestep, tl1.z);
glRotatef (rot->c+90, 0, -1, 0);
glRotatef (-rot->a+90, 0, 0, 1);
glRotatef (rot->b+180, 1, 0, 0);
glScalef (zoom, zoom, zoom);
if (o->refpoint)
for (i = 0; i < numRefModels; i ++)
if (refscale [i] > 0.001)
refmodel [i]->draw (&o->refpoint [i / 3], &reftl [i], &refrot [i], refscale [i], lum * lum2, explode);
glPopMatrix ();
}
}
else
{
glDisable (GL_LIGHTING);
if (istextured2)
{
o->draw2 (tl, this->tl, this->rot, this->zoom, explode);
}
else
{
if (drawlight2)
o->draw3 (tl, this->tl, this->rot, this->zoom, lum * lum2, explode);
else
o->draw3 (tl, this->tl, this->rot, this->zoom, explode);
}
}
}
} | false | false | false | true | false | 1 |
get_time()
{
if (susp_cnt == 0)
return sys_time() - susp_accum;
else
return susp_start - susp_accum;
} | false | false | false | false | false | 0 |
remove_lat_multicast(int ifn)
{
// Add Multicast membership for LAT on socket
struct packet_mreq pack_info;
/* Fill in socket options */
pack_info.mr_type = PACKET_MR_MULTICAST;
pack_info.mr_alen = 6;
pack_info.mr_ifindex = ifn;
/* This is the LAT multicast address */
pack_info.mr_address[0] = 0x09;
pack_info.mr_address[1] = 0x00;
pack_info.mr_address[2] = 0x2b;
pack_info.mr_address[3] = 0x00;
pack_info.mr_address[4] = 0x00;
pack_info.mr_address[5] = 0x0f;
if (setsockopt(fd, SOL_PACKET, PACKET_DROP_MEMBERSHIP,
&pack_info, sizeof(pack_info)))
{
syslog(LOG_ERR, "can't remove socket multicast : %m\n");
return -1;
}
/* This is the LAT solicit address */
pack_info.mr_address[0] = 0x09;
pack_info.mr_address[1] = 0x00;
pack_info.mr_address[2] = 0x2b;
pack_info.mr_address[3] = 0x02;
pack_info.mr_address[4] = 0x01;
pack_info.mr_address[5] = 0x04;
if (setsockopt(fd, SOL_PACKET, PACKET_DROP_MEMBERSHIP,
&pack_info, sizeof(pack_info)))
{
syslog(LOG_ERR, "can't remove socket multicast : %m\n");
return -1;
}
return 0;
} | false | false | false | false | false | 0 |
str_str( UBYTE *s, UBYTE *t )
{
int c;
while( *s )
{
c = str_cmp( s, t );
if( c == 0 || c == STR_LONGER )
return s;
s++;
}
return NULL;
} | false | false | false | false | false | 0 |
OdModf(order *od,
xlist *elist,
int *node_status,
int *marker,
int *isize,
int *oinfo,
int rsze,
int *rchset,
int *ibuf1)
{
int i,x,deg;
for(i=0; i<rsze; ++i) {
x=rchset[i];
if (node_status[x]==2)
if (node_status[oinfo[x]]==0||node_status[oinfo[x]]==3)
node_status[x]=1;
if (node_status[x]==1) {
deg=OdOrder(od,node_status,marker,isize,x,ibuf1);
XtPut(elist,x,deg-isize[x]);
}
else
XtDel(elist,x);
}
} | false | false | false | false | false | 0 |
index_get(struct index *idx, struct slice *sk, struct slice *sv)
{
int ret = 0, value_len, result;
uint64_t value_off = 0UL;
struct skipnode *node;
struct skiplist *cur_list;
struct skiplist *merge_list;
/*
* 0) Get from bloomfilter,if bloom_get return 1,next
* 1) First lookup from active memtable
* 2) Then from merge memtable
* 3) Last from sst on-disk indexes
*/
ret = bloom_get(idx->sst->bloom, sk->data);
if (ret != 1)
return ret;
cur_list = idx->list;
node = skiplist_lookup(cur_list, sk->data);
if (node){
if(node->opt == DEL) {
ret = -1;
goto out_get;
}
value_off = node->val;
} else {
merge_list = idx->park->list;
if (merge_list) {
node = skiplist_lookup(merge_list, sk->data);
if (node && node->opt == ADD )
value_off = node->val;
}
}
if (value_off == 0UL)
value_off = sst_getoff(idx->sst, sk);
if (value_off != 0UL) {
__be32 be32len;
lseek(idx->db_rfd, value_off, SEEK_SET);
result = read(idx->db_rfd, &be32len, sizeof(int));
if(FILE_ERR(result)) {
ret = -1;
goto out_get;
}
value_len = from_be32(be32len);
if(result == sizeof(int)) {
char *data = malloc(value_len + 1);
memset(data, 0, value_len + 1);
result = read(idx->db_rfd, data, value_len);
if(FILE_ERR(result)) {
free(data);
ret = -1;
goto out_get;
}
sv->len = value_len;
sv->data = data;
return 1;
}
}
out_get:
return ret;
} | false | true | false | false | true | 1 |
parse_modem_interfaces(const char *path, DBusMessageIter *ifaces)
{
DBG("%s", path);
while (dbus_message_iter_get_arg_type(ifaces) == DBUS_TYPE_STRING) {
const char *iface;
dbus_message_iter_get_basic(ifaces, &iface);
if (g_str_equal(iface, OFONO_NETWORKREG_INTERFACE)) {
network_found(path);
return;
}
dbus_message_iter_next(ifaces);
}
modem_removed(path);
} | false | false | false | false | false | 0 |
extract(u_int start, u_int chars) const
{
fxAssert(start+chars<slength, "Str::extract: Invalid range");
return fxStr(data+start,chars);
} | false | false | false | false | false | 0 |
gdl_dock_notebook_set_orientation (GdlDockItem *item,
GtkOrientation orientation)
{
GtkWidget *child = gdl_dock_item_get_child (item);
if (child && GTK_IS_NOTEBOOK (child)) {
if (orientation == GTK_ORIENTATION_HORIZONTAL)
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (child), GTK_POS_TOP);
else
gtk_notebook_set_tab_pos (GTK_NOTEBOOK (child), GTK_POS_LEFT);
}
GDL_DOCK_ITEM_CLASS (gdl_dock_notebook_parent_class)->set_orientation (item, orientation);
} | false | false | false | false | false | 0 |
IoBlock_activate(IoBlock *self, IoObject *target, IoObject *locals, IoMessage *m, IoObject *slotContext)
{
IoState *state = IOSTATE;
IoBlockData *selfData = DATA(self);
List *argNames = selfData->argNames;
IoObject *scope = selfData->scope;
IoObject *blockLocals = IOCLONE(state->localsProto);
IoObject *result;
IoObject *callObject;
IoObject_isLocals_(blockLocals, 1);
if (!scope)
{
scope = target;
}
IoObject_createSlotsIfNeeded(blockLocals);
callObject = IoCall_with(state,
locals,
target,
m,
slotContext,
self,
state->currentCoroutine);
{
PHash *bslots = IoObject_slots(blockLocals);
PHash_at_put_(bslots, state->callSymbol, callObject);
PHash_at_put_(bslots, state->selfSymbol, scope);
PHash_at_put_(bslots, state->updateSlotSymbol, state->localsUpdateSlotCFunc);
}
IoObject_isReferenced_(blockLocals, 0);
IoObject_isReferenced_(callObject, 0);
LIST_FOREACH(argNames, i, name,
IoObject *arg = IoMessage_locals_valueArgAt_(m, locals, (int)i);
// gc may kick in while evaling locals, so we need to be safe
IoObject_setSlot_to_(blockLocals, name, arg);
);
if (Coro_stackSpaceAlmostGone(IoCoroutine_cid(state->currentCoroutine)))
{
/*
IoCoroutine *currentCoroutine = state->currentCoroutine;
Coro *coro = IoCoroutine_cid(currentCoroutine);
printf("%p-%p block overflow %i/%i\n",
(void *)currentCoroutine, (void *)coro, Coro_bytesLeftOnStack(coro), Coro_stackSize(coro));
printf("message = %s\n", CSTRING(IoMessage_name(selfData->message)));
*/
{
IoCoroutine *newCoro = IoCoroutine_new(state);
IoCoroutine_try(newCoro, blockLocals, blockLocals, selfData->message);
result = IoCoroutine_rawResult(newCoro);
}
}
else
{
result = IoMessage_locals_performOn_(selfData->message, blockLocals, blockLocals);
}
if (DATA(self)->passStops == 0)
{
state->returnValue = result;
state->stopStatus = IoCall_rawStopStatus(callObject);
}
IoState_stackRetain_(state, result);
#ifdef IO_BLOCK_LOCALS_RECYCLING
#ifndef STACK_POP_CALLBACK
if(!IoObject_isReferenced(blockLocals) && !IoObject_isReferenced(callObject))
{
CollectorMarker_remove((CollectorMarker *)blockLocals);
IoObject_free(blockLocals);
CollectorMarker_remove((CollectorMarker *)callObject);
IoObject_free(callObject);
//IoObject_freeIfUnreferenced(blockLocals);
//IoObject_freeIfUnreferenced(callObject);
}
else
#endif
{
// since the callObject doesn't IOREF its blockLocals pointer
if (IoObject_isReferenced(callObject))
{
IoObject_isReferenced_(blockLocals, 1);
}
}
#endif
return result;
} | false | false | false | false | false | 0 |
dun_error (NmaBtDevice *self, const char *func, GError *error, const char *fallback)
{
g_warning ("%s: DUN error: %s", func, (error && error->message) ? error->message : fallback);
_set_status (self, _("Error: %s"), (error && error->message) ? error->message : fallback);
_set_busy (self, FALSE);
dun_cleanup (self);
recheck_services_enabled (self);
} | false | false | false | false | false | 0 |
etfci_drop_full_header (ETableFieldChooserItem *etfci)
{
GObject *header;
if (!etfci->full_header)
return;
header = G_OBJECT (etfci->full_header);
if (etfci->full_header_structure_change_id)
g_signal_handler_disconnect (
header, etfci->full_header_structure_change_id);
if (etfci->full_header_dimension_change_id)
g_signal_handler_disconnect (
header, etfci->full_header_dimension_change_id);
etfci->full_header_structure_change_id = 0;
etfci->full_header_dimension_change_id = 0;
if (header)
g_object_unref (header);
etfci->full_header = NULL;
etfci->height = 0;
e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (etfci));
} | false | false | false | false | false | 0 |
lto_symtab_encoder_delete_node (lto_symtab_encoder_t encoder,
symtab_node node)
{
void **slot, **last_slot;
int index;
lto_encoder_entry last_node;
slot = pointer_map_contains (encoder->map, node);
if (slot == NULL || !*slot)
return false;
index = (size_t) *slot - 1;
gcc_checking_assert (encoder->nodes[index].node == node);
/* Remove from vector. We do this by swapping node with the last element
of the vector. */
last_node = encoder->nodes.pop ();
if (last_node.node != node)
{
last_slot = pointer_map_contains (encoder->map, last_node.node);
gcc_checking_assert (last_slot && *last_slot);
*last_slot = (void *)(size_t) (index + 1);
/* Move the last element to the original spot of NODE. */
encoder->nodes[index] = last_node;
}
/* Remove element from hash table. */
*slot = NULL;
return true;
} | false | false | false | false | false | 0 |
NotifyModified(DocModification mh) {
if (mh.modificationType & SC_MOD_INSERTTEXT) {
decorations.InsertSpace(mh.position, mh.length);
} else if (mh.modificationType & SC_MOD_DELETETEXT) {
decorations.DeleteRange(mh.position, mh.length);
}
for (int i = 0; i < lenWatchers; i++) {
watchers[i].watcher->NotifyModified(this, mh, watchers[i].userData);
}
} | false | false | false | false | false | 0 |
IsTag(P_WBXML_INFO buffer, WBXML_TAG tag)
{
BOOL result = FALSE;
if (buffer)
{
if (BytesLeft(buffer) >= sizeof(WBXML_TAG))
{
result = ((*((WBXML_TAG*) buffer->m_curpos)) == tag);
}
else
{
/* No more data, so nope, not this tag */
result = FALSE;
}
}
else
{
ParseError(ERR_INTERNAL_BAD_PARAM);
}
return result;
} | false | false | false | false | false | 0 |
parse_len(const char *line)
{
char num[PKT_LEN_SIZE + 1];
int i, error;
long len;
const char *num_end;
memcpy(num, line, PKT_LEN_SIZE);
num[PKT_LEN_SIZE] = '\0';
for (i = 0; i < PKT_LEN_SIZE; ++i) {
if (!isxdigit(num[i]))
return GIT_ENOTNUM;
}
error = git__strtol32(&len, num, &num_end, 16);
if (error < GIT_SUCCESS) {
return error;
}
return (unsigned int) len;
} | false | false | false | false | false | 0 |
ocrdma_add(struct be_dev_info *dev_info)
{
int status = 0, i;
u8 lstate = 0;
struct ocrdma_dev *dev;
dev = (struct ocrdma_dev *)ib_alloc_device(sizeof(struct ocrdma_dev));
if (!dev) {
pr_err("Unable to allocate ib device\n");
return NULL;
}
dev->mbx_cmd = kzalloc(sizeof(struct ocrdma_mqe_emb_cmd), GFP_KERNEL);
if (!dev->mbx_cmd)
goto idr_err;
memcpy(&dev->nic_info, dev_info, sizeof(*dev_info));
dev->id = idr_alloc(&ocrdma_dev_id, NULL, 0, 0, GFP_KERNEL);
if (dev->id < 0)
goto idr_err;
status = ocrdma_init_hw(dev);
if (status)
goto init_err;
status = ocrdma_alloc_resources(dev);
if (status)
goto alloc_err;
ocrdma_init_service_level(dev);
status = ocrdma_register_device(dev);
if (status)
goto alloc_err;
/* Query Link state and update */
status = ocrdma_mbx_get_link_speed(dev, NULL, &lstate);
if (!status)
ocrdma_update_link_state(dev, lstate);
for (i = 0; i < ARRAY_SIZE(ocrdma_attributes); i++)
if (device_create_file(&dev->ibdev.dev, ocrdma_attributes[i]))
goto sysfs_err;
/* Init stats */
ocrdma_add_port_stats(dev);
/* Interrupt Moderation */
INIT_DELAYED_WORK(&dev->eqd_work, ocrdma_eqd_set_task);
schedule_delayed_work(&dev->eqd_work, msecs_to_jiffies(1000));
pr_info("%s %s: %s \"%s\" port %d\n",
dev_name(&dev->nic_info.pdev->dev), hca_name(dev),
port_speed_string(dev), dev->model_number,
dev->hba_port_num);
pr_info("%s ocrdma%d driver loaded successfully\n",
dev_name(&dev->nic_info.pdev->dev), dev->id);
return dev;
sysfs_err:
ocrdma_remove_sysfiles(dev);
alloc_err:
ocrdma_free_resources(dev);
ocrdma_cleanup_hw(dev);
init_err:
idr_remove(&ocrdma_dev_id, dev->id);
idr_err:
kfree(dev->mbx_cmd);
ib_dealloc_device(&dev->ibdev);
pr_err("%s() leaving. ret=%d\n", __func__, status);
return NULL;
} | false | false | false | false | false | 0 |
icalparameter_free (icalparameter* parameter)
{
struct icalparameter_impl * impl;
impl = (struct icalparameter_impl*)parameter;
/* HACK. This always triggers, even when parameter is non-zero
icalerror_check_arg_rv((parameter==0),"parameter");*/
#ifdef ICAL_FREE_ON_LIST_IS_ERROR
icalerror_assert( (impl->parent ==0),"Tried to free a parameter that is still attached to a component. ");
#else
if(impl->parent !=0){
return;
}
#endif
if (impl->string != 0){
free ((void*)impl->string);
}
if (impl->x_name != 0){
free ((void*)impl->x_name);
}
memset(impl,0,sizeof(impl));
impl->parent = 0;
impl->id[0] = 'X';
free(impl);
} | false | false | false | false | true | 1 |
del_bezier_vectors(Bezier_Vectors * bvectors) {
GDEBUG("Removing bezier vectors %p and vectors %p, %p, %p, and %p", bvectors, bvectors->p0, bvectors->p1, bvectors->p2, bvectors->p3);
del_vector(bvectors->p0);
del_vector(bvectors->p1);
del_vector(bvectors->p2);
del_vector(bvectors->p3);
free(bvectors);
return 0;
} | false | false | false | false | false | 0 |
uvd_v1_0_init(struct radeon_device *rdev)
{
struct radeon_ring *ring = &rdev->ring[R600_RING_TYPE_UVD_INDEX];
uint32_t tmp;
int r;
/* raise clocks while booting up the VCPU */
if (rdev->family < CHIP_RV740)
radeon_set_uvd_clocks(rdev, 10000, 10000);
else
radeon_set_uvd_clocks(rdev, 53300, 40000);
r = uvd_v1_0_start(rdev);
if (r)
goto done;
ring->ready = true;
r = radeon_ring_test(rdev, R600_RING_TYPE_UVD_INDEX, ring);
if (r) {
ring->ready = false;
goto done;
}
r = radeon_ring_lock(rdev, ring, 10);
if (r) {
DRM_ERROR("radeon: ring failed to lock UVD ring (%d).\n", r);
goto done;
}
tmp = PACKET0(UVD_SEMA_WAIT_FAULT_TIMEOUT_CNTL, 0);
radeon_ring_write(ring, tmp);
radeon_ring_write(ring, 0xFFFFF);
tmp = PACKET0(UVD_SEMA_WAIT_INCOMPLETE_TIMEOUT_CNTL, 0);
radeon_ring_write(ring, tmp);
radeon_ring_write(ring, 0xFFFFF);
tmp = PACKET0(UVD_SEMA_SIGNAL_INCOMPLETE_TIMEOUT_CNTL, 0);
radeon_ring_write(ring, tmp);
radeon_ring_write(ring, 0xFFFFF);
/* Clear timeout status bits */
radeon_ring_write(ring, PACKET0(UVD_SEMA_TIMEOUT_STATUS, 0));
radeon_ring_write(ring, 0x8);
radeon_ring_write(ring, PACKET0(UVD_SEMA_CNTL, 0));
radeon_ring_write(ring, 3);
radeon_ring_unlock_commit(rdev, ring, false);
done:
/* lower clocks again */
radeon_set_uvd_clocks(rdev, 0, 0);
if (!r) {
switch (rdev->family) {
case CHIP_RV610:
case CHIP_RV630:
case CHIP_RV620:
/* 64byte granularity workaround */
WREG32(MC_CONFIG, 0);
WREG32(MC_CONFIG, 1 << 4);
WREG32(RS_DQ_RD_RET_CONF, 0x3f);
WREG32(MC_CONFIG, 0x1f);
/* fall through */
case CHIP_RV670:
case CHIP_RV635:
/* write clean workaround */
WREG32_P(UVD_VCPU_CNTL, 0x10, ~0x10);
break;
default:
/* TODO: Do we need more? */
break;
}
DRM_INFO("UVD initialized successfully.\n");
}
return r;
} | false | false | false | false | false | 0 |
list_insert_after(list, data, bytes)
LIST *list;
char *data;
int bytes;
{
LIST_ELEMENT *new;
/* Allocate storage for the new element and its data.*/
new = list_create_element(data, bytes);
if (new == NULL)
return(NULL);
/* Now insert the element after the current, considering the cases:
* 1) List is empty
* 2) Inserting at rear
* 3) Otherwise
* We handle them directly, in order.
*/
if (list->front == NULL) {
/* The list is empty. Easy. */
new->prev = new->next = NULL;
list->front = list->rear = list->curr = new;
}
else if (list->curr->next == NULL) {
/* Inserting at the rear. */
new->next = NULL;
new->prev = list->curr;
list->curr->next = new;
list->rear = new;
}
else {
/* Otherwise. */
new->next = list->curr->next;
new->next->prev = new;
new->prev = list->curr;
list->curr->next = new;
}
list->curr = new;
list->size++;
return(new->data);
} | false | false | false | false | false | 0 |
ProcessHeader(const char* name, size_t nlen, const char* value,
size_t vlen, HttpError* error) {
std::string sname(name, nlen), svalue(value, vlen);
data_->addHeader(sname, svalue);
return PR_CONTINUE;
} | false | false | false | false | false | 0 |
stb0899_postproc(struct stb0899_state *state, u8 ctl, int enable)
{
struct stb0899_config *config = state->config;
const struct stb0899_postproc *postproc = config->postproc;
/* post process event */
if (postproc) {
if (enable) {
if (postproc[ctl].level == STB0899_GPIOPULLUP)
stb0899_write_reg(state, postproc[ctl].gpio, 0x02);
else
stb0899_write_reg(state, postproc[ctl].gpio, 0x82);
} else {
if (postproc[ctl].level == STB0899_GPIOPULLUP)
stb0899_write_reg(state, postproc[ctl].gpio, 0x82);
else
stb0899_write_reg(state, postproc[ctl].gpio, 0x02);
}
}
return 0;
} | false | false | false | false | false | 0 |
handler_msn_prp (u_char *raw, int length, ip_address source,
u_short source_port, ip_address destination, u_short destination_port)
{
int rc, nt;
log_debug (4, "Entry into handler_msn_prp");
rc= get_new_line_malloc (&next_line, raw, length);
if (rc<0)
return rc;
nt= get_tokens (next_line, &line_tokens, 0); /* Split in all tokens */
if (nt==3)
{
if (strcmp ((char *) line_tokens[1],"MFN")==0)
{
struct msn_connection *conn = get_or_create_msn_connection
(&source,source_port,&destination,destination_port,
create_no);
u_char *nick=NULL;
if (conn!=NULL)
nick=conn->owner;
urldecode (line_tokens[2]);
log_event(nick, "Changed display name to [%s]", line_tokens[2]);
}
}
else
if (nt==4)
{
if (strcmp ((char *) line_tokens[2],"MFN")==0)
{
struct msn_connection *conn = get_or_create_msn_connection
(&source,source_port,&destination,destination_port,
create_no);
u_char *nick=NULL;
if (conn!=NULL)
nick=conn->owner;
urldecode (line_tokens[3]);
log_event(nick, "Changed display name to [%s]", line_tokens[3]);
}
}
else
{
log_debug (0, "Unable to parse PRP correcty");
log_debug (0, "Line read: %s", next_line);
dump_tokens (line_tokens);
return NOT_MSN;
}
return rc;
} | false | false | false | false | false | 0 |
odm_cfo(char value)
{
int ret_val;
if (value < 0) {
ret_val = 0 - value;
ret_val = (ret_val << 1) + (ret_val >> 1);
/* set bit12 as 1 for negative cfo */
ret_val = ret_val | BIT(12);
} else {
ret_val = value;
ret_val = (ret_val << 1) + (ret_val >> 1);
}
return ret_val;
} | false | false | false | false | false | 0 |
LI1(object first,...)
{
va_list ap;
int narg = VFUN_NARGS; VMB1 VMS1 VMV1
{object V1;
object V2;
object V3;
object V4;
object V5;
object V6;
va_start(ap,first);
narg= narg - 0;
{
parse_key_new_new(narg,Vcs +0,(struct key *)(void *)&LI1key,first,ap);
V1=(Vcs[0]);
V2=(Vcs[1]);
V3=(Vcs[2]);
V4=(Vcs[3]);
V5=(Vcs[4]);
V6=(Vcs[5]);
base[0]= ((object)VV[0]);
base[1]= (V1);
base[2]= (V2);
base[3]= (V3);
base[4]= (V4);
base[5]= (V5);
base[6]= (V6);
vs_top=(vs_base=base+0)+7;
siLmake_structure();
vs_top=sup;
{object V7 = vs_base[0];
VMR1(V7)}
va_end(ap);
base[0]=base[0];
return Cnil;}
}} | false | false | false | false | false | 0 |
gck_session_get_info (GckSession *self)
{
GckSessionInfo *sessioninfo;
CK_FUNCTION_LIST_PTR funcs;
CK_SESSION_INFO info;
GckModule *module;
CK_RV rv;
g_return_val_if_fail (GCK_IS_SESSION (self), NULL);
module = gck_session_get_module (self);
g_return_val_if_fail (GCK_IS_MODULE (module), NULL);
funcs = gck_module_get_functions (module);
g_return_val_if_fail (funcs, NULL);
memset (&info, 0, sizeof (info));
rv = (funcs->C_GetSessionInfo) (self->pv->handle, &info);
g_object_unref (module);
if (rv != CKR_OK) {
g_warning ("couldn't get session info: %s", gck_message_from_rv (rv));
return NULL;
}
sessioninfo = g_new0 (GckSessionInfo, 1);
sessioninfo->flags = info.flags;
sessioninfo->slot_id = info.slotID;
sessioninfo->state = info.state;
sessioninfo->device_error = info.ulDeviceError;
return sessioninfo;
} | false | false | false | false | false | 0 |
loose_clipboard()
{
if (clip_star.owned || clip_plus.owned)
{
x11_export_final_selection();
if (clip_star.owned)
clip_lose_selection(&clip_star);
if (clip_plus.owned)
clip_lose_selection(&clip_plus);
if (x11_display != NULL)
XFlush(x11_display);
}
} | false | false | false | false | false | 0 |
sigs_eq(jl_value_t *a, jl_value_t *b)
{
if (jl_has_typevars(a) || jl_has_typevars(b)) {
return jl_types_equal_generic(a,b);
}
return jl_types_equal(a, b);
} | false | false | false | false | false | 0 |
_e2_window_toggle_full_screen (gpointer from, E2_ActionRuntime *art)
{
if (app.mainwindow_state & GDK_WINDOW_STATE_FULLSCREEN)
gtk_window_unfullscreen (GTK_WINDOW(app.main_window));
else
gtk_window_fullscreen (GTK_WINDOW(app.main_window));
return TRUE;
} | false | false | false | false | false | 0 |
snd_mixer_detach_hctl(snd_mixer_t *mixer, snd_hctl_t *hctl)
{
struct list_head *pos;
list_for_each(pos, &mixer->slaves) {
snd_mixer_slave_t *s;
s = list_entry(pos, snd_mixer_slave_t, list);
if (hctl == s->hctl) {
list_del(pos);
free(s);
return 0;
}
}
return -ENOENT;
} | false | false | false | false | false | 0 |
init_ctrl_async(struct dim_channel *ch, u8 type, u8 is_tx,
u16 ch_address, u16 hw_buffer_size)
{
if (!g.dim_is_initialized || !ch)
return DIM_ERR_DRIVER_NOT_INITIALIZED;
if (!check_channel_address(ch_address))
return DIM_INIT_ERR_CHANNEL_ADDRESS;
ch->dbr_size = hw_buffer_size;
ch->dbr_addr = alloc_dbr(ch->dbr_size);
if (ch->dbr_addr >= DBR_SIZE)
return DIM_INIT_ERR_OUT_OF_MEMORY;
channel_init(ch, ch_address / 2);
dim2_configure_channel(ch->addr, type, is_tx,
ch->dbr_addr, ch->dbr_size, 0, false);
return DIM_NO_ERROR;
} | false | false | false | false | false | 0 |
ocfs2_set_refcount_tree(struct inode *inode,
struct buffer_head *di_bh,
u64 refcount_loc)
{
int ret;
handle_t *handle = NULL;
struct ocfs2_dinode *di = (struct ocfs2_dinode *)di_bh->b_data;
struct ocfs2_inode_info *oi = OCFS2_I(inode);
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
struct buffer_head *ref_root_bh = NULL;
struct ocfs2_refcount_block *rb;
struct ocfs2_refcount_tree *ref_tree;
BUG_ON(oi->ip_dyn_features & OCFS2_HAS_REFCOUNT_FL);
ret = ocfs2_lock_refcount_tree(osb, refcount_loc, 1,
&ref_tree, &ref_root_bh);
if (ret) {
mlog_errno(ret);
return ret;
}
handle = ocfs2_start_trans(osb, OCFS2_REFCOUNT_TREE_SET_CREDITS);
if (IS_ERR(handle)) {
ret = PTR_ERR(handle);
mlog_errno(ret);
goto out;
}
ret = ocfs2_journal_access_di(handle, INODE_CACHE(inode), di_bh,
OCFS2_JOURNAL_ACCESS_WRITE);
if (ret) {
mlog_errno(ret);
goto out_commit;
}
ret = ocfs2_journal_access_rb(handle, &ref_tree->rf_ci, ref_root_bh,
OCFS2_JOURNAL_ACCESS_WRITE);
if (ret) {
mlog_errno(ret);
goto out_commit;
}
rb = (struct ocfs2_refcount_block *)ref_root_bh->b_data;
le32_add_cpu(&rb->rf_count, 1);
ocfs2_journal_dirty(handle, ref_root_bh);
spin_lock(&oi->ip_lock);
oi->ip_dyn_features |= OCFS2_HAS_REFCOUNT_FL;
di->i_dyn_features = cpu_to_le16(oi->ip_dyn_features);
di->i_refcount_loc = cpu_to_le64(refcount_loc);
spin_unlock(&oi->ip_lock);
ocfs2_journal_dirty(handle, di_bh);
out_commit:
ocfs2_commit_trans(osb, handle);
out:
ocfs2_unlock_refcount_tree(osb, ref_tree, 1);
brelse(ref_root_bh);
return ret;
} | false | false | false | false | false | 0 |
encodeLiteralStatic(unsigned int ch)
{
//trace("c: %d", ch);
if (ch < 144)
{
putBitsR(ch + 0x0030 , 8); // 00110000
}
else if (ch < 256)
{
putBitsR(ch - 144 + 0x0190 , 9); // 110010000
}
else if (ch < 280)
{
putBitsR(ch - 256 + 0x0000 , 7); // 0000000
}
else if (ch < 288)
{
putBitsR(ch - 280 + 0x00c0 , 8); // 11000000
}
else //out of range
{
error("Literal out of range: %d", ch);
}
} | false | false | false | false | false | 0 |
insertRepresentationEntry(
DcmRepresentationEntry * repEntry)
{
DcmRepresentationListIterator insertedEntry;
DcmRepresentationListIterator result;
if (findRepresentationEntry(*repEntry, result).good())
{
// this type of representation entry was already present in the list
if (repEntry != *result)
{
insertedEntry = repList.insert(result, repEntry);
// delete old entry from representation list
delete *result;
repList.erase(result);
}
}
else
insertedEntry = repList.insert(result,repEntry);
return insertedEntry;
} | false | false | false | false | false | 0 |
frame_airmass(struct ccd_frame *fr, double ra, double dec)
{
double v;
double lat, lng, jd;
char dms[64];
if (fits_get_double(fr, P_STR(FN_AIRMASS), &v) > 0) {
return v;
}
if (fits_get_string(fr, P_STR(FN_LATITUDE), dms, 63) <= 0)
return 0.0;
if (dms_to_degrees(dms, &lat))
return 0.0;
if (fits_get_string(fr, P_STR(FN_LONGITUDE), dms, 63) <= 0)
return 0.0;
if (dms_to_degrees(dms, &lng))
return 0.0;
if (fits_get_double(fr, P_STR(FN_MJD), &v) > 0) {
jd = mjd_to_jd(v);
} else if (fits_get_double(fr, P_STR(FN_JDATE), &v) > 0) {
jd = v;
} else {
return 0.0;
}
return calculate_airmass(ra, dec, jd, lat, lng);
} | false | false | false | false | false | 0 |
gtk_source_view_style_updated (GtkWidget *widget)
{
GtkSourceView *view;
/* call default handler first */
GTK_WIDGET_CLASS (gtk_source_view_parent_class)->style_updated (widget);
view = GTK_SOURCE_VIEW (widget);
/* re-set tab stops, but only if we already modified them, i.e.
* do nothing with good old 8-space tabs */
if (view->priv->tabs_set)
{
set_tab_stops_internal (view);
}
/* make sure the margin position is recalculated on next expose */
view->priv->cached_right_margin_pos = -1;
} | false | false | false | false | false | 0 |
f_serverlist(argvars, rettv)
typval_T *argvars UNUSED;
typval_T *rettv;
{
char_u *r = NULL;
#ifdef FEAT_CLIENTSERVER
# ifdef WIN32
r = serverGetVimNames();
# else
make_connection();
if (X_DISPLAY != NULL)
r = serverGetVimNames(X_DISPLAY);
# endif
#endif
rettv->v_type = VAR_STRING;
rettv->vval.v_string = r;
} | false | false | false | false | false | 0 |
set_units (GtkComboBox *combo, GNCDateDelta *gdd)
{
gint active;
active = gtk_combo_box_get_active(GTK_COMBO_BOX(gdd->units_combo));
if ((active < GNC_DATE_DELTA_DAYS) || (active > GNC_DATE_DELTA_YEARS))
active = GNC_DATE_DELTA_DAYS;
gdd->units = active;
g_signal_emit (gdd, date_delta_signals [UNITS_CHANGED], 0);
g_signal_emit (gdd, date_delta_signals [DELTA_CHANGED], 0);
} | false | false | false | false | false | 0 |
TIFFWriteBufferSetup(TIFF* tif, void* bp, tmsize_t size)
{
static const char module[] = "TIFFWriteBufferSetup";
if (tif->tif_rawdata) {
if (tif->tif_flags & TIFF_MYBUFFER) {
_TIFFfree(tif->tif_rawdata);
tif->tif_flags &= ~TIFF_MYBUFFER;
}
tif->tif_rawdata = NULL;
}
if (size == (tmsize_t)(-1)) {
size = (isTiled(tif) ?
tif->tif_tilesize : TIFFStripSize(tif));
/*
* Make raw data buffer at least 8K
*/
if (size < 8*1024)
size = 8*1024;
bp = NULL; /* NB: force malloc */
}
if (bp == NULL) {
bp = _TIFFmalloc(size);
if (bp == NULL) {
TIFFErrorExt(tif->tif_clientdata, module, "No space for output buffer");
return (0);
}
tif->tif_flags |= TIFF_MYBUFFER;
} else
tif->tif_flags &= ~TIFF_MYBUFFER;
tif->tif_rawdata = (uint8*) bp;
tif->tif_rawdatasize = size;
tif->tif_rawcc = 0;
tif->tif_rawcp = tif->tif_rawdata;
tif->tif_flags |= TIFF_BUFFERSETUP;
return (1);
} | false | false | false | false | false | 0 |
ncx_get_short_uchar(const void *xp, uchar *ip)
{
ix_short xx;
get_ix_short(xp, &xx);
*ip = xx;
if(xx > UCHAR_MAX || xx < 0)
return NC_ERANGE;
return ENOERR;
} | false | false | false | false | false | 0 |
ocfs2_inode_unlock(struct inode *inode,
int ex)
{
int level = ex ? DLM_LOCK_EX : DLM_LOCK_PR;
struct ocfs2_lock_res *lockres = &OCFS2_I(inode)->ip_inode_lockres;
struct ocfs2_super *osb = OCFS2_SB(inode->i_sb);
mlog(0, "inode %llu drop %s META lock\n",
(unsigned long long)OCFS2_I(inode)->ip_blkno,
ex ? "EXMODE" : "PRMODE");
if (!ocfs2_is_hard_readonly(OCFS2_SB(inode->i_sb)) &&
!ocfs2_mount_local(osb))
ocfs2_cluster_unlock(OCFS2_SB(inode->i_sb), lockres, level);
} | false | false | false | false | false | 0 |
rl_ding ()
{
if (_rl_echoing_p)
{
switch (_rl_bell_preference)
{
case NO_BELL:
default:
break;
case VISIBLE_BELL:
#ifdef __MSDOS__
ScreenVisualBell ();
break;
#else
if (_rl_visible_bell)
{
tputs (_rl_visible_bell, 1, _rl_output_character_function);
break;
}
/* FALLTHROUGH */
#endif
case AUDIBLE_BELL:
fprintf (stderr, "\007");
fflush (stderr);
break;
}
return (0);
}
return (-1);
} | false | false | false | false | false | 0 |
sec_filter(trans *p, int filtn, int off)
{
int i,j;
int error;
int count,c;
uint8_t *buf, *secbuf;
section *sec;
// fprintf(stderr,"sec_filter\n");
if (filtn < 0 || filtn >= MAXFILT) return;
count = 188 - off;
c = 0;
buf = p->packet+off;
sec = &p->sec[filtn];
secbuf = sec->payload;
if(!filt_is_ready(p,filtn)){
p->is_full &= ~((tflags) (1 << filtn) );
sec->found = 0;
sec->length = 0;
}
if ( !sec->found ){
c = buf[c]+1;
if (c >= count) return;
sec->id = buf[c];
secbuf[0] = buf[c];
c++;
sec->found++;
sec->length = 0;
}
while ( c < count && sec->found < 3){
secbuf[sec->found] = buf[c];
c++;
sec->found++;
}
if (c == count) return;
if (!sec->length && sec->found == 3){
sec->length |= ((secbuf[1] & 0x0F) << 8);
sec->length |= (secbuf[2] & 0xFF);
}
while ( c < count && sec->found < sec->length+3){
secbuf[sec->found] = buf[c];
c++;
sec->found++;
}
if ( sec->length && sec->found == sec->length+3 ){
error=0;
for ( i = 0; i < MASKL; i++){
if (i > 0 ) j=2+i;
else j = 0;
error += (sec->payload[j]&p->mask[MASKL*filtn+i])^
(p->filt[MASKL*filtn+i]&
p->mask[MASKL*filtn+i]);
}
if (!error){
p->is_full |= (tflags) (1 << filtn);
}
if (buf[0]+1 < c ) c=count;
}
if ( c < count ) sec_filter(p, filtn, off);
} | false | false | false | false | false | 0 |
replaceInString(const char *str, const char *before, const char *after)
{
int len;
size_t beforeLen = strlen(before), afterLen = strlen(after);
char *buf, *ret;
const char *ptr;
for (ptr = str, len = 0; (ptr = strstr(ptr, before)); len++)
ptr += beforeLen;
len = strlen(str) + (afterLen - beforeLen) * len;
if (!(buf = ret = Malloc(len + 1)))
return 0;
for (ptr = str; (str = strstr(str, before)); str += beforeLen, ptr = str) {
strCatL(&buf, ptr, str - ptr);
strCatL(&buf, after, afterLen);
}
strcpy(buf, ptr);
return ret;
} | false | true | false | false | false | 1 |
DU_ngetStatusString(Uint16 statusCode)
{
const char *s = NULL;
switch (statusCode) {
case STATUS_Success:
s = "Success";
break;
case STATUS_N_AttributeListError:
s = "Warning: AttributeListError";
break;
case STATUS_N_ClassInstanceConflict:
s = "Failure: ClassInstanceConflict";
break;
case STATUS_N_DuplicateInvocation:
s = "Failure: DuplicateInvocation";
break;
case STATUS_N_InvalidObjectInstance:
s = "Failure: InvalidObjectInstance";
break;
case STATUS_N_MistypedArgument:
s = "Failure: MistypedArgument";
break;
case STATUS_N_NoSuchSOPClass:
s = "Failure: NoSuchSOPClass";
break;
case STATUS_N_NoSuchObjectInstance:
s = "Failure: NoSuchObjectInstance";
break;
case STATUS_N_ProcessingFailure:
s = "Failure: ProcessingFailure";
break;
case STATUS_N_ResourceLimitation:
s = "Failure: ResourceLimitation";
break;
}
if (s)
return s;
switch (statusCode & 0xf000) { /* high nibble significant */
case STATUS_FIND_Failed_UnableToProcess: /* high nibble */
s = "Failed: UnableToProcess";
break;
}
if (s == NULL) {
sprintf(staticBuf, "Unknown Status: 0x%x", (unsigned int)statusCode);
s = staticBuf;
}
return s;
} | false | false | false | false | false | 0 |
CreateVechMatWdata(int n, int ishift, double alpha, const int *ind, const double *vals, int nnz, vechmat **A){
int info;
vechmat* V;
DSDPCALLOC1(&V,vechmat,&info);DSDPCHKERR(info);
V->n=n; V->ishift=ishift, V->ind=ind; V->val=vals;V->nnzeros=nnz;
V->alpha=alpha;
V->owndata=0;
*A=V;
return 0;
} | false | false | false | false | false | 0 |
_mesa_CallList(GLuint list)
{
GLboolean save_compile_flag;
GET_CURRENT_CONTEXT(ctx);
FLUSH_CURRENT(ctx, 0);
if (MESA_VERBOSE & VERBOSE_API)
_mesa_debug(ctx, "glCallList %d\n", list);
if (list == 0) {
_mesa_error(ctx, GL_INVALID_VALUE, "glCallList(list==0)");
return;
}
if (0)
mesa_print_display_list( list );
/* VERY IMPORTANT: Save the CompileFlag status, turn it off,
* execute the display list, and restore the CompileFlag.
*/
save_compile_flag = ctx->CompileFlag;
if (save_compile_flag) {
ctx->CompileFlag = GL_FALSE;
}
execute_list(ctx, list);
ctx->CompileFlag = save_compile_flag;
/* also restore API function pointers to point to "save" versions */
if (save_compile_flag) {
ctx->CurrentDispatch = ctx->Save;
_glapi_set_dispatch(ctx->CurrentDispatch);
}
} | false | false | false | false | false | 0 |
gauche_glib_g_signal_lookup(ScmObj *SCM_FP, int SCM_ARGCNT, void *data_)
{
ScmObj name_scm;
const char * name;
ScmObj type_scm;
ScmClass* type;
ScmObj SCM_SUBRARGS[2];
int SCM_i;
SCM_ENTER_SUBR("g-signal-lookup");
for (SCM_i=0; SCM_i<2; SCM_i++) {
SCM_SUBRARGS[SCM_i] = SCM_ARGREF(SCM_i);
}
name_scm = SCM_SUBRARGS[0];
if (!SCM_STRINGP(name_scm)) Scm_Error("<const-char*> required, but got %S", name_scm);
name = CONST_CHAR_PTR(name_scm);
type_scm = SCM_SUBRARGS[1];
if (!SCM_CLASSP(type_scm)) Scm_Error("class required, but got %S", type_scm);
type = SCM_CLASS(type_scm);
{
GType gtype = Scm_ClassToGtkType(type);
if (gtype == G_TYPE_INVALID) {
Scm_Error("given class doesn't correspond to an GObject class: %S", type);
}
int sig= g_signal_lookup(name, gtype);
#if 0
/* if (sig == 0) ? */
Scm_Warn("g-signal-lookup: %s x %s -> %d", g_type_name(gtype), name, sig);
#endif
SCM_RETURN (Scm_MakeInteger(sig));
}
} | false | false | false | false | false | 0 |
HandleNotification(const CMuleNotiferBase& ntf)
{
if (wxThread::IsMain()) {
#ifdef AMULE_DAEMON
ntf.Notify();
#else
if (theApp->amuledlg) {
ntf.Notify();
}
#endif
} else {
CMuleGUIEvent evt(ntf.Clone());
wxPostEvent(wxTheApp, evt);
}
} | false | false | false | false | false | 0 |
xfs_btree_decrement(
struct xfs_btree_cur *cur,
int level,
int *stat) /* success/failure */
{
struct xfs_btree_block *block;
xfs_buf_t *bp;
int error; /* error return value */
int lev;
union xfs_btree_ptr ptr;
XFS_BTREE_TRACE_CURSOR(cur, XBT_ENTRY);
XFS_BTREE_TRACE_ARGI(cur, level);
ASSERT(level < cur->bc_nlevels);
/* Read-ahead to the left at this level. */
xfs_btree_readahead(cur, level, XFS_BTCUR_LEFTRA);
/* We're done if we remain in the block after the decrement. */
if (--cur->bc_ptrs[level] > 0)
goto out1;
/* Get a pointer to the btree block. */
block = xfs_btree_get_block(cur, level, &bp);
#ifdef DEBUG
error = xfs_btree_check_block(cur, block, level, bp);
if (error)
goto error0;
#endif
/* Fail if we just went off the left edge of the tree. */
xfs_btree_get_sibling(cur, block, &ptr, XFS_BB_LEFTSIB);
if (xfs_btree_ptr_is_null(cur, &ptr))
goto out0;
XFS_BTREE_STATS_INC(cur, decrement);
/*
* March up the tree decrementing pointers.
* Stop when we don't go off the left edge of a block.
*/
for (lev = level + 1; lev < cur->bc_nlevels; lev++) {
if (--cur->bc_ptrs[lev] > 0)
break;
/* Read-ahead the left block for the next loop. */
xfs_btree_readahead(cur, lev, XFS_BTCUR_LEFTRA);
}
/*
* If we went off the root then we are seriously confused.
* or the root of the tree is in an inode.
*/
if (lev == cur->bc_nlevels) {
if (cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)
goto out0;
ASSERT(0);
error = -EFSCORRUPTED;
goto error0;
}
ASSERT(lev < cur->bc_nlevels);
/*
* Now walk back down the tree, fixing up the cursor's buffer
* pointers and key numbers.
*/
for (block = xfs_btree_get_block(cur, lev, &bp); lev > level; ) {
union xfs_btree_ptr *ptrp;
ptrp = xfs_btree_ptr_addr(cur, cur->bc_ptrs[lev], block);
--lev;
error = xfs_btree_read_buf_block(cur, ptrp, 0, &block, &bp);
if (error)
goto error0;
xfs_btree_setbuf(cur, lev, bp);
cur->bc_ptrs[lev] = xfs_btree_get_numrecs(block);
}
out1:
XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
*stat = 1;
return 0;
out0:
XFS_BTREE_TRACE_CURSOR(cur, XBT_EXIT);
*stat = 0;
return 0;
error0:
XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
return error;
} | false | false | false | false | false | 0 |
transmit_timeout(void *arg)
{
NCR_Instance inst = (NCR_Instance) arg;
double timeout_delay;
int do_auth;
inst->timer_running = 0;
switch (inst->opmode) {
case MD_BURST_WAS_ONLINE:
/* With online burst switch to online before last packet */
if (inst->burst_total_samples_to_go <= 1)
inst->opmode = MD_ONLINE;
case MD_BURST_WAS_OFFLINE:
if (inst->burst_total_samples_to_go <= 0)
take_offline(inst);
break;
default:
break;
}
if (inst->opmode == MD_OFFLINE) {
return;
}
#ifdef TRACEON
LOG(LOGS_INFO, LOGF_NtpCore, "Transmit timeout for [%s:%d]",
UTI_IPToString(&inst->remote_addr.ip_addr), inst->remote_addr.port);
#endif
/* Check whether we need to 'warm up' the link to the other end by
sending an echo exchange to ensure both ends' ARP caches are
primed. On loaded systems this might also help ensure that bits
of the program are paged in properly before we start. */
if ((inst->presend_minpoll > 0) &&
(inst->presend_minpoll <= inst->local_poll) &&
!inst->presend_done) {
/* Send */
NIO_SendEcho(&inst->remote_addr);
inst->presend_done = 1;
/* Requeue timeout */
inst->timer_running = 1;
inst->timeout_id = SCH_AddTimeoutInClass(WARM_UP_DELAY, SAMPLING_SEPARATION,
SAMPLING_RANDOMNESS,
SCH_NtpSamplingClass,
transmit_timeout, (void *)inst);
return;
}
inst->presend_done = 0; /* Reset for next time */
++inst->tx_count;
/* If the source loses connectivity, back off the sampling rate to reduce
wasted sampling. If it's the source to which we are currently locked,
back off slower. */
if (inst->tx_count >= 2) {
/* Implies we have missed at least one transmission */
adjust_poll(inst, SRC_IsSyncPeer(inst->source) ? 0.1 : 0.25);
SRC_UpdateReachability(inst->source, 0);
if (inst->auto_offline && inst->tx_count >= 3) {
NCR_TakeSourceOffline(inst);
}
}
if (inst->do_auth && KEY_KeyKnown(inst->auth_key_id)) {
do_auth = 1;
} else {
do_auth = 0;
}
transmit_packet(inst->mode, inst->local_poll,
NTP_VERSION,
do_auth, inst->auth_key_id,
&inst->remote_orig,
&inst->local_rx, &inst->local_tx, &inst->local_ntp_tx,
&inst->remote_addr);
switch (inst->opmode) {
case MD_BURST_WAS_ONLINE:
case MD_BURST_WAS_OFFLINE:
--inst->burst_total_samples_to_go;
break;
default:
break;
}
/* Restart timer for this message */
timeout_delay = get_transmit_delay(inst, 1, 0.0);
inst->timer_running = 1;
inst->timeout_id = SCH_AddTimeoutInClass(timeout_delay, SAMPLING_SEPARATION,
SAMPLING_RANDOMNESS,
SCH_NtpSamplingClass,
transmit_timeout, (void *)inst);
} | false | false | false | false | false | 0 |
get_string_width(Display *display, char *s, Font font)
/* width of s in font */
{
XFontStruct *fstruct = NULL;
int rv = 0;
fstruct = XQueryFont(display, font);
if(!fstruct) {
fprintf(stderr, "string_width: cannot find font %d.\n", (int)font);
goto ERROR;
}
rv = XTextWidth(fstruct, s, strlen(s));
XFreeFontInfo(NULL, fstruct, 1);
DONE:
return(rv);
ERROR:
goto DONE;
} | false | false | false | false | false | 0 |
updateGC(GC gc_)
{
unsigned long mask;
MSClipArea *clip;
MSDashLine *dash;
mask=GCLineWidth|GCLineStyle|GCForeground|GCBackground|GCFont|
GCCapStyle|GCJoinStyle|GCFillStyle|GCFillRule|GCDashOffset|GCArcMode;
XGetGCValues(owner()->display(),gc_,mask,&gcValues());
if ((dash=findDashGC(gc_))!=0)
{
if (dash!=activeDash()) activeDash(dash);
else updateDash(MSFalse);
}
if ((clip=findClipGC(gc_))!=0)
{
if (clip!=activeClip())
{
if (activeClip()!=0) unsetClip();
setClip(clip);
lineWidth(-1);
}
}
else if (activeClip()!=0) unsetClip();
} | false | false | false | false | false | 0 |
applyHidingScheme(VisuData *data)
{
gboolean redraw;
g_signal_emit_by_name(G_OBJECT(data), "AskForShowHide", &redraw, NULL);
if (redraw)
g_signal_emit_by_name(G_OBJECT(data), "VisibilityChanged", NULL);
return redraw;
} | false | false | false | false | false | 0 |
UnpicklerMemoProxy_New(UnpicklerObject *unpickler)
{
UnpicklerMemoProxyObject *self;
self = PyObject_GC_New(UnpicklerMemoProxyObject,
&UnpicklerMemoProxyType);
if (self == NULL)
return NULL;
Py_INCREF(unpickler);
self->unpickler = unpickler;
PyObject_GC_Track(self);
return (PyObject *)self;
} | false | false | false | false | false | 0 |
gst_ossmixer_open (GstOssMixer * mixer)
{
#ifdef SOUND_MIXER_INFO
struct mixer_info minfo;
#endif
g_return_val_if_fail (mixer->mixer_fd == -1, FALSE);
mixer->mixer_fd = open (mixer->device, O_RDWR);
if (mixer->mixer_fd == -1)
goto open_failed;
/* get masks */
if (ioctl (mixer->mixer_fd, SOUND_MIXER_READ_RECMASK, &mixer->recmask) < 0
|| ioctl (mixer->mixer_fd, SOUND_MIXER_READ_RECSRC, &mixer->recdevs) < 0
|| ioctl (mixer->mixer_fd, SOUND_MIXER_READ_STEREODEVS,
&mixer->stereomask) < 0
|| ioctl (mixer->mixer_fd, SOUND_MIXER_READ_DEVMASK, &mixer->devmask) < 0
|| ioctl (mixer->mixer_fd, SOUND_MIXER_READ_CAPS, &mixer->mixcaps) < 0)
goto masks_failed;
/* get name, not fatal */
g_free (mixer->cardname);
#ifdef SOUND_MIXER_INFO
if (ioctl (mixer->mixer_fd, SOUND_MIXER_INFO, &minfo) == 0) {
mixer->cardname = g_strdup (minfo.name);
GST_INFO ("Card name = %s", GST_STR_NULL (mixer->cardname));
} else
#endif
{
mixer->cardname = g_strdup ("Unknown");
GST_INFO ("Unknown card name");
}
GST_INFO ("Opened mixer for device %s", mixer->device);
return TRUE;
/* ERRORS */
open_failed:
{
/* this is valid. OSS devices don't need to expose a mixer */
GST_DEBUG ("Failed to open mixer device %s, mixing disabled: %s",
mixer->device, strerror (errno));
return FALSE;
}
masks_failed:
{
GST_DEBUG ("Failed to get device masks");
close (mixer->mixer_fd);
mixer->mixer_fd = -1;
return FALSE;
}
} | false | false | false | false | true | 1 |
snd_ca0106_free(struct snd_ca0106 *chip)
{
if (chip->res_port != NULL) {
/* avoid access to already used hardware */
ca0106_stop_chip(chip);
}
if (chip->irq >= 0)
free_irq(chip->irq, chip);
// release the data
#if 1
if (chip->buffer.area)
snd_dma_free_pages(&chip->buffer);
#endif
// release the i/o port
release_and_free_resource(chip->res_port);
pci_disable_device(chip->pci);
kfree(chip);
return 0;
} | false | false | false | false | false | 0 |
add_stream (GstPlayBaseGroup * group, GstStreamInfo * info)
{
GValue v = { 0, };
GST_DEBUG ("add stream to group %p", group);
/* keep ref to the group */
g_object_set_data (G_OBJECT (info), "group", group);
g_value_init (&v, G_TYPE_OBJECT);
g_value_set_object (&v, info);
g_value_array_append (group->streaminfo_value_array, &v);
g_value_unset (&v);
group->streaminfo = g_list_append (group->streaminfo, info);
if (info->type > 0 && info->type <= NUM_TYPES) {
group->type[info->type - 1].npads++;
}
} | false | false | false | false | false | 0 |
validate_numnodes(node *n, int num, const char *const name)
{
if (NCH(n) != num) {
PyErr_Format(parser_error,
"Illegal number of children for %s node.", name);
return 0;
}
return 1;
} | false | false | false | false | false | 0 |
e2_fs_walk_link (gchar **local_path E2_ERR_ARG())
{
struct stat sb;
#ifdef E2_VFSTMP
FIXME get proper spacedata
#endif
#ifdef E2_VFS
VPATH data = { *local_path, NULL };
if (!e2_fs_lstat (&data, &sb E2_ERR_SAMEARG()) && S_ISLNK (sb.st_mode))
#else
if (!e2_fs_lstat (*local_path, &sb E2_ERR_SAMEARG()) && S_ISLNK (sb.st_mode))
#endif
{
#ifdef E2_VFS
if (e2_fs_item_is_mounted ((&data)))
{
#endif
#ifdef __USE_GNU
gchar *resolved_path = canonicalize_file_name (*local_path);
if (resolved_path != NULL)
{
g_free (*local_path);
*local_path = resolved_path;
return TRUE;
}
#else
gchar resolved_path [PATH_MAX+1];
if (realpath (*local_path, resolved_path) != NULL)
{
*(resolved_path + PATH_MAX) = '\0'; //ensure an end
g_free (*local_path);
*local_path = g_strdup (resolved_path);
return TRUE;
}
#endif
#ifdef E2_VFS
}
else //item is virtual
{
/* if (E2_ERR_NAME != NULL && *E2_ERR_NAME != NULL)
{
g_error_free (*E2_ERR_NAME); //just in case?
*E2_ERR_NAME = NULL;
} */
# ifdef E2_VFSTMP
//FIXME vfs if relevant, get information about virtual item, how ??
# endif
return FALSE;
}
#endif
}
return FALSE;
} | false | false | false | false | false | 0 |
ap_proxy_get_worker(apr_pool_t *p,
proxy_balancer *balancer,
proxy_server_conf *conf,
const char *url)
{
proxy_worker *worker;
proxy_worker *max_worker = NULL;
int max_match = 0;
int url_length;
int min_match;
int worker_name_length;
const char *c;
char *url_copy;
int i;
c = ap_strchr_c(url, ':');
if (c == NULL || c[1] != '/' || c[2] != '/' || c[3] == '\0') {
return NULL;
}
url_length = strlen(url);
url_copy = apr_pstrmemdup(p, url, url_length);
/*
* We need to find the start of the path and
* therefore we know the length of the scheme://hostname/
* part to we can force-lowercase everything up to
* the start of the path.
*/
c = ap_strchr_c(c+3, '/');
if (c) {
char *pathstart;
pathstart = url_copy + (c - url);
*pathstart = '\0';
ap_str_tolower(url_copy);
min_match = strlen(url_copy);
*pathstart = '/';
}
else {
ap_str_tolower(url_copy);
min_match = strlen(url_copy);
}
/*
* Do a "longest match" on the worker name to find the worker that
* fits best to the URL, but keep in mind that we must have at least
* a minimum matching of length min_match such that
* scheme://hostname[:port] matches between worker and url.
*/
if (balancer) {
proxy_worker **workers = (proxy_worker **)balancer->workers->elts;
for (i = 0; i < balancer->workers->nelts; i++, workers++) {
worker = *workers;
if ( ((worker_name_length = strlen(worker->s->name)) <= url_length)
&& (worker_name_length >= min_match)
&& (worker_name_length > max_match)
&& (strncmp(url_copy, worker->s->name, worker_name_length) == 0) ) {
max_worker = worker;
max_match = worker_name_length;
}
}
} else {
worker = (proxy_worker *)conf->workers->elts;
for (i = 0; i < conf->workers->nelts; i++, worker++) {
if ( ((worker_name_length = strlen(worker->s->name)) <= url_length)
&& (worker_name_length >= min_match)
&& (worker_name_length > max_match)
&& (strncmp(url_copy, worker->s->name, worker_name_length) == 0) ) {
max_worker = worker;
max_match = worker_name_length;
}
}
}
return max_worker;
} | false | false | false | false | false | 0 |
list_members_replaced (const int *list, const DATASET *dset,
int ref_id)
{
const char *errmsg = N_("Can't do this: some vars in original "
"model have been redefined");
const char *label;
char rword[16];
int j, mc, repl;
if (ref_id == 0) {
mc = get_model_count();
} else {
mc = ref_id;
}
for (j=1; j<=list[0]; j++) {
if (list[j] == LISTSEP) {
continue;
}
if (list[j] >= dset->v) {
gretl_errmsg_set(_(errmsg));
return E_DATA;
}
label = series_get_label(dset, list[j]);
*rword = '\0';
sscanf(label, "%15s", rword);
if (!strcmp(rword, _("Replaced"))) {
repl = 0;
sscanf(label, "%*s %*s %*s %d", &repl);
if (repl >= mc) {
gretl_errmsg_set(_(errmsg));
return E_DATA;
}
}
}
return 0;
} | true | true | false | false | false | 1 |
unit_heal(struct block_list *bl,int hp,int sp)
{
nullpo_retr(0, bl);
if(bl->type == BL_PC)
pc_heal((struct map_session_data*)bl,hp,sp);
else if(bl->type == BL_MOB)
mob_heal((struct mob_data*)bl,hp);
else if(bl->type == BL_HOM)
homun_heal((struct homun_data*)bl,hp,sp);
else if(bl->type == BL_MERC)
merc_heal((struct merc_data*)bl,hp,sp);
else if(bl->type == BL_ELEM)
elem_heal((struct elem_data*)bl,hp,sp);
return 0;
} | false | false | false | false | false | 0 |
soxr_process(soxr_t p,
void const * in , size_t ilen0, size_t * idone0,
void * out, size_t olen , size_t * odone0)
{
size_t ilen, idone, odone = 0;
unsigned u;
bool flush_requested = false;
if (!p) return "null pointer";
if (!in)
flush_requested = true, ilen = ilen0 = 0;
else {
if ((ptrdiff_t)ilen0 < 0)
flush_requested = true, ilen0 = ~ilen0;
if (idone0 && (1 || flush_requested))
ilen = soxr_i_for_o(p, olen, ilen0);
else
ilen = ilen0/*, olen = soxr_o_for_i(p, ilen, olen)*/;
}
p->flushing |= ilen == ilen0 && flush_requested;
if (!out && !in)
idone = ilen;
else if (p->io_spec.itype & p->io_spec.otype & SOXR_SPLIT) { /* Both i & o */
#if defined _OPENMP
int i;
if (!p->runtime_spec.num_threads && p->num_channels > 1)
#pragma omp parallel for
for (i = 0; i < (int)p->num_channels; ++i) {
size_t done;
if (in)
soxr_input_1ch(p, (unsigned)i, ((soxr_cbufs_t)in)[i], ilen);
done = soxr_output_1ch(p, (unsigned)i, ((soxr_bufs_t)out)[i], olen, true);
if (!i)
odone = done;
} else
#endif
for (u = 0; u < p->num_channels; ++u) {
if (in)
soxr_input_1ch(p, u, ((soxr_cbufs_t)in)[u], ilen);
odone = soxr_output_1ch(p, u, ((soxr_bufs_t)out)[u], olen, true);
}
idone = ilen;
}
else {
idone = ilen? soxr_input (p, in , ilen) : 0;
odone = soxr_output(p, out, olen);
}
if (idone0) *idone0 = idone;
if (odone0) *odone0 = odone;
return p->error;
} | false | false | false | false | false | 0 |
sfip_convert_ip_text_to_binary( const int family, char *ip, void *dst)
{
char *my_ip;
my_ip = ip;
if( my_ip == NULL )
return( SFIP_FAILURE );
/* Across platforms, inet_pton() is inconsistent about leading 0's in
AF_INET (ie IPv4 addresses. */
if( family == AF_INET ) {
char chr;
bool new_octet;
new_octet = true;
while( (chr = *my_ip++) != '\0') {
/* If we are at the first char of a new octet, look for a leading zero
followed by another digit */
if( new_octet && (chr == '0') && isdigit(*my_ip))
return( SFIP_INET_PARSE_ERR );
/* when we see an octet separator, set the flag to start looking for a
leading zero. */
new_octet = (chr == '.');
}
}
if( inet_pton(family, ip, dst) < 1 )
return( SFIP_INET_PARSE_ERR );
return( SFIP_SUCCESS ); /* Otherwise, ip is OK */
} | false | false | false | false | false | 0 |
SITEfind(Name, CanCreate)
char *Name;
BOOL CanCreate;
{
register char *p;
register int i;
unsigned int j;
register SITE *sp;
SITEHASH *shp;
char c;
char buff[BUFSIZ];
/* Look for site in the hash table. */
/* SUPPRESS 6 *//* Over/underflow from plus expression */
SITE_HASH(Name, p, j);
shp = SITE_BUCKET(j);
for (c = *Name, sp = shp->Sites, i = shp->Used; --i >= 0; sp++)
if (c == sp->Name[0] && caseEQ(Name, sp->Name))
return sp;
if (!CanCreate)
return NULL;
/* Adding a new site -- grow hash bucket if we need to. */
if (shp->Used == shp->Size - 1) {
shp->Size *= 2;
RENEW(shp->Sites, SITE, shp->Size);
}
sp = &shp->Sites[shp->Used++];
/* Fill in the structure for the new site. */
sp->Name = COPY(Name);
(void)sprintf(buff, (STRING)Format, Map ? MAPname(Name) : sp->Name);
sp->Filename = COPY(buff);
if (BufferMode == 'u')
sp->Buffer = NULL;
else if (BufferMode == 'b')
sp->Buffer = NEW(char, BUFSIZ);
SITEopen(sp);
return sp;
} | false | false | false | false | false | 0 |
throw_gold(struct obj *obj)
{
int range, odx, ody;
long zorks = obj->quan;
register struct monst *mon;
if(!u.dx && !u.dy && !u.dz) {
u.ugold += obj->quan;
flags.botl = 1;
dealloc_obj(obj);
You("cannot throw gold at yourself.");
return(0);
}
if(u.uswallow) {
pline(is_animal(u.ustuck->data) ?
"%s in the %s's entrails." : "%s into %s.",
"The gold disappears", mon_nam(u.ustuck));
u.ustuck->mgold += zorks;
dealloc_obj(obj);
return(1);
}
if(u.dz) {
if (u.dz < 0 && !Is_airlevel(&u.uz) &&
!Underwater && !Is_waterlevel(&u.uz)) {
pline_The("gold hits the %s, then falls back on top of your %s.",
ceiling(u.ux,u.uy), body_part(HEAD));
/* some self damage? */
if(uarmh) pline("Fortunately, you are wearing a helmet!");
}
bhitpos.x = u.ux;
bhitpos.y = u.uy;
} else {
/* consistent with range for normal objects */
range = (int)((ACURRSTR)/2 - obj->owt/40);
/* see if the gold has a place to move into */
odx = u.ux + u.dx;
ody = u.uy + u.dy;
if(!ZAP_POS(levl[odx][ody].typ) || closed_door(odx, ody)) {
bhitpos.x = u.ux;
bhitpos.y = u.uy;
} else {
mon = bhit(u.dx, u.dy, range, THROWN_WEAPON,
(int (*)(struct monst *,struct obj *))0,
(int (*)(struct obj *,struct obj *))0,
obj);
if(mon) {
if (ghitm(mon, obj)) /* was it caught? */
return 1;
} else {
if(ship_object(obj, bhitpos.x, bhitpos.y, false))
return 1;
}
}
}
if(flooreffects(obj,bhitpos.x,bhitpos.y,"fall")) return(1);
if(u.dz > 0)
pline_The("gold hits the %s.", surface(bhitpos.x,bhitpos.y));
place_object(obj,bhitpos.x,bhitpos.y);
if(*u.ushops) sellobj(obj, bhitpos.x, bhitpos.y);
stackobj(obj);
newsym(bhitpos.x,bhitpos.y);
return(1);
} | false | false | false | false | false | 0 |
bcm5600_dump_ports(struct nm_16esw_data *d)
{
struct bcm5600_table *table;
struct bcm5600_port *port;
m_uint32_t *entry;
u_int vlan,tgid;
int i;
if (!(table = bcm5600_table_find(d,BCM5600_ADDR_PTABLE0)))
return(-1);
printf("%s: physical ports:\n",d->name);
for(i=0;i<d->nr_port;i++) {
if (!(entry = bcm5600_table_get_entry(d,table,i)))
break;
port = &d->ports[i];
vlan = entry[0] & BCM5600_PTABLE_VLAN_TAG_MASK;
printf(" %-10s: VLAN %u",port->name,vlan);
if (entry[0] & BCM5600_PTABLE_TRUNK_FLAG) {
tgid = entry[0] & BCM5600_PTABLE_TGID_MASK;
tgid >>= BCM5600_PTABLE_TGID_SHIFT;
printf(", Trunk Group %u ",tgid);
}
printf("\n");
}
printf("\n");
return(0);
} | false | false | false | false | false | 0 |
CL_BaseMove (usercmd_t *cmd)
{
CL_AdjustAngles ();
memset (cmd, 0, sizeof(*cmd));
VectorCopy (cl.viewangles, cmd->angles);
if (in_strafe.state & 1)
{
cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_right);
cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_left);
}
cmd->sidemove += cl_sidespeed->value * CL_KeyState (&in_moveright);
cmd->sidemove -= cl_sidespeed->value * CL_KeyState (&in_moveleft);
cmd->upmove += cl_upspeed->value * CL_KeyState (&in_up);
cmd->upmove -= cl_upspeed->value * CL_KeyState (&in_down);
if (! (in_klook.state & 1) )
{
cmd->forwardmove += cl_forwardspeed->value * CL_KeyState (&in_forward);
cmd->forwardmove -= cl_forwardspeed->value * CL_KeyState (&in_back);
}
//
// adjust for speed key / running
//
if (!cl.tactical && ( (in_speed.state & 1) ^ cl_run->integer ))
{
cmd->forwardmove *= 2;
cmd->sidemove *= 2;
cmd->upmove *= 2;
}
} | false | false | false | false | false | 0 |
command_expand(char *cmd)
{
GSList *tmp;
const char *match;
int len, multiple;
g_return_val_if_fail(cmd != NULL, NULL);
multiple = FALSE;
match = NULL;
len = strlen(cmd);
for (tmp = commands; tmp != NULL; tmp = tmp->next) {
COMMAND_REC *rec = tmp->data;
if (g_strncasecmp(rec->cmd, cmd, len) == 0 &&
strchr(rec->cmd+len, ' ') == NULL) {
if (rec->cmd[len] == '\0') {
/* full match */
return rec->cmd;
}
if (match != NULL) {
/* multiple matches, we still need to check
if there's some command left that is a
full match.. */
multiple = TRUE;
}
/* check that this is the only match */
match = rec->cmd;
}
}
if (multiple) {
signal_emit("error command", 2,
GINT_TO_POINTER(CMDERR_AMBIGUOUS), cmd);
return NULL;
}
return match != NULL ? match : cmd;
} | false | false | false | false | false | 0 |
ovclosesearch(void *handle, bool freeblock) {
OVSEARCH *search = (OVSEARCH *)handle;
GROUPDATABLOCK *gdb;
int i;
#ifdef OV_DEBUG
GROUPENTRY *ge;
GROUPLOC gloc;
#endif /* OV_DEBUG */
for (i = 0 ; i < GROUPDATAHASHSIZE ; i++) {
for (gdb = groupdatablock[i] ; gdb != NULL ; gdb = gdb->next) {
if (gdb->mmapped)
munmap(gdb->addr, gdb->len);
}
}
if (search->gdb.mmapped)
munmap(search->gdb.addr, search->gdb.len);
if (freeblock) {
#ifdef OV_DEBUG
gloc = GROUPfind(search->group, false);
if (!GROUPLOCempty(gloc)) {
ge = &GROUPentries[gloc.recno];
freegroupblock(ge);
}
#else
freegroupblock();
#endif /* OV_DEBUG */
}
ovgroupunmap();
if (Cache) {
Cachesearch = search;
} else {
free(search->group);
free(search);
}
return;
} | false | false | false | false | false | 0 |
drawAttenction()
{
setMarkOpacity(1.0);
#if 0
ANIMATE_PARAM(this, "backColor", 1000, QColor(255, 20, 20));
ANIMATE_PARAM(this, "textColor", 1000, QColor(255, 255, 255));
#else
ANIMATE_PARAM(this, "backColor", 1000, QApplication::palette().color(QPalette::Highlight));
ANIMATE_PARAM(this, "textColor", 1000, QApplication::palette().color(QPalette::HighlightedText));
#endif
} | false | false | false | false | false | 0 |
start_async_command(const char *descr, char *cmd)
{
int pid;
char err_str[512];
char *cwd;
struct passwd *pw=NULL;
struct passwd pw_struct;
char *buffer;
int size;
size = get_pw_buffer_size();
buffer = sge_malloc(size);
pw = sge_getpwnam_r(get_conf_val("job_owner"), &pw_struct, buffer, size);
if (!pw) {
shepherd_error(1, "can't get password entry for user \"%s\"",
get_conf_val("job_owner"));
}
/* the getpwnam is only a verification - the result is not used - free it */
FREE(buffer);
/* Create "error" and "exit_status" files here */
shepherd_error_init();
if ((pid = fork()) == -1) {
shepherd_trace("can't fork for starting %s command", descr);
} else if (pid == 0) {
int use_qsub_gid;
gid_t gid;
char *tmp_str;
shepherd_trace("starting %s command: %s", descr, cmd);
pid = getpid();
setpgid(pid, pid);
setrlimits(0);
sge_set_environment(true);
umask(022);
tmp_str = search_conf_val("qsub_gid");
if (tmp_str && strcmp(tmp_str, "no")) {
use_qsub_gid = 1;
gid = atol(tmp_str);
} else {
use_qsub_gid = 0;
gid = 0;
}
if (sge_set_uid_gid_addgrp(get_conf_val("job_owner"), NULL, 0, 0, 0,
err_str, use_qsub_gid, gid) > 0) {
shepherd_trace(err_str);
exit(1);
}
sge_close_all_fds(NULL, 0);
/* we have to provide the async command with valid io file handles
* else it might fail
*/
if((open("/dev/null", O_RDONLY, 0) != 0) ||
(open("/dev/null", O_WRONLY, 0) != 1) ||
(open("/dev/null", O_WRONLY, 0) != 2)) {
shepherd_trace("error opening std* file descriptors");
exit(1);
}
foreground = 0;
cwd = get_conf_val("cwd");
if (sge_chdir(cwd)) {
shepherd_trace("%s: can't chdir to %s", descr, cwd);
}
sge_set_def_sig_mask(NULL, NULL);
start_command(descr, get_conf_val("shell_path"),
cmd, cmd, "start_as_command", 0, 0, 0, 0, "", 0);
return 0;
}
return pid;
} | true | true | false | false | true | 1 |
acct_collect(long exitcode, int group_dead)
{
struct pacct_struct *pacct = ¤t->signal->pacct;
cputime_t utime, stime;
unsigned long vsize = 0;
if (group_dead && current->mm) {
struct vm_area_struct *vma;
down_read(¤t->mm->mmap_sem);
vma = current->mm->mmap;
while (vma) {
vsize += vma->vm_end - vma->vm_start;
vma = vma->vm_next;
}
up_read(¤t->mm->mmap_sem);
}
spin_lock_irq(¤t->sighand->siglock);
if (group_dead)
pacct->ac_mem = vsize / 1024;
if (thread_group_leader(current)) {
pacct->ac_exitcode = exitcode;
if (current->flags & PF_FORKNOEXEC)
pacct->ac_flag |= AFORK;
}
if (current->flags & PF_SUPERPRIV)
pacct->ac_flag |= ASU;
if (current->flags & PF_DUMPCORE)
pacct->ac_flag |= ACORE;
if (current->flags & PF_SIGNALED)
pacct->ac_flag |= AXSIG;
task_cputime(current, &utime, &stime);
pacct->ac_utime += utime;
pacct->ac_stime += stime;
pacct->ac_minflt += current->min_flt;
pacct->ac_majflt += current->maj_flt;
spin_unlock_irq(¤t->sighand->siglock);
} | false | false | false | false | false | 0 |
cx_debug_init(void)
{
const cxchar *value;
cx_debug_initialized = TRUE;
value = getenv("CX_DEBUG");
if (value != NULL) {
static const cx_debug_key keys[] = {
{"fatal_warnings", CX_DEBUG_FATAL_WARNINGS},
{"fatal_criticals", CX_DEBUG_FATAL_CRITICALS}
};
cx_debug_flags = cx_debug_parse_string(value, keys,
CX_N_ELEMENTS(keys));
}
if (cx_debug_flags & CX_DEBUG_FATAL_WARNINGS) {
cx_log_level_flags fatal_mask;
fatal_mask = cx_log_set_always_fatal(CX_LOG_FATAL_MASK);
fatal_mask |= CX_LOG_LEVEL_WARNING | CX_LOG_LEVEL_CRITICAL;
cx_log_set_always_fatal(fatal_mask);
}
if (cx_debug_flags & CX_DEBUG_FATAL_CRITICALS) {
cx_log_level_flags fatal_mask;
fatal_mask = cx_log_set_always_fatal(CX_LOG_FATAL_MASK);
fatal_mask |= CX_LOG_LEVEL_CRITICAL;
cx_log_set_always_fatal(fatal_mask);
}
return;
} | false | true | false | false | true | 1 |
pre_svm_run(struct vcpu_svm *svm)
{
int cpu = raw_smp_processor_id();
struct svm_cpu_data *sd = per_cpu(svm_data, cpu);
/* FIXME: handle wraparound of asid_generation */
if (svm->asid_generation != sd->asid_generation)
new_asid(svm, sd);
} | false | false | false | false | false | 0 |
_ipmipower_setup (void)
{
int i;
struct rlimit rlim;
/* Make best effort to increase file descriptor limit, if it fails
* for any reason, don't worry about it, its no big deal.
*/
if (getrlimit (RLIMIT_NOFILE, &rlim) == 0)
{
rlim.rlim_cur = rlim.rlim_max;
setrlimit (RLIMIT_NOFILE,&rlim);
}
if (ipmi_rmcpplus_init () < 0)
{
if (errno == EPERM)
IPMIPOWER_ERROR (("ipmi_rmcpplus_init: incompatible crypto library"));
else
IPMIPOWER_ERROR (("ipmi_rmcpplus_init: %s", strerror (errno)));
exit (1);
}
/* Create TTY bufs */
if (!(ttyin = cbuf_create (IPMIPOWER_MIN_TTY_BUF, IPMIPOWER_MAX_TTY_BUF)))
{
IPMIPOWER_ERROR (("cbuf_create: %s", strerror (errno)));
exit (1);
}
cbuf_opt_set (ttyin, CBUF_OPT_OVERWRITE, CBUF_WRAP_MANY);
if (!(ttyout = cbuf_create (IPMIPOWER_MIN_TTY_BUF, IPMIPOWER_MAX_TTY_BUF)))
{
IPMIPOWER_ERROR (("cbuf_create: %s", strerror (errno)));
exit (1);
}
cbuf_opt_set (ttyout, CBUF_OPT_OVERWRITE, CBUF_WRAP_MANY);
for (i = 0; i < MSG_TYPE_NUM_ENTRIES; i++)
{
if (!(output_hostrange[i] = hostlist_create (NULL)))
{
IPMIPOWER_ERROR (("hostlist_create: %s", strerror (errno)));
exit (1);
}
}
} | false | false | false | false | false | 0 |
GTextInfoArrayCount(GTextInfo **ti) {
int i;
for ( i=0; ti[i]->text || ti[i]->image || ti[i]->line; ++i );
return( i );
} | false | false | false | false | false | 0 |
file_util_write_metadata_full(FileData *source_fd, GList *flist, GtkWidget *parent, UtilityPhase phase, FileUtilDoneFunc done_func, gpointer done_data)
{
UtilityData *ud;
if (source_fd)
flist = g_list_append(flist, file_data_ref(source_fd));
if (!flist) return;
if (!file_data_add_ci_write_metadata_list(flist))
{
file_util_warn_op_in_progress(_("Can't write metadata"));
filelist_free(flist);
return;
}
ud = file_util_data_new(UTILITY_TYPE_WRITE_METADATA);
ud->phase = phase;
ud->with_sidecars = FALSE; /* operate on individual files, not groups */
ud->dir_fd = NULL;
ud->flist = flist;
ud->content_list = NULL;
ud->parent = parent;
ud->done_func = done_func;
ud->done_data = done_data;
ud->details_func = file_util_write_metadata_details_dialog;
ud->finalize_func = metadata_write_queue_remove;
ud->discard_func = metadata_write_queue_remove;
ud->messages.title = _("Write metadata");
ud->messages.question = _("Write metadata?");
ud->messages.desc_flist = _("This will write the changed metadata into the following files");
ud->messages.desc_source_fd = "";
ud->messages.fail = _("Metadata writting failed");
file_util_dialog_run(ud);
} | false | false | false | false | false | 0 |
canSetRole(const XMPP::MUCItem& i1, const XMPP::MUCItem& i2, XMPP::MUCItem::Role r)
{
if (i2.role() == r)
return true;
if (r == MUCItem::Visitor) {
return (i2.role() == MUCItem::Moderator ? canRevokeModerator(i1,i2) : canRevokeVoice(i1,i2));
}
else if (r == MUCItem::Participant) {
return (i2.role() < r ? canGrantVoice(i1,i2) : canRevokeModerator(i1,i2));
}
else if (r == MUCItem::Moderator) {
return canGrantModerator(i1,i2);
}
return false;
} | 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.