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 |
|---|---|---|---|---|---|---|
make_filename(PyObject *prefix, PyObject *name)
{
PyObject *pathobj;
Py_UCS4 *p, *buf;
Py_ssize_t len;
len = PyUnicode_GET_LENGTH(prefix) + PyUnicode_GET_LENGTH(name) + 1;
p = buf = PyMem_Malloc(sizeof(Py_UCS4) * len);
if (buf == NULL) {
PyErr_NoMemory();
return NULL;
}
if (!PyUnicode_AsUCS4(prefix, p, len, 0))
return NULL;
p += PyUnicode_GET_LENGTH(prefix);
len -= PyUnicode_GET_LENGTH(prefix);
if (!PyUnicode_AsUCS4(name, p, len, 1))
return NULL;
for (; *p; p++) {
if (*p == '.')
*p = SEP;
}
pathobj = PyUnicode_FromKindAndData(PyUnicode_4BYTE_KIND,
buf, p-buf);
PyMem_Free(buf);
return pathobj;
} | false | false | false | false | false | 0 |
string_hash( const char *str )
{
unsigned long h = 0;
unsigned long g;
/*
* From the "Dragon" book by Aho, Sethi and Ullman.
*/
while ( *str )
{
h = ( h << 4 ) + *str++;
if ( ( g = ( h & 0xf0000000 ) ) != 0 )
{
h ^= ( g >> 24 );
h ^= g;
}
}
return h;
} | false | false | false | false | false | 0 |
mask_op(i_ctx_t *i_ctx_p,
int (*mask_proc)(gs_state *, gs_transparency_channel_selector_t))
{
int csel;
int code = int_param(osp, 1, &csel);
if (code < 0)
return code;
code = mask_proc(igs, csel);
if (code >= 0)
pop(1);
return code;
} | false | false | false | false | false | 0 |
rq_ioc(struct bio *bio)
{
#ifdef CONFIG_BLK_CGROUP
if (bio && bio->bi_ioc)
return bio->bi_ioc;
#endif
return current->io_context;
} | false | false | false | false | false | 0 |
CountUserBackends(Oid roleid)
{
ProcArrayStruct *arrayP = procArray;
int count = 0;
int index;
LWLockAcquire(ProcArrayLock, LW_SHARED);
for (index = 0; index < arrayP->numProcs; index++)
{
int pgprocno = arrayP->pgprocnos[index];
volatile PGPROC *proc = &allProcs[pgprocno];
if (proc->pid == 0)
continue; /* do not count prepared xacts */
if (proc->roleId == roleid)
count++;
}
LWLockRelease(ProcArrayLock);
return count;
} | false | false | false | false | false | 0 |
inittable(void)
{
/* Define a lookup table. Precompute values and store in a table */
long i;
for (i = 0; i < categs; i++) {
tbl[i].rat = rate[i];
tbl[i].ratxv = rate[i] * xv;
}
} | false | false | false | false | false | 0 |
_iodbcdm_admin_dialbox (HWND hwnd)
{
RETCODE retcode = SQL_ERROR;
/* Check input parameters */
if (!hwnd)
goto quit;
create_administrator (hwnd);
retcode = SQL_SUCCESS;
quit:
return retcode;
} | false | false | false | false | false | 0 |
_setAbiSuiteLibDir()
{
// FIXME: this code sucks hard
char * buf = NULL;
// see if ABIWORD_DATADIR was set in the environment
const char * sz = getenv("ABIWORD_DATADIR");
if (sz && *sz)
{
int len = strlen(sz);
buf = (gchar *)g_malloc(len+1);
strcpy(buf,sz);
char * p = buf;
if ( (p[0]=='"') && (p[len-1]=='"') )
{
// trim leading and trailing DQUOTES
p[len-1]=0;
p++;
len -= 2;
}
if (p[len-1]=='/') // trim trailing slash
p[len-1] = 0;
XAP_App::_setAbiSuiteLibDir(p);
g_free(buf);
return;
}
// otherwise, use the hard-coded value
XAP_App::_setAbiSuiteLibDir(getAbiSuiteHome());
return;
} | false | false | false | false | false | 0 |
encdesc_write_header(GtEncdesc *encdesc, FILE *fp)
{
unsigned long cur_field_num;
DescField *cur_field;
encdesc_header_io_basics(encdesc, fp, encdesc_gt_xfwrite);
for (cur_field_num = 0;
cur_field_num < encdesc->num_of_fields;
cur_field_num++) {
cur_field = &encdesc->fields[cur_field_num];
io_field_sep_and_is_cons(cur_field, fp, encdesc_gt_xfwrite);
if (cur_field->is_cons) {
write_cons_field_header(cur_field, fp);
}
else {
gt_xfwrite(&cur_field->is_numeric, sizeof (bool), (size_t) 1, fp);
if (cur_field->is_numeric) {
write_numeric_field_header(cur_field, fp);
}
else {
io_field_len_header(cur_field, fp, encdesc_gt_xfwrite);
gt_xfwrite(cur_field->data, sizeof (char), (size_t) cur_field->len, fp);
write_field_header_bittab(cur_field, fp);
write_field_char_dists(cur_field, fp);
}
}
}
} | false | false | false | false | false | 0 |
dmaend_callback(int data)
{
if (cur_control2 & 0x0040)
{
// foul-proof (CPU0 could be deactivated while we wait)
if (suspension_active) { suspension_active = 0; cpu_trigger(resume_trigger); }
// IRQ 5 is the "object DMA end interrupt" and shouldn't be triggered
// if object data isn't ready for DMA within the frame.
cpu_set_irq_line(0, 5, HOLD_LINE);
}
} | false | false | false | false | false | 0 |
lookupResultElementType(const StringC &name)
{
Dtd *dtd = defComplexLpd().resultDtd().pointer();
if (!dtd)
return 0;
ElementType *e = dtd->lookupElementType(name);
if (!e)
message(ParserMessages::noSuchResultElement, StringMessageArg(name));
return e;
} | false | false | false | false | false | 0 |
HPDF_Stream_Read (HPDF_Stream stream,
HPDF_BYTE *ptr,
HPDF_UINT *size)
{
if (!(stream->read_fn))
return HPDF_SetError (stream->error, HPDF_INVALID_OPERATION, 0);
/*
if (HPDF_Error_GetCode(stream->error) != HPDF_NOERROR)
return HPDF_THIS_FUNC_WAS_SKIPPED;
*/
return stream->read_fn(stream, ptr, size);
} | false | false | false | false | false | 0 |
create_variant_part_from (tree old_variant_part,
vec<variant_desc> variant_list,
tree record_type, tree pos_list,
vec<subst_pair> subst_list)
{
tree offset = DECL_FIELD_OFFSET (old_variant_part);
tree old_union_type = TREE_TYPE (old_variant_part);
tree new_union_type, new_variant_part;
tree union_field_list = NULL_TREE;
variant_desc *v;
unsigned int i;
/* First create the type of the variant part from that of the old one. */
new_union_type = make_node (QUAL_UNION_TYPE);
TYPE_NAME (new_union_type)
= concat_name (TYPE_NAME (record_type),
IDENTIFIER_POINTER (DECL_NAME (old_variant_part)));
/* If the position of the variant part is constant, subtract it from the
size of the type of the parent to get the new size. This manual CSE
reduces the code size when not optimizing. */
if (TREE_CODE (offset) == INTEGER_CST)
{
tree bitpos = DECL_FIELD_BIT_OFFSET (old_variant_part);
tree first_bit = bit_from_pos (offset, bitpos);
TYPE_SIZE (new_union_type)
= size_binop (MINUS_EXPR, TYPE_SIZE (record_type), first_bit);
TYPE_SIZE_UNIT (new_union_type)
= size_binop (MINUS_EXPR, TYPE_SIZE_UNIT (record_type),
byte_from_pos (offset, bitpos));
SET_TYPE_ADA_SIZE (new_union_type,
size_binop (MINUS_EXPR, TYPE_ADA_SIZE (record_type),
first_bit));
TYPE_ALIGN (new_union_type) = TYPE_ALIGN (old_union_type);
relate_alias_sets (new_union_type, old_union_type, ALIAS_SET_COPY);
}
else
copy_and_substitute_in_size (new_union_type, old_union_type, subst_list);
/* Now finish up the new variants and populate the union type. */
FOR_EACH_VEC_ELT_REVERSE (variant_list, i, v)
{
tree old_field = v->field, new_field;
tree old_variant, old_variant_subpart, new_variant, field_list;
/* Skip variants that don't belong to this nesting level. */
if (DECL_CONTEXT (old_field) != old_union_type)
continue;
/* Retrieve the list of fields already added to the new variant. */
new_variant = v->new_type;
field_list = TYPE_FIELDS (new_variant);
/* If the old variant had a variant subpart, we need to create a new
variant subpart and add it to the field list. */
old_variant = v->type;
old_variant_subpart = get_variant_part (old_variant);
if (old_variant_subpart)
{
tree new_variant_subpart
= create_variant_part_from (old_variant_subpart, variant_list,
new_variant, pos_list, subst_list);
DECL_CHAIN (new_variant_subpart) = field_list;
field_list = new_variant_subpart;
}
/* Finish up the new variant and create the field. No need for debug
info thanks to the XVS type. */
finish_record_type (new_variant, nreverse (field_list), 2, false);
compute_record_mode (new_variant);
create_type_decl (TYPE_NAME (new_variant), new_variant, NULL,
true, false, Empty);
new_field
= create_field_decl_from (old_field, new_variant, new_union_type,
TYPE_SIZE (new_variant),
pos_list, subst_list);
DECL_QUALIFIER (new_field) = v->qual;
DECL_INTERNAL_P (new_field) = 1;
DECL_CHAIN (new_field) = union_field_list;
union_field_list = new_field;
}
/* Finish up the union type and create the variant part. No need for debug
info thanks to the XVS type. Note that we don't reverse the field list
because VARIANT_LIST has been traversed in reverse order. */
finish_record_type (new_union_type, union_field_list, 2, false);
compute_record_mode (new_union_type);
create_type_decl (TYPE_NAME (new_union_type), new_union_type, NULL,
true, false, Empty);
new_variant_part
= create_field_decl_from (old_variant_part, new_union_type, record_type,
TYPE_SIZE (new_union_type),
pos_list, subst_list);
DECL_INTERNAL_P (new_variant_part) = 1;
/* With multiple discriminants it is possible for an inner variant to be
statically selected while outer ones are not; in this case, the list
of fields of the inner variant is not flattened and we end up with a
qualified union with a single member. Drop the useless container. */
if (!DECL_CHAIN (union_field_list))
{
DECL_CONTEXT (union_field_list) = record_type;
DECL_FIELD_OFFSET (union_field_list)
= DECL_FIELD_OFFSET (new_variant_part);
DECL_FIELD_BIT_OFFSET (union_field_list)
= DECL_FIELD_BIT_OFFSET (new_variant_part);
SET_DECL_OFFSET_ALIGN (union_field_list,
DECL_OFFSET_ALIGN (new_variant_part));
new_variant_part = union_field_list;
}
return new_variant_part;
} | false | false | false | false | false | 0 |
tocase(
bool (*xiswcase)(const unsigned long wc),
unsigned long (*xtowcase)(const unsigned long wc)) const
{
GP<GStringRep> retval;
char const * const eptr=data+size;
char const *ptr=data;
while(ptr<eptr)
{
char const * const xptr=isCharType(xiswcase,ptr,false);
if(ptr == xptr)
break;
ptr=xptr;
}
if(ptr<eptr)
{
const int n=(int)((size_t)ptr-(size_t)data);
unsigned char *buf;
GPBuffer<unsigned char> gbuf(buf,n+(1+size-n)*6);
if(n>0)
{
strncpy((char *)buf,data,n);
}
unsigned char *buf_ptr=buf+n;
for(char const *ptr=data+n;ptr<eptr;)
{
char const * const xptr=ptr;
const unsigned long w=getValidUCS4(ptr);
if(ptr == xptr)
break;
if(xiswcase(w))
{
const int len=(int)((size_t)ptr-(size_t)xptr);
strncpy((char *)buf_ptr,xptr,len);
buf_ptr+=len;
}else
{
mbstate_t ps;
memset(&ps,0,sizeof(mbstate_t));
buf_ptr=UCS4toString(xtowcase(w),buf_ptr,&ps);
}
}
buf_ptr[0]=0;
retval=substr((const char *)buf,0,(int)((size_t)buf_ptr-(size_t)buf));
}else
{
retval=const_cast<GStringRep *>(this);
}
return retval;
} | false | false | false | false | false | 0 |
normalize_action_name(lrmd_rsc_t * rsc, const char *action)
{
if (safe_str_eq(action, "monitor") &&
(safe_str_eq(rsc->class, "lsb") ||
safe_str_eq(rsc->class, "service") || safe_str_eq(rsc->class, "systemd"))) {
return "status";
}
return action;
} | false | false | false | false | false | 0 |
gst_audio_karaoke_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstAudioKaraoke *filter;
filter = GST_AUDIO_KARAOKE (object);
switch (prop_id) {
case PROP_LEVEL:
filter->level = g_value_get_float (value);
break;
case PROP_MONO_LEVEL:
filter->mono_level = g_value_get_float (value);
break;
case PROP_FILTER_BAND:
filter->filter_band = g_value_get_float (value);
update_filter (filter, NULL);
break;
case PROP_FILTER_WIDTH:
filter->filter_width = g_value_get_float (value);
update_filter (filter, NULL);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
} | false | false | false | false | false | 0 |
deleteTuple(s)
space1_t *s;
{
apptq_t *qtr;
for (qtr = tsh.space ; qtr != NULL ; qtr = qtr->next)
if (!strcmp(qtr->appid, s->appid)) break;
if (qtr == NULL) return;
if (s == qtr->Tqueue) /* remove tuple from space */
qtr->Tqueue = s->next ;
else
s->prev->next = s->next ;
if (s->next != NULL) s->next->prev = s->prev ;
/*
printf("CID::deleteTuple::appid:(%s)name(%s)\n", s->appid, s->name);
*/
free(s);
} | false | false | false | false | false | 0 |
static_vertex_find (double *n1, double *n2, double *n3, double *v)
{
double m[9];
double a, b, c, d;
double d1, d2, d3;
/*****************************************
* determine the apex of the triangular *
* piramid defined by neighbours 1,2,3 *
* *
* 1) calculate determinants: a, b, c, d *
* 2) detect and remove aligned points *
* 3) use the Cramer's rule to get apex *
*****************************************/
d1 = n1[0] * n1[0] + n1[1] * n1[1] + n1[2] * n1[2];
d2 = n2[0] * n2[0] + n2[1] * n2[1] + n2[2] * n2[2];
d3 = n3[0] * n3[0] + n3[1] * n3[1] + n3[2] * n3[2];
/******************************************************
* When d=0, the four points (seed,1,2,3) are in the *
* same plane, so they cannot define a proper vertex. *
******************************************************/
gamgi_math_matrix_absolute (m,
n1[0], n1[1], n1[2], n2[0], n2[1], n2[2], n3[0], n3[1], n3[2]);
d = gamgi_math_matrix_determinant (m);
if (fabs (d) < GAMGI_MATH_TOLERANCE) return FALSE;
/******************************************************
* Cramer's rule: *
* *
* for the system: get the determinant: *
* a1x + b1y + c1z = d1 D = | a1 b1 c1 | *
* a2x + b2y + c2z = d2 | a2 b2 c2 | *
* a3x + b3y + c3z = d3 | a3 b3 c3 | *
* *
* if D = 0 the system has no unique solution, *
* if D != 0: *
* *
* x = | d1 b1 c1 | y = | a1 d1 c1 | z = | a1 b1 d1 | *
* | d2 b2 c2 | | a2 d2 c2 | | a2 b2 d2 | *
* | d3 b3 c3 | | a3 d3 c3 | | a3 b3 d3 | *
* ------------ ------------ ------------ *
* D D D *
******************************************************/
gamgi_math_matrix_absolute (m,
d1, n1[1], n1[2], d2, n2[1], n2[2], d3, n3[1], n3[2]);
a = gamgi_math_matrix_determinant (m);
gamgi_math_matrix_absolute (m,
n1[0], d1, n1[2], n2[0], d2, n2[2], n3[0], d3, n3[2]);
b = gamgi_math_matrix_determinant (m);
gamgi_math_matrix_absolute (m,
n1[0], n1[1], d1, n2[0], n2[1], d2, n3[0], n3[1], d3);
c = gamgi_math_matrix_determinant (m);
v[0] = a / d;
v[1] = b / d;
v[2] = c / d;
return TRUE;
} | false | false | false | false | false | 0 |
live_messages_notify (DBusCounter *counter,
void *user_data)
{
DBusTransport *transport = user_data;
_dbus_transport_ref (transport);
#if 0
_dbus_verbose ("Size counter value is now %d\n",
(int) _dbus_counter_get_size_value (counter));
_dbus_verbose ("Unix FD counter value is now %d\n",
(int) _dbus_counter_get_unix_fd_value (counter));
#endif
/* disable or re-enable the read watch for the transport if
* required.
*/
if (transport->vtable->live_messages_changed)
{
_dbus_connection_lock (transport->connection);
(* transport->vtable->live_messages_changed) (transport);
_dbus_connection_unlock (transport->connection);
}
_dbus_transport_unref (transport);
} | false | false | false | false | false | 0 |
udl_get_modes(struct drm_connector *connector)
{
struct udl_device *udl = connector->dev->dev_private;
struct edid *edid;
int ret;
edid = (struct edid *)udl_get_edid(udl);
if (!edid) {
drm_mode_connector_update_edid_property(connector, NULL);
return 0;
}
/*
* We only read the main block, but if the monitor reports extension
* blocks then the drm edid code expects them to be present, so patch
* the extension count to 0.
*/
edid->checksum += edid->extensions;
edid->extensions = 0;
drm_mode_connector_update_edid_property(connector, edid);
ret = drm_add_edid_modes(connector, edid);
kfree(edid);
return ret;
} | false | false | false | false | false | 0 |
undo_partition (ltrans_partition partition, unsigned int n_cgraph_nodes,
unsigned int n_varpool_nodes)
{
while (VEC_length (cgraph_node_ptr, partition->cgraph_set->nodes) >
n_cgraph_nodes)
{
struct cgraph_node *node = VEC_index (cgraph_node_ptr,
partition->cgraph_set->nodes,
n_cgraph_nodes);
partition->insns -= node->local.inline_summary.self_size;
cgraph_node_set_remove (partition->cgraph_set, node);
node->aux = (void *)((size_t)node->aux - 1);
}
while (VEC_length (varpool_node_ptr, partition->varpool_set->nodes) >
n_varpool_nodes)
{
struct varpool_node *node = VEC_index (varpool_node_ptr,
partition->varpool_set->nodes,
n_varpool_nodes);
varpool_node_set_remove (partition->varpool_set, node);
node->aux = (void *)((size_t)node->aux - 1);
}
} | false | false | false | false | false | 0 |
lev_sel(int cmd, dico_key_t key, const char *dict_word)
{
if (cmd == DICO_SELECT_RUN) {
int dist = dico_levenshtein_distance(key->word, dict_word,
(int)key->strat->closure);
if (dist < 0)
return 0;
return dist <= levenshtein_distance;
}
return 0;
} | false | false | false | false | false | 0 |
Unpack(const Buffer *b)
{
unpack_status_t res=PacketSTRING::Unpack(b);
if(res!=UNPACK_SUCCESS)
return res;
int *offset=&unpacked;
int limit=length+4;
if(*offset<limit)
UNPACK8(eof);
return UNPACK_SUCCESS;
} | false | false | false | false | false | 0 |
exif_mnote_data_fuji_save (ExifMnoteData *ne, unsigned char **buf,
unsigned int *buf_size)
{
ExifMnoteDataFuji *n = (ExifMnoteDataFuji *) ne;
size_t i, o, s, doff;
unsigned char *t;
size_t ts;
if (!n || !buf || !buf_size) return;
/*
* Allocate enough memory for all entries and the number
* of entries.
*/
*buf_size = 8 + 4 + 2 + n->count * 12 + 4;
*buf = exif_mem_alloc (ne->mem, *buf_size);
if (!*buf) {
*buf_size = 0;
return;
}
/*
* Header: "FUJIFILM" and 4 bytes offset to the first entry.
* As the first entry will start right thereafter, the offset is 12.
*/
memcpy (*buf, "FUJIFILM", 8);
exif_set_long (*buf + 8, n->order, 12);
/* Save the number of entries */
exif_set_short (*buf + 8 + 4, n->order, (ExifShort) n->count);
/* Save each entry */
for (i = 0; i < n->count; i++) {
o = 8 + 4 + 2 + i * 12;
exif_set_short (*buf + o + 0, n->order, (ExifShort) n->entries[i].tag);
exif_set_short (*buf + o + 2, n->order, (ExifShort) n->entries[i].format);
exif_set_long (*buf + o + 4, n->order, n->entries[i].components);
o += 8;
s = exif_format_get_size (n->entries[i].format) *
n->entries[i].components;
if (s > 65536) {
/* Corrupt data: EXIF data size is limited to the
* maximum size of a JPEG segment (64 kb).
*/
continue;
}
if (s > 4) {
ts = *buf_size + s;
/* Ensure even offsets. Set padding bytes to 0. */
if (s & 1) ts += 1;
t = exif_mem_realloc (ne->mem, *buf, ts);
if (!t) {
return;
}
*buf = t;
*buf_size = ts;
doff = *buf_size - s;
if (s & 1) { doff--; *(*buf + *buf_size - 1) = '\0'; }
exif_set_long (*buf + o, n->order, doff);
} else
doff = o;
/*
* Write the data. Fill unneeded bytes with 0. Do not
* crash if data is NULL.
*/
if (!n->entries[i].data) memset (*buf + doff, 0, s);
else memcpy (*buf + doff, n->entries[i].data, s);
}
} | false | false | false | false | false | 0 |
_urlpath(path, hostp, typep)
CONST char *path;
char **hostp;
int *typep;
{
int n;
if (!urldrive) return(0);
n = urlparse(path, NULL, hostp, typep, 0);
return((n > 0) ? n : 0);
} | false | false | false | false | false | 0 |
update_window_title(win_struct *win)
{
char *title = NULL;
Window child=None;
if (debug) printf ("update window title\n");
if (win->xmms) {
child=win->xmms_main_window_xlib;
} else {
child=win->child_xlib;
}
if (!assert_window(child)) {
return;
}
title= wnck_get_name (child);
if (title) {
char *title_string = NULL;
if (debug) printf ("title: %s\n", title);
if (!win->xmms && win->no_reparent && g_str_has_suffix (title,"(AllTray)")) {
g_free (title);
return;
}
// Interact nicely with Compiz, which works slightly differently.
// We use get_window_manager() instead of win->window_manager because
// win->window_manager is not always populated when running under
// Compiz.
if ((!strcasecmp(get_window_manager(), "compiz")) && (win->no_title)
&& (!win->xmms)) {
title_string = title;
if (win->no_reparent) {
gdk_window_set_title(win->child_gdk, title_string);
} else {
gdk_window_set_title(win->parent_gdk, title_string);
}
}
if (!win->xmms) {
title_string=g_strconcat (title, " (AllTray)", NULL);
if (!win->no_title) {
if (win->no_reparent)
gdk_window_set_title (win->child_gdk, title_string);
else
gdk_window_set_title (win->parent_gdk, title_string);
}
g_free (title_string);
}
if (win->title)
g_free (win->title);
if (win->xmms) {
if (!strcmp (title, "XMMS")) {
win->title = g_strdup ("no title");
} else {
win->title = g_strdup (title+7*sizeof(char));
}
} else {
win->title=g_strdup (title);
}
if (debug) printf ("win->title: %s\n", win->title);
gtk_widget_set_tooltip_text(win->plug, win->title);
g_free(title);
if (win->title_time) {
show_balloon (win, win->title, win->title_time);
}
}
} | false | false | false | false | false | 0 |
CheckIdent (ident)
char *ident;
{
char *cpt;
int i;
cpt = ident;
while ( isspace (*cpt) != 0 )
cpt ++;
if (isalpha(*cpt++) == 0)
Erreur ("IDENT error not an identifier");
for (i = strlen(cpt); i >0; i--)
{
if (isalnum(*cpt) == 0)
if ((*cpt != '_') && (*cpt != '.'))
Erreur ("IDENT error not an identifier");
cpt ++;
}
} | false | false | false | false | false | 0 |
_e_border_show(E_Border *bd)
{
Eina_List *l;
E_Border *tmp;
ecore_evas_show(bd->bg_ecore_evas);
if (bd->post_job)
{
bd->post_show = 1;
return;
}
if (!((bd->comp_hidden) || (bd->tmp_input_hidden > 0)))
{
_e_border_shape_input_rectangle_set(bd);
// not anymore
// ecore_x_composite_window_events_enable(bd->win);
ecore_x_window_ignore_set(bd->win, EINA_FALSE);
}
ecore_x_window_show(bd->win);
EINA_LIST_FOREACH(bd->client.e.state.video_child, l, tmp)
ecore_x_window_show(tmp->win);
} | false | false | false | false | false | 0 |
init( void )
#else
init( )
#endif
{
SignalEntry *q;
Tname = newHashTable();
Rname = newHashTable();
Fcache = newHashTable();
Tcache = newHashTable();
Sname = newHashTable();
Pname = newHashTable(); /* MR11 */
/* Add default signal names */
q = (SignalEntry *)hash_add(Sname,
"NoViableAlt",
(Entry *)newSignalEntry("NoViableAlt"));
require(q!=NULL, "cannot alloc signal entry");
q->signum = sigNoViableAlt;
q = (SignalEntry *)hash_add(Sname,
"MismatchedToken",
(Entry *)newSignalEntry("MismatchedToken"));
require(q!=NULL, "cannot alloc signal entry");
q->signum = sigMismatchedToken;
q = (SignalEntry *)hash_add(Sname,
"NoSemViableAlt",
(Entry *)newSignalEntry("NoSemViableAlt"));
require(q!=NULL, "cannot alloc signal entry");
q->signum = sigNoSemViableAlt;
reserved_positions = empty;
all_tokens = empty;
imag_tokens = empty;
tokclasses = empty;
TokenStr = (char **) calloc(TSChunk, sizeof(char *));
require(TokenStr!=NULL, "main: cannot allocate TokenStr");
FoStack = (int **) calloc(CLL_k+1, sizeof(int *));
require(FoStack!=NULL, "main: cannot allocate FoStack");
FoTOS = (int **) calloc(CLL_k+1, sizeof(int *));
require(FoTOS!=NULL, "main: cannot allocate FoTOS");
Cycles = (ListNode **) calloc(CLL_k+1, sizeof(ListNode *));
require(Cycles!=NULL, "main: cannot allocate Cycles List");
MR_CompromisedRules=empty; /* MR14 */
} | false | false | false | false | false | 0 |
ioctl_fibmap(struct file *filp, int __user *p)
{
struct address_space *mapping = filp->f_mapping;
int res, block;
/* do we support this mess? */
if (!mapping->a_ops->bmap)
return -EINVAL;
if (!capable(CAP_SYS_RAWIO))
return -EPERM;
res = get_user(block, p);
if (res)
return res;
res = mapping->a_ops->bmap(mapping, block);
return put_user(res, p);
} | false | false | false | false | false | 0 |
sh_first_smallest_max_neighbours()
{
Partition::Cell* best_cell = 0;
int best_value = -1;
unsigned int best_size = UINT_MAX;
KStack<Partition::Cell*> neighbour_cells_visited;
neighbour_cells_visited.init(get_nof_vertices());
for(Partition::Cell* cell = p.first_nonsingleton_cell;
cell;
cell = cell->next_nonsingleton)
{
if(opt_use_comprec and p.cr_get_level(cell->first) != cr_level)
continue;
const Vertex& v = vertices[p.elements[cell->first]];
std::vector<unsigned int>::const_iterator ei = v.edges.begin();
for(unsigned int j = v.nof_edges(); j > 0; j--)
{
Partition::Cell* const neighbour_cell = p.get_cell(*ei++);
if(neighbour_cell->is_unit())
continue;
neighbour_cell->max_ival++;
if(neighbour_cell->max_ival == 1)
neighbour_cells_visited.push(neighbour_cell);
}
int value = 0;
while(!neighbour_cells_visited.is_empty())
{
Partition::Cell* const neighbour_cell = neighbour_cells_visited.pop();
if(neighbour_cell->max_ival != neighbour_cell->length)
value++;
neighbour_cell->max_ival = 0;
}
if((value > best_value) or
(value == best_value and cell->length < best_size))
{
best_value = value;
best_size = cell->length;
best_cell = cell;
}
}
return best_cell;
} | false | false | false | false | false | 0 |
pochhammer (gnm_float x, gnm_float n, gboolean give_log)
{
gnm_float rn, rx, lr;
GnmQuad m1, m2;
int e1, e2;
if (gnm_isnan (x) || gnm_isnan (n))
return gnm_nan;
/* This isn't a fundamental restriction, but one we impose. */
if (x <= 0 || x + n <= 0)
return gnm_nan;
if (n == 0)
return give_log ? 0 : 1;
rx = gnm_floor (x + 0.5);
rn = gnm_floor (n + 0.5);
/*
* Use naive multiplication when n is a small integer.
* We don't want to use this if x is also an integer
* (but we might do so below if x is insanely large).
*/
if (n == rn && x != rx && n >= 0 && n < 40) {
gnm_float r = pochhammer_naive (x, (int)n);
return give_log ? gnm_log (r) : r;
}
if (!qfactf (x + n - 1, &m1, &e1) &&
!qfactf (x - 1, &m2, &e2)) {
void *state = gnm_quad_start ();
int de = e1 - e2;
GnmQuad qr;
gnm_float r;
gnm_quad_div (&qr, &m1, &m2);
r = gnm_quad_value (&qr);
gnm_quad_end (state);
return give_log
? gnm_log (r) + M_LN2gnum * de
: gnm_ldexp (r, de);
}
/*
* We have left the common cases. One of x+n and x is
* insanely big, possibly both.
*/
if (gnm_abs (x) < 1) {
/* n is big. */
if (give_log)
goto via_log;
else
return gnm_pinf;
}
if (n < 0) {
gnm_float r = pochhammer (x + n, -n, give_log);
return give_log ? -r : 1 / r;
}
if (n == rn && n >= 0 && n < 100) {
gnm_float r = pochhammer_naive (x, (int)n);
return give_log ? gnm_log (r) : r;
}
if (gnm_abs (n) < 1) {
/* x is big. */
void *state = gnm_quad_start ();
GnmQuad qr;
gnm_float r;
pochhammer_small_n (x, n, &qr);
r = gnm_quad_value (&qr);
gnm_quad_end (state);
return give_log ? gnm_log (r) : r;
}
/* Panic mode. */
g_printerr ("x=%.20g n=%.20g\n", x, n);
via_log:
lr = ((x - 0.5) * gnm_log1p (n / x) +
n * gnm_log (x + n) -
n +
(lgammacor (x + n) - lgammacor (x)));
return give_log ? lr : gnm_exp (lr);
} | false | false | false | false | false | 0 |
is_operator (char c)
{
return c == ':' || c == ',' || c == '{' || c == '}';
} | false | false | false | false | false | 0 |
initPlayers()
{
// Create yellow
KWin4Player* yellow = (KWin4Player*)createPlayer(1, mPlayedBy[Yellow], false);
yellow->setUserId(Yellow);
yellow->setName(Prefs::name1());
addPlayer(yellow);
setPlayedBy(Yellow,mPlayedBy[Yellow]);
// Create Red
KWin4Player* red = (KWin4Player*)createPlayer(1, mPlayedBy[Red], false);
red->setUserId(Red);
red->setName(Prefs::name1());
addPlayer(red);
setPlayedBy(Red,mPlayedBy[Red]);
} | false | false | false | false | false | 0 |
debug(double me2) const {
if( !generator()->logfile().is_open() ) return;
if( (mePartonData()[0]->id() != 1 && mePartonData()[0]->id() != 2) ||
(mePartonData()[1]->id() != -1 && mePartonData()[1]->id() != -2) ||
mePartonData()[2]->id() != 5100021 ||
mePartonData()[3]->id() != 5100021 ) return;
tcSMPtr sm = generator()->standardModel();
double gs4 = sqr( 4.*Constants::pi*sm->alphaS(scale()) );
Energy2 s(sHat());
Energy2 mf2 = meMomenta()[2].m2();
Energy2 t3(tHat() - mf2), u4(uHat() - mf2);
double analytic = gs4*( mf2*( (57.*s/t3/u4) - (4.*s*s*s/t3/t3/u4/u4)
- (108./s) )
+ (20.*s*s/t3/u4) - 93. + (108.*t3*u4/s/s) )/27.;
double diff = abs( analytic - me2 );
if( diff > 1e-4 ) {
generator()->log()
<< mePartonData()[0]->PDGName() << ","
<< mePartonData()[1]->PDGName() << "->"
<< mePartonData()[2]->PDGName() << ","
<< mePartonData()[3]->PDGName() << " difference: "
<< setprecision(10) << diff << " ratio: "
<< analytic/me2 << '\n';
}
} | false | false | false | false | false | 0 |
bcmdec_negotiate_format(GstBcmDec *bcmdec)
{
GstCaps *caps;
gboolean result;
guint num = (guint)(bcmdec->output_params.framerate * 1000);
guint den = 1000;
GstStructure *s1;
const GValue *framerate_value;
GstVideoFormat vidFmt;
GstVideoInfo info;
#ifdef YV12__
vidFmt = GST_VIDEO_FORMAT_YV12;
#else
vidFmt = GST_VIDEO_FORMAT_YUY2;
#endif
GST_DEBUG_OBJECT(bcmdec, "framerate = %f", bcmdec->output_params.framerate);
gst_video_info_init (&info);
gst_video_info_set_format (&info,
vidFmt,
bcmdec->output_params.width,
bcmdec->output_params.height);
info.fps_n = num;
info.fps_d = den;
info.par_n = bcmdec->output_params.aspectratio_x;
info.par_d = bcmdec->output_params.aspectratio_y;
info.interlace_mode = bcmdec->interlace ?
GST_VIDEO_INTERLACE_MODE_INTERLEAVED :
GST_VIDEO_INTERLACE_MODE_PROGRESSIVE;
caps = gst_video_info_to_caps (&info);
result = gst_pad_set_caps(bcmdec->srcpad, caps);
GST_DEBUG_OBJECT(bcmdec, "gst_bcm_dec_negotiate_format %d", result);
if (bcmdec->output_params.clr_space == MODE422_YUY2) {
bcmdec->output_params.y_size = bcmdec->output_params.width * bcmdec->output_params.height * BUF_MULT;
if (bcmdec->interlace) {
GST_DEBUG_OBJECT(bcmdec, "bcmdec_negotiate_format Interlaced");
bcmdec->output_params.y_size /= 2;
}
bcmdec->output_params.uv_size = 0;
GST_DEBUG_OBJECT(bcmdec, "YUY2 set on caps");
} else if (bcmdec->output_params.clr_space == MODE420) {
bcmdec->output_params.y_size = bcmdec->output_params.width * bcmdec->output_params.height;
bcmdec->output_params.uv_size = bcmdec->output_params.width * bcmdec->output_params.height / 2;
#ifdef YV12__
if (bcmdec->interlace) {
GST_DEBUG_OBJECT(bcmdec, "bcmdec_negotiate_format Interlaced");
bcmdec->output_params.y_size = bcmdec->output_params.width * bcmdec->output_params.height / 2;
bcmdec->output_params.uv_size = bcmdec->output_params.y_size / 2;
}
#endif
GST_DEBUG_OBJECT(bcmdec, "420 set on caps");
}
s1 = gst_caps_get_structure(caps, 0);
framerate_value = gst_structure_get_value(s1, "framerate");
if (framerate_value != NULL) {
num = gst_value_get_fraction_numerator(framerate_value);
den = gst_value_get_fraction_denominator(framerate_value);
GST_DEBUG_OBJECT(bcmdec, "framerate = %f rate_num %d rate_den %d", bcmdec->output_params.framerate, num, den);
} else {
GST_DEBUG_OBJECT(bcmdec, "failed to get framerate_value");
}
framerate_value = gst_structure_get_value (s1, "pixel-aspect-ratio");
if (framerate_value) {
num = gst_value_get_fraction_numerator(framerate_value);
den = gst_value_get_fraction_denominator(framerate_value);
GST_DEBUG_OBJECT(bcmdec, "pixel-aspect-ratio_x = %d y %d ", num, den);
} else {
GST_DEBUG_OBJECT(bcmdec, "failed to get par");
}
gst_caps_unref(caps);
return result;
} | false | false | false | false | false | 0 |
Scm_ForkptyAndExec(ScmString *file, ScmObj args, ScmObj iomap,
ScmObj slaveterm, ScmSysSigset *mask)
{
int argc = Scm_Length(args);
char **argv;
const char *program;
int *fds;
int master;
pid_t pid;
struct termios *term = NULL;
if (argc < 1) {
Scm_Error("argument list must have at least one element: %S", args);
}
argv = Scm_ListToCStringArray(args, TRUE, NULL);
program = Scm_GetStringConst(file);
if (SCM_SYS_TERMIOS_P(slaveterm)) {
term = &SCM_SYS_TERMIOS(slaveterm)->term;
}
fds = Scm_SysPrepareFdMap(iomap);
if ((pid = forkpty(&master, NULL, term, NULL)) < 0) {
Scm_SysError("forkpty failed");
}
if (pid == 0) {
Scm_SysSwapFds(fds);
if (mask) {
Scm_ResetSignalHandlers(&mask->set);
Scm_SysSigmask(SIG_SETMASK, mask);
}
execvp(program, (char *const*)argv);
/* here, we failed */
Scm_Panic("exec failed: %s: %s", program, strerror(errno));
}
return Scm_Values2(Scm_MakeInteger(pid), SCM_MAKE_INT(master));
} | false | false | false | false | false | 0 |
InternalFieldCount() {
if (IsDeadCheck("v8::ObjectTemplate::InternalFieldCount()")) {
return 0;
}
return i::Smi::cast(Utils::OpenHandle(this)->internal_field_count())->value();
} | false | false | false | false | false | 0 |
record_voperand_set (bitmap global, bitmap *local, unsigned int uid)
{
/* Lazily allocate the bitmap. Note that we do not get a notification
when the block local data structures die, so we allocate the local
bitmap backed by the GC system. */
if (*local == NULL)
*local = BITMAP_GGC_ALLOC ();
/* Set the bit in the local and global bitmaps. */
bitmap_set_bit (*local, uid);
bitmap_set_bit (global, uid);
} | false | false | false | false | false | 0 |
MG_dest_field_changed_cb(AW_root *aw_root) {
if (allow_callbacks) {
// if this is changed -> a new definition will be generated
char *dest_field = aw_root->awar(AWAR_MERGE_GENE_SPECIES_DEST)->read_string();
check_and_correct_current_field(dest_field);
const char *search = GBS_global_string(";%s;", dest_field);
char *existing_definitions = aw_root->awar(AWAR_MERGE_GENE_SPECIES_FIELDS_DEFS)->read_string();
mg_assert(existing_definitions[0] == ';');
if (strstr(existing_definitions, search) == 0) { // not found -> create a new definition
aw_root->awar(AWAR_MERGE_GENE_SPECIES_FIELDS_DEFS)
->write_string(GBS_global_string("%s%s;", existing_definitions, dest_field));
}
aw_root->awar(AWAR_MERGE_GENE_SPECIES_CURRENT_FIELD)->write_string(dest_field);
free(existing_definitions);
free(dest_field);
MG_update_example(aw_root);
}
} | false | false | false | false | false | 0 |
fat_fh_to_parent_nostale(struct super_block *sb,
struct fid *fh, int fh_len,
int fh_type)
{
struct inode *inode = NULL;
struct fat_fid *fid = (struct fat_fid *)fh;
loff_t i_pos;
if (fh_len < FAT_FID_SIZE_WITH_PARENT)
return NULL;
switch (fh_type) {
case FILEID_FAT_WITH_PARENT:
i_pos = fid->parent_i_pos_hi;
i_pos = (i_pos << 32) | (fid->parent_i_pos_low);
inode = __fat_nfs_get_inode(sb, 0, fid->parent_i_gen, i_pos);
break;
}
return d_obtain_alias(inode);
} | false | false | false | false | false | 0 |
make_car_info_local_array(const Stasche_localize_table *localize_table,
const Stasche_localize_tlg_info *tlg_info,
const Stasche_localize_car_info *car_info)
{
int array_num;
int pg_no;
int base;
int i;
if (car_info == NULL) return;
array_num = tlg_info->array_num;
pg_no = car_info->pg_no;
base = 0;
for (i = 1; i <= array_num; i++) {
Stasche_localize_dsm_array_info *dsm_array_info;
dsm_array_info = car_info->dsm_array_info[i];
if (dsm_array_info != NULL) {
base = make_dsm_array_info_local_array(localize_table,
tlg_info,
car_info,
dsm_array_info,
base);
}
}
if (base > localize_table->dsm_array_size[pg_no]) {
localize_table->dsm_array_size[pg_no] = base;
}
} | false | false | false | false | false | 0 |
attach_one_config(SANEI_Config __sane_unused__ *config, const char *line)
{
int vendor, product, timeout;
int len = strlen(line);
DBG(7, "%s: len = %d, line = %s\n", __func__, len, line);
if (sscanf(line, "usb %i %i", &vendor, &product) == 2) {
/* add the vendor and product IDs to the list of
* known devices before we call the attach function */
int numIds = kodakaio_getNumberOfUSBProductIds();
if (vendor != SANE_KODAKAIO_VENDOR_ID) {
DBG(7, "Wrong vendor: numIds = %d, vendor = %d\n", numIds, vendor);
return SANE_STATUS_INVAL; /* this is not a Kodak device */
}
/* kodakaio_usb_product_ids[numIds - 1] = product; */
kodakaio_cap[numIds - 1].id = product;
sanei_usb_attach_matching_devices(line, attach_one_usb);
} else if (strncmp(line, "usb", 3) == 0 && len == 3) {
int i, numIds;
/* auto detect ? */
numIds = kodakaio_getNumberOfUSBProductIds();
for (i = 0; i < numIds; i++) {
/* sanei_usb_find_devices(SANE_KODAKAIO_VENDOR_ID,
kodakaio_usb_product_ids[i], attach_one_usb); */
sanei_usb_find_devices(SANE_KODAKAIO_VENDOR_ID,
kodakaio_cap[i].id, attach_one_usb);
}
} else if (strncmp(line, "net", 3) == 0) {
/* remove the "net" sub string */
const char *name = sanei_config_skip_whitespace(line + 3);
char IP[1024];
unsigned int model = 0;
if (strncmp(name, "autodiscovery", 13) == 0) {
#if WITH_AVAHI
DBG (30, "%s: Initiating network autodiscovery via avahi\n", __func__);
kodak_network_discovery(NULL);
#else
DBG (20, "%s: Network autodiscovery not done because not configured with avahi.\n", __func__);
#endif
} else if (sscanf(name, "%s %x", IP, &model) == 2) {
DBG(30, "%s: Using network device on IP %s, forcing model 0x%x\n", __func__, IP, model);
attach_one_net(IP, model);
} else {
DBG(1, "%s: net entry %s may be a host name?\n", __func__, name);
attach_one_net(name, 0);
}
} else if (sscanf(line, "snmp-timeout %i\n", &timeout)) {
/* Timeout for auto network discovery */
DBG(50, "%s: network auto-discovery timeout set to %d\n", __func__, timeout);
K_SNMP_Timeout = timeout;
} else if (sscanf(line, "scan-data-timeout %i\n", &timeout)) {
/* Timeout for scan data requests */
DBG(50, "%s: Scan data timeout set to %d\n", __func__, timeout);
K_Scan_Data_Timeout = timeout;
} else if (sscanf(line, "request-timeout %i\n", &timeout)) {
/* Timeout for all other read requests */
DBG(50, "%s: Request timeout set to %d\n", __func__, timeout);
K_Request_Timeout = timeout;
} else {
/* TODO: Warning about unparsable line! */
}
return SANE_STATUS_GOOD;
} | true | true | false | false | true | 1 |
eel_push_context(void)
{
eel_context_t *c = malloc(sizeof(eel_context_t));
if(!c)
{
eel_error("INTERNAL ERROR: Failed to push context!");
return;
}
memcpy(c, &eel_current, sizeof(eel_context_t));
c->previous = context_stack;
context_stack = c;
} | false | false | false | false | false | 0 |
archive_strncat(struct archive_string *as, const void *_p, size_t n)
{
size_t s;
const char *p, *pp;
p = (const char *)_p;
/* Like strlen(p), except won't examine positions beyond p[n]. */
s = 0;
pp = p;
while (s < n && *pp) {
pp++;
s++;
}
if ((as = archive_string_append(as, p, s)) == NULL)
__archive_errx(1, "Out of memory");
return (as);
} | false | false | false | false | false | 0 |
gsfsln (struct gscmn *pcmn) {
struct gsvar *pvar;
char *res;
gaint ret, len;
pcmn->rres = NULL;
pvar = pcmn->farg;
if (pvar==NULL) {
printf ("Error in strlen: Argument missing\n");
ret = 1;
goto retrn;
}
len = 0;
while (*(pvar->strng+len)) {
len++;
if (len==9999999) break;
}
/* Allocate storage for the result */
res = (char *)malloc(12);
if (res==NULL) {
printf ("Error: Storage allocation error\n");
ret = 1;
goto retrn;
}
/* Deliver the result and return */
snprintf(res,11,"%i",len);
ret = 0;
pcmn->rres = res;
/* Release arg storage and return */
retrn:
gsfrev (pcmn->farg);
pcmn->farg = NULL;
return (ret);
} | false | false | false | false | false | 0 |
insert_section_boundary_note (void)
{
basic_block bb;
rtx new_note;
int first_partition = 0;
if (flag_reorder_blocks_and_partition)
FOR_EACH_BB (bb)
{
if (!first_partition)
first_partition = BB_PARTITION (bb);
if (BB_PARTITION (bb) != first_partition)
{
new_note = emit_note_before (NOTE_INSN_SWITCH_TEXT_SECTIONS,
BB_HEAD (bb));
/* ??? This kind of note always lives between basic blocks,
but add_insn_before will set BLOCK_FOR_INSN anyway. */
BLOCK_FOR_INSN (new_note) = NULL;
break;
}
}
} | false | false | false | false | false | 0 |
Ns_ConfigGetInt(char *section, char *key, int *valuePtr)
{
char *s;
s = Ns_ConfigGetValue(section, key);
if (s == NULL || sscanf(s, "%d", valuePtr) != 1) {
return NS_FALSE;
}
return NS_TRUE;
} | false | false | false | false | false | 0 |
gdef_get_string_var(GDEFVariable *var)
{
if (var->type == VAR_CHAR)
return g_strndup(var->data, var->size);
g_return_val_if_reached(NULL);
} | false | false | false | false | false | 0 |
wrk_do_cnt_sess(struct worker *w, void *priv)
{
struct sess *sess;
CAST_OBJ_NOTNULL(sess, priv, SESS_MAGIC);
AZ(sess->wrk);
THR_SetSession(sess);
sess->wrk = w;
CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
CNT_Session(sess);
CHECK_OBJ_ORNULL(w->nobjhead, OBJHEAD_MAGIC);
THR_SetSession(NULL);
} | false | false | false | false | false | 0 |
sleep_exec ( int argc, char **argv ) {
struct sleep_options opts;
unsigned int seconds;
unsigned long start;
unsigned long delay;
int rc;
/* Parse options */
if ( ( rc = parse_options ( argc, argv, &sleep_cmd, &opts ) ) != 0 )
return rc;
/* Parse number of seconds */
if ( ( rc = parse_integer ( argv[optind], &seconds ) ) != 0 )
return rc;
/* Delay for specified number of seconds */
start = currticks();
delay = ( seconds * TICKS_PER_SEC );
while ( ( currticks() - start ) <= delay ) {
step();
if ( iskey() && ( getchar() == CTRL_C ) )
return -ECANCELED;
cpu_nap();
}
return 0;
} | false | true | false | false | true | 1 |
GotoTokenPosition(int line, const wxString& tokenName)
{
cbStyledTextCtrl* control = GetControl();
if (line > control->GetLineCount())
return false;
GotoLine(line, true); // center function on screen
SetFocus(); // ...and set focus to this editor
// Now highlight the token
const int startPos = control->GetCurrentPos();
const int endPos = startPos + control->LineLength(line);
if (endPos <= startPos)
return false;
int tokenPos = control->FindText(startPos, endPos, tokenName,
wxSCI_FIND_WHOLEWORD | wxSCI_FIND_MATCHCASE, nullptr);
if (tokenPos != wxSCI_INVALID_POSITION)
control->SetSelectionInt(tokenPos, tokenPos + tokenName.Len());
else
control->GotoPos(startPos); // fall back, point the cursor to it
return true;
} | false | false | false | false | false | 0 |
Save_PAL(T_IO_Context * context)
{
FILE *file;
char filename[MAX_PATH_CHARACTERS]; ///< full filename
Get_full_filename(filename, context->File_name, context->File_directory);
File_error=0;
// Open output file
if ((file=fopen(filename,"w")))
{
int i;
if (fputs("JASC-PAL\n0100\n256\n", file)==EOF)
File_error=1;
for (i = 0; i < 256 && File_error==0; i++)
{
if (fprintf(file,"%d %d %d\n",context->Palette[i].R, context->Palette[i].G, context->Palette[i].B) <= 0)
File_error=1;
}
fclose(file);
if (File_error)
remove(filename);
}
else
{
// unable to open output file, nothing saved.
File_error=1;
}
} | true | true | false | false | true | 1 |
zstream_append_input(struct zstream *z, const Bytef *src, long len)
{
if (len <= 0) return;
if (NIL_P(z->input)) {
z->input = rb_str_buf_new(len);
rb_str_buf_cat(z->input, (const char*)src, len);
RBASIC(z->input)->klass = 0;
}
else {
rb_str_buf_cat(z->input, (const char*)src, len);
}
} | false | false | false | false | false | 0 |
cb(int ok, X509_STORE_CTX *ctx)
{
int cert_error = X509_STORE_CTX_get_error(ctx);
X509 *current_cert = X509_STORE_CTX_get_current_cert(ctx);
if (!ok)
{
if (current_cert)
{
X509_NAME_print_ex_fp(stdout,
X509_get_subject_name(current_cert),
0, XN_FLAG_ONELINE);
printf("\n");
}
printf("%serror %d at %d depth lookup:%s\n",
X509_STORE_CTX_get0_parent_ctx(ctx) ? "[CRL path]" : "",
cert_error,
X509_STORE_CTX_get_error_depth(ctx),
X509_verify_cert_error_string(cert_error));
switch(cert_error)
{
case X509_V_ERR_NO_EXPLICIT_POLICY:
policies_print(NULL, ctx);
case X509_V_ERR_CERT_HAS_EXPIRED:
/* since we are just checking the certificates, it is
* ok if they are self signed. But we should still warn
* the user.
*/
case X509_V_ERR_DEPTH_ZERO_SELF_SIGNED_CERT:
/* Continue after extension errors too */
case X509_V_ERR_INVALID_CA:
case X509_V_ERR_INVALID_NON_CA:
case X509_V_ERR_PATH_LENGTH_EXCEEDED:
case X509_V_ERR_INVALID_PURPOSE:
case X509_V_ERR_CRL_HAS_EXPIRED:
case X509_V_ERR_CRL_NOT_YET_VALID:
case X509_V_ERR_UNHANDLED_CRITICAL_EXTENSION:
ok = 1;
}
return ok;
}
if (cert_error == X509_V_OK && ok == 2)
policies_print(NULL, ctx);
if (!v_verbose)
ERR_clear_error();
return(ok);
} | false | false | false | false | false | 0 |
query_isduplicate(ns_client_t *client, dns_name_t *name,
dns_rdatatype_t type, dns_name_t **mnamep)
{
dns_section_t section;
dns_name_t *mname = NULL;
isc_result_t result;
CTRACE("query_isduplicate");
for (section = DNS_SECTION_ANSWER;
section <= DNS_SECTION_ADDITIONAL;
section++) {
result = dns_message_findname(client->message, section,
name, type, 0, &mname, NULL);
if (result == ISC_R_SUCCESS) {
/*
* We've already got this RRset in the response.
*/
CTRACE("query_isduplicate: true: done");
return (ISC_TRUE);
} else if (result == DNS_R_NXRRSET) {
/*
* The name exists, but the rdataset does not.
*/
if (section == DNS_SECTION_ADDITIONAL)
break;
} else
RUNTIME_CHECK(result == DNS_R_NXDOMAIN);
mname = NULL;
}
if (mnamep != NULL)
*mnamep = mname;
CTRACE("query_isduplicate: false: done");
return (ISC_FALSE);
} | false | false | false | false | false | 0 |
regcache_rbtree_drop(struct regmap *map, unsigned int min,
unsigned int max)
{
struct regcache_rbtree_ctx *rbtree_ctx;
struct regcache_rbtree_node *rbnode;
struct rb_node *node;
unsigned int base_reg, top_reg;
unsigned int start, end;
rbtree_ctx = map->cache;
for (node = rb_first(&rbtree_ctx->root); node; node = rb_next(node)) {
rbnode = rb_entry(node, struct regcache_rbtree_node, node);
regcache_rbtree_get_base_top_reg(map, rbnode, &base_reg,
&top_reg);
if (base_reg > max)
break;
if (top_reg < min)
continue;
if (min > base_reg)
start = (min - base_reg) / map->reg_stride;
else
start = 0;
if (max < top_reg)
end = (max - base_reg) / map->reg_stride + 1;
else
end = rbnode->blklen;
bitmap_clear(rbnode->cache_present, start, end - start);
}
return 0;
} | false | false | false | false | false | 0 |
unity_internal_aggregator_scope_impl_real_search_data_free (gpointer _data) {
UnityInternalAggregatorScopeImplSearchData* _data_;
_data_ = _data;
_g_free0 (_data_->search_string);
_g_hash_table_unref0 (_data_->hints);
_g_object_unref0 (_data_->cancellable);
_g_hash_table_unref0 (_data_->result);
_g_object_unref0 (_data_->self);
g_slice_free (UnityInternalAggregatorScopeImplSearchData, _data_);
} | false | false | false | false | false | 0 |
gl_print_op_finalize (GObject *object)
{
glPrintOp *op = GL_PRINT_OP (object);
gl_debug (DEBUG_PRINT, "");
g_return_if_fail (object != NULL);
g_return_if_fail (GL_IS_PRINT_OP (op));
g_return_if_fail (op->priv != NULL);
g_object_unref (G_OBJECT(op->priv->label));
g_free (op->priv->filename);
g_free (op->priv);
G_OBJECT_CLASS (gl_print_op_parent_class)->finalize (object);
g_free (op->priv);
} | false | false | false | false | false | 0 |
commodity_table_book_begin (QofBook *book)
{
gnc_commodity_table *ct;
ENTER ("book=%p", book);
if (gnc_commodity_table_get_table(book))
return;
ct = gnc_commodity_table_new ();
qof_book_set_data (book, GNC_COMMODITY_TABLE, ct);
if (!gnc_commodity_table_add_default_data(ct, book))
{
PWARN("unable to initialize book's commodity_table");
}
LEAVE ("book=%p", book);
} | false | false | false | false | false | 0 |
perror(void) const
{
fflush(0);
DjVuPrintErrorUTF8("*** ");
DjVuMessageLite::perror(get_cause());
if (file && line>0)
DjVuPrintErrorUTF8("*** (%s:%d)\n", file, line);
else if (file)
DjVuPrintErrorUTF8("*** (%s)\n", file);
if (func)
DjVuPrintErrorUTF8("*** '%s'\n", func);
DjVuPrintErrorUTF8("\n");
} | false | false | false | false | false | 0 |
my_stftime_tz(RESULT * result, RESULT * arg1, RESULT * arg2, RESULT * arg3)
{
char value[256] = "";
time_t t = R2N(arg2);
char *tz = R2S(arg3);
char *old_tz;
old_tz = getenv("TZ");
/*
* because the next setenv() call may overwrite that string, we
* duplicate it here
*/
if (old_tz) {
old_tz = strdup(old_tz);
}
setenv("TZ", tz, 1);
tzset();
strftime(value, sizeof(value), R2S(arg1), localtime(&t));
if (old_tz) {
setenv("TZ", old_tz, 1);
} else {
unsetenv("TZ");
}
tzset();
free(old_tz);
SetResult(&result, R_STRING, value);
} | false | false | false | false | false | 0 |
locate_read_oeminstall(xfile **pxf, int verb) {
int j;
char tname[1000], *pf, *ap;
xfile *xf = NULL; /* return value */
aglob ag;
if (verb) { printf("Looking for OEM install files .. \n"); fflush(stdout); }
tname[0] = '\000';
#ifdef NT
/* Where the normal instalation goes */
if ((pf = getenv("PROGRAMFILES")) != NULL)
strcpy(tname, pf);
else
strcpy(tname, "C:/Program Files");
#endif /* NT */
ap = tname + strlen(tname);
for (j = 0; oemtargs.instpaths[j].path != NULL; j++) {
strcpy(ap, oemtargs.instpaths[j].path);
if (verb) printf("Looking for '%s'\n",tname);
if (aglob_create(&ag, tname))
error("Searching for '%s' malloc error",oemtargs.instpaths[j].path);
for (;;) {
char *pp;
if ((pp = aglob_next(&ag)) == NULL)
break;
xf = new_add_xf(&xf, pp, NULL, 0, oemtargs.archnames[j].ftype,
oemtargs.archnames[j].ttype);
if (load_xfile(xf, verb))
error("Failed to load file '%s'",xf->name);
}
aglob_cleanup(&ag);
}
return xf;
} | false | false | false | false | false | 0 |
add_server_conf(struct server_conf *server_p)
{
if(EmptyString(server_p->class_name))
{
server_p->class_name = rb_strdup("default");
server_p->class = default_class;
return;
}
server_p->class = find_class(server_p->class_name);
if(server_p->class == default_class)
{
conf_report_error("Warning connect::class invalid for %s",
server_p->name);
rb_free(server_p->class_name);
server_p->class_name = rb_strdup("default");
}
if(strchr(server_p->host, '*') || strchr(server_p->host, '?'))
return;
} | false | false | false | false | false | 0 |
od_multibutton_init(ODMultiButton *mb)
{
guint i;
#if GTK_CHECK_VERSION(2, 2, 0)
gtk_widget_set_can_focus(GTK_WIDGET(mb), FALSE);
gtk_widget_set_can_default(GTK_WIDGET(mb), FALSE);
gtk_widget_set_receives_default(GTK_WIDGET(mb), FALSE);
#else
GTK_WIDGET_UNSET_FLAGS(mb, GTK_CAN_FOCUS | GTK_CAN_DEFAULT | GTK_RECEIVES_DEFAULT);
#endif
for(i = 0; i < sizeof mb->page / sizeof *mb->page; i++)
{
mb->page[i].widget = NULL;
mb->page[i].user = NULL;
}
mb->width = mb->height = 0;
mb->config = FALSE;
mb->config_down = FALSE;
mb->last_index = 0;
} | false | false | false | false | false | 0 |
module_set_fixed_variables( struct module_t * m, int n_variables )
{
/* Reallocate */
struct hash * variable_indices;
LIST * * fixed_variables = BJAM_MALLOC( n_variables * sizeof( LIST * ) );
if ( m->fixed_variables )
{
memcpy( fixed_variables, m->fixed_variables, n_variables * sizeof( LIST * ) );
BJAM_FREE( m->fixed_variables );
}
m->fixed_variables = fixed_variables;
if ( m->class_module )
{
variable_indices = m->class_module->variable_indices;
}
else
{
variable_indices = m->variable_indices;
}
if ( variable_indices )
hashenumerate( variable_indices, &load_fixed_variable, m );
m->num_fixed_variables = n_variables;
} | false | true | false | false | false | 1 |
camel_write (gint fd,
const gchar *buf,
gsize n,
GCancellable *cancellable,
GError **error)
{
gssize w, written = 0;
gint cancel_fd;
if (g_cancellable_set_error_if_cancelled (cancellable, error)) {
errno = EINTR;
return -1;
}
cancel_fd = g_cancellable_get_fd (cancellable);
if (cancel_fd == -1) {
do {
do {
w = write (fd, buf + written, n - written);
} while (w == -1 && (errno == EINTR || errno == EAGAIN || errno == EWOULDBLOCK));
if (w > 0)
written += w;
} while (w != -1 && written < n);
} else {
#ifndef G_OS_WIN32
gint errnosav, flags, fdmax;
fd_set rdset, wrset;
flags = fcntl (fd, F_GETFL);
fcntl (fd, F_SETFL, flags | O_NONBLOCK);
fdmax = MAX (fd, cancel_fd) + 1;
do {
struct timeval tv;
gint res;
FD_ZERO (&rdset);
FD_ZERO (&wrset);
FD_SET (fd, &wrset);
FD_SET (cancel_fd, &rdset);
tv.tv_sec = IO_TIMEOUT;
tv.tv_usec = 0;
w = -1;
res = select (fdmax, &rdset, &wrset, 0, &tv);
if (res == -1) {
if (errno == EINTR)
w = 0;
} else if (res == 0)
errno = ETIMEDOUT;
else if (FD_ISSET (cancel_fd, &rdset))
errno = EINTR;
else {
do {
w = write (fd, buf + written, n - written);
} while (w == -1 && errno == EINTR);
if (w == -1) {
if (errno == EAGAIN || errno == EWOULDBLOCK)
w = 0;
} else
written += w;
}
} while (w != -1 && written < n);
errnosav = errno;
fcntl (fd, F_SETFL, flags);
errno = errnosav;
#endif
}
g_cancellable_release_fd (cancellable);
if (g_cancellable_set_error_if_cancelled (cancellable, error))
return -1;
if (w == -1) {
g_set_error (
error, G_IO_ERROR,
g_io_error_from_errno (errno),
"%s", g_strerror (errno));
return -1;
}
return written;
} | false | false | false | false | false | 0 |
unique_qvars(Formula f, Ilist vars)
{
if (f->type == ATOM_FORM)
return vars;
else if (quant_form(f)) {
Term var = get_rigid_term(f->qvar, 0);
if (ilist_member(vars, SYMNUM(var))) {
/* Rename this variable. */
int sn = gen_new_symbol("x", 0, vars);
Term newvar = get_rigid_term(sn_to_str(sn), 0);
subst_free_var(f->kids[0], var, newvar);
f->qvar = sn_to_str(sn);
free_term(var);
var = newvar;
}
vars = ilist_prepend(vars, SYMNUM(var));
return unique_qvars(f->kids[0], vars);
}
else {
int i;
for (i = 0; i < f->arity; i++)
vars = unique_qvars(f->kids[i], vars);
return vars;
}
} | false | false | false | false | false | 0 |
kvp_match_predicate (gpointer object, QofParam *getter,
QofQueryPredData *pd)
{
int compare;
KvpFrame *kvp;
KvpValue *value;
query_kvp_t pdata = (query_kvp_t)pd;
VERIFY_PREDICATE (query_kvp_type);
kvp = ((query_kvp_getter)getter->param_getfcn) (object, getter);
if (!kvp)
return 0;
value = kvp_frame_get_slot_path_gslist (kvp, pdata->path);
if (!value)
return 0;
if (kvp_value_get_type (value) != kvp_value_get_type (pdata->value))
return 0;
compare = kvp_value_compare (value, pdata->value);
switch (pd->how)
{
case QOF_COMPARE_LT:
return (compare < 0);
case QOF_COMPARE_LTE:
return (compare <= 0);
case QOF_COMPARE_EQUAL:
return (compare == 0);
case QOF_COMPARE_GTE:
return (compare >= 0);
case QOF_COMPARE_GT:
return (compare > 0);
case QOF_COMPARE_NEQ:
return (compare != 0);
default:
PWARN ("bad match type: %d", pd->how);
return 0;
}
} | false | false | false | false | false | 0 |
validate_exec(const char *path)
{
struct stat buf;
#ifndef WIN32
uid_t euid;
struct group *gp;
struct passwd *pwp;
int i;
int in_grp = 0;
#else
char path_exe[MAXPGPATH + sizeof(".exe") - 1];
#endif
int is_r;
int is_x;
#ifdef WIN32
/* Win32 requires a .exe suffix for stat() */
if (strlen(path) >= strlen(".exe") &&
pg_strcasecmp(path + strlen(path) - strlen(".exe"), ".exe") != 0)
{
strcpy(path_exe, path);
strcat(path_exe, ".exe");
path = path_exe;
}
#endif
/*
* Ensure that the file exists and is a regular file.
*
* XXX if you have a broken system where stat() looks at the symlink
* instead of the underlying file, you lose.
*/
if (stat(path, &buf) < 0)
return -1;
if (!S_ISREG(buf.st_mode))
return -1;
/*
* Ensure that we are using an authorized executable.
*/
/*
* Ensure that the file is both executable and readable (required for
* dynamic loading).
*/
#ifdef WIN32
is_r = buf.st_mode & S_IRUSR;
is_x = buf.st_mode & S_IXUSR;
return is_x ? (is_r ? 0 : -2) : -1;
#else
euid = geteuid();
/* If owned by us, just check owner bits */
if (euid == buf.st_uid)
{
is_r = buf.st_mode & S_IRUSR;
is_x = buf.st_mode & S_IXUSR;
return is_x ? (is_r ? 0 : -2) : -1;
}
/* OK, check group bits */
pwp = getpwuid(euid); /* not thread-safe */
if (pwp)
{
if (pwp->pw_gid == buf.st_gid) /* my primary group? */
++in_grp;
else if (pwp->pw_name &&
(gp = getgrgid(buf.st_gid)) != NULL && /* not thread-safe */
gp->gr_mem != NULL)
{ /* try list of member groups */
for (i = 0; gp->gr_mem[i]; ++i)
{
if (!strcmp(gp->gr_mem[i], pwp->pw_name))
{
++in_grp;
break;
}
}
}
if (in_grp)
{
is_r = buf.st_mode & S_IRGRP;
is_x = buf.st_mode & S_IXGRP;
return is_x ? (is_r ? 0 : -2) : -1;
}
}
/* Check "other" bits */
is_r = buf.st_mode & S_IROTH;
is_x = buf.st_mode & S_IXOTH;
return is_x ? (is_r ? 0 : -2) : -1;
#endif
} | true | true | false | false | false | 1 |
set_Foreground(MudProfile *profile, const gchar *candidate)
{
GdkColor color;
if (candidate && gdk_color_parse(candidate, &color))
{
if (!gdk_color_equal(&color, &profile->priv->preferences.Foreground))
{
profile->priv->preferences.Foreground.red = color.red;
profile->priv->preferences.Foreground.green = color.green;
profile->priv->preferences.Foreground.blue = color.blue;
return TRUE;
}
}
return FALSE;
} | false | false | false | false | false | 0 |
load_servicefp_file(char *sigfile, signature **db, int len)
{
FILE *fp;
bstring filename;
bstring filedata;
struct bstrList *lines;
int i;
(void)(len); // doesn't matter
/*
* Check for a PADS_SIGNATURE_LIST file within the current directory.
*/
if ((fp = fopen(TCP_SIGNATURE_LIST, "r")) != NULL) {
filename = bformat("%s", sigfile);
fclose(fp);
} else {
filename = bformat(sigfile);
}
/*
* Open Signature File
*/
if ((fp = fopen(bdata(filename), "r")) == NULL) {
printf("Unable to open signature file - %s\n", bdata(filename));
return 1;
}
/*
* Read file into 'filedata' and process it accordingly.
*/
filedata = bread((bNread) fread, fp);
if ((lines = bsplit(filedata, '\n')) != NULL) {
for (i = 0; i < lines->qty; i++) {
parse_raw_signature(lines->entry[i], i + 1, db);
}
}
/*
* Clean Up
*/
bdestroy(filename);
bdestroy(filedata);
bstrListDestroy(lines);
fclose(fp);
return 0;
} | false | false | false | false | true | 1 |
emp_randomize_chars(char *str)
{
int idx;
int char_index;
// shuffle chars around
for(idx=0; idx<(int)(strlen(str)-1); idx++){
if(frand_range(0.0f, 1.0f) < Emp_intensity){
char_index = (int)frand_range(0.0f, (float)(NUM_RANDOM_CHARS - 1));
str[idx] = Emp_random_char[char_index];
}
}
} | false | false | false | false | false | 0 |
ipmi_print_get_instan_power_Amps_data(IPMI_INST_POWER_CONSUMPTION_DATA instpowerconsumptiondata)
{
uint16_t intampsval=0;
uint16_t decimalampsval=0;
if (instpowerconsumptiondata.instanApms > 0) {
decimalampsval = (instpowerconsumptiondata.instanApms % 10);
intampsval = instpowerconsumptiondata.instanApms / 10;
}
printf("\nAmperage value: %d.%d A \n", intampsval, decimalampsval);
} | false | false | false | false | false | 0 |
init_pipe_struct_pair(struct pipe_struct *read_pipe, struct pipe_struct *write_pipe)
{
int retval;
int pipefds[2];
retval = pipe(pipefds);
if (retval < 0) {
perror("Unable to create a new pipe!");
goto out;
}
read_pipe->pipe_fd = pipefds[0];
read_pipe->pipe_mate_fd = pipefds[1];
write_pipe->pipe_fd = pipefds[1];
write_pipe->pipe_mate_fd = pipefds[0];
retval = update_pipe_struct(read_pipe);
if (retval < 0) {
goto out;
}
retval = update_pipe_struct(write_pipe);
out:
return retval;
} | false | false | false | false | false | 0 |
pushblock(u)
struct undostack *u;
{
if (u->blockp == 0)
if ((uwrite = OPEN_NEW(undobuf)) < 0)
return FALSE;
if (BUFSZ == WRITE_TEXT(uwrite, u->coreblock, BUFSZ)) {
u->blockp++;
u->ptr = 0;
return TRUE;
}
return FALSE;
} | false | false | false | false | false | 0 |
save( QTextStream * ts, int indent )
{
indentation( ts, indent );
if( _type == ArtefactElementaryAction::AT_CHARAC ) {
*ts << "<elementary type=\"CHARAC\" ";
} else {
*ts << "<elementary type=\"SKILL\" ";
}
if( _modif == ArtefactElementaryAction::MT_VALUE ) {
*ts << "modif=\"VALUE\" ";
} else {
*ts << "modif=\"PERCENT\" ";
}
*ts << "param=\"" << _param << "\">";
*ts << _value << "</elementary>" << endl;
} | false | false | false | false | false | 0 |
r8712_createbss_cmd(struct _adapter *padapter)
{
struct cmd_obj *pcmd;
struct cmd_priv *pcmdpriv = &padapter->cmdpriv;
struct wlan_bssid_ex *pdev_network =
&padapter->registrypriv.dev_network;
padapter->ledpriv.LedControlHandler(padapter, LED_CTL_START_TO_LINK);
pcmd = kmalloc(sizeof(*pcmd), GFP_ATOMIC);
if (pcmd == NULL)
return _FAIL;
INIT_LIST_HEAD(&pcmd->list);
pcmd->cmdcode = _CreateBss_CMD_;
pcmd->parmbuf = (unsigned char *)pdev_network;
pcmd->cmdsz = r8712_get_wlan_bssid_ex_sz(pdev_network);
pcmd->rsp = NULL;
pcmd->rspsz = 0;
/* notes: translate IELength & Length after assign to cmdsz; */
pdev_network->Length = pcmd->cmdsz;
pdev_network->IELength = pdev_network->IELength;
pdev_network->Ssid.SsidLength = pdev_network->Ssid.SsidLength;
r8712_enqueue_cmd(pcmdpriv, pcmd);
return _SUCCESS;
} | false | false | false | false | false | 0 |
i915_gem_obj_offset(struct drm_i915_gem_object *o,
struct i915_address_space *vm)
{
struct drm_i915_private *dev_priv = o->base.dev->dev_private;
struct i915_vma *vma;
WARN_ON(vm == &dev_priv->mm.aliasing_ppgtt->base);
list_for_each_entry(vma, &o->vma_list, obj_link) {
if (vma->is_ggtt &&
vma->ggtt_view.type != I915_GGTT_VIEW_NORMAL)
continue;
if (vma->vm == vm)
return vma->node.start;
}
WARN(1, "%s vma for this object not found.\n",
i915_is_ggtt(vm) ? "global" : "ppgtt");
return -1;
} | false | false | false | false | false | 0 |
check_vgs(int32 id,
uintn start_vg,
uintn n_vgs,
char *ident_text, /* just for debugging, remove when done */
uintn resultcount, /* expected number of vgroups */
uint16 *resultarray) /* array containing expected values */
{
uint16 *refarray=NULL;
uintn count=0, ii;
char message[30];
intn ret_value=SUCCEED;
HDstrcpy(message, "Vgetvgroups: ");
HDstrcat(message, ident_text);
/* Get and verify the number of vgroups in the file */
count = Vgetvgroups(id, start_vg, n_vgs, NULL);
CHECK(count, FAIL, "Vgetvgroups");
VERIFY(count, resultcount, "Vgetvgroups");
/* Allocate space to retrieve the reference numbers of 'count' vgroups */
refarray = (uint16 *)HDmalloc(sizeof(uint16)*count);
if (refarray == NULL) {
fprintf(stderr, "check_vgs: Allocation refarray failed\n");
return (-1);
}
/* Get all the vgroups in the file */
count = Vgetvgroups(id, start_vg, count, refarray);
CHECK(count, FAIL, "Vgetvgroups");
VERIFY(count, resultcount, "Vgetvgroups");
for (ii = 0; ii < count; ii++)
if (refarray[ii] != resultarray[ii])
fprintf(stderr, "%s: at index %d - read value=%d, should be %d\n",
ident_text, ii, refarray[ii], resultarray[ii]);
if (refarray != NULL)
HDfree(refarray);
return ret_value;
} | false | false | false | false | false | 0 |
evry_state_push(Evry_Selector *sel, Eina_List *plugins)
{
Evry_State *s, *new_state;
Eina_List *l;
Evry_Plugin *p;
Evry_View *view = NULL;
Evry_Window *win = sel->win;
s = sel->state;
if (!(new_state = _evry_state_new(sel, plugins)))
{
DBG("no new state");
return 0;
}
EINA_LIST_FOREACH (plugins, l, p)
p->state = new_state;
if (s && s->view)
{
_evry_view_hide(win, s->view, SLIDE_LEFT);
view = s->view;
}
_evry_matches_update(sel, 1);
s = new_state;
_evry_selector_update(sel);
if (view && win->visible)
{
s->view = view->create(view, s, win->o_main);
if (s->view)
{
s->view->state = s;
_evry_view_show(win, s->view, SLIDE_LEFT);
s->view->update(s->view);
}
}
_evry_update_text_label(sel->state);
return 1;
} | false | false | false | false | false | 0 |
add_SubSigs(
/* add SubSig1 and SubSig2 to form SubSig3 */
struct SubSig *SubSig1,
struct SubSig *SubSig2,
struct SubSig *SubSig3, int nbands)
{
int b1, b2;
double wt1, wt2;
double tmp;
wt1 = SubSig1->N / (SubSig1->N + SubSig2->N);
wt2 = 1 - wt1;
/* compute means */
for (b1 = 0; b1 < nbands; b1++)
SubSig3->means[b1] =
wt1 * SubSig1->means[b1] + wt2 * SubSig2->means[b1];
/* compute covariance */
for (b1 = 0; b1 < nbands; b1++)
for (b2 = b1; b2 < nbands; b2++) {
tmp = (SubSig3->means[b1] - SubSig1->means[b1])
* (SubSig3->means[b2] - SubSig1->means[b2]);
SubSig3->R[b1][b2] = wt1 * (SubSig1->R[b1][b2] + tmp);
tmp = (SubSig3->means[b1] - SubSig2->means[b1])
* (SubSig3->means[b2] - SubSig2->means[b2]);
SubSig3->R[b1][b2] += wt2 * (SubSig2->R[b1][b2] + tmp);
SubSig3->R[b2][b1] = SubSig3->R[b1][b2];
}
/* compute pi and N */
SubSig3->pi = SubSig1->pi + SubSig2->pi;
SubSig3->N = SubSig1->N + SubSig2->N;
} | false | false | false | false | false | 0 |
getvarval(Var *var)
{
return (var && (var->flags & VARSET)) ? &var->val : NULL;
} | false | false | false | false | false | 0 |
lua_pushnil (lua_State *L) {
ttype(L->top) = LUA_TNIL;
api_incr_top(L);
} | false | false | false | false | false | 0 |
apei_osc_setup(void)
{
static u8 whea_uuid_str[] = "ed855e0c-6c90-47bf-a62a-26de0fc5ad5c";
acpi_handle handle;
u32 capbuf[3];
struct acpi_osc_context context = {
.uuid_str = whea_uuid_str,
.rev = 1,
.cap.length = sizeof(capbuf),
.cap.pointer = capbuf,
};
capbuf[OSC_QUERY_DWORD] = OSC_QUERY_ENABLE;
capbuf[OSC_SUPPORT_DWORD] = 1;
capbuf[OSC_CONTROL_DWORD] = 0;
if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle))
|| ACPI_FAILURE(acpi_run_osc(handle, &context)))
return -EIO;
else {
kfree(context.ret.pointer);
return 0;
}
} | false | false | false | false | false | 0 |
gda_meta_table_foreign_key_free (GdaMetaTableForeignKey *tfk)
{
gint i;
for (i = 0; i < tfk->cols_nb; i++) {
g_free (tfk->fk_names_array[i]);
g_free (tfk->ref_pk_names_array[i]);
}
g_free (tfk->fk_cols_array);
g_free (tfk->fk_names_array);
g_free (tfk->ref_pk_cols_array);
g_free (tfk->ref_pk_names_array);
g_free (tfk->fk_name);
g_free (tfk);
} | false | false | false | false | false | 0 |
unpack_UYVP (const GstVideoFormatInfo * info, GstVideoPackFlags flags,
gpointer dest, const gpointer data[GST_VIDEO_MAX_PLANES],
const gint stride[GST_VIDEO_MAX_PLANES], gint x, gint y, gint width)
{
int i;
const guint8 *s = GET_LINE (y);
guint16 *d = dest;
for (i = 0; i < width; i += 2) {
guint16 y0, y1;
guint16 u0;
guint16 v0;
u0 = ((s[(i / 2) * 5 + 0] << 2) | (s[(i / 2) * 5 + 1] >> 6)) << 6;
y0 = (((s[(i / 2) * 5 + 1] & 0x3f) << 4) | (s[(i / 2) * 5 + 2] >> 4)) << 6;
v0 = (((s[(i / 2) * 5 + 2] & 0x0f) << 6) | (s[(i / 2) * 5 + 3] >> 2)) << 6;
y1 = (((s[(i / 2) * 5 + 3] & 0x03) << 8) | s[(i / 2) * 5 + 4]) << 6;
if (!(flags & GST_VIDEO_PACK_FLAG_TRUNCATE_RANGE)) {
y0 |= (y0 >> 4);
y1 |= (y1 >> 4);
u0 |= (u0 >> 4);
v0 |= (v0 >> 4);
}
d[i * 4 + 0] = 0xffff;
d[i * 4 + 1] = y0;
d[i * 4 + 2] = u0;
d[i * 4 + 3] = v0;
if (i < width - 1) {
d[i * 4 + 4] = 0xffff;
d[i * 4 + 5] = y1;
d[i * 4 + 6] = u0;
d[i * 4 + 7] = v0;
}
}
} | false | false | false | false | false | 0 |
_HZClose(UConverter *cnv){
if(cnv->extraInfo != NULL) {
ucnv_close (((UConverterDataHZ *) (cnv->extraInfo))->gbConverter);
if(!cnv->isExtraLocal) {
uprv_free(cnv->extraInfo);
}
cnv->extraInfo = NULL;
}
} | false | false | false | false | false | 0 |
read_test_msas_text(char *alnfile, char *stkfile)
{
char msg[] = "CLUSTAL msa text-mode read unit test failed";
ESLX_MSAFILE *afp1 = NULL;
ESLX_MSAFILE *afp2 = NULL;
ESL_MSA *msa1, *msa2, *msa3, *msa4;
FILE *alnfp, *stkfp;
char alnfile2[32] = "esltmpaln2XXXXXX";
char stkfile2[32] = "esltmpstk2XXXXXX";
/* vvvv-- everything's the same as the digital utest except these NULLs */
if ( eslx_msafile_Open(NULL, alnfile, NULL, eslMSAFILE_CLUSTALLIKE, NULL, &afp1) != eslOK) esl_fatal(msg);
if ( eslx_msafile_Open(NULL, stkfile, NULL, eslMSAFILE_STOCKHOLM, NULL, &afp2) != eslOK) esl_fatal(msg);
if ( esl_msafile_clustal_Read (afp1, &msa1) != eslOK) esl_fatal(msg);
if ( esl_msafile_stockholm_Read(afp2, &msa2) != eslOK) esl_fatal(msg);
if ( esl_msa_Compare(msa1, msa2) != eslOK) esl_fatal(msg);
if ( esl_msafile_clustal_Read (afp1, &msa3) != eslEOF) esl_fatal(msg);
if ( esl_msafile_stockholm_Read(afp2, &msa3) != eslEOF) esl_fatal(msg);
eslx_msafile_Close(afp2);
eslx_msafile_Close(afp1);
if ( esl_tmpfile_named(alnfile2, &alnfp) != eslOK) esl_fatal(msg);
if ( esl_tmpfile_named(stkfile2, &stkfp) != eslOK) esl_fatal(msg);
if ( esl_msafile_clustal_Write (alnfp, msa2, eslMSAFILE_CLUSTAL) != eslOK) esl_fatal(msg);
if ( esl_msafile_stockholm_Write(stkfp, msa1, eslMSAFILE_STOCKHOLM) != eslOK) esl_fatal(msg);
fclose(alnfp);
fclose(stkfp);
if ( eslx_msafile_Open(NULL, alnfile2, NULL, eslMSAFILE_CLUSTAL, NULL, &afp1) != eslOK) esl_fatal(msg);
if ( eslx_msafile_Open(NULL, stkfile2, NULL, eslMSAFILE_STOCKHOLM, NULL, &afp2) != eslOK) esl_fatal(msg);
if ( esl_msafile_clustal_Read (afp1, &msa3) != eslOK) esl_fatal(msg);
if ( esl_msafile_stockholm_Read(afp2, &msa4) != eslOK) esl_fatal(msg);
if ( esl_msa_Compare(msa3, msa4) != eslOK) esl_fatal(msg);
remove(alnfile2);
remove(stkfile2);
eslx_msafile_Close(afp2);
eslx_msafile_Close(afp1);
esl_msa_Destroy(msa1);
esl_msa_Destroy(msa2);
esl_msa_Destroy(msa3);
esl_msa_Destroy(msa4);
} | true | true | false | false | false | 1 |
sl_if_print(const struct pcap_pkthdr *h, const u_char *p)
{
register u_int caplen = h->caplen;
register u_int length = h->len;
register const struct ip *ip;
if (caplen < SLIP_HDRLEN) {
printf("[|slip]");
return (caplen);
}
length -= SLIP_HDRLEN;
ip = (struct ip *)(p + SLIP_HDRLEN);
if (eflag)
sliplink_print(p, ip, length);
switch (IP_V(ip)) {
case 4:
ip_print(gndo, (u_char *)ip, length);
break;
#ifdef INET6
case 6:
ip6_print((u_char *)ip, length);
break;
#endif
default:
printf ("ip v%d", IP_V(ip));
}
return (SLIP_HDRLEN);
} | false | false | false | false | false | 0 |
moveDirBrute(Dir::eDir dir)
{
//NOTE: make place after oneself, e.g. object in U
m_mask->unmask();
Cube::t_models resist = m_mask->getResist(dir);
Cube::t_models::iterator end = resist.end();
for (Cube::t_models::iterator i = resist.begin(); i != end; ++i) {
if (!(*i)->isBorder()) {
(*i)->rules()->moveDirBrute(dir);
m_pushing = true;
}
}
m_dir = dir;
m_mask->mask();
} | false | false | false | false | false | 0 |
DecodeRUSSrcDstBitpInstruction(MCInst &Inst, unsigned Insn, uint64_t Address,
const void *Decoder) {
unsigned Op1, Op2;
DecodeStatus S = Decode2OpInstruction(Insn, Op1, Op2);
if (S != MCDisassembler::Success)
return Decode2OpInstructionFail(Inst, Insn, Address, Decoder);
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
DecodeGRRegsRegisterClass(Inst, Op1, Address, Decoder);
DecodeBitpOperand(Inst, Op2, Address, Decoder);
return S;
} | false | false | false | false | false | 0 |
T1_CopyGlyph( GLYPH *glyph)
{
GLYPH *dest;
long size;
if (glyph==NULL){
T1_errno=T1ERR_INVALID_PARAMETER;
return(NULL);
}
/* Assign padding value */
T1_pad=pFontBase->bitmap_pad;
/* Allocate memory for struct: */
if ((dest=(GLYPH *)malloc(sizeof(GLYPH)))==NULL){
T1_errno=T1ERR_ALLOC_MEM;
return(NULL);
}
/* Copy the structure members: */
*dest=*glyph;
/* Allocate memory for bitmap, initialize pointer to it and copy bitmap: */
size=PAD((dest->metrics.rightSideBearing-dest->metrics.leftSideBearing)*
glyph->bpp, T1_pad) / 8;
size=size*(dest->metrics.ascent-dest->metrics.descent);
/* We must check whether there's actually a bits-pointer different from
NULL. If not omit the following step: */
if (glyph->bits!=NULL){
if ((dest->bits=(char *)malloc(size*sizeof(char)))==NULL){
free(dest);
T1_errno=T1ERR_ALLOC_MEM;
return(NULL);
}
memcpy(dest->bits,glyph->bits,size);
}
return(dest);
} | false | true | false | false | false | 1 |
socket_connect_tcp (char *server, unsigned int port, unsigned int timeout)
{
struct sockaddr_in localAddr, servAddr;
struct hostent *h;
struct timeval timeval_v;
int rc;
int sock;
h = gethostbyname(server);
if (h == NULL)
return -1;
memset((char *)&servAddr, 0x0, sizeof(servAddr));
servAddr.sin_family = h->h_addrtype;
memcpy((char *)&servAddr.sin_addr.s_addr, h->h_addr_list[0], h->h_length);
servAddr.sin_port = htons(port);
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock < 0)
return -1;
if (timeout > 0) {
timeval_v.tv_sec = timeout;
timeval_v.tv_usec = 0;
socket_set_option(sock, SOL_SOCKET, SO_SNDTIMEO, &timeval_v);
socket_set_option(sock, SOL_SOCKET, SO_RCVTIMEO, &timeval_v);
}
memset((char *)&localAddr, 0x0, sizeof(localAddr));
localAddr.sin_family = AF_INET;
localAddr.sin_addr.s_addr = htonl(INADDR_ANY);
localAddr.sin_port = htons(0);
rc = bind(sock, (struct sockaddr *)&localAddr, sizeof(localAddr));
if (rc < 0)
return -1;
rc = connect(sock, (struct sockaddr *)&servAddr, sizeof(servAddr));
if (rc < 0)
return -1;
return sock;
} | false | false | false | false | false | 0 |
getExprForDwarfReference(const MCSymbol *Sym, unsigned Encoding,
MCStreamer &Streamer) const {
const MCExpr *Res = MCSymbolRefExpr::Create(Sym, getContext());
switch (Encoding & 0x70) {
default:
report_fatal_error("We do not support this DWARF encoding yet!");
case dwarf::DW_EH_PE_absptr:
// Do nothing special
return Res;
case dwarf::DW_EH_PE_pcrel: {
// Emit a label to the streamer for the current position. This gives us
// .-foo addressing.
MCSymbol *PCSym = getContext().CreateTempSymbol();
Streamer.EmitLabel(PCSym);
const MCExpr *PC = MCSymbolRefExpr::Create(PCSym, getContext());
return MCBinaryExpr::CreateSub(Res, PC, getContext());
}
}
} | false | false | false | false | false | 0 |
on_glade_drop (IAnjutaEditor* editor,
IAnjutaIterable* iterator,
const gchar* signal_data,
PythonPlugin* lang_plugin)
{
GSignalQuery query;
GType type;
guint id;
const gchar* widget;
const gchar* signal;
const gchar* handler;
GList* names = NULL;
GString* str = g_string_new (NULL);
int i;
IAnjutaIterable* start, * end;
GStrv data = g_strsplit(signal_data, ":", 5);
widget = data[0];
signal = data[1];
handler = data[2];
type = g_type_from_name (widget);
id = g_signal_lookup (signal, type);
g_signal_query (id, &query);
g_string_append_printf (str, "\ndef %s (self, %s", handler,
language_support_get_signal_parameter (widget,
&names));
for (i = 0; i < query.n_params; i++)
{
const gchar* type_name = g_type_name (query.param_types[i]);
const gchar* param_name = language_support_get_signal_parameter (type_name,
&names);
g_string_append_printf (str, ", %s", param_name);
}
g_string_append (str, "):\n");
ianjuta_editor_insert (editor, iterator,
str->str, -1, NULL);
/* Indent code correctly */
start = iterator;
end = ianjuta_iterable_clone (iterator, NULL);
ianjuta_iterable_set_position (end,
ianjuta_iterable_get_position (iterator, NULL)
+ g_utf8_strlen (str->str, -1),
NULL);
ianjuta_indenter_indent (IANJUTA_INDENTER (lang_plugin),
start, end, NULL);
g_object_unref (end);
g_string_free (str, TRUE);
anjuta_util_glist_strings_free (names);
g_strfreev (data);
} | false | false | false | false | false | 0 |
ExpandFPLibCall(SDNode* Node,
RTLIB::Libcall Call_F32,
RTLIB::Libcall Call_F64,
RTLIB::Libcall Call_F80,
RTLIB::Libcall Call_F128,
RTLIB::Libcall Call_PPCF128) {
RTLIB::Libcall LC;
switch (Node->getSimpleValueType(0).SimpleTy) {
default: llvm_unreachable("Unexpected request for libcall!");
case MVT::f32: LC = Call_F32; break;
case MVT::f64: LC = Call_F64; break;
case MVT::f80: LC = Call_F80; break;
case MVT::f128: LC = Call_F128; break;
case MVT::ppcf128: LC = Call_PPCF128; break;
}
return ExpandLibCall(LC, Node, false);
} | false | false | false | false | false | 0 |
cisco_eeprom_get_region(struct cisco_eeprom *eeprom,size_t offset,
m_uint8_t *data,size_t data_len)
{
size_t i;
for(i=0;i<data_len;i++) {
if (cisco_eeprom_get_byte(eeprom,offset+i,&data[i]) == -1)
return(-1);
}
return(0);
} | false | false | false | false | false | 0 |
arcfb_probe(struct platform_device *dev)
{
struct fb_info *info;
int retval = -ENOMEM;
int videomemorysize;
unsigned char *videomemory;
struct arcfb_par *par;
int i;
videomemorysize = (((64*64)*num_cols)*num_rows)/8;
/* We need a flat backing store for the Arc's
less-flat actual paged framebuffer */
videomemory = vzalloc(videomemorysize);
if (!videomemory)
return retval;
info = framebuffer_alloc(sizeof(struct arcfb_par), &dev->dev);
if (!info)
goto err;
info->screen_base = (char __iomem *)videomemory;
info->fbops = &arcfb_ops;
info->var = arcfb_var;
info->fix = arcfb_fix;
par = info->par;
par->info = info;
if (!dio_addr || !cio_addr || !c2io_addr) {
printk(KERN_WARNING "no IO addresses supplied\n");
goto err1;
}
par->dio_addr = dio_addr;
par->cio_addr = cio_addr;
par->c2io_addr = c2io_addr;
par->cslut[0] = 0x00;
par->cslut[1] = 0x06;
info->flags = FBINFO_FLAG_DEFAULT;
spin_lock_init(&par->lock);
retval = register_framebuffer(info);
if (retval < 0)
goto err1;
platform_set_drvdata(dev, info);
if (irq) {
par->irq = irq;
if (request_irq(par->irq, &arcfb_interrupt, IRQF_SHARED,
"arcfb", info)) {
printk(KERN_INFO
"arcfb: Failed req IRQ %d\n", par->irq);
retval = -EBUSY;
goto err1;
}
}
fb_info(info, "Arc frame buffer device, using %dK of video memory\n",
videomemorysize >> 10);
/* this inits the lcd but doesn't clear dirty pixels */
for (i = 0; i < num_cols * num_rows; i++) {
ks108_writeb_ctl(par, i, KS_DPY_OFF);
ks108_set_start_line(par, i, 0);
ks108_set_yaddr(par, i, 0);
ks108_set_xaddr(par, i, 0);
ks108_writeb_ctl(par, i, KS_DPY_ON);
}
/* if we were told to splash the screen, we just clear it */
if (!nosplash) {
for (i = 0; i < num_cols * num_rows; i++) {
fb_info(info, "splashing lcd %d\n", i);
ks108_set_start_line(par, i, 0);
ks108_clear_lcd(par, i);
}
}
return 0;
err1:
framebuffer_release(info);
err:
vfree(videomemory);
return retval;
} | false | false | false | false | false | 0 |
newConnection(GDBusServer *server, GDBusConnection *newConn, void *data) throw()
{
DBusServerCXX *me = static_cast<DBusServerCXX *>(data);
if (me->m_newConnection) {
GCredentials *credentials;
std::string credString;
credentials = g_dbus_connection_get_peer_credentials(newConn);
if (credentials == NULL) {
credString = "(no credentials received)";
} else {
gchar *s = g_credentials_to_string(credentials);
credString = s;
g_free(s);
}
g_debug("Client connected.\n"
"Peer credentials: %s\n"
"Negotiated capabilities: unix-fd-passing=%d\n",
credString.c_str(),
g_dbus_connection_get_capabilities(newConn) & G_DBUS_CAPABILITY_FLAGS_UNIX_FD_PASSING);
try {
// Ref count of connection has to be increased if we want to handle it.
// Something inside m_newConnection has to take ownership of connection,
// because conn increases ref count only temporarily.
DBusConnectionPtr conn(newConn, true);
me->m_newConnection(*me, conn);
} catch (...) {
g_error("handling new D-Bus connection failed with C++ exception");
return FALSE;
}
return TRUE;
} else {
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.