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 |
|---|---|---|---|---|---|---|
get_allocated_undo_memory_size(void)
{
int i = 0;
size_t dynamic_memory_size = (size_t)(
active_z_story->dynamic_memory_end - z_mem + 1 );
size_t result
= ( sizeof(struct undo_frame*) * max_undo_steps )
+ ( undo_index * (sizeof(struct undo_frame) + dynamic_memory_size) );
while (i < undo_index)
result += undo_frames[i++]->z_stack_size * sizeof(uint16_t);
return result;
} | false | false | false | false | false | 0 |
callAsFunction(ExecState *exec, JSObject * /*thisObj*/, const List &args)
{
fprintf(stderr,"--> %s\n",args[0]->toString(exec).ascii());
return jsUndefined();
} | false | false | false | false | false | 0 |
gst_mss_stream_get_current_bitrate (GstMssStream * stream)
{
GstMssStreamQuality *q;
if (stream->current_quality == NULL)
return 0;
q = stream->current_quality->data;
return q->bitrate;
} | false | false | false | false | false | 0 |
io_open(struct io *io, const char *name)
{
init_io(io, NULL, IO_FD);
io->pipe = *name ? open(name, O_RDONLY) : STDIN_FILENO;
return io->pipe != -1;
} | false | false | false | false | false | 0 |
get_generic_param (VerifyContext *ctx, MonoType *param)
{
guint16 param_num = mono_type_get_generic_param_num (param);
if (param->type == MONO_TYPE_VAR) {
if (!ctx->generic_context->class_inst || ctx->generic_context->class_inst->type_argc <= param_num) {
ADD_VERIFY_ERROR (ctx, g_strdup_printf ("Invalid generic type argument %d", param_num));
return NULL;
}
return ctx->generic_context->class_inst->type_argv [param_num]->data.generic_param;
}
/*param must be a MVAR */
if (!ctx->generic_context->method_inst || ctx->generic_context->method_inst->type_argc <= param_num) {
ADD_VERIFY_ERROR (ctx, g_strdup_printf ("Invalid generic method argument %d", param_num));
return NULL;
}
return ctx->generic_context->method_inst->type_argv [param_num]->data.generic_param;
} | false | false | false | false | false | 0 |
KernAdvance(unsigned int index1, unsigned int index2)
{
float x, y;
if(!hasKerningTable || !index1 || !index2)
{
return FTPoint(0.0f, 0.0f);
}
if(kerningCache && index1 < FTFace::MAX_PRECOMPUTED
&& index2 < FTFace::MAX_PRECOMPUTED)
{
x = kerningCache[2 * (index2 * FTFace::MAX_PRECOMPUTED + index1)];
y = kerningCache[2 * (index2 * FTFace::MAX_PRECOMPUTED + index1) + 1];
return FTPoint(x, y);
}
FT_Vector kernAdvance;
kernAdvance.x = kernAdvance.y = 0;
err = FT_Get_Kerning(*ftFace, index1, index2, ft_kerning_unfitted,
&kernAdvance);
if(err)
{
return FTPoint(0.0f, 0.0f);
}
x = static_cast<float>(kernAdvance.x) / 64.0f;
y = static_cast<float>(kernAdvance.y) / 64.0f;
return FTPoint(x, y);
} | false | false | false | false | false | 0 |
requestSuggestions(const QString &searchTerm)
{
if (searchTerm.isEmpty() || !providesSuggestions())
return;
Q_ASSERT(m_networkAccessManager);
if (!m_networkAccessManager)
return;
if (m_suggestionsReply) {
m_suggestionsReply->disconnect(this);
m_suggestionsReply->abort();
m_suggestionsReply->deleteLater();
m_suggestionsReply = 0;
}
Q_ASSERT(m_requestMethods.contains(m_suggestionsMethod));
if (m_suggestionsMethod == QLatin1String("get")) {
m_suggestionsReply = m_networkAccessManager->get(QNetworkRequest(suggestionsUrl(searchTerm)));
} else {
QStringList parameters;
Parameters::const_iterator end = m_suggestionsParameters.constEnd();
Parameters::const_iterator i = m_suggestionsParameters.constBegin();
for (; i != end; ++i)
parameters.append(i->first + QLatin1String("=") + i->second);
QByteArray data = parameters.join(QLatin1String("&")).toUtf8();
m_suggestionsReply = m_networkAccessManager->post(QNetworkRequest(suggestionsUrl(searchTerm)), data);
}
connect(m_suggestionsReply, SIGNAL(finished()), this, SLOT(suggestionsObtained()));
} | false | false | false | false | false | 0 |
event_music_start_default()
{
int next_pattern;
if ( Event_Music_battle_started == TRUE ) {
if ( hostile_ships_present() ) {
next_pattern = SONG_BTTL_1;
}
else {
Event_Music_battle_started = FALSE;
next_pattern = SONG_NRML_1;
}
}
else
{
next_pattern = SONG_NRML_1;
}
// switch now
if ( Current_pattern == -1 ) {
Current_pattern = next_pattern;
}
// switch later
else {
Patterns[Current_pattern].next_pattern = next_pattern;
Patterns[Current_pattern].force_pattern = TRUE;
}
} | false | false | false | false | false | 0 |
event_area_paint (GthImageSelector *self,
EventArea *event_area,
cairo_t *cr)
{
Sides sides = SIDE_NONE;
switch (event_area->id) {
case C_SELECTION_AREA:
break;
case C_TOP_AREA:
sides = SIDE_RIGHT | SIDE_BOTTOM | SIDE_LEFT;
break;
case C_BOTTOM_AREA:
sides = SIDE_TOP | SIDE_RIGHT | SIDE_LEFT;
break;
case C_LEFT_AREA:
sides = SIDE_TOP | SIDE_RIGHT | SIDE_BOTTOM;
break;
case C_RIGHT_AREA:
sides = SIDE_TOP | SIDE_BOTTOM | SIDE_LEFT;
break;
case C_TOP_LEFT_AREA:
sides = SIDE_RIGHT | SIDE_BOTTOM;
break;
case C_TOP_RIGHT_AREA:
sides = SIDE_BOTTOM | SIDE_LEFT;
break;
case C_BOTTOM_LEFT_AREA:
sides = SIDE_TOP | SIDE_RIGHT;
break;
case C_BOTTOM_RIGHT_AREA:
sides = SIDE_TOP | SIDE_LEFT;
break;
}
_cairo_rectangle_partial (cr,
event_area->area.x + self->priv->viewer->image_area.x - self->priv->viewer->x_offset + 0.5,
event_area->area.y + self->priv->viewer->image_area.y - self->priv->viewer->y_offset + 0.5,
event_area->area.width - 1.0,
event_area->area.height - 1.0,
sides);
} | false | false | false | false | false | 0 |
pg_detoast_datum_copy(struct varlena * datum)
{
if (VARATT_IS_EXTENDED(datum))
return heap_tuple_untoast_attr(datum);
else
{
/* Make a modifiable copy of the varlena object */
Size len = VARSIZE(datum);
struct varlena *result = (struct varlena *) palloc(len);
memcpy(result, datum, len);
return result;
}
} | false | false | false | false | false | 0 |
atp_on_editor_input_variable_show (GtkButton *button, gpointer user_data)
{
ATPToolEditor* this = (ATPToolEditor*)user_data;
switch (get_combo_box_value (this->input_com))
{
case ATP_TIN_FILE:
atp_variable_dialog_show (&this->input_file_var, ATP_FILE_VARIABLE);
break;
case ATP_TIN_STRING:
atp_variable_dialog_show (&this->input_string_var, ATP_DEFAULT_VARIABLE);
break;
}
} | false | false | false | false | false | 0 |
ToUpperStr (char *str)
{ static char buffer[CF_BUFSIZE];
int i;
memset(buffer,0,CF_BUFSIZE);
if (strlen(str) >= CF_BUFSIZE)
{
char *tmp;
tmp = malloc(40+strlen(str));
sprintf(tmp,"String too long in ToUpperStr: %s",str);
FatalError(tmp);
}
for (i = 0; (str[i] != '\0') && (i < CF_BUFSIZE-1); i++)
{
buffer[i] = ToUpper(str[i]);
}
buffer[i] = '\0';
return buffer;
} | false | false | false | false | false | 0 |
word_get_index(const char *str, int pos)
{
bool in_word = false;
int words = 0;
int c;
for (c = 0; str[c] != '\0' && c < pos; c++) {
if (!in_word && !isspace(str[c])) {
in_word = true;
}
if (in_word && isspace(str[c])) {
in_word = false;
words++;
}
}
return words;
} | false | false | false | false | false | 0 |
http_GetHdr(const struct http *hp, const char *hdr, char **ptr)
{
unsigned u, l;
char *p;
l = hdr[0];
diagnostic(l == strlen(hdr + 1));
assert(hdr[l] == ':');
hdr++;
u = http_findhdr(hp, l - 1, hdr);
if (u == 0) {
if (ptr != NULL)
*ptr = NULL;
return (0);
}
if (ptr != NULL) {
p = hp->hd[u].b + l;
while (vct_issp(*p))
p++;
*ptr = p;
}
return (1);
} | false | false | false | false | false | 0 |
Java_magick_MagickImage_convolveImage
(JNIEnv *env, jobject self, jint order, jdoubleArray kernel)
{
Image *image = NULL, *convolvedImage = NULL;
jobject newObj;
ExceptionInfo exception;
double *karray;
image = (Image*) getHandle(env, self, "magickImageHandle", NULL);
if (image == NULL) {
throwMagickException(env, "Cannot retrieve image handle");
return NULL;
}
karray = (*env)->GetDoubleArrayElements(env, kernel, NULL);
GetExceptionInfo(&exception);
convolvedImage = ConvolveImage(image, order, karray, &exception);
(*env)->ReleaseDoubleArrayElements(env, kernel, karray, JNI_ABORT);
if (convolvedImage == NULL) {
throwMagickApiException(env, "Cannot convolve image", &exception);
DestroyExceptionInfo(&exception);
return NULL;
}
DestroyExceptionInfo(&exception);
newObj = newImageObject(env, convolvedImage);
if (newObj == NULL) {
DestroyImages(convolvedImage);
throwMagickException(env, "Unable to create convolved image");
return NULL;
}
return newObj;
} | false | false | false | false | false | 0 |
get( const char *key, void *data, const void *defaultValue, int defaultSize, int maxSize )
{
const char *v = node->get( key );
if ( v )
{
int dsize;
void *w = decodeHex( v, dsize );
memmove( data, w, dsize>maxSize?maxSize:dsize );
free( w );
return 1;
}
if ( defaultValue )
memmove( data, defaultValue, defaultSize>maxSize?maxSize:defaultSize );
return 0;
} | false | false | false | false | false | 0 |
language_cobol_trigger_completion (Language_Provider *lgcobol, guint ch)
{
g_return_if_fail(lgcobol);
Language_COBOLDetails *lgcoboldet = LANGUAGE_COBOL_GET_PRIVATE(lgcobol);
gint current_pos;
gchar *member_function_buffer = NULL;
current_pos = gtk_scintilla_get_current_pos(lgcoboldet->sci);
gboolean auto_brace;
g_object_get(lgcoboldet->prefmg, "auto_complete_braces", &auto_brace, NULL);
if (IsOpenBrace(ch) && auto_brace) {
InsertCloseBrace (lgcoboldet->sci, current_pos, ch);
return;
}
switch(ch) {
case ('\r'):
case ('\n'):
autoindent_brace_code (lgcoboldet->sci, lgcoboldet->prefmg);
break;
default:
member_function_buffer = documentable_get_current_word(lgcoboldet->doc);
if (member_function_buffer && strlen(member_function_buffer)>=3) show_autocompletion (LANGUAGE_COBOL(lgcobol), current_pos);
g_free(member_function_buffer);
}
} | false | false | false | false | false | 0 |
ExChildProcess ()
{
/*
* Wait for all the children to appear and the parent to signal OK to
* start processing.
*/
_dxf_ExInitTaskPerProc();
/* don't send out worker messages for slaves */
if(!_dxd_exRemoteSlave)
DXMessage ("#1060", getpid ());
while ((nprocs > 1) && (! *exReady))
;
ExMainLoop ();
} | false | false | false | false | false | 0 |
xmms_diskwrite_flush (xmms_output_t *output)
{
xmms_diskwrite_data_t *data;
g_return_if_fail (output);
data = xmms_output_private_data_get (output);
g_return_if_fail (data);
g_return_if_fail (data->fp);
fflush (data->fp);
} | false | false | false | false | false | 0 |
add_exclude_hpb(char *input, unsigned char mode)
{
struct parser_options *excluded_this;
struct in_addr ip;
excluded_this = xmalloc(sizeof(struct parser_options));
excluded_this->mode = mode;
excluded_this->svalue = NULL;
if (mode & PARSER_MODE_HOST) {
struct parser_options *excluded_test;
excluded_this->netmask.s_addr = parse_cidr(input);
if (convert_ip(input, &ip) == IN_ADDR_ERROR) {
fprintf(stderr, _("(excluded host)\n"));
free(excluded_this);
exit(EXIT_FAILURE);
}
excluded_this->value = ip.s_addr & excluded_this->netmask.s_addr;
excluded_test = excluded_first;
while (excluded_test != NULL) {
if (excluded_test->value == excluded_this->value) {
free(excluded_this);
return;
}
excluded_test = excluded_test->next;
}
} else if (mode & PARSER_MODE_PORT) {
excluded_this->value = atoi(input);
} else if (mode & (PARSER_MODE_CHAIN | PARSER_MODE_BRANCH)) {
excluded_this->svalue = xmalloc(strlen(input) + 1);
xstrncpy(excluded_this->svalue, input, strlen(input) + 1);
}
excluded_this->next = excluded_first;
excluded_first = excluded_this;
} | false | false | false | false | false | 0 |
uncompress_bcd(unsigned char *bcd)
{
char *out = calloc(INLINE_STR_LEN*2 + 1, sizeof(char));
for (int inpos = 0; inpos < INLINE_STR_LEN*2; inpos++) {
unsigned int code = bcd[inpos/2];
if (inpos % 2 == 0) {
code &= 15;
} else {
code >>= 4;
}
if (code == bcd_nul) {
break;
}
out[inpos] = bcd_map[code];
}
return out;
} | false | false | false | false | false | 0 |
handle_content_base64(struct ntb_mail_parser *parser,
const uint8_t *data,
size_t length_in,
struct ntb_error **error)
{
size_t length = length_in;
size_t chunk_size;
ssize_t got;
uint8_t buf[512];
while (length > 0) {
chunk_size = MIN(NTB_BASE64_MAX_INPUT_FOR_SIZE(sizeof buf),
length);
got = ntb_base64_decode(&parser->base64_data,
data,
chunk_size,
buf,
error);
if (got == -1)
return -1;
if (!parser->data_cb(NTB_MAIL_PARSER_EVENT_CONTENT,
buf,
got,
parser->cb_user_data,
error))
return -1;
length -= chunk_size;
data += chunk_size;
}
return length_in;
} | false | false | false | false | false | 0 |
readFromStream(mrpt::utils::CStream &in,int version)
{
switch(version)
{
case 0:
{
int32_t n;
in >> n;
gaps_ini.resize(n);
gaps_end.resize(n);
in.ReadBuffer( &(*gaps_ini.begin()), sizeof(gaps_ini[0]) * n );
in.ReadBuffer( &(*gaps_end.begin()), sizeof(gaps_end[0]) * n );
in >> n;
gaps_eval.resize(n);
in.ReadBuffer( &(*gaps_eval.begin()), sizeof(gaps_eval[0]) * n );
in >> selectedSector >> evaluation >> riskEvaluation >> n;
situation = (CHolonomicND::TSituations) n;
} break;
case 1:
{
uint32_t n;
in >> gaps_ini >> gaps_end >> gaps_eval;
in >> selectedSector >> evaluation >> riskEvaluation >> n;
situation = (CHolonomicND::TSituations) n;
} break;
default:
MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(version)
};
} | false | false | false | false | false | 0 |
intel_miptree_set_level_info(struct intel_mipmap_tree *mt,
GLuint level,
GLuint x, GLuint y,
GLuint w, GLuint h, GLuint d)
{
mt->level[level].width = w;
mt->level[level].height = h;
mt->level[level].depth = d;
mt->level[level].level_x = x;
mt->level[level].level_y = y;
DBG("%s level %d size: %d,%d,%d offset %d,%d\n", __FUNCTION__,
level, w, h, d, x, y);
assert(mt->level[level].slice == NULL);
mt->level[level].slice = calloc(d, sizeof(*mt->level[0].slice));
mt->level[level].slice[0].x_offset = mt->level[level].level_x;
mt->level[level].slice[0].y_offset = mt->level[level].level_y;
} | false | false | false | false | false | 0 |
ftp_disconnect(struct connectdata *conn, bool dead_connection)
{
struct ftp_conn *ftpc= &conn->proto.ftpc;
struct pingpong *pp = &ftpc->pp;
/* We cannot send quit unconditionally. If this connection is stale or
bad in any way, sending quit and waiting around here will make the
disconnect wait in vain and cause more problems than we need to.
ftp_quit() will check the state of ftp->ctl_valid. If it's ok it
will try to send the QUIT command, otherwise it will just return.
*/
if(dead_connection)
ftpc->ctl_valid = FALSE;
/* The FTP session may or may not have been allocated/setup at this point! */
(void)ftp_quit(conn); /* ignore errors on the QUIT */
if(ftpc->entrypath) {
struct SessionHandle *data = conn->data;
if(data->state.most_recent_ftp_entrypath == ftpc->entrypath) {
data->state.most_recent_ftp_entrypath = NULL;
}
free(ftpc->entrypath);
ftpc->entrypath = NULL;
}
freedirs(ftpc);
if(ftpc->prevpath) {
free(ftpc->prevpath);
ftpc->prevpath = NULL;
}
if(ftpc->server_os) {
free(ftpc->server_os);
ftpc->server_os = NULL;
}
Curl_pp_disconnect(pp);
#ifdef HAVE_GSSAPI
Curl_sec_end(conn);
#endif
return CURLE_OK;
} | false | false | false | false | false | 0 |
v4l2_fh_init(struct v4l2_fh *fh, struct video_device *vdev)
{
fh->vdev = vdev;
/* Inherit from video_device. May be overridden by the driver. */
fh->ctrl_handler = vdev->ctrl_handler;
INIT_LIST_HEAD(&fh->list);
set_bit(V4L2_FL_USES_V4L2_FH, &fh->vdev->flags);
/*
* determine_valid_ioctls() does not know if struct v4l2_fh
* is used by this driver, but here we do. So enable the
* prio ioctls here.
*/
set_bit(_IOC_NR(VIDIOC_G_PRIORITY), vdev->valid_ioctls);
set_bit(_IOC_NR(VIDIOC_S_PRIORITY), vdev->valid_ioctls);
fh->prio = V4L2_PRIORITY_UNSET;
init_waitqueue_head(&fh->wait);
INIT_LIST_HEAD(&fh->available);
INIT_LIST_HEAD(&fh->subscribed);
fh->sequence = -1;
} | false | false | false | false | false | 0 |
caml_sha3_wipe(value ctx)
{
if (Context_val(ctx) != NULL) {
memset(Context_val(ctx), 0, sizeof(struct SHA3Context));
caml_stat_free(Context_val(ctx));
Context_val(ctx) = NULL;
}
return Val_unit;
} | false | false | false | false | false | 0 |
append_avrule_to_subject_vector(const apol_policy_t * p,
apol_relabel_analysis_t * r, const qpol_avrule_t * avrule, apol_vector_t * results)
{
const qpol_type_t *target;
apol_vector_t *target_v = NULL, *result_list = NULL;
size_t i;
apol_relabel_result_t *result;
apol_relabel_result_pair_t *pair = NULL;
int retval = -1, dir, compval;
if ((dir = relabel_analysis_get_direction(p, avrule)) < 0) {
goto cleanup;
}
if (qpol_avrule_get_target_type(p->p, avrule, &target) < 0 || (target_v = apol_query_expand_type(p, target)) == NULL) {
goto cleanup;
}
for (i = 0; i < apol_vector_get_size(target_v); i++) {
target = (qpol_type_t *) apol_vector_get_element(target_v, i);
compval = apol_compare_type(p, target, r->type, 0, NULL);
if (compval < 0) {
goto cleanup;
} else if (compval == 1) {
continue; /* don't care about relabels to itself */
}
compval = apol_compare_type(p, target, r->result, APOL_QUERY_REGEX, &r->result_regex);
if (compval < 0) {
goto cleanup;
} else if (compval == 0) {
continue;
}
if ((result = relabel_result_get_node(p, results, target)) == NULL) {
goto cleanup;
}
if ((pair = calloc(1, sizeof(*pair))) == NULL) {
ERR(p, "%s", strerror(ENOMEM));
goto cleanup;
}
pair->ruleA = avrule;
pair->ruleB = NULL;
pair->intermed = NULL;
switch (dir) {
case APOL_RELABEL_DIR_TO:
result_list = result->to;
break;
case APOL_RELABEL_DIR_FROM:
result_list = result->from;
break;
case APOL_RELABEL_DIR_BOTH:
result_list = result->both;
break;
}
if ((apol_vector_append(result_list, pair)) < 0) {
ERR(p, "%s", strerror(ENOMEM));
goto cleanup;
}
pair = NULL;
}
retval = 0;
cleanup:
apol_vector_destroy(&target_v);
free(pair);
return retval;
} | false | false | false | false | false | 0 |
alt_size_entry_set_unit (AltSizeEntry *gse,
GimpUnit unit)
{
g_return_if_fail (ALT_IS_SIZE_ENTRY (gse));
g_return_if_fail (gse->menu_show_pixels || (unit != GIMP_UNIT_PIXEL));
g_return_if_fail (gse->menu_show_percent || (unit != GIMP_UNIT_PERCENT));
gimp_unit_menu_set_unit (GIMP_UNIT_MENU (gse->unitmenu), unit);
alt_size_entry_update_unit (gse, unit);
} | false | false | false | false | false | 0 |
SingleDefgenericToCode(
void *theEnv,
FILE *theFile,
int imageID,
int maxIndices,
DEFGENERIC *theDefgeneric,
int moduleCount,
int methodArrayVersion,
int methodArrayCount)
{
/* ==================
Defgeneric Header
================== */
fprintf(theFile,"{");
ConstructHeaderToCode(theEnv,theFile,&theDefgeneric->header,imageID,maxIndices,moduleCount,
ModulePrefix(DefgenericData(theEnv)->DefgenericCodeItem),
ConstructPrefix(DefgenericData(theEnv)->DefgenericCodeItem));
/* =========================
Defgeneric specific data
========================= */
fprintf(theFile,",0,0,");
if (theDefgeneric->methods == NULL)
fprintf(theFile,"NULL");
else
{
fprintf(theFile,"&%s%d_%d[%d]",MethodPrefix(),imageID,
methodArrayVersion,methodArrayCount);
}
fprintf(theFile,",%u,0}",theDefgeneric->mcnt);
} | false | false | false | false | false | 0 |
viewfsmtrans( Trans )
fsmtrans_list *Trans;
{
fprintf( stdout, "\n--> Transition" );
fprintf( stdout, "\n\t\tFLAGS : %lx", Trans->FLAGS );
fprintf( stdout, "\n\t\tUSER : %lx", (long)Trans->USER );
fprintf( stdout, "\n\t\tFROM : " );
if ( Trans->FROM != (fsmstate_list *)0 )
{
fprintf( stdout, "%s", Trans->FROM->NAME );
}
fprintf( stdout, "\n\t\tTO : " );
if ( Trans->TO != (fsmstate_list *)0 )
{
fprintf( stdout, "%s", Trans->TO->NAME );
}
fprintf( stdout, "\n\t\tABL : " );
if ( Trans->ABL != (ablexpr *)0 )
{
viewablexpr( Trans->ABL, ABL_VIEW_VHDL );
}
fprintf( stdout, "\n<-- Transition" );
} | false | false | false | false | false | 0 |
gtk_xtext_find_char (GtkXText * xtext, int x, int y, int *off,
int *out_of_bounds)
{
textentry *ent;
int line;
int subline;
line = (y + xtext->pixel_offset) / xtext->fontsize;
ent = gtk_xtext_nth (xtext, line + (int)xtext->adj->value, &subline);
if (!ent)
return 0;
if (off)
*off = gtk_xtext_find_x (xtext, x, ent, subline, line, out_of_bounds);
return ent;
} | false | false | false | false | false | 0 |
lua_init_specials(struct hid_device *hdev)
{
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
struct usb_device *usb_dev = interface_to_usbdev(intf);
struct lua_device *lua;
int retval;
lua = kzalloc(sizeof(*lua), GFP_KERNEL);
if (!lua) {
hid_err(hdev, "can't alloc device descriptor\n");
return -ENOMEM;
}
hid_set_drvdata(hdev, lua);
retval = lua_init_lua_device_struct(usb_dev, lua);
if (retval) {
hid_err(hdev, "couldn't init struct lua_device\n");
goto exit;
}
retval = lua_create_sysfs_attributes(intf);
if (retval) {
hid_err(hdev, "cannot create sysfs files\n");
goto exit;
}
return 0;
exit:
kfree(lua);
return retval;
} | false | false | false | false | false | 0 |
HandleDown(wxDC &dc, int x, int y)
{
HandleMotion(dc, x, y);
if( m_current ) {
m_current->Push(dc);
}
} | false | false | false | false | false | 0 |
_st_pgsql_count(st_driver_t drv, const char *type, const char *owner, const char *filter, int *count) {
drvdata_t data = (drvdata_t) drv->private;
char *cond, *buf = NULL;
int buflen = 0;
PGresult *res;
int ntuples, nfields;
char tbuf[128];
if(data->prefix != NULL) {
snprintf(tbuf, sizeof(tbuf), "%s%s", data->prefix, type);
type = tbuf;
}
cond = _st_pgsql_convert_filter(drv, owner, filter);
log_debug(ZONE, "generated filter: %s", cond);
PGSQL_SAFE(buf, strlen(type) + strlen(cond) + 31, buflen);
sprintf(buf, "SELECT COUNT(*) FROM \"%s\" WHERE %s", type, cond);
free(cond);
log_debug(ZONE, "prepared sql: %s", buf);
res = PQexec(data->conn, buf);
if(PQresultStatus(res) != PGRES_TUPLES_OK && PQstatus(data->conn) != CONNECTION_OK) {
log_write(drv->st->log, LOG_ERR, "pgsql: lost connection to database, attempting reconnect");
PQclear(res);
PQreset(data->conn);
res = PQexec(data->conn, buf);
}
free(buf);
if(PQresultStatus(res) != PGRES_TUPLES_OK) {
log_write(drv->st->log, LOG_ERR, "pgsql: sql select failed: %s", PQresultErrorMessage(res));
PQclear(res);
return st_FAILED;
}
ntuples = PQntuples(res);
if(ntuples == 0) {
PQclear(res);
return st_NOTFOUND;
}
log_debug(ZONE, "%d tuples returned", ntuples);
nfields = PQnfields(res);
if(nfields == 0) {
log_debug(ZONE, "weird, tuples were returned but no fields *shrug*");
PQclear(res);
return st_NOTFOUND;
}
if(PQgetisnull(res, 0, 0) || PQftype(res, 0) != 20)
return st_NOTFOUND;
if (count!=NULL)
*count = atoi(PQgetvalue(res, 0, 0));
PQclear(res);
return st_SUCCESS;
} | false | false | false | false | false | 0 |
convert_hline_Y444 (paintinfo * p, int y)
{
int i;
guint8 *Y = p->yp + y * p->ystride;
guint8 *U = p->up + y * p->ustride;
guint8 *V = p->vp + y * p->vstride;
guint8 *ayuv = p->tmpline;
for (i = 0; i < p->width; i++) {
Y[i] = ayuv[4 * i + 1];
U[i] = ayuv[4 * i + 2];
V[i] = ayuv[4 * i + 3];
}
} | false | false | false | false | false | 0 |
omapi_io_signal_handler (omapi_object_t *h,
const char *name, va_list ap)
{
if (h -> type != omapi_type_io_object)
return DHCP_R_INVALIDARG;
if (h -> inner && h -> inner -> type -> signal_handler)
return (*(h -> inner -> type -> signal_handler)) (h -> inner,
name, ap);
return ISC_R_NOTFOUND;
} | false | false | false | false | false | 0 |
slot_actionDelCondition()
{
if( _contextItem ) {
QuestConditionItem * parentItem = dynamic_cast<QuestConditionItem*> ( _contextItem->parent() );
QuestCondition * parentCondition = parentItem->getCondition();
if( parentCondition->getType() == QuestCondition::COMPOSITE ) {
( ( QuestConditionComposite * )parentCondition )->delCondition( _contextItem->getCondition() );
}
buildTree();
}
} | false | false | false | false | false | 0 |
sget(struct file_system_type *type,
int (*test)(struct super_block *,void *),
int (*set)(struct super_block *,void *),
int flags,
void *data)
{
struct user_namespace *user_ns = current_user_ns();
/* We don't yet pass the user namespace of the parent
* mount through to here so always use &init_user_ns
* until that changes.
*/
if (flags & MS_SUBMOUNT)
user_ns = &init_user_ns;
/* Ensure the requestor has permissions over the target filesystem */
if (!(flags & (MS_KERNMOUNT|MS_SUBMOUNT)) && !ns_capable(user_ns, CAP_SYS_ADMIN))
return ERR_PTR(-EPERM);
return sget_userns(type, test, set, flags, user_ns, data);
} | false | false | false | false | false | 0 |
possible_selection(GtkAllocation area, gint x, gint y)
{
GtkPlotCanvasPos return_value = GTK_PLOT_CANVAS_OUT;
if(x >= area.x - DEFAULT_MARKER_SIZE / 2 &&
x <= area.x + DEFAULT_MARKER_SIZE / 2){
if(y >= area.y - DEFAULT_MARKER_SIZE / 2. &&
y <= area.y + DEFAULT_MARKER_SIZE / 2.)
return_value = GTK_PLOT_CANVAS_TOP_LEFT;
if(y >= area.y + area.height - DEFAULT_MARKER_SIZE / 2. &&
y <= area.y + area.height + DEFAULT_MARKER_SIZE / 2.)
return_value = GTK_PLOT_CANVAS_BOTTOM_LEFT;
if(y >= area.y + area.height / 2 - DEFAULT_MARKER_SIZE / 2. &&
y <= area.y + area.height / 2 + DEFAULT_MARKER_SIZE / 2. &&
area.height > DEFAULT_MARKER_SIZE * 2)
return_value = GTK_PLOT_CANVAS_LEFT;
}
if(x >= area.x + area.width - DEFAULT_MARKER_SIZE / 2 &&
x <= area.x + area.width + DEFAULT_MARKER_SIZE / 2){
if(y >= area.y - DEFAULT_MARKER_SIZE / 2. &&
y <= area.y + DEFAULT_MARKER_SIZE / 2.)
return_value = GTK_PLOT_CANVAS_TOP_RIGHT;
if(y >= area.y + area.height - DEFAULT_MARKER_SIZE / 2. &&
y <= area.y + area.height + DEFAULT_MARKER_SIZE / 2.)
return_value = GTK_PLOT_CANVAS_BOTTOM_RIGHT;
if(y >= area.y + area.height / 2 - DEFAULT_MARKER_SIZE / 2. &&
y <= area.y + area.height / 2 + DEFAULT_MARKER_SIZE / 2. &&
area.height > DEFAULT_MARKER_SIZE * 2)
return_value = GTK_PLOT_CANVAS_RIGHT;
}
if(x >= area.x + area.width / 2 - DEFAULT_MARKER_SIZE / 2 &&
x <= area.x + area.width / 2 + DEFAULT_MARKER_SIZE / 2 &&
area.width > DEFAULT_MARKER_SIZE * 2){
if(y >= area.y - DEFAULT_MARKER_SIZE / 2. &&
y <= area.y + DEFAULT_MARKER_SIZE / 2.)
return_value = GTK_PLOT_CANVAS_TOP;
if(y >= area.y + area.height - DEFAULT_MARKER_SIZE / 2. &&
y <= area.y + area.height + DEFAULT_MARKER_SIZE / 2.)
return_value = GTK_PLOT_CANVAS_BOTTOM;
}
if(return_value == GTK_PLOT_CANVAS_OUT){
if (x >= area.x && x <= area.x + area.width &&
y >= area.y && y <= area.y + area.height)
return_value = GTK_PLOT_CANVAS_IN;
}
return (return_value);
} | false | false | false | false | false | 0 |
mkdir_minus_p(char *path)
{
char *slash;
slash = strrchr(path, '/');
if (slash && slash > path)
{
string_ty *tmp;
tmp = str_n_from_c(path, slash - path);
mkdir_minus_p(tmp->str_text);
str_free(tmp);
}
/*
* Ignore any error codes coming back. (The commonest will be
* EEXISTS, which we won't be complaining about anyway.) When we
* try to access the directory contents, some other fatal error
* will occur, so the user foinds out anyway.
*/
mkdir(path, 0777);
} | false | false | false | false | false | 0 |
SegCompare(const void *p1, const void *p2)
{
const seg_t *A = ((const seg_t **) p1)[0];
const seg_t *B = ((const seg_t **) p2)[0];
if (A->index < 0)
InternalError("Seg %p never reached a subsector !", A);
if (B->index < 0)
InternalError("Seg %p never reached a subsector !", B);
return (A->index - B->index);
} | false | false | false | false | false | 0 |
__ecereProp___ecereNameSpace__ecere__gui__controls__DropBox_Get_firstRow(struct __ecereNameSpace__ecere__com__Instance * this)
{
struct __ecereNameSpace__ecere__gui__controls__DropBox * __ecerePointer___ecereNameSpace__ecere__gui__controls__DropBox = (struct __ecereNameSpace__ecere__gui__controls__DropBox *)(this ? (((char *)this) + __ecereClass___ecereNameSpace__ecere__gui__controls__DropBox->offset) : 0);
return this ? __ecereProp___ecereNameSpace__ecere__gui__controls__ListBox_Get_firstRow(__ecerePointer___ecereNameSpace__ecere__gui__controls__DropBox->listBox) : (((void *)0));
} | false | false | false | false | false | 0 |
ssl_print_cb(BIO *bio,int cmd,const char *argp,int argi,long argl,long ret)
{
BIO *out;
out=(BIO *)BIO_get_callback_arg(bio);
if (out == NULL) return(ret);
if (cmd == (BIO_CB_READ|BIO_CB_RETURN)) {
BIO_printf(out,"read from %p [%p] (%d bytes => %ld (0x%lX))\n",
bio, argp, argi, ret, ret);
BIO_dump(out,(char *)argp,(int)ret);
return(ret);
}
else if (cmd == (BIO_CB_WRITE|BIO_CB_RETURN)) {
BIO_printf(out,"write to %p [%p] (%d bytes => %ld (0x%lX))\n",
bio, argp, argi, ret, ret);
BIO_dump(out,(char *)argp,(int)ret);
}
return ret;
} | false | false | false | false | false | 0 |
is_crashkernel_mem_reserved(void)
{
uint64_t start, end;
return parse_iomem_single("Crash kernel\n", &start, &end) == 0 ?
(start != end) : 0;
} | false | false | false | false | false | 0 |
set_origin(struct vc_data *vc)
{
WARN_CONSOLE_UNLOCKED();
if (!CON_IS_VISIBLE(vc) ||
!vc->vc_sw->con_set_origin ||
!vc->vc_sw->con_set_origin(vc))
vc->vc_origin = (unsigned long)vc->vc_screenbuf;
vc->vc_visible_origin = vc->vc_origin;
vc->vc_scr_end = vc->vc_origin + vc->vc_screenbuf_size;
vc->vc_pos = vc->vc_origin + vc->vc_size_row * vc->vc_y + 2 * vc->vc_x;
} | false | false | false | false | false | 0 |
processHeapForDead( bdescr *bd )
{
StgPtr p;
while (bd != NULL) {
p = bd->start;
while (p < bd->free) {
p += processHeapClosureForDead((StgClosure *)p);
while (p < bd->free && !*p) // skip slop
p++;
}
ASSERT(p == bd->free);
bd = bd->link;
}
} | false | false | false | false | false | 0 |
pcm1681_i2c_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
int ret;
struct pcm1681_private *priv;
priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL);
if (!priv)
return -ENOMEM;
priv->regmap = devm_regmap_init_i2c(client, &pcm1681_regmap);
if (IS_ERR(priv->regmap)) {
ret = PTR_ERR(priv->regmap);
dev_err(&client->dev, "Failed to create regmap: %d\n", ret);
return ret;
}
i2c_set_clientdata(client, priv);
return snd_soc_register_codec(&client->dev, &soc_codec_dev_pcm1681,
&pcm1681_dai, 1);
} | false | false | false | false | false | 0 |
keyPressEvent(QKeyEvent* event)
{
if (event->key() == Qt::Key_Up) {
emit previousHistory();
}
if (event->key() == Qt::Key_Down) {
emit nextHistory();
}
QGraphicsWidget::keyPressEvent(event);
} | false | false | false | false | false | 0 |
addPositionCalculations(Function* vsMain, int& funcCounter)
{
FunctionInvocation* curFuncInvocation = NULL;
if (mDoBoneCalculations == true)
{
//set functions to calculate world position
for(int i = 0 ; i < getWeightCount() ; ++i)
{
addIndexedPositionWeight(vsMain, i, funcCounter);
}
//update back the original position relative to the object
curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_TRANSFORM, FFP_VS_TRANSFORM, funcCounter++);
curFuncInvocation->pushOperand(mParamInInvWorldMatrix, Operand::OPS_IN);
curFuncInvocation->pushOperand(mParamLocalPositionWorld, Operand::OPS_IN);
curFuncInvocation->pushOperand(mParamInPosition, Operand::OPS_OUT);
vsMain->addAtomInstance(curFuncInvocation);
//update the projective position thereby filling the transform stage role
curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_TRANSFORM, FFP_VS_TRANSFORM, funcCounter++);
curFuncInvocation->pushOperand(mParamInViewProjMatrix, Operand::OPS_IN);
curFuncInvocation->pushOperand(mParamLocalPositionWorld, Operand::OPS_IN);
curFuncInvocation->pushOperand(mParamOutPositionProj, Operand::OPS_OUT);
vsMain->addAtomInstance(curFuncInvocation);
}
else
{
//update from object to world space
curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_TRANSFORM, FFP_VS_TRANSFORM, funcCounter++);
curFuncInvocation->pushOperand(mParamInWorldMatrix, Operand::OPS_IN);
curFuncInvocation->pushOperand(mParamInPosition, Operand::OPS_IN);
curFuncInvocation->pushOperand(mParamLocalPositionWorld, Operand::OPS_OUT);
vsMain->addAtomInstance(curFuncInvocation);
//update from object to projective space
curFuncInvocation = OGRE_NEW FunctionInvocation(FFP_FUNC_TRANSFORM, FFP_VS_TRANSFORM, funcCounter++);
curFuncInvocation->pushOperand(mParamInWorldViewProjMatrix, Operand::OPS_IN);
curFuncInvocation->pushOperand(mParamInPosition, Operand::OPS_IN);
curFuncInvocation->pushOperand(mParamOutPositionProj, Operand::OPS_OUT);
vsMain->addAtomInstance(curFuncInvocation);
}
} | false | false | false | false | false | 0 |
pend_type (type)
tree type;
{
if (pending_types == pending_types_allocated)
{
pending_types_allocated += PENDING_TYPES_INCREMENT;
pending_types_list
= (tree *) xrealloc (pending_types_list,
sizeof (tree) * pending_types_allocated);
}
pending_types_list[pending_types++] = type;
/* Mark the pending type as having been output already (even though
it hasn't been). This prevents the type from being added to the
pending_types_list more than once. */
TREE_ASM_WRITTEN (type) = 1;
} | false | false | false | false | false | 0 |
spell_suggest_file(su, fname)
suginfo_T *su;
char_u *fname;
{
FILE *fd;
char_u line[MAXWLEN * 2];
char_u *p;
int len;
char_u cword[MAXWLEN];
/* Open the file. */
fd = mch_fopen((char *)fname, "r");
if (fd == NULL)
{
EMSG2(_(e_notopen), fname);
return;
}
/* Read it line by line. */
while (!vim_fgets(line, MAXWLEN * 2, fd) && !got_int)
{
line_breakcheck();
p = vim_strchr(line, '/');
if (p == NULL)
continue; /* No Tab found, just skip the line. */
*p++ = NUL;
if (STRICMP(su->su_badword, line) == 0)
{
/* Match! Isolate the good word, until CR or NL. */
for (len = 0; p[len] >= ' '; ++len)
;
p[len] = NUL;
/* If the suggestion doesn't have specific case duplicate the case
* of the bad word. */
if (captype(p, NULL) == 0)
{
make_case_word(p, cword, su->su_badflags);
p = cword;
}
add_suggestion(su, &su->su_ga, p, su->su_badlen,
SCORE_FILE, 0, TRUE, su->su_sallang, FALSE);
}
}
fclose(fd);
/* Remove bogus suggestions, sort and truncate at "maxcount". */
check_suggestions(su, &su->su_ga);
(void)cleanup_suggestions(&su->su_ga, su->su_maxscore, su->su_maxcount);
} | false | false | false | false | false | 0 |
freeAlarms(SingleList* chain)
{
listSingleFullFree((chain ? chain : _alarmList), destroyAlarm);
if (!chain) {
_alarmList = NULL;
}
} | false | false | false | false | false | 0 |
knot_rrset_find_rr_pos(const knot_rrset_t *rr_search_in,
const knot_rrset_t *rr_reference, size_t pos,
size_t *pos_out)
{
int found = 0;
for (uint16_t i = 0; i < rr_search_in->rdata_count && !found; ++i) {
if (rrset_rdata_compare_one(rr_search_in,
rr_reference, i, pos) == 0) {
*pos_out = i;
found = 1;
}
}
return found ? KNOT_EOK : KNOT_ENOENT;
} | false | false | false | false | false | 0 |
Update() {
void* v;
subject->GetValue(v);
if (!chosen && value == v) {
Choose();
} else if (chosen && value != v) {
UnChoose();
}
} | false | false | false | false | false | 0 |
create_iv (tree base, tree step, tree var, struct loop *loop,
gimple_stmt_iterator *incr_pos, bool after,
tree *var_before, tree *var_after)
{
gimple stmt;
tree initial, step1;
gimple_seq stmts;
tree vb, va;
enum tree_code incr_op = PLUS_EXPR;
edge pe = loop_preheader_edge (loop);
if (var != NULL_TREE)
{
vb = make_ssa_name (var, NULL);
va = make_ssa_name (var, NULL);
}
else
{
vb = make_temp_ssa_name (TREE_TYPE (base), NULL, "ivtmp");
va = make_temp_ssa_name (TREE_TYPE (base), NULL, "ivtmp");
}
if (var_before)
*var_before = vb;
if (var_after)
*var_after = va;
/* For easier readability of the created code, produce MINUS_EXPRs
when suitable. */
if (TREE_CODE (step) == INTEGER_CST)
{
if (TYPE_UNSIGNED (TREE_TYPE (step)))
{
step1 = fold_build1 (NEGATE_EXPR, TREE_TYPE (step), step);
if (tree_int_cst_lt (step1, step))
{
incr_op = MINUS_EXPR;
step = step1;
}
}
else
{
bool ovf;
if (!tree_expr_nonnegative_warnv_p (step, &ovf)
&& may_negate_without_overflow_p (step))
{
incr_op = MINUS_EXPR;
step = fold_build1 (NEGATE_EXPR, TREE_TYPE (step), step);
}
}
}
if (POINTER_TYPE_P (TREE_TYPE (base)))
{
if (TREE_CODE (base) == ADDR_EXPR)
mark_addressable (TREE_OPERAND (base, 0));
step = convert_to_ptrofftype (step);
if (incr_op == MINUS_EXPR)
step = fold_build1 (NEGATE_EXPR, TREE_TYPE (step), step);
incr_op = POINTER_PLUS_EXPR;
}
/* Gimplify the step if necessary. We put the computations in front of the
loop (i.e. the step should be loop invariant). */
step = force_gimple_operand (step, &stmts, true, NULL_TREE);
if (stmts)
gsi_insert_seq_on_edge_immediate (pe, stmts);
stmt = gimple_build_assign_with_ops (incr_op, va, vb, step);
if (after)
gsi_insert_after (incr_pos, stmt, GSI_NEW_STMT);
else
gsi_insert_before (incr_pos, stmt, GSI_NEW_STMT);
initial = force_gimple_operand (base, &stmts, true, var);
if (stmts)
gsi_insert_seq_on_edge_immediate (pe, stmts);
stmt = create_phi_node (vb, loop->header);
add_phi_arg (stmt, initial, loop_preheader_edge (loop), UNKNOWN_LOCATION);
add_phi_arg (stmt, va, loop_latch_edge (loop), UNKNOWN_LOCATION);
} | false | false | false | false | false | 0 |
map_new_zchar(int32 unicode)
{ /* Attempts to enter the given Unicode character into the "alphabet[]"
array, in place of one which has not so far been used in the
compilation of the current file. This may of course fail. */
int i, j; int zscii;
zscii = unicode_to_zscii(unicode);
/* Out of ZSCII range? */
if ((zscii == 5) || (zscii >= 0x100))
{ unicode_char_error(
"Character must first be entered into Zcharacter table:", unicode);
return;
}
/* Already there? */
for (i=0;i<3;i++) for (j=0;j<26;j++)
if (alphabet[i][j] == zscii) return;
/* A0 and A1 are never changed. Try to find a place in alphabet A2:
xx0123456789.,!?_#'~/\-:()
^^^^^^^^^^ ^^^^^ ^^^^^^
The letters marked ^ are considered to be replaceable, as long as
they haven't yet been used in any text already encoded, and haven't
already been replaced. The routine works along from the left, since
numerals are more of a luxury than punctuation. */
for (i=2; i<26; i++)
{ if ((i == 12) || (i == 13) || (i == 19)) continue;
if (alphabet_used[52+i] == 'N')
{ alphabet_used[52+i] = 'Y';
alphabet[2][i] = zscii;
alphabet_modified = TRUE;
make_iso_to_alphabet_grid();
return;
}
}
} | false | false | false | false | false | 0 |
SetWidgetRepresentation(vtkWidgetRepresentation *r)
{
if ( r != this->WidgetRep )
{
int enabled=0;
if ( this->Enabled )
{
enabled = 1;
this->SetEnabled(0);
}
if ( this->WidgetRep )
{
this->WidgetRep->Delete();
}
this->WidgetRep = r;
if ( this->WidgetRep )
{
this->WidgetRep->Register(this);
}
this->Modified();
if ( enabled )
{
this->SetEnabled(1);
}
}
} | false | false | false | false | false | 0 |
AddAddress(const char *rfc_type, const Barry::PostalAddress &address)
{
// add label first
vAttrPtr label = NewAttr("LABEL");
AddParam(label, "TYPE", rfc_type);
AddValue(label, address.GetLabel().c_str());
AddAttr(label);
// add breakout address form
vAttrPtr adr = NewAttr("ADR"); // RFC 2426, 3.2.1
AddParam(adr, "TYPE", rfc_type);
AddValue(adr, address.Address3.c_str()); // PO Box
AddValue(adr, address.Address2.c_str()); // Extended address
AddValue(adr, address.Address1.c_str()); // Street address
AddValue(adr, address.City.c_str()); // Locality (city)
AddValue(adr, address.Province.c_str()); // Region (province)
AddValue(adr, address.PostalCode.c_str()); // Postal code
AddValue(adr, address.Country.c_str()); // Country name
AddAttr(adr);
} | false | false | false | false | false | 0 |
r128_emit_masks(drm_r128_private_t *dev_priv)
{
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_r128_context_regs_t *ctx = &sarea_priv->context_state;
RING_LOCALS;
DRM_DEBUG("\n");
BEGIN_RING(5);
OUT_RING(CCE_PACKET0(R128_DP_WRITE_MASK, 0));
OUT_RING(ctx->dp_write_mask);
OUT_RING(CCE_PACKET0(R128_STEN_REF_MASK_C, 1));
OUT_RING(ctx->sten_ref_mask_c);
OUT_RING(ctx->plane_3d_mask_c);
ADVANCE_RING();
} | false | false | false | false | false | 0 |
aarch64_print_extension (void)
{
const struct aarch64_option_extension *opt = NULL;
for (opt = all_extensions; opt->name != NULL; opt++)
if ((aarch64_isa_flags & opt->flags_on) == opt->flags_on)
asm_fprintf (asm_out_file, "+%s", opt->name);
asm_fprintf (asm_out_file, "\n");
} | false | false | false | false | false | 0 |
adlibemu_init_lists(void)
{
int i;
int j;
for (i = 0 ; i < 16 ; i++) {
for (j = 0; j < 64 ; j++) {
sci_adlib_vol_tables[i][j] = ((guint16)sci_adlib_vol_base[i]) * j / 63;
}
}
for (i = 0; i < MIDI_CHANNELS ; i++) {
pitch[i] = 8192; /* center the pitch wheel */
}
free_voices = ADLIB_VOICES;
memset(instr, 0, sizeof(instr));
memset(vol, 0x7f, sizeof(vol));
memset(pan, 0x3f, sizeof(pan));
memset(adlib_reg_L, 0, sizeof(adlib_reg_L));
memset(adlib_reg_R, 0, sizeof(adlib_reg_R));
memset(oper_chn, 0xff, sizeof(oper_chn));
memset(oper_note, 0xff, sizeof(oper_note));
adlib_master=12;
} | false | false | false | false | false | 0 |
set_parameter(int param,
std::string value)
{
switch (param) {
case 1:
label(value);
break;
case 2:
device_name_rep = value;
break;
}
} | false | false | false | false | false | 0 |
gg_image_infos_create (int pixel_format, int width, int height,
int bits_per_sample, int samples_per_pixel,
int sample_format, const char *srs_name,
const char *proj4text)
{
/* creating an image infos struct */
gGraphImageInfosPtr img;
int len;
char *SrsName = NULL;
char *Proj4Text = NULL;
/* checking PIXEL_FORMAT */
if (pixel_format == GG_PIXEL_RGB || pixel_format == GG_PIXEL_RGBA
|| pixel_format == GG_PIXEL_ARGB || pixel_format == GG_PIXEL_BGR
|| pixel_format == GG_PIXEL_GRAYSCALE
|| pixel_format == GG_PIXEL_PALETTE || pixel_format == GG_PIXEL_GRID
|| pixel_format == GG_PIXEL_UNKNOWN)
;
else
return NULL;
if (srs_name)
{
len = strlen (srs_name);
SrsName = malloc (len + 1);
if (!SrsName)
return NULL;
strcpy (SrsName, srs_name);
}
if (proj4text)
{
len = strlen (proj4text);
Proj4Text = malloc (len + 1);
if (!Proj4Text)
{
if (SrsName)
free (SrsName);
return NULL;
}
strcpy (Proj4Text, proj4text);
}
/* allocating the image INFOS struct */
img = malloc (sizeof (gGraphImage));
if (!img)
return NULL;
img->signature = GG_IMAGE_INFOS_MAGIC_SIGNATURE;
img->width = width;
img->height = height;
img->bits_per_sample = bits_per_sample;
img->samples_per_pixel = samples_per_pixel;
img->sample_format = sample_format;
img->pixel_format = pixel_format;
img->max_palette = 0;
img->is_transparent = 0;
img->tile_width = -1;
img->tile_height = -1;
img->rows_per_strip = -1;
img->compression = GGRAPH_TIFF_COMPRESSION_NONE;
img->scale_1_2 = 0;
img->scale_1_4 = 0;
img->scale_1_8 = 0;
img->is_georeferenced = 0;
img->srid = -1;
img->srs_name = SrsName;
img->proj4text = Proj4Text;
img->upper_left_x = DBL_MAX;
img->upper_left_y = DBL_MAX;
img->pixel_x_size = 0.0;
img->pixel_y_size = 0.0;
img->no_data_value = 0.0 - DBL_MAX;
img->min_value = DBL_MAX;
img->max_value = 0.0 - DBL_MAX;
return img;
} | false | false | false | false | true | 1 |
wi_tmpfile(void) {
char path[WI_PATH_SIZE];
int fd;
#ifdef _PATH_TMP
snprintf(path, sizeof(path), "%s/%s", _PATH_TMP, "tmp.XXXXXXXXXX");
#else
snprintf(path, sizeof(path), "/tmp/%s", "tmp.XXXXXXXXXX");
#endif
fd = mkstemp(path);
unlink(path);
return (fd < 0) ? NULL : fdopen(fd, "w+");
} | false | false | false | false | false | 0 |
pvr2_stream_create(void)
{
struct pvr2_stream *sp;
sp = kzalloc(sizeof(*sp),GFP_KERNEL);
if (!sp) return sp;
pvr2_trace(PVR2_TRACE_INIT,"pvr2_stream_create: sp=%p",sp);
pvr2_stream_init(sp);
return sp;
} | false | false | false | false | false | 0 |
search_easter_egg( Slapi_PBlock *pb, Slapi_Entry *entryBefore, Slapi_Entry *entryAfter, int *returncode, char *returntext, void *arg)
{
char *fstr= NULL;
char eggfilter[64];
PR_snprintf(eggfilter,sizeof(eggfilter),"(objectclass=%s)",EGG_OBJECT_CLASS);
slapi_pblock_get( pb, SLAPI_SEARCH_STRFILTER, &fstr );
if(fstr!=NULL && strcasecmp(fstr,eggfilter)==0)
{
static int twiddle= -1;
char *copy;
struct berval bvtype = {0, NULL};
struct berval bv = {0, NULL};
int freeval = 0;
struct berval *bvals[2];
if (twiddle < 0) {
twiddle = slapi_rand();
}
bvals[0] = &bv;
bvals[1] = NULL;
copy= slapi_ch_strdup(easter_egg_photos[twiddle%NUM_EASTER_EGG_PHOTOS]);
if ( slapi_ldif_parse_line(copy, &bvtype, &bv, &freeval) < 0 ) {
return SLAPI_DSE_CALLBACK_ERROR;
}
slapi_entry_attr_delete(entryBefore, "jpegphoto");
slapi_entry_attr_merge(entryBefore, "jpegphoto", bvals);
slapi_ch_free((void**)©);
twiddle++;
/* the memory below was not allocated by the slapi_ch_ functions */
if (freeval) slapi_ch_free_string(&bv.bv_val);
return SLAPI_DSE_CALLBACK_OK;
}
return SLAPI_DSE_CALLBACK_ERROR;
} | false | false | false | false | false | 0 |
PushIncidence (Shape * a, int cb, int pt, double theta)
{
if (theta < 0 || theta > 1)
return -1;
if (nbInc >= maxInc)
{
maxInc = 2 * nbInc + 1;
iData =
(incidenceData *) g_realloc(iData, maxInc * sizeof (incidenceData));
}
int n = nbInc++;
iData[n].nextInc = a->swsData[cb].firstLinkedPoint;
iData[n].pt = pt;
iData[n].theta = theta;
a->swsData[cb].firstLinkedPoint = n;
return n;
} | false | false | false | false | false | 0 |
post_process_2pass (j_decompress_ptr cinfo,
JSAMPIMAGE input_buf, JDIMENSION *in_row_group_ctr,
JDIMENSION in_row_groups_avail,
JSAMPARRAY output_buf, JDIMENSION *out_row_ctr,
JDIMENSION out_rows_avail)
{
my_post_ptr post = (my_post_ptr) cinfo->post;
JDIMENSION num_rows, max_rows;
/* Reposition virtual buffer if at start of strip. */
if (post->next_row == 0) {
post->buffer = (*cinfo->mem->access_virt_sarray)
((j_common_ptr) cinfo, post->whole_image,
post->starting_row, post->strip_height, FALSE);
}
/* Determine number of rows to emit. */
num_rows = post->strip_height - post->next_row; /* available in strip */
max_rows = out_rows_avail - *out_row_ctr; /* available in output area */
if (num_rows > max_rows)
num_rows = max_rows;
/* We have to check bottom of image here, can't depend on upsampler. */
max_rows = cinfo->output_height - post->starting_row;
if (num_rows > max_rows)
num_rows = max_rows;
/* Quantize and emit data. */
(*cinfo->cquantize->color_quantize) (cinfo,
post->buffer + post->next_row, output_buf + *out_row_ctr,
(int) num_rows);
*out_row_ctr += num_rows;
/* Advance if we filled the strip. */
post->next_row += num_rows;
if (post->next_row >= post->strip_height) {
post->starting_row += post->strip_height;
post->next_row = 0;
}
} | false | false | false | false | false | 0 |
task_get_sizepos(task *t)
{
Window root, junkwin;
int rx, ry;
guint dummy;
XWindowAttributes win_attributes;
ENTER;
if (!XGetWindowAttributes(GDK_DISPLAY(), t->win, &win_attributes)) {
if (!XGetGeometry (GDK_DISPLAY(), t->win, &root, &t->x, &t->y, &t->w, &t->h,
&dummy, &dummy)) {
t->x = t->y = t->w = t->h = 2;
}
} else {
XTranslateCoordinates (GDK_DISPLAY(), t->win, win_attributes.root,
-win_attributes.border_width,
-win_attributes.border_width,
&rx, &ry, &junkwin);
t->x = rx;
t->y = ry;
t->w = win_attributes.width;
t->h = win_attributes.height;
DBG("win=0x%lx WxH=%dx%d\n", t->win,t->w, t->h);
}
RET();
} | false | false | false | false | false | 0 |
ADIOI_NFS_Open(ADIO_File fd, int *error_code)
{
int perm, amode;
unsigned int old_mask;
#ifndef PRINT_ERR_MSG
static char myname[] = "ADIOI_NFS_OPEN";
#endif
if (fd->perm == ADIO_PERM_NULL) {
old_mask = umask(022);
umask(old_mask);
perm = old_mask ^ 0666;
}
else perm = fd->perm;
amode = 0;
if (fd->access_mode & ADIO_CREATE)
amode = amode | O_CREAT;
if (fd->access_mode & ADIO_RDONLY)
amode = amode | O_RDONLY;
if (fd->access_mode & ADIO_WRONLY)
amode = amode | O_WRONLY;
if (fd->access_mode & ADIO_RDWR)
amode = amode | O_RDWR;
if (fd->access_mode & ADIO_EXCL)
amode = amode | O_EXCL;
fd->fd_sys = open(fd->filename, amode, perm);
if ((fd->fd_sys != -1) && (fd->access_mode & ADIO_APPEND))
fd->fp_ind = fd->fp_sys_posn = lseek(fd->fd_sys, 0, SEEK_END);
#ifdef PRINT_ERR_MSG
*error_code = (fd->fd_sys == -1) ? MPI_ERR_UNKNOWN : MPI_SUCCESS;
#else
if (fd->fd_sys == -1) {
*error_code = MPIR_Err_setmsg(MPI_ERR_IO, MPIR_ADIO_ERROR,
myname, "I/O Error", "%s", strerror(errno));
ADIOI_Error(ADIO_FILE_NULL, *error_code, myname);
}
else *error_code = MPI_SUCCESS;
#endif
} | false | false | false | false | true | 1 |
fw_fill_request(struct fw_packet *packet, int tcode, int tlabel,
int destination_id, int source_id, int generation, int speed,
unsigned long long offset, void *payload, size_t length)
{
int ext_tcode;
if (tcode == TCODE_STREAM_DATA) {
packet->header[0] =
HEADER_DATA_LENGTH(length) |
destination_id |
HEADER_TCODE(TCODE_STREAM_DATA);
packet->header_length = 4;
packet->payload = payload;
packet->payload_length = length;
goto common;
}
if (tcode > 0x10) {
ext_tcode = tcode & ~0x10;
tcode = TCODE_LOCK_REQUEST;
} else
ext_tcode = 0;
packet->header[0] =
HEADER_RETRY(RETRY_X) |
HEADER_TLABEL(tlabel) |
HEADER_TCODE(tcode) |
HEADER_DESTINATION(destination_id);
packet->header[1] =
HEADER_OFFSET_HIGH(offset >> 32) | HEADER_SOURCE(source_id);
packet->header[2] =
offset;
switch (tcode) {
case TCODE_WRITE_QUADLET_REQUEST:
packet->header[3] = *(u32 *)payload;
packet->header_length = 16;
packet->payload_length = 0;
break;
case TCODE_LOCK_REQUEST:
case TCODE_WRITE_BLOCK_REQUEST:
packet->header[3] =
HEADER_DATA_LENGTH(length) |
HEADER_EXTENDED_TCODE(ext_tcode);
packet->header_length = 16;
packet->payload = payload;
packet->payload_length = length;
break;
case TCODE_READ_QUADLET_REQUEST:
packet->header_length = 12;
packet->payload_length = 0;
break;
case TCODE_READ_BLOCK_REQUEST:
packet->header[3] =
HEADER_DATA_LENGTH(length) |
HEADER_EXTENDED_TCODE(ext_tcode);
packet->header_length = 16;
packet->payload_length = 0;
break;
default:
WARN(1, "wrong tcode %d\n", tcode);
}
common:
packet->speed = speed;
packet->generation = generation;
packet->ack = 0;
packet->payload_mapped = false;
} | false | false | false | false | false | 0 |
CatalogCacheComputeHashValue(CatCache *cache, int nkeys, ScanKey cur_skey)
{
uint32 hashValue = 0;
uint32 oneHash;
CACHE4_elog(DEBUG2, "CatalogCacheComputeHashValue %s %d %p",
cache->cc_relname,
nkeys,
cache);
switch (nkeys)
{
case 4:
oneHash =
DatumGetUInt32(DirectFunctionCall1(cache->cc_hashfunc[3],
cur_skey[3].sk_argument));
hashValue ^= oneHash << 24;
hashValue ^= oneHash >> 8;
/* FALLTHROUGH */
case 3:
oneHash =
DatumGetUInt32(DirectFunctionCall1(cache->cc_hashfunc[2],
cur_skey[2].sk_argument));
hashValue ^= oneHash << 16;
hashValue ^= oneHash >> 16;
/* FALLTHROUGH */
case 2:
oneHash =
DatumGetUInt32(DirectFunctionCall1(cache->cc_hashfunc[1],
cur_skey[1].sk_argument));
hashValue ^= oneHash << 8;
hashValue ^= oneHash >> 24;
/* FALLTHROUGH */
case 1:
oneHash =
DatumGetUInt32(DirectFunctionCall1(cache->cc_hashfunc[0],
cur_skey[0].sk_argument));
hashValue ^= oneHash;
break;
default:
elog(FATAL, "wrong number of hash keys: %d", nkeys);
break;
}
return hashValue;
} | false | false | false | false | false | 0 |
indexReadsByID()
{
m_pIndex = new ReadIndex;
for(size_t i = 0; i < m_table.size(); ++i)
{
std::pair<ReadIndex::iterator, bool> result =
m_pIndex->insert(std::make_pair(m_table[i].id, &m_table[i]));
if(!result.second)
{
std::cerr << "Error: Attempted to insert vertex into table with a duplicate id: " <<
m_table[i].id << "\n";
std::cerr << "All reads must have a unique identifier\n";
exit(1);
}
}
} | false | false | false | false | false | 0 |
daemon_pidfile(const char *name)
{
int rc;
ptry(pthread_mutex_lock(&g.lock))
rc = daemon_pidfile_unlocked(name);
ptry(pthread_mutex_unlock(&g.lock))
return rc;
} | false | false | false | false | false | 0 |
Distance2ToBounds(double x[3], double bounds[6])
{
double distance;
double deltas[3];
// Are we within the bounds?
if (x[0] >= bounds[0] && x[0] <= bounds[1]
&& x[1] >= bounds[2] && x[1] <= bounds[3]
&& x[2] >= bounds[4] && x[2] <= bounds[5])
{
return 0.0;
}
deltas[0] = deltas[1] = deltas[2] = 0.0;
// dx
//
if (x[0] < bounds[0])
{
deltas[0] = bounds[0] - x[0];
}
else if (x[0] > bounds[1])
{
deltas[0] = x[0] - bounds[1];
}
// dy
//
if (x[1] < bounds[2])
{
deltas[1] = bounds[2] - x[1];
}
else if (x[1] > bounds[3])
{
deltas[1] = x[1] - bounds[3];
}
// dz
//
if (x[2] < bounds[4])
{
deltas[2] = bounds[4] - x[2];
}
else if (x[2] > bounds[5])
{
deltas[2] = x[2] - bounds[5];
}
distance = vtkMath::Dot(deltas, deltas);
return distance;
} | false | false | false | false | false | 0 |
write_optvar() {
// *** process UUID (hidden option)
if (jack_uuid != NULL) {
optvar[JACK_UUID] = jack_uuid; // leads to no automatic connection
g_free(jack_uuid);
} else if (!optvar[JACK_UUID].empty()) {
optvar[JACK_UUID] = "";
}
// *** process ENGINE options
if (pitch != NULL) {
optvar[PITCH] = pitch;
g_free(pitch);
} else if (!optvar[PITCH].empty()) {
optvar[PITCH] = "";
}
if (threshold != NULL) {
optvar[THRESHOLD] = threshold;
g_free(threshold);
} else if (!optvar[THRESHOLD].empty()) {
optvar[THRESHOLD] = "";
}
// *** process GTK options
if (size_x != NULL) {
optvar[SIZE_Y] = size_y;
g_free(size_y);
} else if (!optvar[SIZE_Y].empty()) {
optvar[SIZE_Y] = "";
}
if (size_y != NULL) {
optvar[SIZE_X] = size_x;
g_free(size_x);
} else if (!optvar[SIZE_X].empty()) {
optvar[SIZE_X] = "";
}
if (pos_y != NULL) {
optvar[POS_Y] = pos_y;
g_free(pos_y);
} else if (!optvar[POS_Y].empty()) {
optvar[POS_Y] = "";
}
if (pos_x != NULL) {
optvar[POS_X] = pos_x;
g_free(pos_x);
} else if (!optvar[POS_X].empty()) {
optvar[POS_X] = "";
}
if (desktop != NULL) {
optvar[DESK] = desktop;
g_free(desktop);
} else if (!optvar[DESK].empty()) {
optvar[DESK] = "";
}
// *** process JACK options
if (jack_input != NULL) {
optvar[JACK_INP] = jack_input;
g_free(jack_input);
} else if (!optvar[JACK_INP].empty()) {
optvar[JACK_INP] = ""; // leads to no automatic connection
}
} | false | false | false | false | false | 0 |
aisc_delete(aisc_com *link,int objekt_type,long source)
{
int len,mes_cnt;
mes_cnt = 2;
link->aisc_mes_buffer[mes_cnt++] = objekt_type;
link->aisc_mes_buffer[mes_cnt++] = source;
link->aisc_mes_buffer[0] = mes_cnt - 2;
link->aisc_mes_buffer[1] = AISC_DELETE+link->magic;
len = aisc_c_write(link->socket, (char *)(link->aisc_mes_buffer), mes_cnt * sizeof(long));
if (!len) {
link->error = err_connection_problems;
PRTERR("AISC_DELETE_ERROR");
return 1;
}
return aisc_check_error(link);
} | false | false | false | false | false | 0 |
s_macro (int ignore ATTRIBUTE_UNUSED)
{
char *file, *eol;
unsigned int line;
sb s;
const char *err;
const char *name;
as_where (&file, &line);
eol = find_end_of_line (input_line_pointer, 0);
sb_build (&s, eol - input_line_pointer);
sb_add_buffer (&s, input_line_pointer, eol - input_line_pointer);
input_line_pointer = eol;
if (line_label != NULL)
{
sb label;
size_t len;
name = S_GET_NAME (line_label);
len = strlen (name);
sb_build (&label, len);
sb_add_buffer (&label, name, len);
err = define_macro (0, &s, &label, get_macro_line_sb, file, line, &name);
sb_kill (&label);
}
else
err = define_macro (0, &s, NULL, get_macro_line_sb, file, line, &name);
if (err != NULL)
as_bad_where (file, line, err, name);
else
{
if (line_label != NULL)
{
S_SET_SEGMENT (line_label, absolute_section);
S_SET_VALUE (line_label, 0);
symbol_set_frag (line_label, &zero_address_frag);
}
if (((NO_PSEUDO_DOT || flag_m68k_mri)
&& hash_find (po_hash, name) != NULL)
|| (!flag_m68k_mri
&& *name == '.'
&& hash_find (po_hash, name + 1) != NULL))
as_warn_where (file,
line,
_("attempt to redefine pseudo-op `%s' ignored"),
name);
}
sb_kill (&s);
} | false | false | false | false | false | 0 |
graph_object_destructor(graph_object *object)
{
graph_edge *edge, *tmp_edge;
graph_node *node, *tmp_node;
if (object->edge_list_head) {
edge = object->edge_list_head;
while (edge) {
tmp_edge = edge->next_edge;
graph_edge_destructor(edge);
edge = tmp_edge;
}
}
if (object->node_list_head) {
node = object->node_list_head;
while (node) {
tmp_node = node->next_node;
graph_node_destructor(node);
node = tmp_node;
}
}
if (object->name) {
free(object->name);
}
free(object);
} | false | false | false | false | false | 0 |
qed_int_cau_conf_sb(struct qed_hwfn *p_hwfn,
struct qed_ptt *p_ptt,
dma_addr_t sb_phys,
u16 igu_sb_id,
u16 vf_number,
u8 vf_valid)
{
struct cau_sb_entry sb_entry;
u32 val;
qed_init_cau_sb_entry(p_hwfn, &sb_entry, p_hwfn->rel_pf_id,
vf_number, vf_valid);
if (p_hwfn->hw_init_done) {
val = CAU_REG_SB_ADDR_MEMORY + igu_sb_id * sizeof(u64);
qed_wr(p_hwfn, p_ptt, val, lower_32_bits(sb_phys));
qed_wr(p_hwfn, p_ptt, val + sizeof(u32),
upper_32_bits(sb_phys));
val = CAU_REG_SB_VAR_MEMORY + igu_sb_id * sizeof(u64);
qed_wr(p_hwfn, p_ptt, val, sb_entry.data);
qed_wr(p_hwfn, p_ptt, val + sizeof(u32), sb_entry.params);
} else {
/* Initialize Status Block Address */
STORE_RT_REG_AGG(p_hwfn,
CAU_REG_SB_ADDR_MEMORY_RT_OFFSET +
igu_sb_id * 2,
sb_phys);
STORE_RT_REG_AGG(p_hwfn,
CAU_REG_SB_VAR_MEMORY_RT_OFFSET +
igu_sb_id * 2,
sb_entry);
}
/* Configure pi coalescing if set */
if (p_hwfn->cdev->int_coalescing_mode == QED_COAL_MODE_ENABLE) {
u8 timeset = p_hwfn->cdev->rx_coalesce_usecs >>
(QED_CAU_DEF_RX_TIMER_RES + 1);
u8 num_tc = 1, i;
qed_int_cau_conf_pi(p_hwfn, p_ptt, igu_sb_id, RX_PI,
QED_COAL_RX_STATE_MACHINE,
timeset);
timeset = p_hwfn->cdev->tx_coalesce_usecs >>
(QED_CAU_DEF_TX_TIMER_RES + 1);
for (i = 0; i < num_tc; i++) {
qed_int_cau_conf_pi(p_hwfn, p_ptt,
igu_sb_id, TX_PI(i),
QED_COAL_TX_STATE_MACHINE,
timeset);
}
}
} | false | false | false | false | false | 0 |
bet_transfert_take_data ( struct_transfert_data *transfert, GtkWidget *dialog )
{
GtkWidget *widget;
GtkTreeView *tree_view;
GtkTreeModel *model;
GtkTreeIter iter;
gint replace_account;
gint type;
tree_view = g_object_get_data ( G_OBJECT ( dialog ), "tree_view" );
gtk_tree_selection_get_selected ( GTK_TREE_SELECTION (
gtk_tree_view_get_selection ( GTK_TREE_VIEW ( tree_view ) ) ),
&model, &iter );
gtk_tree_model_get ( GTK_TREE_MODEL ( model ), &iter,
2, &replace_account,
3, &type,
-1 );
transfert -> replace_account = replace_account;
transfert -> type = type;
widget = g_object_get_data ( G_OBJECT ( dialog ), "date_entry" );
if ( gsb_form_widget_check_empty ( widget ) == FALSE )
{
transfert -> date = gsb_calendar_entry_get_date ( widget );
if ( transfert -> date == NULL )
return FALSE;
}
else
return FALSE;
widget = g_object_get_data ( G_OBJECT ( dialog ), "bet_transfert_auto_inc" );
transfert -> auto_inc_month = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON ( widget ) );
widget = g_object_get_data ( G_OBJECT ( dialog ), "bet_transfert_replace_data" );
transfert -> replace_transaction = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON ( widget ) );
if ( transfert -> replace_transaction )
{
gboolean empty = TRUE;
widget = g_object_get_data ( G_OBJECT ( dialog ), "bet_transfert_category_combo" );
if ( gsb_form_widget_check_empty( widget ) == FALSE )
{
bet_future_get_category_data ( widget, 1, ( gpointer ) transfert );
empty = FALSE;
}
widget = g_object_get_data ( G_OBJECT ( dialog ), "bet_transfert_budget_combo" );
if ( gsb_form_widget_check_empty( widget ) == FALSE )
{
bet_future_get_budget_data ( widget, 1, ( gpointer ) transfert );
empty = FALSE;
}
if ( empty )
return FALSE;
}
return TRUE;
} | false | false | false | false | false | 0 |
ColToInd( const wxColour& colour ) const
{
size_t i;
size_t i_max = m_choices.GetCount();
if ( !(m_flags & wxPG_PROP_HIDE_CUSTOM_COLOUR) )
i_max -= 1;
for ( i=0; i<i_max; i++ )
{
int ind = m_choices[i].GetValue();
if ( colour == GetColour(ind) )
{
/*wxLogDebug(wxT("%s(%s): Index %i for ( getcolour(%i,%i,%i), colour(%i,%i,%i))"),
GetClassName(),GetLabel().c_str(),
(int)i,(int)GetColour(ind).Red(),(int)GetColour(ind).Green(),(int)GetColour(ind).Blue(),
(int)colour.Red(),(int)colour.Green(),(int)colour.Blue());*/
return ind;
}
}
return wxNOT_FOUND;
} | false | false | false | false | false | 0 |
checkOverride (Variable *var) {
if (var->flags & VAR_PRIVATE) { // defining a private block? No override
return NULL ;
}
Scope *scope ;
Variable *v = NULL ;
string tagname = "." + var->name ;
Tag *tag = (Tag*)Scope::findVariable (tagname, scope, VAR_ACCESSFULL, NULL, NULL) ;
if (tag != NULL) {
v = tag->var ;
if (v->flags & VAR_PRIVATE) { // private blocks are not overridden
return NULL ;
}
}
if (v == NULL && superblock != NULL) {
v = superblock->block->checkOverride (var) ;
}
return v ;
} | false | false | false | false | false | 0 |
next_marker (void)
{
int c;
int discarded_bytes = 0;
/* Find 0xFF byte; count and skip any non-FFs. */
c = read_1_byte();
while (c != 0xFF) {
discarded_bytes++;
c = read_1_byte();
}
/* Get marker code byte, swallowing any duplicate FF bytes. Extra FFs
* are legal as pad bytes, so don't count them in discarded_bytes.
*/
do {
c = read_1_byte();
} while (c == 0xFF);
if (discarded_bytes != 0) {
fprintf(stderr, "Warning: garbage data found in JPEG file\n");
}
return c;
} | false | false | false | false | false | 0 |
rb_ary_resize(VALUE ary, long len)
{
long olen;
rb_ary_modify(ary);
olen = RARRAY_LEN(ary);
if (len == olen) return ary;
if (len > ARY_MAX_SIZE) {
rb_raise(rb_eIndexError, "index %ld too big", len);
}
if (len > olen) {
if (len >= ARY_CAPA(ary)) {
ary_double_capa(ary, len);
}
rb_mem_clear(RARRAY_PTR(ary) + olen, len - olen);
ARY_SET_LEN(ary, len);
}
else if (ARY_EMBED_P(ary)) {
ARY_SET_EMBED_LEN(ary, len);
}
else if (len <= RARRAY_EMBED_LEN_MAX) {
VALUE tmp[RARRAY_EMBED_LEN_MAX];
MEMCPY(tmp, ARY_HEAP_PTR(ary), VALUE, len);
ary_discard(ary);
MEMCPY(ARY_EMBED_PTR(ary), tmp, VALUE, len);
ARY_SET_EMBED_LEN(ary, len);
}
else {
if (olen > len + ARY_DEFAULT_SIZE) {
REALLOC_N(RARRAY(ary)->as.heap.ptr, VALUE, len);
ARY_SET_CAPA(ary, len);
}
ARY_SET_HEAP_LEN(ary, len);
}
return ary;
} | false | false | false | false | false | 0 |
gcr_certificate_compare (GcrComparable *first, GcrComparable *other)
{
gconstpointer data1, data2;
gsize size1, size2;
if (!GCR_IS_CERTIFICATE (first))
first = NULL;
if (!GCR_IS_CERTIFICATE (other))
other = NULL;
if (first == other)
return TRUE;
if (!first)
return 1;
if (!other)
return -1;
data1 = gcr_certificate_get_der_data (GCR_CERTIFICATE (first), &size1);
data2 = gcr_certificate_get_der_data (GCR_CERTIFICATE (other), &size2);
return gcr_comparable_memcmp (data1, size1, data2, size2);
} | false | false | false | false | false | 0 |
mpegts_base_apply_sdt (MpegTSBase * base,
guint16 pmt_pid, GstStructure * sdt_info)
{
GST_DEBUG_OBJECT (base, "SDT %" GST_PTR_FORMAT, sdt_info);
mpegts_base_get_tags_from_sdt (base, sdt_info);
gst_element_post_message (GST_ELEMENT_CAST (base),
gst_message_new_element (GST_OBJECT (base),
gst_structure_copy (sdt_info)));
} | false | false | false | false | false | 0 |
latexMarkChange(otexstream & os, BufferParams const & bparams,
Change const & oldChange, Change const & change,
OutputParams const & runparams)
{
if (!bparams.outputChanges || oldChange == change)
return 0;
int column = 0;
if (oldChange.type != Change::UNCHANGED) {
// close \lyxadded or \lyxdeleted
os << '}';
column++;
}
docstring chgTime;
chgTime += ctime(&change.changetime);
// remove trailing '\n'
chgTime.erase(chgTime.end() - 1);
docstring macro_beg;
if (change.type == Change::DELETED)
macro_beg = from_ascii("\\lyxdeleted{");
else if (change.type == Change::INSERTED)
macro_beg = from_ascii("\\lyxadded{");
docstring str = getLaTeXMarkup(macro_beg,
bparams.authors().get(change.author).name(),
chgTime, runparams);
os << str;
column += str.size();
return column;
} | false | false | false | false | false | 0 |
renderer_change_view_impl (GtkSourceGutterRenderer *renderer,
GtkTextView *old_view)
{
if (old_view)
{
g_signal_handlers_disconnect_by_func (old_view,
G_CALLBACK (on_buffer_changed),
renderer);
}
if (renderer->priv->view)
{
emit_buffer_changed (renderer->priv->view, renderer);
g_signal_connect (renderer->priv->view,
"notify::buffer",
G_CALLBACK (on_buffer_changed),
renderer);
}
} | false | false | false | false | false | 0 |
pinbo_get_bg_tile_info(int tile_index)
{
int code = lasso_videoram[tile_index];
int color = lasso_colorram[tile_index];
SET_TILE_INFO(0,
code + ((color & 0x30) << 4),
color & 0x0f,
0)
} | false | false | false | false | false | 0 |
read_from_stdin(struct path_list *list)
{
char buffer[1024];
while (fgets(buffer, sizeof(buffer), stdin) != NULL) {
char *bob;
if ((buffer[0] == 'A' || buffer[0] == 'a') &&
!prefixcmp(buffer + 1, "uthor: ") &&
(bob = strchr(buffer + 7, '<')) != NULL) {
char buffer2[1024], offset = 0;
if (map_email(&mailmap, bob + 1, buffer, sizeof(buffer)))
bob = buffer + strlen(buffer);
else {
offset = 8;
while (buffer + offset < bob &&
isspace(bob[-1]))
bob--;
}
while (fgets(buffer2, sizeof(buffer2), stdin) &&
buffer2[0] != '\n')
; /* chomp input */
if (fgets(buffer2, sizeof(buffer2), stdin)) {
int l2 = strlen(buffer2);
int i;
for (i = 0; i < l2; i++)
if (!isspace(buffer2[i]))
break;
insert_author_oneline(list,
buffer + offset,
bob - buffer - offset,
buffer2 + i, l2 - i);
}
}
}
} | false | false | false | false | false | 0 |
possibleBufferOverrunError(const Token *tok, const std::string &src, const std::string &dst, bool cat)
{
if (cat)
reportError(tok, Severity::warning, "possibleBufferAccessOutOfBounds",
"Possible buffer overflow if strlen(" + src + ") is larger than sizeof(" + dst + ")-strlen(" + dst +").\n"
"Possible buffer overflow if strlen(" + src + ") is larger than sizeof(" + dst + ")-strlen(" + dst +"). "
"The source buffer is larger than the destination buffer so there is the potential for overflowing the destination buffer.");
else
reportError(tok, Severity::warning, "possibleBufferAccessOutOfBounds",
"Possible buffer overflow if strlen(" + src + ") is larger than or equal to sizeof(" + dst + ").\n"
"Possible buffer overflow if strlen(" + src + ") is larger than or equal to sizeof(" + dst + "). "
"The source buffer is larger than the destination buffer so there is the potential for overflowing the destination buffer.");
} | false | false | false | false | false | 0 |
ews_decode_binary (EwsOabDecoder *eod,
GCancellable *cancellable,
GError **error)
{
EwsOabDecoderPrivate *priv = GET_PRIVATE (eod);
guint32 len;
gchar *binary;
GBytes *val = NULL;
len = ews_decode_uint32 (eod, cancellable, error);
if (*error)
return NULL;
binary = g_malloc (len);
g_input_stream_read (G_INPUT_STREAM (priv->fis), binary, len, cancellable, error);
if (*error) {
g_free (binary);
goto exit;
}
val = g_bytes_new_take (binary, len);
binary = NULL;
exit:
return val;
} | false | false | false | false | false | 0 |
OutputFeatureValuesForHypergraph(const Hypothesis* hypo, std::ostream &outputSearchGraphStream) const
{
outputSearchGraphStream.setf(std::ios::fixed);
outputSearchGraphStream.precision(6);
const StaticData& staticData = StaticData::Instance();
const TranslationSystem& system = staticData.GetTranslationSystem(TranslationSystem::DEFAULT);
const vector<const StatelessFeatureFunction*>& slf =system.GetStatelessFeatureFunctions();
const vector<const StatefulFeatureFunction*>& sff = system.GetStatefulFeatureFunctions();
size_t featureIndex = 1;
for (size_t i = 0; i < sff.size(); ++i) {
featureIndex = OutputFeatureValuesForHypergraph(featureIndex, hypo, sff[i], outputSearchGraphStream);
}
for (size_t i = 0; i < slf.size(); ++i) {
if (slf[i]->GetScoreProducerWeightShortName() != "u" &&
slf[i]->GetScoreProducerWeightShortName() != "tm" &&
slf[i]->GetScoreProducerWeightShortName() != "I" &&
slf[i]->GetScoreProducerWeightShortName() != "g")
{
featureIndex = OutputFeatureValuesForHypergraph(featureIndex, hypo, slf[i], outputSearchGraphStream);
}
}
const vector<PhraseDictionaryFeature*>& pds = system.GetPhraseDictionaries();
for( size_t i=0; i<pds.size(); i++ ) {
featureIndex = OutputFeatureValuesForHypergraph(featureIndex, hypo, pds[i], outputSearchGraphStream);
}
const vector<GenerationDictionary*>& gds = system.GetGenerationDictionaries();
for( size_t i=0; i<gds.size(); i++ ) {
featureIndex = OutputFeatureValuesForHypergraph(featureIndex, hypo, gds[i], outputSearchGraphStream);
}
} | false | false | false | false | false | 0 |
SD_PowerON(void) {
SDIO_InitTypeDef SDIO_InitStructure;
SDIO_CmdInitTypeDef SDIO_CmdInitStructure;
__IO SD_Error errorstatus = SD_OK;
uint32_t response = 0, count = 0, validvoltage = 0;
uint32_t SDType = SD_STD_CAPACITY;
// Power ON Sequence
// Configure the SDIO peripheral
// SDIOCLK = HCLK, SDIO_CK = HCLK/(2 + SDIO_INIT_CLK_DIV)
// on STM32F2xx devices, SDIOCLK is fixed to 48MHz
// SDIO_CK for initialization should not exceed 400 KHz
SDIO_InitStructure.SDIO_ClockDiv = SDIO_INIT_CLK_DIV;
SDIO_InitStructure.SDIO_ClockEdge = SDIO_ClockEdge_Rising;
SDIO_InitStructure.SDIO_ClockBypass = SDIO_ClockBypass_Disable;
SDIO_InitStructure.SDIO_ClockPowerSave = SDIO_ClockPowerSave_Disable;
SDIO_InitStructure.SDIO_BusWide = SDIO_BusWide_1b;
SDIO_InitStructure.SDIO_HardwareFlowControl = SDIO_HardwareFlowControl_Disable;
SDIO_Init(&SDIO_InitStructure);
// Set Power State to ON
SDIO_SetPowerState(SDIO_PowerState_ON);
// Enable SDIO Clock
SDIO_ClockCmd(ENABLE);
// CMD0: GO_IDLE_STATE
// No CMD response required
SDIO_CmdInitStructure.SDIO_Argument = 0x0;
SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_GO_IDLE_STATE;
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_No;
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus = CmdError();
// CMD Response TimeOut (wait for CMDSENT flag)
if (errorstatus != SD_OK) {
return (errorstatus);
}
// CMD8: SEND_IF_COND
// Send CMD8 to verify SD card interface operating condition
// Argument: - [31:12]: Reserved (shall be set to '0')
// - [11:8]: Supply Voltage (VHS) 0x1 (Range: 2.7-3.6 V)
// - [7:0]: Check Pattern (recommended 0xAA)
// CMD Response: R7
SDIO_CmdInitStructure.SDIO_Argument = SD_CHECK_PATTERN;
SDIO_CmdInitStructure.SDIO_CmdIndex = SDIO_SEND_IF_COND;
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus = CmdResp7Error();
if (errorstatus == SD_OK) {
sdioData.CardType = SDIO_STD_CAPACITY_SD_CARD_V2_0; // SD Card 2.0
SDType = SD_HIGH_CAPACITY;
} else {
// CMD55
SDIO_CmdInitStructure.SDIO_Argument = 0x00;
SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_APP_CMD;
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus = CmdResp1Error(SD_CMD_APP_CMD);
}
// CMD55
SDIO_CmdInitStructure.SDIO_Argument = 0x00;
SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_APP_CMD;
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus = CmdResp1Error(SD_CMD_APP_CMD);
// If errorstatus is Command TimeOut, it is a MMC card
// If errorstatus is SD_OK it is a SD card: SD card 2.0 (voltage range mismatch)
// or SD card 1.x
if (errorstatus == SD_OK) {
// SD CARD
// Send ACMD41 SD_APP_OP_COND with Argument 0x80100000
while ((!validvoltage) && (count < SD_MAX_VOLT_TRIAL)) {
// SEND CMD55 APP_CMD with RCA as 0
SDIO_CmdInitStructure.SDIO_Argument = 0x00;
SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_APP_CMD;
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus = CmdResp1Error(SD_CMD_APP_CMD);
if (errorstatus != SD_OK) {
return(errorstatus);
}
SDIO_CmdInitStructure.SDIO_Argument = SD_VOLTAGE_WINDOW_SD | SDType;
SDIO_CmdInitStructure.SDIO_CmdIndex = SD_CMD_SD_APP_OP_COND;
SDIO_CmdInitStructure.SDIO_Response = SDIO_Response_Short;
SDIO_CmdInitStructure.SDIO_Wait = SDIO_Wait_No;
SDIO_CmdInitStructure.SDIO_CPSM = SDIO_CPSM_Enable;
SDIO_SendCommand(&SDIO_CmdInitStructure);
errorstatus = CmdResp3Error();
if (errorstatus != SD_OK) {
return(errorstatus);
}
response = SDIO_GetResponse(SDIO_RESP1);
validvoltage = (((response >> 31) == 1) ? 1 : 0);
count++;
}
if (count >= SD_MAX_VOLT_TRIAL) {
errorstatus = SD_INVALID_VOLTRANGE;
return(errorstatus);
}
if (response &= SD_HIGH_CAPACITY) {
sdioData.CardType = SDIO_HIGH_CAPACITY_SD_CARD;
}
} // else MMC Card
return(errorstatus);
} | false | false | false | false | false | 0 |
strnpointerid(char *dest, const void *pointer, size_t len)
{
*dest=0;
if (pointer)
snprintf(dest, len, ".x%lx", (unsigned long)pointer);
return dest;
} | false | false | false | false | false | 0 |
processMap(void)
{
std::list<ArMapObject *>::const_iterator it;
ArMapObject *obj;
myDataMutex.lock();
ArUtil::deleteSet(mySegments.begin(), mySegments.end());
mySegments.clear();
for (it = myMap->getMapObjects()->begin();
it != myMap->getMapObjects()->end();
it++)
{
obj = (*it);
if (strcmp(obj->getType(), "ForbiddenLine") == 0 &&
obj->hasFromTo())
{
mySegments.push_back(new ArLineSegment(obj->getFromPose(),
obj->getToPose()));
}
if (strcmp(obj->getType(), "ForbiddenArea") == 0 &&
obj->hasFromTo())
{
double angle = obj->getPose().getTh();
double sa = ArMath::sin(angle);
double ca = ArMath::cos(angle);
double fx = obj->getFromPose().getX();
double fy = obj->getFromPose().getY();
double tx = obj->getToPose().getX();
double ty = obj->getToPose().getY();
ArPose P0((fx*ca - fy*sa), (fx*sa + fy*ca));
ArPose P1((tx*ca - fy*sa), (tx*sa + fy*ca));
ArPose P2((tx*ca - ty*sa), (tx*sa + ty*ca));
ArPose P3((fx*ca - ty*sa), (fx*sa + ty*ca));
mySegments.push_back(new ArLineSegment(P0, P1));
mySegments.push_back(new ArLineSegment(P1, P2));
mySegments.push_back(new ArLineSegment(P2, P3));
mySegments.push_back(new ArLineSegment(P3, P0));
}
}
myDataMutex.unlock();
} | false | false | false | false | false | 0 |
find_induction_variables (struct ivopts_data *data)
{
unsigned i;
bitmap_iterator bi;
if (!find_bivs (data))
return false;
find_givs (data);
mark_bivs (data);
if (dump_file && (dump_flags & TDF_DETAILS))
{
struct tree_niter_desc *niter = niter_for_single_dom_exit (data);
if (niter)
{
fprintf (dump_file, " number of iterations ");
print_generic_expr (dump_file, niter->niter, TDF_SLIM);
if (!integer_zerop (niter->may_be_zero))
{
fprintf (dump_file, "; zero if ");
print_generic_expr (dump_file, niter->may_be_zero, TDF_SLIM);
}
fprintf (dump_file, "\n\n");
};
fprintf (dump_file, "Induction variables:\n\n");
EXECUTE_IF_SET_IN_BITMAP (data->relevant, 0, i, bi)
{
if (ver_info (data, i)->iv)
dump_iv (dump_file, ver_info (data, i)->iv);
}
}
return true;
} | false | false | false | false | false | 0 |
_elm_layout_smart_table_unpack(Evas_Object *obj,
const char *part,
Evas_Object *child)
{
EINA_SAFETY_ON_NULL_RETURN_VAL(part, NULL);
EINA_SAFETY_ON_NULL_RETURN_VAL(child, NULL);
ELM_LAYOUT_DATA_GET(obj, sd);
const Eina_List *l;
Elm_Layout_Sub_Object_Data *sub_d;
EINA_LIST_FOREACH (sd->subs, l, sub_d)
{
if (sub_d->type != TABLE_PACK) continue;
if ((sub_d->obj == child) && (!strcmp(sub_d->part, part)))
return _sub_table_remove(obj, sd, sub_d);
}
return NULL;
} | 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.