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 |
|---|---|---|---|---|---|---|
method_56(const int *account, int *weight) {
number2Array("4327654320", weight);
int result = 11 - algo03(11, weight, false, account, 0, 9);
// Ausnahme fuer 9 als erste Stelle; nach Hinweis von Michael
// Plugge <m.plugge@fh-mannheim.de>
if (result > 9) {
if (account[0] == 9) {
if (result == 10)
result = 7;
else
result = 8;
} else
return AccountNumberCheck::ERROR;
}
if (result == account[9])
return AccountNumberCheck::OK;
return AccountNumberCheck::ERROR;
} | false | false | false | false | false | 0 |
qh_pointid (pointT *point) {
unsigned id;
if (!point)
return -3;
id= ((unsigned long) point - (unsigned long) qh first_point)/qh normal_size;
if ((int)id >= qh num_points) {
if (point == qh interior_point)
id= (unsigned int) -2;
else if ((int)(id= qh_setindex (qh other_points, point)) != -1)
id += qh num_points;
}
return (int) id;
} | false | false | false | false | false | 0 |
source_load_from_key_file (GObject *object,
GKeyFile *key_file,
const gchar *group_name)
{
GObjectClass *class;
GParamSpec **properties;
guint n_properties, ii;
class = G_OBJECT_GET_CLASS (object);
properties = g_object_class_list_properties (class, &n_properties);
g_object_freeze_notify (object);
for (ii = 0; ii < n_properties; ii++) {
if (properties[ii]->flags & E_SOURCE_PARAM_SETTING) {
source_set_property_from_key_file (
object, properties[ii], key_file, group_name);
}
}
g_object_thaw_notify (object);
g_free (properties);
} | false | false | false | false | false | 0 |
description() const {
ostringstream ostr;
ostr << _phimin << " <= phi <= " << _phimax;
return ostr.str();
} | false | false | false | false | false | 0 |
bio_associate_blkcg(struct bio *bio, struct cgroup_subsys_state *blkcg_css)
{
if (unlikely(bio->bi_css))
return -EBUSY;
css_get(blkcg_css);
bio->bi_css = blkcg_css;
return 0;
} | false | false | false | false | false | 0 |
readQueryFromClient(aeEventLoop *el, int fd, void *privdata, int mask) {
redisClient *c = (redisClient*) privdata;
char buf[REDIS_IOBUF_LEN];
int nread;
REDIS_NOTUSED(el);
REDIS_NOTUSED(mask);
nread = read(fd, buf, REDIS_IOBUF_LEN);
if (nread == -1) {
if (errno == EAGAIN) {
nread = 0;
} else {
redisLog(REDIS_VERBOSE, "Reading from client: %s",strerror(errno));
freeClient(c);
return;
}
} else if (nread == 0) {
redisLog(REDIS_VERBOSE, "Client closed connection");
freeClient(c);
return;
}
if (nread) {
c->querybuf = sdscatlen(c->querybuf,buf,nread);
c->lastinteraction = time(NULL);
} else {
return;
}
if (sdslen(c->querybuf) > server.client_max_querybuf_len) {
sds ci = getClientInfoString(c);
redisLog(REDIS_WARNING,"Closing client that reached max query buffer length: %s", ci);
sdsfree(ci);
freeClient(c);
return;
}
processInputBuffer(c);
} | false | false | false | false | false | 0 |
hostlist_coalesce(hostlist_t hl)
{
int i, j;
hostrange_t new;
LOCK_HOSTLIST(hl);
for (i = hl->nranges - 1; i > 0; i--) {
new = hostrange_intersect(hl->hr[i - 1], hl->hr[i]);
if (new) {
hostrange_t hprev = hl->hr[i - 1];
hostrange_t hnext = hl->hr[i];
j = i;
if (new->hi < hprev->hi)
hnext->hi = hprev->hi;
hprev->hi = new->lo;
hnext->lo = new->hi;
if (hostrange_empty(hprev))
hostlist_delete_range(hl, i);
while (new->lo <= new->hi) {
hostrange_t hr = hostrange_create( new->prefix,
new->lo, new->lo,
new->width );
if (new->lo > hprev->hi)
hostlist_insert_range(hl, hr, j++);
if (new->lo < hnext->lo)
hostlist_insert_range(hl, hr, j++);
hostrange_destroy(hr);
new->lo++;
}
i = hl->nranges;
hostrange_destroy(new);
}
}
UNLOCK_HOSTLIST(hl);
hostlist_collapse(hl);
} | false | false | false | false | false | 0 |
comboentry_index_from_id(const ComboEntry centries[], guint32 id) {
gint i;
g_return_val_if_fail (centries, -1);
/* handle field types not yet supported */
if (centries == splaction_notsupported_comboentries)
return 0;
for (i = 0; centries[i].str; ++i) {
if (centries[i].id == id)
return i;
}
return -1;
} | false | false | false | false | false | 0 |
Print_CSeq(FILE *fp, allseq *alldata)
{
int i,j,k;
int n_otu;
n_otu = alldata->n_otu;
fprintf(fp,"%d\t%d\n",n_otu,alldata->init_len);
For(i,n_otu)
{
For(j,23)
{
if(j<(int)strlen(alldata->c_seq[i]->name))
fputc(alldata->c_seq[i]->name[j],fp);
else fputc(' ',fp);
}
For(j,alldata->crunch_len)
{
For(k,alldata->wght[j])
fprintf(fp,"%c",alldata->c_seq[i]->state[j]);
}
fprintf(fp,"\n");
}
fprintf(fp,"\n");
/* printf("\t"); */
/* For(j,alldata->crunch_len) */
/* printf("%.0f ",alldata->wght[j]); */
/* printf("\n"); */
} | false | false | false | false | false | 0 |
remove_entry (ACE_Token::ACE_Token_Queue_Entry *entry)
{
ACE_TRACE ("ACE_Token::ACE_Token_Queue::remove_entry");
ACE_Token_Queue_Entry *curr = 0;
ACE_Token_Queue_Entry *prev = 0;
if (this->head_ == 0)
return;
for (curr = this->head_;
curr != 0 && curr != entry;
curr = curr->next_)
prev = curr;
if (curr == 0)
// Didn't find the entry...
return;
else if (prev == 0)
// Delete at the head.
this->head_ = this->head_->next_;
else
// Delete in the middle.
prev->next_ = curr->next_;
// We need to update the tail of the list if we've deleted the last
// entry.
if (curr->next_ == 0)
this->tail_ = prev;
} | false | false | false | false | false | 0 |
is_valid(void) const
{
if (csetup_repp == 0 ||
csetup_repp->is_enabled() != true ||
csetup_repp->is_valid() != true ||
chains_repp == 0 ||
chains_repp->size() == 0 ||
inputs_repp == 0 ||
inputs_repp->size() == 0 ||
outputs_repp == 0 ||
outputs_repp->size() == 0) {
return false;
}
return true;
} | false | false | false | false | false | 0 |
pt_buffer_setup_aux(int cpu, void **pages, int nr_pages, bool snapshot)
{
struct pt_buffer *buf;
int node, ret;
if (!nr_pages)
return NULL;
if (cpu == -1)
cpu = raw_smp_processor_id();
node = cpu_to_node(cpu);
buf = kzalloc_node(offsetof(struct pt_buffer, topa_index[nr_pages]),
GFP_KERNEL, node);
if (!buf)
return NULL;
buf->cpu = cpu;
buf->snapshot = snapshot;
buf->data_pages = pages;
INIT_LIST_HEAD(&buf->tables);
ret = pt_buffer_init_topa(buf, nr_pages, GFP_KERNEL);
if (ret) {
kfree(buf);
return NULL;
}
return buf;
} | false | false | false | false | false | 0 |
event_system_start_free (CkLogSystemStartEvent *event)
{
g_assert (event != NULL);
g_free (event->kernel_release);
g_free (event->boot_arguments);
} | false | false | false | false | false | 0 |
expose_cb (GtkWidget * widget, GdkEventExpose * event)
{
gxineinfo_private_t *priv;
gtk_paint_flat_box (widget->style, widget->window,
GTK_WIDGET_STATE (widget), GTK_SHADOW_NONE,
&event->area, widget, gtk_widget_get_name (widget),
widget->allocation.x, widget->allocation.y,
widget->allocation.width, widget->allocation.height);
parent_class->expose_event (widget, event);
if ((priv = GET_PRIVATE (widget))->postinit)
{
priv->postinit ((GtkGxineInfo *) widget);
priv->postinit = NULL;
}
return FALSE;
} | false | false | false | false | false | 0 |
gst_rtp_asf_pay_parse_headers (GstRtpAsfPay * rtpasfpay)
{
gchar *maxps;
g_return_val_if_fail (rtpasfpay->headers, GST_FLOW_ERROR);
if (!gst_asf_parse_headers (rtpasfpay->headers, &rtpasfpay->asfinfo))
goto error;
GST_DEBUG_OBJECT (rtpasfpay, "Packets number: %" G_GUINT64_FORMAT,
rtpasfpay->asfinfo.packets_count);
GST_DEBUG_OBJECT (rtpasfpay, "Packets size: %" G_GUINT32_FORMAT,
rtpasfpay->asfinfo.packet_size);
GST_DEBUG_OBJECT (rtpasfpay, "Broadcast mode: %s",
rtpasfpay->asfinfo.broadcast ? "true" : "false");
/* get the config for caps */
g_free (rtpasfpay->config);
rtpasfpay->config = g_base64_encode (GST_BUFFER_DATA (rtpasfpay->headers),
GST_BUFFER_SIZE (rtpasfpay->headers));
GST_DEBUG_OBJECT (rtpasfpay, "Serialized headers to base64 string %s",
rtpasfpay->config);
g_assert (rtpasfpay->config != NULL);
GST_DEBUG_OBJECT (rtpasfpay, "Setting optional caps values: maxps=%"
G_GUINT32_FORMAT " and config=%s", rtpasfpay->asfinfo.packet_size,
rtpasfpay->config);
maxps =
g_strdup_printf ("%" G_GUINT32_FORMAT, rtpasfpay->asfinfo.packet_size);
gst_basertppayload_set_outcaps (GST_BASE_RTP_PAYLOAD (rtpasfpay), "maxps",
G_TYPE_STRING, maxps, "config", G_TYPE_STRING, rtpasfpay->config, NULL);
g_free (maxps);
return GST_FLOW_OK;
error:
{
GST_ELEMENT_ERROR (rtpasfpay, STREAM, DECODE, (NULL),
("Error parsing headers"));
return GST_FLOW_ERROR;
}
} | false | false | false | false | false | 0 |
execd_merge_load_report(u_long32 seqno)
{
if (last_lr == NULL || seqno != lGetUlong(last_lr, REP_seqno)) {
return;
} else {
lListElem *old_lr;
for_each(old_lr, lGetList(last_lr, REP_list)) {
const void *iterator = NULL;
const char *hostname = lGetHost(old_lr, LR_host);
const char *name = lGetString(old_lr, LR_name);
lListElem *lr, *lr_next;
bool found = false;
lr_next = lGetElemStrFirst(lr_list, LR_name, name, &iterator);
while ((lr = lr_next)) {
lr_next = lGetElemStrNext(lr_list, LR_name, name, &iterator);
if (sge_hostcmp(lGetHost(lr, LR_host), hostname) == 0) {
found = true;
if (lGetUlong(old_lr, LR_static) == 2) {
lRemoveElem(lr_list, &lr);
} else {
lSetString(lr, LR_value, lGetString(old_lr, LR_value));
}
break;
}
}
if (!found) {
lAppendElem(lr_list, lCopyElem(old_lr));
}
}
}
lFreeElem(&last_lr);
} | false | false | false | false | false | 0 |
usbtouch_reset_resume(struct usb_interface *intf)
{
struct usbtouch_usb *usbtouch = usb_get_intfdata(intf);
struct input_dev *input = usbtouch->input;
int err = 0;
/* reinit the device */
if (usbtouch->type->init) {
err = usbtouch->type->init(usbtouch);
if (err) {
dev_dbg(&intf->dev,
"%s - type->init() failed, err: %d\n",
__func__, err);
return err;
}
}
/* restart IO if needed */
mutex_lock(&input->mutex);
if (input->users)
err = usb_submit_urb(usbtouch->irq, GFP_NOIO);
mutex_unlock(&input->mutex);
return err;
} | false | false | false | false | false | 0 |
init_masks() {
for(Square s = SQ_A1; s <= SQ_H8; s++) {
SetMaskBB[s] = (1ULL << s);
ClearMaskBB[s] = ~SetMaskBB[s];
}
for(Color c = WHITE; c <= BLACK; c++)
for(Square s = SQ_A1; s <= SQ_H8; s++) {
PassedPawnMask[c][s] =
in_front_bb(c, s) & this_and_neighboring_files_bb(s);
OutpostMask[c][s] = in_front_bb(c, s) & neighboring_files_bb(s);
}
} | false | false | false | false | false | 0 |
alloc_image ( void ) {
struct image *image;
image = zalloc ( sizeof ( *image ) );
if ( image ) {
ref_init ( &image->refcnt, free_image );
}
return image;
} | false | false | false | false | false | 0 |
activated (reader_t *pipe_)
{
for (inpipes_t::iterator it = inpipes.begin (); it != inpipes.end ();
++it) {
if (it->reader == pipe_) {
zmq_assert (!it->active);
it->active = true;
return;
}
}
zmq_assert (false);
} | false | false | false | false | false | 0 |
int_round(int argc, VALUE* argv, VALUE num)
{
VALUE n;
int ndigits;
if (argc == 0) return num;
rb_scan_args(argc, argv, "1", &n);
ndigits = NUM2INT(n);
if (ndigits > 0) {
return rb_Float(num);
}
if (ndigits == 0) {
return num;
}
return int_round_0(num, ndigits);
} | false | false | false | false | false | 0 |
btrfs_iget_by_inr(struct fs_info *fs, u64 inr)
{
struct inode *inode;
struct btrfs_inode_item inode_item;
struct btrfs_disk_key search_key;
struct btrfs_path path;
int ret;
/* FIXME: some BTRFS inode member are u64, while our logical inode
is u32, we may need change them to u64 later */
search_key.objectid = inr;
search_key.type = BTRFS_INODE_ITEM_KEY;
search_key.offset = 0;
clear_path(&path);
ret = search_tree(fs, fs_tree, &search_key, &path);
if (ret)
return NULL;
inode_item = *(struct btrfs_inode_item *)path.data;
if (!(inode = alloc_inode(fs, inr, sizeof(struct btrfs_pvt_inode))))
return NULL;
inode->ino = inr;
inode->size = inode_item.size;
inode->mode = IFTODT(inode_item.mode);
if (inode->mode == DT_REG || inode->mode == DT_LNK) {
struct btrfs_file_extent_item extent_item;
u64 offset;
/* get file_extent_item */
search_key.type = BTRFS_EXTENT_DATA_KEY;
search_key.offset = 0;
clear_path(&path);
ret = search_tree(fs, fs_tree, &search_key, &path);
if (ret)
return NULL; /* impossible */
extent_item = *(struct btrfs_file_extent_item *)path.data;
if (extent_item.type == BTRFS_FILE_EXTENT_INLINE)/* inline file */
offset = path.offsets[0] + sizeof(struct btrfs_header)
+ path.item.offset
+ offsetof(struct btrfs_file_extent_item, disk_bytenr);
else
offset = extent_item.disk_bytenr;
PVT(inode)->offset = offset;
}
return inode;
} | false | false | false | false | false | 0 |
ldns_resolver_restore_rtt(ldns_resolver *r, size_t *old_rtt)
{
size_t *cur_rtt = ldns_resolver_rtt(r);
if (cur_rtt) {
LDNS_FREE(cur_rtt);
}
ldns_resolver_set_rtt(r, old_rtt);
} | false | false | false | false | false | 0 |
ast_aoc_set_termination_request(struct ast_aoc_decoded *decoded)
{
if (decoded->msg_type != AST_AOC_REQUEST) {
return -1;
}
decoded->termination_request = 1;
return 0;
} | false | false | false | false | false | 0 |
goo_canvas_set_adjustments (GooCanvas *canvas,
GtkAdjustment *hadj,
GtkAdjustment *vadj)
{
gboolean need_reconfigure = FALSE;
g_return_if_fail (GOO_IS_CANVAS (canvas));
if (hadj)
g_return_if_fail (GTK_IS_ADJUSTMENT (hadj));
else if (canvas->hadjustment)
hadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
if (vadj)
g_return_if_fail (GTK_IS_ADJUSTMENT (vadj));
else if (canvas->vadjustment)
vadj = GTK_ADJUSTMENT (gtk_adjustment_new (0.0, 0.0, 0.0, 0.0, 0.0, 0.0));
if (canvas->hadjustment && (canvas->hadjustment != hadj))
{
g_signal_handlers_disconnect_by_func (canvas->hadjustment,
goo_canvas_adjustment_value_changed,
canvas);
g_object_unref (canvas->hadjustment);
}
if (canvas->vadjustment && (canvas->vadjustment != vadj))
{
g_signal_handlers_disconnect_by_func (canvas->vadjustment,
goo_canvas_adjustment_value_changed,
canvas);
g_object_unref (canvas->vadjustment);
}
if (canvas->hadjustment != hadj)
{
canvas->hadjustment = hadj;
g_object_ref_sink (canvas->hadjustment);
g_signal_connect (canvas->hadjustment, "value_changed",
G_CALLBACK (goo_canvas_adjustment_value_changed),
canvas);
need_reconfigure = TRUE;
}
if (canvas->vadjustment != vadj)
{
canvas->vadjustment = vadj;
g_object_ref_sink (canvas->vadjustment);
g_signal_connect (canvas->vadjustment, "value_changed",
G_CALLBACK (goo_canvas_adjustment_value_changed),
canvas);
need_reconfigure = TRUE;
}
if (need_reconfigure)
reconfigure_canvas (canvas, TRUE);
} | false | false | false | false | false | 0 |
calcTangentIntersectionPoints(const Vector2D startPoint, Vector2D &point1, Vector2D &point2){
if(isInside(startPoint)){
// Startpoint is inside circle -> there are no tangent interception points
return(false);
}
//float d = posCenter.getLength()-startPoint.getLength();
float d = (posCenter-startPoint).getLength();
float r = radius;
float alphaRad = asin(r/d);
float p = sqrt(d*d-r*r);
point1.setX(cos(alphaRad)*p);
point1.setY(sin(alphaRad)*p);
point2.setX(cos(-alphaRad)*p);
point2.setY(sin(-alphaRad)*p);
point1=point1.rotate((posCenter-startPoint).getDirection());
point2=point2.rotate((posCenter-startPoint).getDirection());
point1+=startPoint;
point2+=startPoint;
return(true);
} | false | false | false | false | false | 0 |
find_battery(const struct dmi_header *dm, void *private)
{
struct acpi_battery *battery = (struct acpi_battery *)private;
/* Note: the hardcoded offsets below have been extracted from
the source code of dmidecode. */
if (dm->type == DMI_ENTRY_PORTABLE_BATTERY && dm->length >= 8) {
const u8 *dmi_data = (const u8 *)(dm + 1);
int dmi_capacity = get_unaligned((const u16 *)(dmi_data + 6));
if (dm->length >= 18)
dmi_capacity *= dmi_data[17];
if (battery->design_capacity * battery->design_voltage / 1000
!= dmi_capacity &&
battery->design_capacity * 10 == dmi_capacity)
set_bit(ACPI_BATTERY_QUIRK_THINKPAD_MAH,
&battery->flags);
}
} | false | false | false | false | false | 0 |
doesfileexist(const char *f) {
int fd;
updatecontext();
if (!f) return 0;
if ((fd = open(f,O_RDONLY | O_CREAT | O_EXCL | ADDED_OPEN_FLAGS, CREAT_PERMISSIONS)) < 0 && errno == EEXIST)
return 1;
else if (fd < 0)
return 0;
close(fd);
unlink(f);
return 0;
} | false | false | false | false | true | 1 |
set_thr_exit (ACE_TSS_TYPE (ACE_Thread_Exit) *ptr)
{
if (ACE_Thread_Manager::thr_exit_ == 0)
ACE_Thread_Manager::thr_exit_ = ptr;
else
return -1;
return 0;
} | false | false | false | false | false | 0 |
mx_application_get_actions (MxApplication *application)
{
MxApplicationPrivate *priv = application->priv;
if (priv->is_proxy)
{
#ifdef HAVE_DBUS
/* Refresh our list of actions if necessary */
if (!priv->actions_valid)
{
DBusGProxy *proxy = mx_application_get_dbus_proxy (application);
if (proxy)
{
GType array_type, struct_type;
GPtrArray *actions;
GError *error = NULL;
/* All this code is just for calling a dbus method with the
* signiature 'a(ssb)' (the GetActions method) and creating
* corresponding MxAction objects.
*/
struct_type = dbus_g_type_get_struct ("GValueArray",
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_BOOLEAN,
G_TYPE_INVALID);
array_type = dbus_g_type_get_collection ("GPtrArray",
struct_type);
if (!dbus_g_proxy_call (proxy,
"GetActions",
&error,
G_TYPE_INVALID,
array_type,
&actions,
G_TYPE_INVALID))
{
g_warning (G_STRLOC "%s", error->message);
g_error_free (error);
}
else
{
guint i;
g_hash_table_remove_all (priv->actions);
for (i = 0; i < actions->len; i++)
{
GValue *name, *display_name, *active;
MxAction *action;
GValueArray *value_array = g_ptr_array_index (actions, i);
name = g_value_array_get_nth (value_array, 0);
display_name = g_value_array_get_nth (value_array, 1);
active = g_value_array_get_nth (value_array, 2);
action =
mx_action_new_full (g_value_get_string (name),
g_value_get_string (display_name),
G_CALLBACK (
mx_application_proxy_action_cb),
application);
mx_action_set_active (action,
g_value_get_boolean (active));
g_hash_table_insert (priv->actions,
g_value_dup_string (name),
action);
g_value_array_free (value_array);
}
g_ptr_array_free (actions, TRUE);
}
g_object_unref (proxy);
}
}
#endif
}
return g_hash_table_get_values (priv->actions);
} | false | false | false | false | false | 0 |
des_ctrl(EVP_CIPHER_CTX *c, int type, int arg, void *ptr)
{
switch(type)
{
case EVP_CTRL_RAND_KEY:
if (RAND_bytes(ptr, 8) <= 0)
return 0;
DES_set_odd_parity((DES_cblock *)ptr);
return 1;
default:
return -1;
}
} | false | false | false | false | false | 0 |
terminaltypeok (char *s)
{
#ifdef HAVE_TGETENT
char buf[2048];
if (terminaltype == NULL)
return 1;
if (tgetent (buf, s) == 0)
return 0;
#endif /* HAVE_TGETENT */
return 1;
} | false | false | false | false | false | 0 |
do_get_nth_value(struct trie_node *node, int n)
{
struct record_val *v = get_nth_val_ent(node, n, 0);
if (v && v->type == RT_VAL) {
return v->u.val;
}
return 0;
} | false | false | false | false | false | 0 |
set_elements(const DynamicAny::AnySeq& as)
{
CHECK_NOT_DESTROYED;
if( as.length() != pd_n_components )
throw DynamicAny::DynAny::InvalidValue();
for( unsigned i = 0; i < pd_n_components; i++ ) {
if( !component_from_any(i, as[i]) )
throw DynamicAny::DynAny::TypeMismatch();
}
} | false | false | false | false | false | 0 |
host_peer_busy(struct host *host)
{
struct peer *unresponsive_peer = NULL;
static const char diag[] = "host_peer_busy";
static const char back_channel_diag[] = "back_channel";
gfarm_mutex_lock(&host->back_channel_mutex, diag, back_channel_diag);
if (!host->is_active || host->invalid)
;
else if (host->busy_time == 0)
host->busy_time = time(NULL);
else if (host_is_unresponsive(host, time(NULL), diag))
unresponsive_peer = host->peer;
gfarm_mutex_unlock(&host->back_channel_mutex, diag, back_channel_diag);
if (unresponsive_peer != NULL) {
gflog_error(GFARM_MSG_1002419,
"back_channel(%s): disconnecting: busy at sending",
host_name(host));
host_disconnect_request(host, unresponsive_peer);
}
} | false | false | false | false | false | 0 |
disqualify_base_of_expr (tree t, const char *reason)
{
t = get_base_address (t);
if (t
&& sra_mode == SRA_MODE_EARLY_IPA
&& TREE_CODE (t) == MEM_REF)
t = get_ssa_base_param (TREE_OPERAND (t, 0));
if (t && DECL_P (t))
disqualify_candidate (t, reason);
} | false | false | false | false | true | 1 |
CreateMachineBasicBlock(const BasicBlock *bb) {
return new (BasicBlockRecycler.Allocate<MachineBasicBlock>(Allocator))
MachineBasicBlock(*this, bb);
} | false | false | false | false | false | 0 |
bash_directory_completion_matches (text)
const char *text;
{
char **m1;
char *dfn;
int qc;
qc = rl_dispatching ? rl_completion_quote_character : 0;
dfn = bash_dequote_filename ((char *)text, qc);
m1 = rl_completion_matches (dfn, rl_filename_completion_function);
free (dfn);
if (m1 == 0 || m1[0] == 0)
return m1;
/* We don't bother recomputing the lcd of the matches, because it will just
get thrown away by the programmable completion code and recomputed
later. */
(void)bash_ignore_filenames (m1);
return m1;
} | false | false | false | false | false | 0 |
gt_bsGetUInt64(constBitString str, BitOffset offset, unsigned numBits)
{
unsigned long long accum = 0;
unsigned bitsLeft = numBits, bitTop = offset%bitElemBits;
size_t elemStart = offset/bitElemBits;
const BitElem *p = str + elemStart;
gt_assert(str);
#ifndef NDEBUG
if (numBits > sizeof (accum)*CHAR_BIT)
fprintf(stderr, "numBits = %u\n", numBits);
#endif
gt_assert(numBits <= sizeof (accum)*CHAR_BIT);
if (bitTop)
{
unsigned long long mask;
unsigned bits2Read = MIN(bitElemBits - bitTop, bitsLeft);
unsigned unreadRightBits = (bitElemBits - bitTop - bits2Read);
mask = (~((~(unsigned long long)0) << bits2Read)) << unreadRightBits;
accum = ((*p++) & mask) >> unreadRightBits;
bitsLeft -= bits2Read;
}
/* get bits from intervening elems */
while (bitsLeft >= bitElemBits)
{
accum = accum << bitElemBits | (*p++);
bitsLeft -= bitElemBits;
}
/* get bits from last elem */
if (bitsLeft)
{
accum = accum << bitsLeft |
(((*p) & ((~(unsigned long long)0)<<(bitElemBits - bitsLeft)))
>>(bitElemBits - bitsLeft));
}
return accum;
} | false | false | false | false | false | 0 |
extractPoint(double index, double offsetDistance) const
{
LinearLocation loc = LengthLocationMap::getLocation(linearGeom, index);
Coordinate ret;
loc.getSegment(linearGeom)->pointAlongOffset(loc.getSegmentFraction(), offsetDistance, ret);
return ret;
} | false | false | false | false | false | 0 |
HD44780_set_brightness(Driver *drvthis, int state, int promille)
{
PrivateData *p = drvthis->private_data;
/* Check it */
if (promille < 0 || promille > 1000)
return;
/* store the software value since there is not get */
if (state == BACKLIGHT_ON) {
p->brightness = promille;
}
else {
p->offbrightness = promille;
}
/*
* Make last backlight state invalid to force update on next
* rendering
*/
p->backlightstate = -1;
} | false | false | false | false | false | 0 |
new_beta_list(GtkWidget *hboxall)
{
GtkWidget *frame;
GtkWidget *scr;
GtkWidget *vbox;
GtkWidget *gtklist;
gint i;
gint N;
gdouble* Energies;
gdouble* Occ;
gchar** sym;
static gint type = 2;
gint widall = 0;
N = NBetaOrb;
Energies = g_malloc(N*sizeof(gdouble));
Occ = g_malloc(N*sizeof(gdouble));
sym = g_malloc(N*sizeof(gchar*));
for(i=0;i<N;i++)
{
Energies[i] = EnerBetaOrbitals[i];
Occ[i] = OccBetaOrbitals[i];
sym[i] = g_strdup(SymBetaOrbitals[i]);
}
gtklist = new_gtk_list_orbitals(N,Energies,Occ,sym,&widall);
g_object_set_data(G_OBJECT (gtklist), "Type",&type);
frame = gtk_frame_new (_("Beta Orbitals"));
gtk_container_set_border_width (GTK_CONTAINER (frame), 1);
gtk_frame_set_shadow_type( GTK_FRAME(frame),GTK_SHADOW_ETCHED_OUT);
gtk_box_pack_start (GTK_BOX (hboxall), frame, TRUE, TRUE, 0);
gtk_widget_show (frame);
vbox = create_vbox(frame);
scr=gtk_scrolled_window_new(NULL,NULL);
gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (scr),GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
gtk_widget_set_size_request(scr,widall,(gint)(ScreenHeight*WIDTHSCR));
gtk_box_pack_start(GTK_BOX (vbox), scr,TRUE, TRUE, 1);
gtk_container_add(GTK_CONTAINER(scr),gtklist);
set_base_style(gtklist,55000,55000,55000);
gtk_widget_show (scr);
gtk_widget_show (gtklist);
for(i=0;i<N;i++) g_free(sym[i]);
g_free(Energies);
g_free(Occ);
g_free(sym);
g_object_set_data(G_OBJECT (hboxall), "BetaList",gtklist);
return frame;
} | false | false | false | false | false | 0 |
hwi_post_async_buffers(struct beiscsi_hba *phba,
unsigned int is_header, uint8_t ulp_num)
{
struct hwi_controller *phwi_ctrlr;
struct hwi_async_pdu_context *pasync_ctx;
struct async_pdu_handle *pasync_handle;
struct list_head *pfree_link, *pbusy_list;
struct phys_addr *pasync_sge;
unsigned int ring_id, num_entries;
unsigned int host_write_num, doorbell_offset;
unsigned int writables;
unsigned int i = 0;
u32 doorbell = 0;
phwi_ctrlr = phba->phwi_ctrlr;
pasync_ctx = HWI_GET_ASYNC_PDU_CTX(phwi_ctrlr, ulp_num);
num_entries = pasync_ctx->num_entries;
if (is_header) {
writables = min(pasync_ctx->async_header.writables,
pasync_ctx->async_header.free_entries);
pfree_link = pasync_ctx->async_header.free_list.next;
host_write_num = pasync_ctx->async_header.host_write_ptr;
ring_id = phwi_ctrlr->default_pdu_hdr[ulp_num].id;
doorbell_offset = phwi_ctrlr->default_pdu_hdr[ulp_num].
doorbell_offset;
} else {
writables = min(pasync_ctx->async_data.writables,
pasync_ctx->async_data.free_entries);
pfree_link = pasync_ctx->async_data.free_list.next;
host_write_num = pasync_ctx->async_data.host_write_ptr;
ring_id = phwi_ctrlr->default_pdu_data[ulp_num].id;
doorbell_offset = phwi_ctrlr->default_pdu_data[ulp_num].
doorbell_offset;
}
writables = (writables / 8) * 8;
if (writables) {
for (i = 0; i < writables; i++) {
pbusy_list =
hwi_get_async_busy_list(pasync_ctx, is_header,
host_write_num);
pasync_handle =
list_entry(pfree_link, struct async_pdu_handle,
link);
WARN_ON(!pasync_handle);
pasync_handle->consumed = 0;
pfree_link = pfree_link->next;
pasync_sge = hwi_get_ring_address(pasync_ctx,
is_header, host_write_num);
pasync_sge->hi = pasync_handle->pa.u.a32.address_lo;
pasync_sge->lo = pasync_handle->pa.u.a32.address_hi;
list_move(&pasync_handle->link, pbusy_list);
host_write_num++;
host_write_num = host_write_num % num_entries;
}
if (is_header) {
pasync_ctx->async_header.host_write_ptr =
host_write_num;
pasync_ctx->async_header.free_entries -= writables;
pasync_ctx->async_header.writables -= writables;
pasync_ctx->async_header.busy_entries += writables;
} else {
pasync_ctx->async_data.host_write_ptr = host_write_num;
pasync_ctx->async_data.free_entries -= writables;
pasync_ctx->async_data.writables -= writables;
pasync_ctx->async_data.busy_entries += writables;
}
doorbell |= ring_id & DB_DEF_PDU_RING_ID_MASK;
doorbell |= 1 << DB_DEF_PDU_REARM_SHIFT;
doorbell |= 0 << DB_DEF_PDU_EVENT_SHIFT;
doorbell |= (writables & DB_DEF_PDU_CQPROC_MASK)
<< DB_DEF_PDU_CQPROC_SHIFT;
iowrite32(doorbell, phba->db_va + doorbell_offset);
}
} | false | false | false | true | false | 1 |
avg_tpel_pixels_mc00_c(uint8_t *dst, const uint8_t *src, int stride, int width, int height){
switch(width){
case 2: avg_pixels2_c (dst, src, stride, height); break;
case 4: avg_pixels4_c (dst, src, stride, height); break;
case 8: avg_pixels8_c (dst, src, stride, height); break;
case 16:avg_pixels16_c(dst, src, stride, height); break;
}
} | false | false | false | false | false | 0 |
conv_star(struct jmt *jmt, struct lens *lens,
struct state **s, struct state **e,
struct state **f) {
*s = make_state(jmt);
*e = make_state(jmt);
*f = make_state(jmt);
ERR_BAIL(jmt);
struct state *si, *ei, *fi, *scall, *fcall;
conv(jmt, lens->child, &si, &ei, &fi);
thompson(jmt, lens->child, &scall, &fcall);
ERR_BAIL(jmt);
add_eps_trans(jmt, *s, si);
add_eps_trans(jmt, ei, si);
add_eps_trans(jmt, *s, *e);
add_eps_trans(jmt, ei, *e);
add_eps_trans(jmt, fi, scall);
add_eps_trans(jmt, fcall, scall);
add_eps_trans(jmt, fi, *f);
add_eps_trans(jmt, fcall, *f);
ERR_BAIL(jmt);
error:
return;
} | false | false | false | false | false | 0 |
ipath_user_sdma_pin_pages(const struct ipath_devdata *dd,
struct ipath_user_sdma_pkt *pkt,
unsigned long addr, int tlen, int npages)
{
struct page *pages[2];
int j;
int ret;
ret = get_user_pages_fast(addr, npages, 0, pages);
if (ret != npages) {
int i;
for (i = 0; i < ret; i++)
put_page(pages[i]);
ret = -ENOMEM;
goto done;
}
for (j = 0; j < npages; j++) {
/* map the pages... */
const int flen =
ipath_user_sdma_page_length(addr, tlen);
dma_addr_t dma_addr =
dma_map_page(&dd->pcidev->dev,
pages[j], 0, flen, DMA_TO_DEVICE);
unsigned long fofs = offset_in_page(addr);
if (dma_mapping_error(&dd->pcidev->dev, dma_addr)) {
ret = -ENOMEM;
goto done;
}
ipath_user_sdma_init_frag(pkt, pkt->naddr, fofs, flen, 1, 1,
pages[j], kmap(pages[j]),
dma_addr);
pkt->naddr++;
addr += flen;
tlen -= flen;
}
done:
return ret;
} | false | false | false | false | true | 1 |
z_check_unicode (void)
{
zword c = zargs[0];
if (c >= 0x20 && c <= 0x7e)
store (3);
else if (c == 0xa0)
store (1);
else if (c >= 0xa1 && c <= 0xff)
store (3);
else
store (0);
} | false | false | false | false | false | 0 |
contains(const std::string name, bool recurse) const
{
CYG_REPORT_FUNCNAMETYPE("CdlContainer::contains (name)", "result %d");
CYG_REPORT_FUNCARG2XV(this, recurse);
CYG_PRECONDITION_THISC();
CYG_PRECONDITIONC("" != name);
bool result = false;
std::vector<CdlNode>::const_iterator node_i;
for (node_i = contents.begin(); node_i != contents.end(); node_i++) {
if ((*node_i)->get_name() == name) {
result = true;
break;
}
if (recurse) {
CdlConstContainer child = dynamic_cast<CdlConstContainer>(*node_i);
if ((0 != child) && child->contains(name, true)) {
result = true;
break;
}
}
}
CYG_REPORT_RETVAL(result);
return result;
} | false | false | false | false | false | 0 |
refreshContactPoints(const btTransform& trA,const btTransform& trB)
{
int i;
#ifdef DEBUG_PERSISTENCY
printf("refreshContactPoints posA = (%f,%f,%f) posB = (%f,%f,%f)\n",
trA.getOrigin().getX(),
trA.getOrigin().getY(),
trA.getOrigin().getZ(),
trB.getOrigin().getX(),
trB.getOrigin().getY(),
trB.getOrigin().getZ());
#endif //DEBUG_PERSISTENCY
/// first refresh worldspace positions and distance
for (i=getNumContacts()-1;i>=0;i--)
{
btManifoldPoint &manifoldPoint = m_pointCache[i];
manifoldPoint.m_positionWorldOnA = trA( manifoldPoint.m_localPointA );
manifoldPoint.m_positionWorldOnB = trB( manifoldPoint.m_localPointB );
manifoldPoint.m_distance1 = (manifoldPoint.m_positionWorldOnA - manifoldPoint.m_positionWorldOnB).dot(manifoldPoint.m_normalWorldOnB);
manifoldPoint.m_lifeTime++;
}
/// then
btScalar distance2d;
btVector3 projectedDifference,projectedPoint;
for (i=getNumContacts()-1;i>=0;i--)
{
btManifoldPoint &manifoldPoint = m_pointCache[i];
//contact becomes invalid when signed distance exceeds margin (projected on contactnormal direction)
if (!validContactDistance(manifoldPoint))
{
removeContactPoint(i);
} else
{
//contact also becomes invalid when relative movement orthogonal to normal exceeds margin
projectedPoint = manifoldPoint.m_positionWorldOnA - manifoldPoint.m_normalWorldOnB * manifoldPoint.m_distance1;
projectedDifference = manifoldPoint.m_positionWorldOnB - projectedPoint;
distance2d = projectedDifference.dot(projectedDifference);
if (distance2d > getContactBreakingThreshold()*getContactBreakingThreshold() )
{
removeContactPoint(i);
} else
{
//contact point processed callback
if (gContactProcessedCallback)
(*gContactProcessedCallback)(manifoldPoint,m_body0,m_body1);
}
}
}
#ifdef DEBUG_PERSISTENCY
DebugPersistency();
#endif //
} | false | false | false | false | false | 0 |
rc_input_new_inet(const char *path, int type) {
char *s_addr, *s_port;
uint32_t addr;
int port;
struct sockaddr_in sin;
int fd;
if (!(s_port = strchr(path, ':'))) {
errno = EINVAL;
return -1;
}
s_addr = xstrndup(path, s_port - path);
addr = inet_addr(s_addr);
port = atoi(s_port + 1);
xfree(s_addr);
sin.sin_family = AF_INET;
sin.sin_port = htons(port);
sin.sin_addr.s_addr = addr;
if ((fd = socket(AF_INET, type, 0)) == -1)
return -1;
if (connect(fd, (struct sockaddr*) &sin, sizeof(sin))) {
int err = errno;
close(fd);
errno = err;
return -1;
}
return fd;
} | false | false | false | false | false | 0 |
qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
{
if (_c == QMetaObject::InvokeMetaMethod) {
Q_ASSERT(staticMetaObject.cast(_o));
MediaInfo *_t = static_cast<MediaInfo *>(_o);
switch (_id) {
case 0: _t->pruneVol(); break;
case 1: _t->purgeVol(); break;
case 2: _t->deleteVol(); break;
case 3: _t->editVol(); break;
case 4: _t->showInfoForJob((*reinterpret_cast< QTableWidgetItem*(*)>(_a[1]))); break;
default: ;
}
}
} | false | false | false | false | false | 0 |
esl_dmatrix_Destroy(ESL_DMATRIX *A)
{
if (A != NULL && A->mx != NULL && A->mx[0] != NULL) free(A->mx[0]);
if (A != NULL && A->mx != NULL) free(A->mx);
if (A != NULL) free(A);
return eslOK;
} | false | false | false | false | false | 0 |
sumEvenTermsFib (const int max) {
int sum = 0;
int last = 0;
int n = 2;
int nextEven;
while (n < ONE_MILLION) {
sum += n;
nextEven = n * 4 + last;
last = n;
n = nextEven;
}
return sum;
} | false | false | false | false | false | 0 |
update_clip(const struct adapter *adap)
{
int i;
struct net_device *dev;
int ret;
rcu_read_lock();
for (i = 0; i < MAX_NPORTS; i++) {
dev = adap->port[i];
ret = 0;
if (dev)
ret = cxgb4_update_root_dev_clip(dev);
if (ret < 0)
break;
}
rcu_read_unlock();
} | false | false | false | false | false | 0 |
build_path_tlist(PlannerInfo *root, Path *path)
{
RelOptInfo *rel = path->parent;
List *tlist = NIL;
int resno = 1;
ListCell *v;
foreach(v, rel->reltargetlist)
{
/* Do we really need to copy here? Not sure */
Node *node = (Node *) copyObject(lfirst(v));
/*
* If it's a parameterized path, there might be lateral references in
* the tlist, which need to be replaced with Params. There's no need
* to remake the TargetEntry nodes, so apply this to each list item
* separately.
*/
if (path->param_info)
node = replace_nestloop_params(root, node);
tlist = lappend(tlist, makeTargetEntry((Expr *) node,
resno,
NULL,
false));
resno++;
}
return tlist;
} | false | false | false | false | false | 0 |
perl_script_load_data(const char *data)
{
char *name;
g_return_val_if_fail(data != NULL, NULL);
name = script_data_get_name();
return script_load(name, NULL, data);
} | false | false | false | false | false | 0 |
addVar(const Variable *var,
VariableType type,
bool write_)
{
if (var->declarationId() > 0) {
_varAddedInScope.back().insert(var->declarationId());
_varUsage.insert(std::make_pair(var->declarationId(), VariableUsage(var, type, false, write_, false)));
}
} | false | false | false | false | false | 0 |
insertRows( int position, int rows, const QModelIndex &parent )
{
Q_UNUSED( parent );
beginInsertRows( QModelIndex(), position, position+rows-1 );
for ( int row = 0; row < rows; ++row )
{
m_labels.insert( position, "" );
}
endInsertRows();
return true;
} | false | false | false | false | false | 0 |
set32x64Bits(uint32_t table[64], int32_t start, int32_t limit) {
U_ASSERT(start<limit);
U_ASSERT(limit<=0x800);
int32_t lead=start>>6; // Named for UTF-8 2-byte lead byte with upper 5 bits.
int32_t trail=start&0x3f; // Named for UTF-8 2-byte trail byte with lower 6 bits.
// Set one bit indicating an all-one block.
uint32_t bits=(uint32_t)1<<lead;
if((start+1)==limit) { // Single-character shortcut.
table[trail]|=bits;
return;
}
int32_t limitLead=limit>>6;
int32_t limitTrail=limit&0x3f;
if(lead==limitLead) {
// Partial vertical bit column.
while(trail<limitTrail) {
table[trail++]|=bits;
}
} else {
// Partial vertical bit column,
// followed by a bit rectangle,
// followed by another partial vertical bit column.
if(trail>0) {
do {
table[trail++]|=bits;
} while(trail<64);
++lead;
}
if(lead<limitLead) {
bits=~((1<<lead)-1);
if(limitLead<0x20) {
bits&=(1<<limitLead)-1;
}
for(trail=0; trail<64; ++trail) {
table[trail]|=bits;
}
}
// limit<=0x800. If limit==0x800 then limitLead=32 and limitTrail=0.
// In that case, bits=1<<limitLead is undefined but the bits value
// is not used because trail<limitTrail is already false.
bits=(uint32_t)1<<((limitLead == 0x20) ? (limitLead - 1) : limitLead);
for(trail=0; trail<limitTrail; ++trail) {
table[trail]|=bits;
}
}
} | false | false | false | false | true | 1 |
ath9k_hw_ani_setup(struct ath_hw *ah)
{
int i;
static const int totalSizeDesired[] = { -55, -55, -55, -55, -62 };
static const int coarseHigh[] = { -14, -14, -14, -14, -12 };
static const int coarseLow[] = { -64, -64, -64, -64, -70 };
static const int firpwr[] = { -78, -78, -78, -78, -80 };
for (i = 0; i < 5; i++) {
ah->totalSizeDesired[i] = totalSizeDesired[i];
ah->coarse_high[i] = coarseHigh[i];
ah->coarse_low[i] = coarseLow[i];
ah->firpwr[i] = firpwr[i];
}
} | false | false | false | false | false | 0 |
locale_from_utf8(const std::string& input) {
GError* error_p = 0;
gsize written = 0;
GcharScopedHandle result_h(g_locale_from_utf8(input.data(), input.size(), 0,
&written, &error_p));
if (error_p) {
GerrorScopedHandle handle_h(error_p);
throw ConversionError(error_p);
}
return std::string(result_h.get(), written);
} | false | false | false | false | false | 0 |
Stop() {
if (!enabled()) {
return;
}
// Move data from hash table to eviction buffer
for (int b = 0; b < kBuckets; b++) {
Bucket* bucket = &hash_[b];
for (int a = 0; a < kAssociativity; a++) {
if (bucket->entry[a].count > 0) {
Evict(bucket->entry[a]);
}
}
}
if (num_evicted_ + 3 > kBufferLength) {
// Ensure there is enough room for end of data marker
FlushEvicted();
}
// Write end of data marker
evict_[num_evicted_++] = 0; // count
evict_[num_evicted_++] = 1; // depth
evict_[num_evicted_++] = 0; // end of data marker
FlushEvicted();
// Dump "/proc/self/maps" so we get list of mapped shared libraries
DumpProcSelfMaps(out_);
Reset();
fprintf(stderr, "PROFILE: interrupts/evictions/bytes = %d/%d/%" PRIuS "\n",
count_, evictions_, total_bytes_);
} | false | false | false | false | false | 0 |
btrfs_init_delayed_node(
struct btrfs_delayed_node *delayed_node,
struct btrfs_root *root, u64 inode_id)
{
delayed_node->root = root;
delayed_node->inode_id = inode_id;
atomic_set(&delayed_node->refs, 0);
delayed_node->count = 0;
delayed_node->flags = 0;
delayed_node->ins_root = RB_ROOT;
delayed_node->del_root = RB_ROOT;
mutex_init(&delayed_node->mutex);
delayed_node->index_cnt = 0;
INIT_LIST_HEAD(&delayed_node->n_list);
INIT_LIST_HEAD(&delayed_node->p_list);
delayed_node->bytes_reserved = 0;
memset(&delayed_node->inode_item, 0, sizeof(delayed_node->inode_item));
} | false | false | false | false | false | 0 |
ast_lookup_path(char *path, struct gfs2_sbd *sbd)
{
int err = 0;
char *c;
struct gfs2_inode *ip, *iptmp;
char *segment;
uint64_t bn = 0;
segment = strtok_r(path, "/", &c);
ip = lgfs2_inode_read(sbd, sbd->sd_sb.sb_root_dir.no_addr);
while (ip != NULL) {
if (segment == NULL) { // No more segments
bn = ip->i_di.di_num.no_addr;
inode_put(&ip);
return bn;
}
ast_string_unescape(segment);
err = gfs2_lookupi(ip, segment, strlen(segment), &iptmp);
inode_put(&ip);
if (err != 0) {
errno = -err;
break;
}
ip = iptmp;
segment = strtok_r(NULL, "/", &c);
}
return 0;
} | false | false | false | false | false | 0 |
setItems(const QList<MUCItem>& items)
{
MUCItemsTask* t = new MUCItemsTask(room_, client_->rootTask());
connect(t,SIGNAL(finished()),SLOT(setItems_finished()));
t->set(items);
t->go(true);
} | false | false | false | false | false | 0 |
rb_ipod_db_set_thumbnail_internal (RbIpodDb *ipod_db,
Itdb_Track *track,
GdkPixbuf *pixbuf)
{
g_return_if_fail (track != NULL);
g_return_if_fail (pixbuf != NULL);
itdb_track_set_thumbnails_from_pixbuf (track, pixbuf);
rb_ipod_db_save_async (ipod_db);
} | false | false | false | false | false | 0 |
_cirrus_pci_read_cirrus(unsigned char addr)
{
uint16_t bus;
uint8_t dev;
uint32_t value;
/* scan all pci devices for the cirrus */
for (bus = 0; bus < 256; bus++) {
for (dev = 0; dev < 0x20; dev++) {
/* read PCI0 device/vendor id */
value = _cirrus_pci_read(bus, dev, 0, 0);
/* are we at home? */
if (value == CIRRUS_DEVICE_VENDOR_ID) {
value = _cirrus_pci_read(bus, dev, 0, addr);
return value;
}
}
}
assert(0);
return 0;
} | false | false | false | false | false | 0 |
flip(const int horz,
const int vert)
{
switch (InterData->getRepresentation())
{
case EPR_Uint8:
{
DiFlipTemplate<Uint8> dummy(InterData, Columns, Rows, NumberOfFrames, horz, vert);
}
break;
case EPR_Uint16:
{
DiFlipTemplate<Uint16> dummy(InterData, Columns, Rows, NumberOfFrames, horz, vert);
}
break;
case EPR_Uint32:
{
DiFlipTemplate<Uint32> dummy(InterData, Columns, Rows, NumberOfFrames, horz, vert);
}
break;
default:
DCMIMAGE_WARN("invalid value for inter-representation");
}
return 1;
} | false | false | false | false | false | 0 |
pixBlockconvGray(PIX *pixs,
PIX *pixacc,
l_int32 wc,
l_int32 hc)
{
l_int32 w, h, d, wpl, wpla;
l_uint32 *datad, *dataa;
PIX *pixd, *pixt;
PROCNAME("pixBlockconvGray");
if (!pixs)
return (PIX *)ERROR_PTR("pixs not defined", procName, NULL);
pixGetDimensions(pixs, &w, &h, &d);
if (d != 8)
return (PIX *)ERROR_PTR("pixs not 8 bpp", procName, NULL);
if (wc < 0) wc = 0;
if (hc < 0) hc = 0;
if (w < 2 * wc + 1 || h < 2 * hc + 1) {
wc = L_MIN(wc, (w - 1) / 2);
hc = L_MIN(hc, (h - 1) / 2);
L_WARNING("kernel too large; reducing!\n", procName);
L_INFO("wc = %d, hc = %d\n", procName, wc, hc);
}
if (wc == 0 && hc == 0) /* no-op */
return pixCopy(NULL, pixs);
if (pixacc) {
if (pixGetDepth(pixacc) == 32) {
pixt = pixClone(pixacc);
} else {
L_WARNING("pixacc not 32 bpp; making new one\n", procName);
if ((pixt = pixBlockconvAccum(pixs)) == NULL)
return (PIX *)ERROR_PTR("pixt not made", procName, NULL);
}
} else {
if ((pixt = pixBlockconvAccum(pixs)) == NULL)
return (PIX *)ERROR_PTR("pixt not made", procName, NULL);
}
if ((pixd = pixCreateTemplate(pixs)) == NULL) {
pixDestroy(&pixt);
return (PIX *)ERROR_PTR("pixd not made", procName, NULL);
}
wpl = pixGetWpl(pixs);
wpla = pixGetWpl(pixt);
datad = pixGetData(pixd);
dataa = pixGetData(pixt);
blockconvLow(datad, w, h, wpl, dataa, wpla, wc, hc);
pixDestroy(&pixt);
return pixd;
} | false | false | false | false | false | 0 |
stash_group_free(StashGroup *group)
{
StashPref *entry;
guint i;
foreach_ptr_array(entry, i, group->entries)
{
if (entry->widget_type == GTK_TYPE_RADIO_BUTTON)
{
g_free(entry->extra.radio_buttons);
}
g_slice_free(StashPref, entry);
}
g_ptr_array_free(group->entries, TRUE);
g_free(group);
} | false | false | false | false | false | 0 |
iso_date(u8 *p, int flag)
{
int year, month, day, hour, minute, second, tz;
int crtime;
year = p[0];
month = p[1];
day = p[2];
hour = p[3];
minute = p[4];
second = p[5];
if (flag == 0) tz = p[6]; /* High sierra has no time zone */
else tz = 0;
if (year < 0) {
crtime = 0;
} else {
crtime = mktime64(year+1900, month, day, hour, minute, second);
/* sign extend */
if (tz & 0x80)
tz |= (-1 << 8);
/*
* The timezone offset is unreliable on some disks,
* so we make a sanity check. In no case is it ever
* more than 13 hours from GMT, which is 52*15min.
* The time is always stored in localtime with the
* timezone offset being what get added to GMT to
* get to localtime. Thus we need to subtract the offset
* to get to true GMT, which is what we store the time
* as internally. On the local system, the user may set
* their timezone any way they wish, of course, so GMT
* gets converted back to localtime on the receiving
* system.
*
* NOTE: mkisofs in versions prior to mkisofs-1.10 had
* the sign wrong on the timezone offset. This has now
* been corrected there too, but if you are getting screwy
* results this may be the explanation. If enough people
* complain, a user configuration option could be added
* to add the timezone offset in with the wrong sign
* for 'compatibility' with older discs, but I cannot see how
* it will matter that much.
*
* Thanks to kuhlmav@elec.canterbury.ac.nz (Volker Kuhlmann)
* for pointing out the sign error.
*/
if (-52 <= tz && tz <= 52)
crtime -= tz * 15 * 60;
}
return crtime;
} | false | false | false | false | false | 0 |
sortByArtist()
{
setLevels( QList<CategoryId::CatMenuId>() << CategoryId::Artist );
} | false | false | false | false | false | 0 |
random_laplace (gnm_float a)
{
gnm_float u;
do {
u = 2 * random_01 () - 1.0;
} while (u == 0.0);
if (u < 0)
return a * gnm_log (-u);
else
return -a * gnm_log (u);
} | false | false | false | false | false | 0 |
ipmi_intf_session_set_username(struct ipmi_intf * intf, char * username)
{
if (intf->session == NULL)
return;
memset(intf->session->username, 0, 17);
if (username == NULL)
return;
memcpy(intf->session->username, username, __min(strlen(username), 16));
} | false | true | false | false | false | 1 |
qlocationutils_readVtg(const char *data, int size, QGeoPositionInfo *info, bool *hasFix)
{
if (hasFix)
*hasFix = false;
QByteArray sentence(data, size);
QList<QByteArray> parts = sentence.split(',');
bool parsed = false;
double value = 0.0;
if (parts.count() > 1 && parts[1].count() > 0) {
value = parts[1].toDouble(&parsed);
if (parsed)
info->setAttribute(QGeoPositionInfo::Direction, qreal(value));
}
if (parts.count() > 7 && parts[7].count() > 0) {
value = parts[7].toDouble(&parsed);
if (parsed)
info->setAttribute(QGeoPositionInfo::GroundSpeed, qreal(value / 3.6)); // km/h -> m/s
}
} | false | false | false | false | false | 0 |
printMinoltaExposureCompensation5D(std::ostream& os, const Value& value, const ExifData*)
{
std::ostringstream oss;
oss.copyfmt(os);
os << std::fixed << std::setprecision(2)
<< (float (value.toLong()-300)/100);
os.copyfmt(oss);
return os;
} | false | false | false | false | false | 0 |
posix_cpu_clock_set(const clockid_t which_clock, const struct timespec *tp)
{
/*
* You can never reset a CPU clock, but we check for other errors
* in the call before failing with EPERM.
*/
int error = check_clock(which_clock);
if (error == 0) {
error = -EPERM;
}
return error;
} | false | false | false | false | false | 0 |
List_do_with_(List *self, ListDoWithCallback *callback, void *arg)
{
LIST_FOREACH(self, i, v, if (v) (*callback)(v, arg));
} | false | false | false | false | false | 0 |
ffe(node_t * u, elist uL, node_t * v, elist vL)
{
int i;
edge_t *e;
if ((uL.size > 0) && (vL.size > 0)) {
if (uL.size < vL.size) {
for (i = 0; (e = uL.list[i]); i++)
if (aghead(e) == v)
break;
} else {
for (i = 0; (e = vL.list[i]); i++)
if (agtail(e) == u)
break;
}
} else
e = 0;
return e;
} | false | false | false | false | false | 0 |
subcat( int category ) {
InnerNode* currNode;
InnerNode* siblingNode;
vector<int> ancestorCategories;
vector<int> siblingCategories;
getAncestors( ancestorCategories, category );
currNode = &_root;
//erase all nodes except the node having the input category and its descendants
for( int i=0; i < ancestorCategories.size(); i++ ) {
currNode = convertCategroyToInnerNode( ancestorCategories[i] );
getSiblings( siblingCategories, currNode->getCategory() );
for( int j=0; j < siblingCategories.size(); j++ ) {
siblingNode = convertCategroyToInnerNode( siblingCategories[j] );
if ( siblingNode->getCategory() != currNode->getCategory() ) {
eraseHierarchy( siblingNode );
delete siblingNode;
siblingNode = NULL;
}
}
//we don't delete the new root
if ( i < ancestorCategories.size()-1 ) {
delete currNode;
currNode = NULL;
}
}
_root.clear();
//copy the children into the root element, and update their parent pointer
_root.adoptChildren( currNode );
delete currNode;
updateMemberVariables();
} | false | false | false | false | true | 1 |
gee_hazard_pointer_get (GeeHazardPointer* self, gboolean other_thread) {
gconstpointer result = NULL;
GeeHazardPointerNode* _tmp0_ = NULL;
gboolean _tmp1_ = FALSE;
void* _tmp2_ = NULL;
g_return_val_if_fail (self != NULL, NULL);
_tmp0_ = self->_node;
_tmp1_ = other_thread;
_tmp2_ = gee_hazard_pointer_node_get (_tmp0_, _tmp1_);
result = _tmp2_;
return result;
} | false | false | false | false | false | 0 |
ShallowCopy(vtkTextProperty *tprop)
{
if (!tprop)
{
return;
}
this->SetColor(tprop->GetColor());
this->SetOpacity(tprop->GetOpacity());
this->SetFontFamilyAsString(tprop->GetFontFamilyAsString());
this->SetFontSize(tprop->GetFontSize());
this->SetBold(tprop->GetBold());
this->SetItalic(tprop->GetItalic());
this->SetShadow(tprop->GetShadow());
this->SetOrientation(tprop->GetOrientation());
this->SetJustification(tprop->GetJustification());
this->SetVerticalJustification(tprop->GetVerticalJustification());
this->SetLineOffset(tprop->GetLineOffset());
this->SetLineSpacing(tprop->GetLineSpacing());
this->SetShadowOffset(tprop->GetShadowOffset());
} | false | false | false | false | false | 0 |
is_listall_mode(void)
{
return (!get_match(COL_SOURCE) &&
!get_match(COL_TARGET) &&
!get_match(COL_FSTYPE) &&
!get_match(COL_OPTIONS));
} | false | false | false | false | false | 0 |
igb_put_hw_semaphore_generic(struct e1000_hw *hw)
{
u32 swsm;
DEBUGFUNC("igb_put_hw_semaphore_generic");
swsm = E1000_READ_REG(hw, E1000_SWSM);
swsm &= ~(E1000_SWSM_SMBI | E1000_SWSM_SWESMBI);
E1000_WRITE_REG(hw, E1000_SWSM, swsm);
} | false | false | false | false | false | 0 |
DeleteChild (Widget w) {
ArrayWidget aw;
CompositeWidgetClass sclass;
int ci;
sclass = (CompositeWidgetClass) compositeWidgetClass;
(*sclass->composite_class.delete_child) (w);
aw = (ArrayWidget) XtParent (w);
for (ci = 0; ci < aw->array.data.cj; ci++)
if (aw->array.data.carray[ci].w == w)
break;
if (ci < aw->array.data.cj) {
for (; ci + 1 < aw->array.data.cj; ci++)
aw->array.data.carray[ci].w = aw->array.data.carray[ci + 1].w;
aw->array.data.cj--;
}
} | false | false | false | false | false | 0 |
FastMeter (long hold, unsigned long dimen, Orientation o, int len, int clr0, int clr1, int clr2, int clr3)
{
orientation = o;
hold_cnt = hold;
hold_state = 0;
current_peak = 0;
current_level = 0;
last_peak_rect.width = 0;
last_peak_rect.height = 0;
rgb0 = clr0;
rgb1 = clr1;
rgb2 = clr2;
rgb3 = clr3;
set_events (BUTTON_PRESS_MASK|BUTTON_RELEASE_MASK);
pixrect.x = 0;
pixrect.y = 0;
if (orientation == Vertical) {
if (!len)
len = 250;
pixbuf = request_vertical_meter(dimen, len);
} else {
if (!len)
len = 186;
pixbuf = request_horizontal_meter(len, dimen);
}
pixheight = pixbuf->get_height();
pixwidth = pixbuf->get_width();
if (orientation == Vertical) {
pixrect.width = min (pixwidth, (gint) dimen);
pixrect.height = pixheight;
} else {
pixrect.width = pixwidth;
pixrect.height = min (pixheight, (gint) dimen);
}
request_width = pixrect.width;
request_height= pixrect.height;
} | false | false | false | false | false | 0 |
bfa_msix_all(struct bfa_s *bfa, int vec)
{
u32 intr, qintr;
int queue;
intr = readl(bfa->iocfc.bfa_regs.intr_status);
if (!intr)
return;
/*
* RME completion queue interrupt
*/
qintr = intr & __HFN_INT_RME_MASK;
if (qintr && bfa->queue_process) {
for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++)
bfa_isr_rspq(bfa, queue);
}
intr &= ~qintr;
if (!intr)
return;
/*
* CPE completion queue interrupt
*/
qintr = intr & __HFN_INT_CPE_MASK;
if (qintr && bfa->queue_process) {
for (queue = 0; queue < BFI_IOC_MAX_CQS; queue++)
bfa_isr_reqq(bfa, queue);
}
intr &= ~qintr;
if (!intr)
return;
bfa_msix_lpu_err(bfa, intr);
} | false | false | false | false | false | 0 |
vim_dialog_yesno(type, title, message, dflt)
int type;
char_u *title;
char_u *message;
int dflt;
{
if (do_dialog(type,
title == NULL ? (char_u *)_("Question") : title,
message,
(char_u *)_("&Yes\n&No"), dflt, NULL) == 1)
return VIM_YES;
return VIM_NO;
} | false | false | false | false | false | 0 |
wilc_wlan_txq_add_mgmt_pkt(void *priv, u8 *buffer, u32 buffer_size, wilc_tx_complete_func_t func)
{
wilc_wlan_dev_t *p = &g_wlan;
struct txq_entry_t *tqe;
if (p->quit)
return 0;
tqe = kmalloc(sizeof(struct txq_entry_t), GFP_KERNEL);
if (tqe == NULL)
return 0;
tqe->type = WILC_MGMT_PKT;
tqe->buffer = buffer;
tqe->buffer_size = buffer_size;
tqe->tx_complete_func = func;
tqe->priv = priv;
#ifdef TCP_ACK_FILTER
tqe->tcp_PendingAck_index = NOT_TCP_ACK;
#endif
PRINT_D(TX_DBG, "Adding Network packet at the Queue tail\n");
wilc_wlan_txq_add_to_tail(tqe);
return 1;
} | false | false | false | false | false | 0 |
setPluginEnabled( bool enabled )
{
KPLUGININFO_ISVALID_ASSERTION;
//kDebug( d->debugArea() ) ;
d->pluginenabled = enabled;
} | false | false | false | false | false | 0 |
cst_track_resize(cst_track *t,int num_frames, int num_channels)
{
float *n_times;
float **n_frames;
int i;
n_times = cst_alloc(float,num_frames);
memmove(n_times,t->times,
(sizeof(float)*((num_frames < t->num_frames) ?
num_frames : t->num_frames)));
n_frames = cst_alloc(float*,num_frames);
for (i=0; i<num_frames; i++)
{
n_frames[i] = cst_alloc(float,num_channels);
if (i<t->num_frames)
{
memmove(n_frames[i],
t->frames[i],
sizeof(float)*((num_channels < t->num_channels) ?
num_channels : t->num_channels));
cst_free(t->frames[i]);
}
}
for ( ; i<t->num_frames; i++)
cst_free(t->frames[i]);
cst_free(t->frames);
t->frames = n_frames;
cst_free(t->times);
t->times = n_times;
t->num_frames = num_frames;
t->num_channels = num_channels;
} | false | false | false | false | false | 0 |
end_word(count, bigword, stop, empty)
long count;
int bigword;
int stop;
int empty;
{
int sclass; /* starting class */
#ifdef FEAT_VIRTUALEDIT
curwin->w_cursor.coladd = 0;
#endif
cls_bigword = bigword;
while (--count >= 0)
{
#ifdef FEAT_FOLDING
/* When inside a range of folded lines, move to the last char of the
* last line. */
if (hasFolding(curwin->w_cursor.lnum, NULL, &curwin->w_cursor.lnum))
coladvance((colnr_T)MAXCOL);
#endif
sclass = cls();
if (inc_cursor() == -1)
return FAIL;
/*
* If we're in the middle of a word, we just have to move to the end
* of it.
*/
if (cls() == sclass && sclass != 0)
{
/*
* Move forward to end of the current word
*/
if (skip_chars(sclass, FORWARD))
return FAIL;
}
else if (!stop || sclass == 0)
{
/*
* We were at the end of a word. Go to the end of the next word.
* First skip white space, if 'empty' is TRUE, stop at empty line.
*/
while (cls() == 0)
{
if (empty && curwin->w_cursor.col == 0
&& lineempty(curwin->w_cursor.lnum))
goto finished;
if (inc_cursor() == -1) /* hit end of file, stop here */
return FAIL;
}
/*
* Move forward to the end of this word.
*/
if (skip_chars(cls(), FORWARD))
return FAIL;
}
dec_cursor(); /* overshot - one char backward */
finished:
stop = FALSE; /* we move only one word less */
}
return OK;
} | false | false | false | false | false | 0 |
irmo_connection_method_call(IrmoConnection *conn,
IrmoMethodData *data)
{
if (conn->state != IRMO_CLIENT_CONNECTED
&& conn->state != IRMO_CLIENT_SYNCHRONIZED) {
return;
}
// Add a new sendatom for this method call.
irmo_client_sendq_add_method(conn, data);
} | false | false | false | false | false | 0 |
asset_loaded_cb (GObject * source, GAsyncResult * res, GMainLoop * mainloop)
{
GESUriClipAsset *mfs =
GES_URI_CLIP_ASSET (ges_asset_request_finish (res, NULL));
GstDiscovererInfo *discoverer_info = NULL;
discoverer_info = ges_uri_clip_asset_get_info (mfs);
GST_DEBUG ("Result is %d", gst_discoverer_info_get_result (discoverer_info));
GST_DEBUG ("Info type is %s", G_OBJECT_TYPE_NAME (mfs));
GST_DEBUG ("Duration is %" GST_TIME_FORMAT,
GST_TIME_ARGS (ges_uri_clip_asset_get_duration (mfs)));
gst_object_unref (mfs);
g_main_loop_quit (mainloop);
} | false | false | false | false | false | 0 |
gftp_free_bookmark (gftp_bookmarks_var * entry, int free_node)
{
gftp_bookmarks_var * tempentry;
if (entry->path)
g_free (entry->path);
if (entry->oldpath)
g_free (entry->oldpath);
if (entry->hostname)
g_free (entry->hostname);
if (entry->remote_dir)
g_free (entry->remote_dir);
if (entry->local_dir)
g_free (entry->local_dir);
if (entry->user)
g_free (entry->user);
if (entry->pass)
g_free (entry->pass);
if (entry->acct)
g_free (entry->acct);
if (entry->protocol)
g_free (entry->protocol);
if (entry->local_options_vars != NULL)
{
gftp_config_free_options (entry->local_options_vars,
entry->local_options_hash,
entry->num_local_options_vars);
entry->local_options_vars = NULL;
entry->local_options_hash = NULL;
entry->num_local_options_vars = 0;
}
if (free_node)
g_free (entry);
else
{
tempentry = entry->children;
memset (entry, 0, sizeof (*entry));
entry->children = tempentry;
}
} | false | false | false | false | false | 0 |
setAlpha( gfloat alpha )
{
g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) );
setColorAlpha( _color, alpha );
} | false | false | false | false | false | 0 |
asyncQueueUnregister(void)
{
bool advanceTail;
Assert(listenChannels == NIL); /* else caller error */
LWLockAcquire(AsyncQueueLock, LW_SHARED);
/* check if entry is valid and oldest ... */
advanceTail = (MyProcPid == QUEUE_BACKEND_PID(MyBackendId)) &&
QUEUE_POS_EQUAL(QUEUE_BACKEND_POS(MyBackendId), QUEUE_TAIL);
/* ... then mark it invalid */
QUEUE_BACKEND_PID(MyBackendId) = InvalidPid;
LWLockRelease(AsyncQueueLock);
/* If we were the laziest backend, try to advance the tail pointer */
if (advanceTail)
asyncQueueAdvanceTail();
} | false | false | false | false | false | 0 |
Read(Lexer & lex, string const & token, string const & bufpath)
{
if (token == "filename") {
lex.eatLine();
filename.set(lex.getString(), bufpath);
} else if (token == "lyxscale") {
lex.next();
lyxscale = lex.getInteger();
} else if (token == "display") {
lex.next();
string const type = lex.getString();
display = lex.getString() != "false";
} else if (token == "scale") {
lex.next();
scale = lex.getString();
} else if (token == "width") {
lex.next();
width = Length(lex.getString());
scale = string();
} else if (token == "height") {
lex.next();
height = Length(lex.getString());
scale = string();
} else if (token == "keepAspectRatio") {
keepAspectRatio = true;
} else if (token == "draft") {
draft = true;
} else if (token == "noUnzip") {
noUnzip = true;
} else if (token == "scaleBeforeRotation") {
scaleBeforeRotation = true;
} else if (token == "BoundingBox") {
bb.erase();
for (int i = 0; i < 4; ++i) {
if (i != 0)
bb += ' ';
lex.next();
bb += lex.getString();
}
} else if (token == "clip") {
clip = true;
} else if (token == "rotateAngle") {
lex.next();
rotateAngle = lex.getString();
} else if (token == "rotateOrigin") {
lex.next();
rotateOrigin=lex.getString();
} else if (token == "special") {
lex.eatLine();
special = lex.getString();
} else if (token == "groupId") {
lex.eatLine();
groupId = lex.getString();
// catch and ignore following two old-format tokens and their arguments.
// e.g. "size_kind scale" clashes with the setting of the
// "scale <value>" keyword.
} else if (token == "size_kind" || token == "lyxsize_kind") {
lex.next();
lex.getString();
} else {
// If it's none of the above, it's not ours.
return false;
}
return true;
} | false | false | false | false | false | 0 |
IsTriggeredSpellWithRedundentCastTime() const
{
return m_IsTriggeredSpell && (m_spellInfo->manaCost || m_spellInfo->ManaCostPercentage);
} | false | false | false | false | false | 0 |
setStyle(int index)
{
if (currentStyle == STYLE_BAR) degrade(bar);
else degrade(water);
switch (index) {
case 0 : // BAR
bar = (Bar*)this->setPlotStyle(Bar(this));
showNormals(false);
updateNormals();
currentStyle = STYLE_BAR;
break;
case 1 : // SURFACE GRID
setPlotStyle(FILLEDMESH);
water = (Water *)addEnrichment(Water(this));
showNormals(false);
updateNormals();
currentStyle = STYLE_GRID;
break;
case 2 : // SURFACE SMOOTH
setPlotStyle(FILLED);
water = (Water *)addEnrichment(Water(this));
showNormals(false);
updateNormals();
currentStyle = STYLE_SURFACE;
break;
case 3 : // DOTS
setPlotStyle(Dot(10,10));
water = (Water *)addEnrichment(Water(this));
showNormals(false);
updateNormals();
currentStyle = STYLE_DOTS;
break;
}
updateData();
updateGL();
} | 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.