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 |
|---|---|---|---|---|---|---|
opal_err2str(int errnum, const char **errmsg)
{
const char *retval;
switch (errnum) {
case OPAL_SUCCESS:
retval = "Success";
break;
case OPAL_ERROR:
retval = "Error";
break;
case OPAL_ERR_OUT_OF_RESOURCE:
retval = "Out of resource";
break;
case OPAL_ERR_TEMP_OUT_OF_RESOURCE:
retval = "Temporarily out of resource";
break;
case OPAL_ERR_RESOURCE_BUSY:
retval = "Resource busy";
break;
case OPAL_ERR_BAD_PARAM:
retval = "Bad parameter";
break;
case OPAL_ERR_FATAL:
retval = "Fatal";
break;
case OPAL_ERR_NOT_IMPLEMENTED:
retval = "Not implemented";
break;
case OPAL_ERR_NOT_SUPPORTED:
retval = "Not supported";
break;
case OPAL_ERR_INTERUPTED:
retval = "Interupted";
break;
case OPAL_ERR_WOULD_BLOCK:
retval = "Would block";
break;
case OPAL_ERR_IN_ERRNO:
retval = "In errno";
break;
case OPAL_ERR_UNREACH:
retval = "Unreachable";
break;
case OPAL_ERR_NOT_FOUND:
retval = "Not found";
break;
case OPAL_EXISTS:
retval = "Exists";
break;
case OPAL_ERR_TIMEOUT:
retval = "Timeout";
break;
case OPAL_ERR_NOT_AVAILABLE:
retval = "Not available";
break;
case OPAL_ERR_PERM:
retval = "No permission";
break;
case OPAL_ERR_VALUE_OUT_OF_BOUNDS:
retval = "Value out of bounds";
break;
case OPAL_ERR_FILE_READ_FAILURE:
retval = "File read failure";
break;
case OPAL_ERR_FILE_WRITE_FAILURE:
retval = "File write failure";
break;
case OPAL_ERR_FILE_OPEN_FAILURE:
retval = "File open failure";
break;
case OPAL_ERR_PACK_MISMATCH:
retval = "Pack data mismatch";
break;
case OPAL_ERR_PACK_FAILURE:
retval = "Data pack failed";
break;
case OPAL_ERR_UNPACK_FAILURE:
retval = "Data unpack failed";
break;
case OPAL_ERR_UNPACK_INADEQUATE_SPACE:
retval = "Data unpack had inadequate space";
break;
case OPAL_ERR_UNPACK_READ_PAST_END_OF_BUFFER:
retval = "Data unpack would read past end of buffer";
break;
case OPAL_ERR_OPERATION_UNSUPPORTED:
retval = "Requested operation is not supported on referenced data type";
break;
case OPAL_ERR_UNKNOWN_DATA_TYPE:
retval = "Unknown data type";
break;
case OPAL_ERR_BUFFER:
retval = "Buffer type (described vs non-described) mismatch - operation not allowed";
break;
case OPAL_ERR_DATA_TYPE_REDEF:
retval = "Attempt to redefine an existing data type";
break;
case OPAL_ERR_DATA_OVERWRITE_ATTEMPT:
retval = "Attempt to overwrite a data value";
break;
case OPAL_ERR_MODULE_NOT_FOUND:
retval = "Framework requires at least one active module, but none found";
break;
case OPAL_ERR_TOPO_SLOT_LIST_NOT_SUPPORTED:
retval = "OS topology does not support slot_list process affinity";
break;
case OPAL_ERR_TOPO_SOCKET_NOT_SUPPORTED:
retval = "Could not obtain socket topology information";
break;
case OPAL_ERR_TOPO_CORE_NOT_SUPPORTED:
retval = "Could not obtain core topology information";
break;
case OPAL_ERR_NOT_ENOUGH_SOCKETS:
retval = "Not enough sockets to meet request";
break;
case OPAL_ERR_NOT_ENOUGH_CORES:
retval = "Not enough cores to meet request";
break;
case OPAL_ERR_INVALID_PHYS_CPU:
retval = "Invalid physical cpu number returned";
break;
case OPAL_ERR_MULTIPLE_AFFINITIES:
retval = "Multiple methods for assigning process affinity were specified";
break;
case OPAL_ERR_SLOT_LIST_RANGE:
retval = "Provided slot_list range is invalid";
break;
case OPAL_ERR_NETWORK_NOT_PARSEABLE:
retval = "Provided network specification is not parseable";
break;
case OPAL_ERR_SILENT:
retval = NULL;
break;
case OPAL_ERR_NOT_INITIALIZED:
retval = "Not initialized";
break;
case OPAL_ERR_NOT_BOUND:
retval = "Not bound";
break;
case OPAL_ERR_TAKE_NEXT_OPTION:
retval = "Take next option";
break;
case OPAL_ERR_PROC_ENTRY_NOT_FOUND:
retval = "Database entry not found";
break;
case OPAL_ERR_DATA_VALUE_NOT_FOUND:
retval = "Data for specified key not found";
break;
case OPAL_ERR_CONNECTION_FAILED:
retval = "Connection failed";
break;
case OPAL_ERR_AUTHENTICATION_FAILED:
retval = "Authentication failed";
break;
default:
retval = NULL;
}
*errmsg = retval;
return OPAL_SUCCESS;
} | false | false | false | false | false | 0 |
welcome_token_exchange()
{
// <auth type="token-welcome-exchange">
// <token>JLKJLKJDS</token></auth>
xmlNodePtr n;
xmlNodePtr m;
xmlDocPtr doc;
xmlChar *xmlbuff;
int buffersize;
doc = xmlNewDoc(BAD_CAST "1.0");
n = xmlNewNode(NULL, BAD_CAST "auth");
m = xmlNewNode(NULL, BAD_CAST "token");
xmlAddChild(n, m);
xmlSetProp(n, (xmlChar*)"type",
(xmlChar*)"token-welcome-exchange");
int i = 0;
char random[21];
for (i = 0; i < 21; i++) {
char c = (char)(rand() % 26+65);
random[i] = c;
}
random[21] ='\0';
xmlNodeSetContent(m, BAD_CAST random);
xmlDocSetRootElement(doc, n);
xmlDocDumpFormatMemory(doc, &xmlbuff, &buffersize, 1);
printf("%s", (char *) xmlbuff);
xmlFreeDoc(doc);
return (char *) xmlbuff;
} | false | false | false | false | false | 0 |
additional_selector_matches_style (StTheme *a_this,
CRAdditionalSel *a_add_sel,
StThemeNode *a_node)
{
CRAdditionalSel *cur_add_sel = NULL;
g_return_val_if_fail (a_add_sel, FALSE);
for (cur_add_sel = a_add_sel; cur_add_sel; cur_add_sel = cur_add_sel->next)
{
switch (cur_add_sel->type)
{
case NO_ADD_SELECTOR:
return FALSE;
case CLASS_ADD_SELECTOR:
if (!class_add_sel_matches_style (cur_add_sel, a_node))
return FALSE;
break;
case ID_ADD_SELECTOR:
if (!id_add_sel_matches_style (cur_add_sel, a_node))
return FALSE;
break;
case ATTRIBUTE_ADD_SELECTOR:
g_warning ("Attribute selectors not supported");
return FALSE;
case PSEUDO_CLASS_ADD_SELECTOR:
if (!pseudo_class_add_sel_matches_style (a_this, cur_add_sel, a_node))
return FALSE;
break;
}
}
return TRUE;
} | false | false | false | false | false | 0 |
write(const QByteArray &buf)
{
if(d->active && !d->udp)
d->sock.write(buf);
} | false | false | false | false | false | 0 |
isInside(QPointF p)
{
QPointF cp = getGLEPoint(CentrePoint);
QPointF gp = QGLE::absQtToGLE(p,dpi,pixmap.height());
double angle;
if (QGLE::distance(cp,gp) < getGLELength(Radius))
{
angle = QGLE::angleBetweenTwoPoints(cp,gp);
if (isOnArc(angle))
return(true);
}
return(false);
} | false | false | false | false | false | 0 |
F_defun(struct alisp_instance *instance, struct alisp_object * args)
{
struct alisp_object * p1 = car(args),
* p2 = car(cdr(args)),
* p3 = cdr(cdr(args));
struct alisp_object * lexpr;
lexpr = new_object(instance, ALISP_OBJ_CONS);
if (lexpr) {
lexpr->value.c.car = new_identifier(instance, "lambda");
if (lexpr->value.c.car == NULL) {
delete_object(instance, lexpr);
delete_tree(instance, args);
return NULL;
}
if ((lexpr->value.c.cdr = new_object(instance, ALISP_OBJ_CONS)) == NULL) {
delete_object(instance, lexpr->value.c.car);
delete_object(instance, lexpr);
delete_tree(instance, args);
return NULL;
}
lexpr->value.c.cdr->value.c.car = p2;
lexpr->value.c.cdr->value.c.cdr = p3;
delete_object(instance, cdr(args));
delete_object(instance, args);
if (set_object(instance, p1, lexpr) == NULL) {
delete_tree(instance, p1);
delete_tree(instance, lexpr);
return NULL;
}
delete_tree(instance, p1);
} else {
delete_tree(instance, args);
}
return &alsa_lisp_nil;
} | false | false | false | false | false | 0 |
seems_valid_real(const Octstr *ostr, const char *filename, long lineno,
const char *function)
{
gw_assert(immutables_init);
gw_assert_place(ostr != NULL,
filename, lineno, function);
gw_assert_allocated(ostr,
filename, lineno, function);
gw_assert_place(ostr->len >= 0,
filename, lineno, function);
gw_assert_place(ostr->size >= 0,
filename, lineno, function);
if (ostr->size == 0) {
gw_assert_place(ostr->len == 0,
filename, lineno, function);
gw_assert_place(ostr->data == NULL,
filename, lineno, function);
} else {
gw_assert_place(ostr->len + 1 <= ostr->size,
filename, lineno, function);
gw_assert_place(ostr->data != NULL,
filename, lineno, function);
if (!ostr->immutable)
gw_assert_allocated(ostr->data,
filename, lineno, function);
gw_assert_place(ostr->data[ostr->len] == '\0',
filename, lineno, function);
}
} | false | false | false | true | false | 1 |
wordlistAdd(wordlist ** list, const char *key)
{
while (*list)
list = &(*list)->next;
*list = memAllocate(MEM_WORDLIST);
(*list)->key = xstrdup(key);
(*list)->next = NULL;
return (*list)->key;
} | false | false | false | false | false | 0 |
dbus_reply_cb(void *data, DBusMessage *replymsg, DBusError *error)
{
if (dbus_error_is_set(error)) {
//printf("Error: %s - %s\n", error->name, error->message);
}
} | false | false | false | false | false | 0 |
syck_map_add_m(VALUE self, VALUE key, VALUE val)
{
SyckNode *node;
VALUE emitter = rb_ivar_get( self, s_emitter );
Data_Get_Struct( self, SyckNode, node );
if ( rb_respond_to( emitter, s_node_export ) ) {
key = rb_funcall( emitter, s_node_export, 1, key );
val = rb_funcall( emitter, s_node_export, 1, val );
}
syck_map_add( node, key, val );
rb_hash_aset( rb_ivar_get( self, s_value ), key, val );
return self;
} | false | false | false | false | false | 0 |
prune_criteria_number (unsigned long *number,char **r)
{
char *t;
STRINGLIST *s = NIL;
/* parse the date and return fn if OK */
int ret = (mail_criteria_string (&s,r) &&
(*number = strtoul ((char *) s->text.data,&t,10)) && !*t) ?
T : NIL;
if (s) mail_free_stringlist (&s);
return ret;
} | false | false | false | false | false | 0 |
archive_read_set_read_callback(struct archive *_a,
archive_read_callback *client_reader)
{
struct archive_read *a = (struct archive_read *)_a;
archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
"archive_read_set_read_callback");
a->client.reader = client_reader;
return ARCHIVE_OK;
} | false | false | false | false | false | 0 |
oprintf (outf_p o, const char *format, ...)
{
char *s;
size_t slength;
va_list ap;
/* In plugin mode, the O could be a NULL pointer, so avoid crashing
in that case. */
if (!o)
return;
va_start (ap, format);
slength = vasprintf (&s, format, ap);
if (s == NULL || (int) slength < 0)
fatal ("out of memory");
va_end (ap);
if (o->bufused + slength > o->buflength)
{
size_t new_len = o->buflength;
if (new_len == 0)
new_len = 1024;
do
{
new_len *= 2;
}
while (o->bufused + slength >= new_len);
o->buf = XRESIZEVEC (char, o->buf, new_len);
o->buflength = new_len;
}
memcpy (o->buf + o->bufused, s, slength);
o->bufused += slength;
free (s);
} | false | false | false | false | false | 0 |
gegl_node_get_cache (GeglNode *node)
{
g_return_val_if_fail (GEGL_IS_NODE (node), NULL);
if (!node->cache)
{
GeglPad *pad;
const Babl *format;
/* XXX: it should be possible to have cache for other pads than
* only "output" pads
*/
pad = gegl_node_get_pad (node, "output");
if (!pad)
return NULL;
format = gegl_pad_get_format (pad);
if (!format)
{
format = babl_format ("RGBA float");
}
node->cache = g_object_new (GEGL_TYPE_CACHE,
"node", node,
"format", format,
NULL);
g_signal_connect (G_OBJECT (node->cache), "computed",
(GCallback) gegl_node_computed_event,
node);
}
return node->cache;
} | false | false | false | false | false | 0 |
DetermineConstraintAxis(int constraint, double *x)
{
// Look for trivial cases
if ( ! this->Constrained )
{
return -1;
}
else if ( constraint >= 0 && constraint < 3 )
{
return constraint;
}
// Okay, figure out constraint. First see if the choice is
// outside the hot spot
if ( ! this->WaitingForMotion )
{
double p[3], d2, tol;
this->CursorPicker->GetPickPosition(p);
d2 = vtkMath::Distance2BetweenPoints(p,this->StartEventPosition);
tol = this->HotSpotSize*this->InitialLength;
if ( d2 > (tol*tol) )
{
this->WaitingForMotion = 0;
return this->CursorPicker->GetCellId();
}
else
{
this->WaitingForMotion = 1;
this->WaitCount = 0;
return -1;
}
}
else if ( this->WaitingForMotion && x )
{
double v[3];
this->WaitingForMotion = 0;
v[0] = fabs(x[0] - this->StartEventPosition[0]);
v[1] = fabs(x[1] - this->StartEventPosition[1]);
v[2] = fabs(x[2] - this->StartEventPosition[2]);
return ( v[0]>v[1] ? (v[0]>v[2]?0:2) : (v[1]>v[2]?1:2));
}
else
{
return -1;
}
} | false | false | false | false | false | 0 |
decode_attr_security_label(struct xdr_stream *xdr, uint32_t *bitmap,
struct nfs4_label *label)
{
uint32_t pi = 0;
uint32_t lfs = 0;
__u32 len;
__be32 *p;
int status = 0;
if (unlikely(bitmap[2] & (FATTR4_WORD2_SECURITY_LABEL - 1U)))
return -EIO;
if (likely(bitmap[2] & FATTR4_WORD2_SECURITY_LABEL)) {
p = xdr_inline_decode(xdr, 4);
if (unlikely(!p))
goto out_overflow;
lfs = be32_to_cpup(p++);
p = xdr_inline_decode(xdr, 4);
if (unlikely(!p))
goto out_overflow;
pi = be32_to_cpup(p++);
p = xdr_inline_decode(xdr, 4);
if (unlikely(!p))
goto out_overflow;
len = be32_to_cpup(p++);
p = xdr_inline_decode(xdr, len);
if (unlikely(!p))
goto out_overflow;
if (len < NFS4_MAXLABELLEN) {
if (label) {
memcpy(label->label, p, len);
label->len = len;
label->pi = pi;
label->lfs = lfs;
status = NFS_ATTR_FATTR_V4_SECURITY_LABEL;
}
bitmap[2] &= ~FATTR4_WORD2_SECURITY_LABEL;
} else
printk(KERN_WARNING "%s: label too long (%u)!\n",
__func__, len);
}
if (label && label->label)
dprintk("%s: label=%s, len=%d, PI=%d, LFS=%d\n", __func__,
(char *)label->label, label->len, label->pi, label->lfs);
return status;
out_overflow:
print_overflow_msg(__func__, xdr);
return -EIO;
} | false | false | false | false | false | 0 |
delete_win_hashtab (WinData *win)
{
int entry;
WinList *list;
entry = win->app_id & 0xff;
list = &hash_tab[entry];
if (win->win_prev)
win->win_prev->win_next = win->win_next;
else
list->head = win->win_next;
if (win->win_next)
win->win_next->win_prev = win->win_prev;
else
list->tail = win->win_prev;
list->n--;
} | false | false | false | false | false | 0 |
Statistics_User_Time_2(WamWord since_start_word, WamWord since_last_word)
{
long user_time;
int since_start, since_last;
user_time = M_User_Time();
since_start = user_time;
since_last = user_time - last_user_time;
last_user_time = user_time;
return Un_Integer_Check(since_start, since_start_word) &&
Un_Integer_Check(since_last, since_last_word);
} | false | false | false | false | false | 0 |
handle_alias_ifunc_attribute (bool is_alias, tree *node, tree name, tree args,
bool *no_add_attrs)
{
tree decl = *node;
if (TREE_CODE (decl) != FUNCTION_DECL
&& (!is_alias || TREE_CODE (decl) != VAR_DECL))
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
else if ((TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
|| (TREE_CODE (decl) != FUNCTION_DECL
&& TREE_PUBLIC (decl) && !DECL_EXTERNAL (decl))
/* A static variable declaration is always a tentative definition,
but the alias is a non-tentative definition which overrides. */
|| (TREE_CODE (decl) != FUNCTION_DECL
&& ! TREE_PUBLIC (decl) && DECL_INITIAL (decl)))
{
error ("%q+D defined both normally and as %qE attribute", decl, name);
*no_add_attrs = true;
return NULL_TREE;
}
else if (!is_alias
&& (lookup_attribute ("weak", DECL_ATTRIBUTES (decl))
|| lookup_attribute ("weakref", DECL_ATTRIBUTES (decl))))
{
error ("weak %q+D cannot be defined %qE", decl, name);
*no_add_attrs = true;
return NULL_TREE;
}
/* Note that the very first time we process a nested declaration,
decl_function_context will not be set. Indeed, *would* never
be set except for the DECL_INITIAL/DECL_EXTERNAL frobbery that
we do below. After such frobbery, pushdecl would set the context.
In any case, this is never what we want. */
else if (decl_function_context (decl) == 0 && current_function_decl == NULL)
{
tree id;
id = TREE_VALUE (args);
if (TREE_CODE (id) != STRING_CST)
{
error ("attribute %qE argument not a string", name);
*no_add_attrs = true;
return NULL_TREE;
}
id = get_identifier (TREE_STRING_POINTER (id));
/* This counts as a use of the object pointed to. */
TREE_USED (id) = 1;
if (TREE_CODE (decl) == FUNCTION_DECL)
DECL_INITIAL (decl) = error_mark_node;
else
{
if (lookup_attribute ("weakref", DECL_ATTRIBUTES (decl)))
DECL_EXTERNAL (decl) = 1;
else
DECL_EXTERNAL (decl) = 0;
TREE_STATIC (decl) = 1;
}
if (!is_alias)
/* ifuncs are also aliases, so set that attribute too. */
DECL_ATTRIBUTES (decl)
= tree_cons (get_identifier ("alias"), args, DECL_ATTRIBUTES (decl));
}
else
{
warning (OPT_Wattributes, "%qE attribute ignored", name);
*no_add_attrs = true;
}
return NULL_TREE;
} | false | false | false | false | false | 0 |
ario_cover_preferences_sync_cover_foreach (GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
ArioCoverPreferences *cover_preferences)
{
ARIO_LOG_FUNCTION_START;
gchar *country;
/* Get country of current row */
gtk_tree_model_get (model, iter,
0, &country,
-1);
if (!strcmp (country, ario_conf_get_string (PREF_COVER_AMAZON_COUNTRY, PREF_COVER_AMAZON_COUNTRY_DEFAULT))) {
/* Row of current country foud: activate this row */
gtk_combo_box_set_active_iter (GTK_COMBO_BOX (cover_preferences->priv->amazon_country), iter);
g_free (country);
/* Stop iterations */
return TRUE;
}
g_free (country);
/* Continue iterations */
return FALSE;
} | false | false | false | false | false | 0 |
YM2612_save_state(void)
{
int num;
const char statename[] = "YM2612";
for(num=0;num<YM2612NumChips;num++)
{
state_save_register_UINT8 (statename, num, "regs" , FM2612[num].REGS , 512);
FMsave_state_st(statename,num,&FM2612[num].OPN.ST);
FMsave_state_channel(statename,num,FM2612[num].CH,6);
/* 3slots */
state_save_register_UINT32 (statename, num, "slot3fc" , FM2612[num].OPN.SL3.fc , 3);
state_save_register_UINT8 (statename, num, "slot3fh" , &FM2612[num].OPN.SL3.fn_h, 1);
state_save_register_UINT8 (statename, num, "slot3kc" , FM2612[num].OPN.SL3.kcode, 3);
/* address register1 */
state_save_register_UINT8 (statename, num, "addr_A1" , &FM2612[num].addr_A1, 1);
}
state_save_register_func_postload(YM2612_postload);
} | false | false | false | false | false | 0 |
ladish_app_supervisor_set_app_properties(
ladish_app_supervisor_proxy_handle proxy,
uint64_t id,
const char * name,
const char * command,
bool run_in_terminal,
const char * level)
{
dbus_bool_t terminal;
terminal = run_in_terminal;
if (!cdbus_call(
0,
proxy_ptr->service,
proxy_ptr->object,
IFACE_APP_SUPERVISOR,
"SetAppProperties2",
"tssbs",
&id,
&name,
&command,
&terminal,
&level,
""))
{
log_error("SetAppProperties2() failed.");
return false;
}
return true;
} | false | false | false | false | false | 0 |
Start(Runnable* runnable) {
ASSERT(owned_);
if (!owned_) return false;
ASSERT(!started_);
if (started_) return false;
// Make sure that ThreadManager is created on the main thread before
// we start a new thread.
ThreadManager::Instance();
ThreadInit* init = new ThreadInit;
init->thread = this;
init->runnable = runnable;
#if defined(WIN32)
DWORD flags = 0;
if (priority_ != PRIORITY_NORMAL) {
flags = CREATE_SUSPENDED;
}
thread_ = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)PreRun, init, flags,
NULL);
if (thread_) {
started_ = true;
if (priority_ != PRIORITY_NORMAL) {
SetPriority(priority_);
::ResumeThread(thread_);
}
} else {
return false;
}
#elif defined(POSIX)
pthread_attr_t attr;
pthread_attr_init(&attr);
if (priority_ != PRIORITY_NORMAL) {
if (priority_ == PRIORITY_IDLE) {
// There is no POSIX-standard way to set a below-normal priority for an
// individual thread (only whole process), so let's not support it.
LOG(LS_WARNING) << "PRIORITY_IDLE not supported";
} else {
// Set real-time round-robin policy.
if (pthread_attr_setschedpolicy(&attr, SCHED_RR) != 0) {
LOG(LS_ERROR) << "pthread_attr_setschedpolicy";
}
struct sched_param param;
if (pthread_attr_getschedparam(&attr, ¶m) != 0) {
LOG(LS_ERROR) << "pthread_attr_getschedparam";
} else {
// The numbers here are arbitrary.
if (priority_ == PRIORITY_HIGH) {
param.sched_priority = 6; // 6 = HIGH
} else {
ASSERT(priority_ == PRIORITY_ABOVE_NORMAL);
param.sched_priority = 4; // 4 = ABOVE_NORMAL
}
if (pthread_attr_setschedparam(&attr, ¶m) != 0) {
LOG(LS_ERROR) << "pthread_attr_setschedparam";
}
}
}
}
int error_code = pthread_create(&thread_, &attr, PreRun, init);
if (0 != error_code) {
LOG(LS_ERROR) << "Unable to create pthread, error " << error_code;
return false;
}
started_ = true;
#endif
return true;
} | false | false | false | false | false | 0 |
HPDF_SetPagesConfiguration (HPDF_Doc pdf,
HPDF_UINT page_per_pages)
{
HPDF_PTRACE ((" HPDF_SetPagesConfiguration\n"));
if (!HPDF_HasDoc (pdf))
return HPDF_INVALID_DOCUMENT;
if (pdf->cur_page)
return HPDF_RaiseError (&pdf->error, HPDF_INVALID_DOCUMENT_STATE, 0);
if (page_per_pages > HPDF_LIMIT_MAX_ARRAY)
return HPDF_RaiseError (&pdf->error, HPDF_INVALID_PARAMETER, 0);
if (pdf->cur_pages == pdf->root_pages) {
pdf->cur_pages = HPDF_Doc_AddPagesTo (pdf, pdf->root_pages);
if (!pdf->cur_pages)
return pdf->error.error_no;
pdf->cur_page_num = 0;
}
pdf->page_per_pages = page_per_pages;
return HPDF_OK;
} | false | false | false | false | false | 0 |
mlx4_pci_enable_device(struct mlx4_dev *dev)
{
struct pci_dev *pdev = dev->persist->pdev;
int err = 0;
mutex_lock(&dev->persist->pci_status_mutex);
if (dev->persist->pci_status == MLX4_PCI_STATUS_DISABLED) {
err = pci_enable_device(pdev);
if (!err)
dev->persist->pci_status = MLX4_PCI_STATUS_ENABLED;
}
mutex_unlock(&dev->persist->pci_status_mutex);
return err;
} | false | false | false | false | false | 0 |
init(void)
{
if (!symbol_table.empty())
return;
trace(("%s\n", __PRETTY_FUNCTION__));
//
// initialize the names of the builtin functions
//
rpt_func::init(symbol_table);
//
// pull values from fmtgen
//
cattr__rpt_init();
common__rpt_init();
cstate__rpt_init();
fstate__rpt_init();
gstate__rpt_init();
pattr__rpt_init();
pconf__rpt_init();
pstate__rpt_init();
uconf__rpt_init();
ustate__rpt_init();
//
// some constants
//
symbol_table.assign("true", rpt_value_boolean::create(true));
symbol_table.assign("false", rpt_value_boolean::create(false));
//
// This one is so you can get at .aegisrc files.
//
symbol_table.assign("user", rpt_value_uconf::create());
symbol_table.assign("passwd", rpt_value_passwd::create());
symbol_table.assign("group", rpt_value_group::create());
symbol_table.assign("project", rpt_value_gstate::create());
//
// the "arg" variable, containing the
// strings specified on the command line.
//
report_parse__init_arg();
} | false | false | false | false | false | 0 |
__backtrace_symbols (array, size)
void *const *array;
int size;
{
Dl_info info[size];
int status[size];
int cnt;
size_t total = 0;
char **result;
/* Fill in the information we can get from `dladdr'. */
for (cnt = 0; cnt < size; ++cnt)
{
struct link_map *map;
status[cnt] = _dl_addr (array[cnt], &info[cnt], &map, NULL);
if (status[cnt] && info[cnt].dli_fname && info[cnt].dli_fname[0] != '\0')
{
/* We have some info, compute the length of the string which will be
"<file-name>(<sym-name>+offset) [address]. */
total += (strlen (info[cnt].dli_fname ?: "")
+ strlen (info[cnt].dli_sname ?: "")
+ 3 + WORD_WIDTH + 3 + WORD_WIDTH + 5);
/* The load bias is more useful to the user than the load
address. The use of these addresses is to calculate an
address in the ELF file, so its prelinked bias is not
something we want to subtract out. */
info[cnt].dli_fbase = (void *) map->l_addr;
}
else
total += 5 + WORD_WIDTH;
}
/* Allocate memory for the result. */
result = (char **) malloc (size * sizeof (char *) + total);
if (result != NULL)
{
char *last = (char *) (result + size);
for (cnt = 0; cnt < size; ++cnt)
{
result[cnt] = last;
if (status[cnt]
&& info[cnt].dli_fname != NULL && info[cnt].dli_fname[0] != '\0')
{
if (info[cnt].dli_sname == NULL)
/* We found no symbol name to use, so describe it as
relative to the file. */
info[cnt].dli_saddr = info[cnt].dli_fbase;
if (info[cnt].dli_sname == NULL && info[cnt].dli_saddr == 0)
last += 1 + sprintf (last, "%s(%s) [%p]",
info[cnt].dli_fname ?: "",
info[cnt].dli_sname ?: "",
array[cnt]);
else
{
char sign;
ptrdiff_t offset;
if (array[cnt] >= (void *) info[cnt].dli_saddr)
{
sign = '+';
offset = array[cnt] - info[cnt].dli_saddr;
}
else
{
sign = '-';
offset = info[cnt].dli_saddr - array[cnt];
}
last += 1 + sprintf (last, "%s(%s%c%#tx) [%p]",
info[cnt].dli_fname ?: "",
info[cnt].dli_sname ?: "",
sign, offset, array[cnt]);
}
}
else
last += 1 + sprintf (last, "[%p]", array[cnt]);
}
assert (last <= (char *) result + size * sizeof (char *) + total);
}
return result;
} | false | false | false | false | true | 1 |
jl_parse_string(const char *str, int pos0, int greedy)
{
value_t s = cvalue_static_cstring(str);
value_t p = fl_applyn(3, symbol_value(symbol("jl-parse-one-string")),
s, fixnum(pos0), greedy?FL_T:FL_F);
jl_value_t *expr=NULL, *pos1=NULL;
JL_GC_PUSH(&expr, &pos1);
value_t e = car_(p);
if (e == FL_T || e == FL_F || e == FL_EOF) {
expr = (jl_value_t*)jl_null;
}
else {
expr = scm_to_julia(e);
}
pos1 = jl_box_long(toulong(cdr_(p),"parse"));
jl_value_t *result = (jl_value_t*)jl_tuple2(expr, pos1);
JL_GC_POP();
return result;
} | false | false | false | false | false | 0 |
jar_gen_index(JAR *jar, jarArch format, JAR_FILE fp)
{
int result = JAR_ERR_CORRUPT;
JAR_FSEEK (fp, 0, (PRSeekWhence)0);
switch (format) {
case jarArchZip:
result = jar_listzip (jar, fp);
break;
case jarArchTar:
result = jar_listtar (jar, fp);
break;
case jarArchGuess:
case jarArchNone:
return JAR_ERR_GENERAL;
}
JAR_FSEEK (fp, 0, (PRSeekWhence)0);
return result;
} | false | false | false | false | false | 0 |
btrfsic_read_from_block_data(
struct btrfsic_block_data_ctx *block_ctx,
void *dstv, u32 offset, size_t len)
{
size_t cur;
size_t offset_in_page;
char *kaddr;
char *dst = (char *)dstv;
size_t start_offset = block_ctx->start & ((u64)PAGE_CACHE_SIZE - 1);
unsigned long i = (start_offset + offset) >> PAGE_CACHE_SHIFT;
WARN_ON(offset + len > block_ctx->len);
offset_in_page = (start_offset + offset) & (PAGE_CACHE_SIZE - 1);
while (len > 0) {
cur = min(len, ((size_t)PAGE_CACHE_SIZE - offset_in_page));
BUG_ON(i >= DIV_ROUND_UP(block_ctx->len, PAGE_CACHE_SIZE));
kaddr = block_ctx->datav[i];
memcpy(dst, kaddr + offset_in_page, cur);
dst += cur;
len -= cur;
offset_in_page = 0;
i++;
}
} | false | true | false | false | false | 1 |
snd_pcm_oss_write2(struct snd_pcm_substream *substream, const char *buf, size_t bytes, int in_kernel)
{
struct snd_pcm_runtime *runtime = substream->runtime;
snd_pcm_sframes_t frames, frames1;
#ifdef CONFIG_SND_PCM_OSS_PLUGINS
if (runtime->oss.plugin_first) {
struct snd_pcm_plugin_channel *channels;
size_t oss_frame_bytes = (runtime->oss.plugin_first->src_width * runtime->oss.plugin_first->src_format.channels) / 8;
if (!in_kernel) {
if (copy_from_user(runtime->oss.buffer, (const char __force __user *)buf, bytes))
return -EFAULT;
buf = runtime->oss.buffer;
}
frames = bytes / oss_frame_bytes;
frames1 = snd_pcm_plug_client_channels_buf(substream, (char *)buf, frames, &channels);
if (frames1 < 0)
return frames1;
frames1 = snd_pcm_plug_write_transfer(substream, channels, frames1);
if (frames1 <= 0)
return frames1;
bytes = frames1 * oss_frame_bytes;
} else
#endif
{
frames = bytes_to_frames(runtime, bytes);
frames1 = snd_pcm_oss_write3(substream, buf, frames, in_kernel);
if (frames1 <= 0)
return frames1;
bytes = frames_to_bytes(runtime, frames1);
}
return bytes;
} | false | false | false | false | false | 0 |
delimiterButton2Event(const XEvent *pEvent_)
{
if (delimiterSelection()==MSTrue)
{
if (delimiterEdit()==MSFalse&&delimiterVector().length()==0) server()->bell();
else selectDelimiter(pEvent_);
}
else server()->bell();
} | false | false | false | false | false | 0 |
unescape_chars(const char* cp, int len, Charset* charset, bool js){
char* s=new(PointerFreeGC) char[len+1]; // must be enough (%uXXXX==6 bytes, max utf-8 char length==6 bytes)
char* dst=s;
EscapeState escapeState=EscapeRest;
uint escapedValue=0;
int srcPos=0;
short int jsCnt=0;
while(srcPos<len){
uchar c=(uchar)cp[srcPos];
if(c=='%' || (c=='\\' && js)){
escapeState=EscapeFirst;
} else {
switch(escapeState) {
case EscapeRest:
if(!js && c=='+'){
*dst++=' ';
} else {
*dst++=c;
}
break;
case EscapeFirst:
if(charset && c=='u'){
// escaped unicode value: %u0430
jsCnt=0;
escapedValue=0;
escapeState=EscapeUnicode;
} else {
if(isxdigit(c)){
escapedValue=hex_value[c] << 4;
escapeState=EscapeSecond;
} else {
*dst++=c;
escapeState=EscapeRest;
}
}
break;
case EscapeSecond:
if(isxdigit(c)){
escapedValue+=hex_value[c];
*dst++=(char)escapedValue;
}
escapeState=EscapeRest;
break;
case EscapeUnicode:
if(isxdigit(c)){
escapedValue=(escapedValue << 4) + hex_value[c];
if(++jsCnt==4){
// transcode utf8 char to client charset (we can lost some chars here)
charset->store_Char((XMLByte*&)dst, (XMLCh)escapedValue, '?');
escapeState=EscapeRest;
}
} else {
// not full unicode value
escapeState=EscapeRest;
}
break;
}
}
srcPos++;
}
*dst=0; // zero-termination
return s;
} | false | false | false | false | false | 0 |
jas_iccattrval_dump(jas_iccattrval_t *attrval, FILE *out)
{
char buf[8];
jas_iccsigtostr(attrval->type, buf);
fprintf(out, "refcnt = %d; type = 0x%08x %s\n", attrval->refcnt,
attrval->type, jas_iccsigtostr(attrval->type, &buf[0]));
if (attrval->ops->dump) {
(*attrval->ops->dump)(attrval, out);
}
} | true | true | false | false | false | 1 |
get_outer_parallel_do_loop(const Block *b)
{
Block *bpt;
for( bpt = b->outer; bpt != NULL; bpt = bpt->outer ){
if( is_parallel_do_loop(bpt) )
return bpt;
}
return NULL;
} | false | false | false | false | false | 0 |
destroy_lease_table(GDHCPServer *dhcp_server)
{
GList *list;
g_hash_table_destroy(dhcp_server->nip_lease_hash);
dhcp_server->nip_lease_hash = NULL;
for (list = dhcp_server->lease_list; list; list = list->next) {
struct dhcp_lease *lease = list->data;
g_free(lease);
}
g_list_free(dhcp_server->lease_list);
dhcp_server->lease_list = NULL;
} | false | false | false | false | false | 0 |
AddIncomingEdge(HBasicBlock* block, HEnvironment* other) {
ASSERT(!block->IsLoopHeader());
ASSERT(values_.length() == other->values_.length());
int length = values_.length();
for (int i = 0; i < length; ++i) {
HValue* value = values_[i];
if (value != NULL && value->IsPhi() && value->block() == block) {
// There is already a phi for the i'th value.
HPhi* phi = HPhi::cast(value);
// Assert index is correct and that we haven't missed an incoming edge.
ASSERT(phi->merged_index() == i);
ASSERT(phi->OperandCount() == block->predecessors()->length());
phi->AddInput(other->values_[i]);
} else if (values_[i] != other->values_[i]) {
// There is a fresh value on the incoming edge, a phi is needed.
ASSERT(values_[i] != NULL && other->values_[i] != NULL);
HPhi* phi = new(block->zone()) HPhi(i);
HValue* old_value = values_[i];
for (int j = 0; j < block->predecessors()->length(); j++) {
phi->AddInput(old_value);
}
phi->AddInput(other->values_[i]);
this->values_[i] = phi;
block->AddPhi(phi);
}
}
} | false | false | false | false | false | 0 |
mp4ff_read_stsz(mp4ff_t *f)
{
mp4ff_read_char(f); /* version */
mp4ff_read_int24(f); /* flags */
f->track[f->total_tracks - 1]->stsz_sample_size = mp4ff_read_int32(f);
f->track[f->total_tracks - 1]->stsz_sample_count = mp4ff_read_int32(f);
if (f->track[f->total_tracks - 1]->stsz_sample_size == 0)
{
int32_t i;
f->track[f->total_tracks - 1]->stsz_table =
(int32_t*)malloc(f->track[f->total_tracks - 1]->stsz_sample_count*sizeof(int32_t));
for (i = 0; i < f->track[f->total_tracks - 1]->stsz_sample_count; i++)
{
f->track[f->total_tracks - 1]->stsz_table[i] = mp4ff_read_int32(f);
}
}
return 0;
} | false | false | false | false | false | 0 |
do_unshift (struct _IO_codecvt *codecvt, __mbstate_t *statep,
char *to_start, char *to_end, char **to_stop)
{
enum __codecvt_result result;
#ifdef _LIBC
struct __gconv_step *gs = codecvt->__cd_out.__cd.__steps;
int status;
size_t dummy;
codecvt->__cd_out.__cd.__data[0].__outbuf = (unsigned char *) to_start;
codecvt->__cd_out.__cd.__data[0].__outbufend = (unsigned char *) to_end;
codecvt->__cd_out.__cd.__data[0].__statep = statep;
__gconv_fct fct = gs->__fct;
#ifdef PTR_DEMANGLE
if (gs->__shlib_handle != NULL)
PTR_DEMANGLE (fct);
#endif
status = DL_CALL_FCT (fct,
(gs, codecvt->__cd_out.__cd.__data, NULL, NULL,
NULL, &dummy, 1, 0));
*to_stop = (char *) codecvt->__cd_out.__cd.__data[0].__outbuf;
switch (status)
{
case __GCONV_OK:
case __GCONV_EMPTY_INPUT:
result = __codecvt_ok;
break;
case __GCONV_FULL_OUTPUT:
case __GCONV_INCOMPLETE_INPUT:
result = __codecvt_partial;
break;
default:
result = __codecvt_error;
break;
}
#else
# ifdef _GLIBCPP_USE_WCHAR_T
size_t res;
char *to_start_copy = (char *) to_start;
size_t to_len = to_end - to_start;
res = iconv (codecvt->__cd_out, NULL, NULL, &to_start_copy, &to_len);
if (res == 0)
result = __codecvt_ok;
else if (to_len < codecvt->__codecvt_do_max_length (codecvt))
result = __codecvt_partial;
else
result = __codecvt_error;
# else
/* Decide what to do. */
result = __codecvt_error;
# endif
#endif
return result;
} | false | false | false | false | false | 0 |
brcmf_proto_detach(struct brcmf_pub *drvr)
{
brcmf_dbg(TRACE, "Enter\n");
if (drvr->proto) {
if (drvr->bus_if->proto_type == BRCMF_PROTO_BCDC)
brcmf_proto_bcdc_detach(drvr);
else if (drvr->bus_if->proto_type == BRCMF_PROTO_MSGBUF)
brcmf_proto_msgbuf_detach(drvr);
kfree(drvr->proto);
drvr->proto = NULL;
}
} | false | false | false | false | false | 0 |
putOctal(char *cp, int len, off_t value)
{
char tempBuffer[sizeof(off_t)*3 + 1];
char *tempString = tempBuffer;
int width;
width = sprintf(tempBuffer, "%0*"OFF_FMT"o", len, value);
tempString += (width - len);
/* If string has leading zeroes, we can drop one */
/* and field will have trailing '\0' */
/* (increases chances of compat with other tars) */
if (tempString[0] == '0')
tempString++;
/* Copy the string to the field */
memcpy(cp, tempString, len);
} | true | true | false | false | false | 1 |
deleteSelection(const Selection &selection)
{
if (selection.state() == Selection::RANGE) {
RefPtr<DeleteSelectionCommandImpl> cmd = new DeleteSelectionCommandImpl(document(), selection);
applyCommandToComposite(cmd);
}
} | false | false | false | false | false | 0 |
htset (ht_t * ht, char *key)
{
long alveole = hash (ht, key);
htelt_t *p;
for (p = ht[alveole]; p && strcmp (p->KEY, key); p = p->NEXT);
if (p)
return p;
return ht[alveole] = eltadd (ht[alveole], key);
} | false | false | false | false | false | 0 |
check_transitions (SkkContext *context,
const SkkTransition *transitions)
{
gint i;
for (i = 0; transitions[i].keys != NULL; i++) {
const gchar *preedit;
gchar *output;
SkkInputMode input_mode;
skk_context_reset (context);
output = skk_context_poll_output (context);
g_free (output);
skk_context_set_input_mode (context, transitions[i].input_mode);
skk_context_process_key_events (context, transitions[i].keys);
preedit = skk_context_get_preedit (context);
g_assert_cmpstr (preedit, ==, transitions[i].preedit);
output = skk_context_poll_output (context);
g_assert_cmpstr (output, ==, transitions[i].output);
g_free (output);
input_mode = skk_context_get_input_mode (context);
g_assert_cmpint (input_mode, ==, transitions[i].next_input_mode);
}
} | false | false | false | false | false | 0 |
PyvtkUnsignedShortArray_GetDataTypeValueMin(PyObject *, PyObject *args)
{
vtkPythonArgs ap(args, "GetDataTypeValueMin");
PyObject *result = NULL;
if (ap.CheckArgCount(0))
{
unsigned short tempr = vtkUnsignedShortArray::GetDataTypeValueMin();
if (!ap.ErrorOccurred())
{
result = ap.BuildValue(tempr);
}
}
return result;
} | false | false | false | false | false | 0 |
voca_mono2tri(WORD_INFO *winfo, HTK_HMM_INFO *hmminfo)
{
WORD_ID w;
int ph;
char *p;
HMM_Logical *tmplg;
boolean ok_flag = TRUE;
for (w=0;w<winfo->num;w++) {
cycle_triphone(NULL);
cycle_triphone(winfo->wseq[w][0]->name);
for (ph = 0; ph < winfo->wlen[w] ; ph++) {
if (ph == winfo->wlen[w] - 1) {
p = cycle_triphone_flush();
} else {
p = cycle_triphone(winfo->wseq[w][ph + 1]->name);
}
if ((tmplg = htk_hmmdata_lookup_logical(hmminfo, p)) == NULL) {
jlog("Error: voca_load_htkdict: word \"%s[%s]\"(id=%d): HMM \"%s\" not found\n", winfo->wname[w], winfo->woutput[w], w, p);
ok_flag = FALSE;
continue;
}
winfo->wseq[w][ph] = tmplg;
}
}
return (ok_flag);
} | false | false | false | false | false | 0 |
native_method_get_modifiers_internal(struct vm_object *this)
{
struct vm_method *vmm;
vmm = vm_object_to_vm_method(this);
if (!vmm)
return 0;
return vmm->method->access_flags;
} | false | false | false | false | false | 0 |
ipmi_lan_send_cmd(struct ipmi_intf * intf, struct ipmi_rq * req)
{
struct ipmi_rq_entry * entry;
struct ipmi_rs * rsp = NULL;
int try = 0;
lprintf(LOG_DEBUG, "ipmi_lan_send_cmd:opened=[%d], open=[%d]",
intf->opened, intf->open);
if (intf->opened == 0 && intf->open != NULL) {
if (intf->open(intf) < 0) {
lprintf(LOG_DEBUG, "Failed to open LAN interface");
return NULL;
}
lprintf(LOG_DEBUG, "\topened=[%d], open=[%d]",
intf->opened, intf->open);
}
for (;;) {
entry = ipmi_lan_build_cmd(intf, req);
if (entry == NULL) {
lprintf(LOG_ERR, "Aborting send command, unable to build");
return NULL;
}
if (ipmi_lan_send_packet(intf, entry->msg_data, entry->msg_len) < 0) {
try++;
usleep(5000);
ipmi_req_remove_entry(entry->rq_seq, entry->req.msg.target_cmd);
continue;
}
/* if we are set to noanswer we do not expect response */
if (intf->noanswer)
break;
if (ipmi_oem_active(intf, "intelwv2"))
ipmi_lan_thump(intf);
usleep(100);
rsp = ipmi_lan_poll_recv(intf);
if (rsp) {
/*
* ignore responses to other commands; for example,
* commands that were retried multiple times and
* genreated multiple responses that we are no longer
* looking for.
*/
if (rsp->payload.ipmi_response.cmd != req->msg.cmd)
continue;
break;
}
usleep(5000);
if (++try >= intf->session->retry) {
lprintf(LOG_DEBUG, " No response from remote controller");
break;
}
}
return rsp;
} | false | false | false | false | false | 0 |
ThreadDisabledLeaks() {
if (FLAGS_no_threads) return;
pthread_t tid;
pthread_attr_t attr;
CHECK_EQ(pthread_attr_init(&attr), 0);
CHECK_EQ(pthread_create(&tid, &attr, RunDisabledLeaks, NULL), 0);
void* res;
CHECK_EQ(pthread_join(tid, &res), 0);
} | false | false | false | false | false | 0 |
gg_convert_image_to_grid_int16 (const gGraphImagePtr img)
{
/* converting this grid-image to Int16 */
int x;
int y;
void *pixels;
short value;
unsigned char *p_in;
short *p_out;
if (img->pixel_format != GG_PIXEL_GRID)
return GGRAPH_INVALID_IMAGE;
if (img->sample_format == GGRAPH_SAMPLE_INT && img->bits_per_sample == 16)
return GGRAPH_OK;
pixels = malloc (img->width * img->height * sizeof (short));
if (!pixels)
return GGRAPH_INSUFFICIENT_MEMORY;
for (y = 0; y < img->height; y++)
{
/* processing any scanline */
p_in = img->pixels + (y * img->scanline_width);
p_out = pixels;
p_out += (y * img->width);
for (x = 0; x < img->width; x++)
{
/* retrieving the origin pixel */
if (img->sample_format == GGRAPH_SAMPLE_UINT
&& img->bits_per_sample == 16)
{
value = (short) *((unsigned short *) p_in);
p_in += sizeof (unsigned short);
}
if (img->sample_format == GGRAPH_SAMPLE_INT
&& img->bits_per_sample == 32)
{
value = (short) *((int *) p_in);
p_in += sizeof (int);
}
if (img->sample_format == GGRAPH_SAMPLE_UINT
&& img->bits_per_sample == 32)
{
value = (short) *((unsigned int *) p_in);
p_in += sizeof (unsigned int);
}
if (img->sample_format == GGRAPH_SAMPLE_FLOAT
&& img->bits_per_sample == 32)
{
value = (short) *((float *) p_in);
p_in += sizeof (float);
}
if (img->sample_format == GGRAPH_SAMPLE_FLOAT
&& img->bits_per_sample == 64)
{
value = (short) *((double *) p_in);
p_in += sizeof (double);
}
/* setting the destination pixel */
*p_out++ = value;
}
}
free (img->pixels);
img->pixels = pixels;
img->pixel_format = GG_PIXEL_GRID;
img->scanline_width = img->width * sizeof (short);
img->pixel_size = sizeof (short);
img->sample_format = GGRAPH_SAMPLE_INT;
img->bits_per_sample = 16;
return GGRAPH_OK;
} | false | false | false | false | true | 1 |
removeTests()
{
while ( isValid() )
removeTest( 0 );
} | false | false | false | false | false | 0 |
panel_background_set_rotate (PanelBackground *background,
gboolean rotate_image)
{
rotate_image = rotate_image != FALSE;
if (background->rotate_image == rotate_image)
return;
free_transformed_resources (background);
panel_background_set_rotate_no_update (background, rotate_image);
panel_background_transform (background);
} | false | false | false | false | false | 0 |
maki_dbus_list (const gchar* server, const gchar* channel, GError** error)
{
makiServer* serv;
makiInstance* inst = maki_instance_get_default();
if ((serv = maki_instance_get_server(inst, server)) != NULL)
{
if (channel[0])
{
maki_server_send_printf(serv, "LIST %s", channel);
}
else
{
maki_server_send_printf(serv, "LIST");
}
}
return TRUE;
} | false | false | false | false | false | 0 |
frfind(P *p, unsigned char *s, int len)
{
long amnt = p->byte;
int x;
unsigned char table[256], c;
if (len > p->b->eof->byte - p->byte) {
x = len - (p->b->eof->byte - p->byte);
if (amnt < x)
return NULL;
amnt -= x;
fbkwd(p, x);
}
if (!len)
return p;
p->valcol = 0;
mset(table, 255, 256);
for (x = len; --x; table[s[x]] = len - x - 1) ;
x = 0;
do {
if ((c = fpgetc(p)) != s[x++]) {
if (table[c] == 255) {
fbkwd(p, len + 1);
amnt -= len - x + 1;
} else if (len - table[c] <= x) {
fbkwd(p, x + 1);
--amnt;
} else {
fbkwd(p, len - table[c]);
amnt -= len - table[c] - x;
}
if (amnt < 0)
return NULL;
else
x = 0;
}
} while (x != len);
fbkwd(p, len);
return p;
} | false | false | false | false | false | 0 |
IntToStr(int num, unsigned int mxlen, char flag){
static char s[LEN+1];
int len;
s[LEN]=0;
char neg=0;
if(num<0){
num=-num;
neg=1;
};
for (len=(LEN-1);len>=(LEN-mxlen);len--){
s[len]=(num%10)+'0';
num/=10;
};
len++;
if(!(flag&F_LONG)){
while(s[len]=='0' && len < (LEN-1))
len++;
}else if(!(flag&F_ZEROS)){
int x=len;
while(s[x]=='0' && x < (LEN-1)){
s[x]=' ';
x++;
};
}
if(neg==1){
len--;
s[len]='-';
}else if(flag&F_SPLUS){
len--;
s[len]='+';
}else if(flag&F_SSPACE){
s[len]=' ';
};
return &s[len];
} | false | false | false | false | false | 0 |
miner_files_get_file_urn (TrackerMinerFiles *miner,
GFile *file,
gboolean *is_iri)
{
const gchar *urn;
urn = tracker_miner_fs_get_urn (TRACKER_MINER_FS (miner), file);
*is_iri = TRUE;
if (!urn) {
/* This is a new insertion, use anonymous URNs to store files */
urn = "_:file";
*is_iri = FALSE;
}
return urn;
} | false | false | false | false | false | 0 |
state_end0(char ch)
{
if (ch == '\n')
{
state = &HeaderParser::state_h0;
return;
}
else if (ch == ' ' || ch == '\t' || ch == '\r')
{
return;
}
else
{
log_warn("invalid character " << chartoprint(ch) << " in http request line");
state = &HeaderParser::state_error;
return;
}
} | false | false | false | false | false | 0 |
_dxfHashTableReset(Htable *table)
{
/* resets the hash table by cleaning all buckets and
deleting all records */
Block
*block=table->block,
*next;
while(block)
{
next=block->next;
if (block->rec) DXFree((Pointer) block->rec);
DXFree((Pointer) block);
block=next;
}
table->block = NULL;
/* clear buckets */
if (table->size > 0 && table->bucket)
bzero((char *)table->bucket, table->size * sizeof(Nodetype *)) ;
return;
} | false | false | false | false | false | 0 |
rgbe_read_uncompressed (const rgbe_file *file,
goffset *cursor,
gfloat *pixels)
{
const guint8 *data;
guint i;
g_return_val_if_fail (file, FALSE);
g_return_val_if_fail (file->file, FALSE);
g_return_val_if_fail (cursor && *cursor > 0, FALSE);
g_return_val_if_fail (pixels, FALSE);
data = (guint8 *)g_mapped_file_get_contents (file->file) + *cursor;
for (i = 0; i < file->header.x_axis.size; ++i)
{
rgbe_rgbe_to_float (file, data, pixels);
data += RGBE_NUM_RGBE;
pixels += RGBE_NUM_RGBE;
}
*cursor = GPOINTER_TO_UINT (data) -
GPOINTER_TO_UINT (g_mapped_file_get_contents (file->file));
return TRUE;
} | false | false | false | false | false | 0 |
ao_device_load_options(ao_device *device, ao_option *options){
while (options != NULL) {
if(!strcmp(options->key,"matrix")){
/* If a driver has a static channel mapping mechanism
(physically constant channel mapping, or at least an
unvarying set of constants for mapping channels), the
output_matrix is already set. An app/user specified
output mapping trumps. */
if(device->output_matrix)
free(device->output_matrix);
/* explicitly set the output matrix to the requested
string; devices must not override. */
device->output_matrix = _sanitize_matrix(32, options->value, device);
if(!device->output_matrix){
aerror("Empty or inavlid output matrix\n");
return AO_EBADOPTION;
}
adebug("Sanitized device output matrix: %s\n",device->output_matrix);
}else if(!strcmp(options->key,"debug")){
device->verbose=2;
}else if(!strcmp(options->key,"verbose")){
if(device->verbose<1)device->verbose=1;
}else if(!strcmp(options->key,"quiet")){
device->verbose=-1;
}else{
if (!device->funcs->set_option(device, options->key, options->value)) {
/* Problem setting options */
return AO_EOPENDEVICE;
}
}
options = options->next;
}
return 0;
} | false | false | false | false | false | 0 |
drawArea(const FXDrawable* source,FXint sx,FXint sy,FXint sw,FXint sh,FXint dx,FXint dy){
if(!surface){ fxerror("FXDCWindow::drawArea: DC not connected to drawable.\n"); }
if(!source || !source->id()){ fxerror("FXDCWindow::drawArea: illegal source specified.\n"); }
XCopyArea(DISPLAY(getApp()),source->id(),surface->id(),(GC)ctx,sx,sy,sw,sh,dx,dy);
} | false | false | false | true | false | 1 |
mono_field_get_rva (MonoClassField *field)
{
guint32 rva;
int field_index;
MonoClass *klass = field->parent;
MonoFieldDefaultValue *field_def_values;
g_assert (field->type->attrs & FIELD_ATTRIBUTE_HAS_FIELD_RVA);
if (!klass->ext || !klass->ext->field_def_values) {
mono_class_alloc_ext (klass);
field_def_values = (MonoFieldDefaultValue *)mono_class_alloc0 (klass, sizeof (MonoFieldDefaultValue) * klass->field.count);
mono_image_lock (klass->image);
if (!klass->ext->field_def_values)
klass->ext->field_def_values = field_def_values;
mono_image_unlock (klass->image);
}
field_index = mono_field_get_index (field);
if (!klass->ext->field_def_values [field_index].data && !image_is_dynamic (klass->image)) {
mono_metadata_field_info (field->parent->image, klass->field.first + field_index, NULL, &rva, NULL);
if (!rva)
g_warning ("field %s in %s should have RVA data, but hasn't", mono_field_get_name (field), field->parent->name);
klass->ext->field_def_values [field_index].data = mono_image_rva_map (field->parent->image, rva);
}
return klass->ext->field_def_values [field_index].data;
} | false | false | false | false | false | 0 |
constructCompileUnit(const MDNode *N) {
DICompileUnit DIUnit(N);
StringRef FN = DIUnit.getFilename();
StringRef Dir = DIUnit.getDirectory();
unsigned ID = GetOrCreateSourceID(FN, Dir);
DIE *Die = new DIE(dwarf::DW_TAG_compile_unit);
CompileUnit *NewCU = new CompileUnit(ID, Die, Asm, this);
NewCU->addString(Die, dwarf::DW_AT_producer, dwarf::DW_FORM_string,
DIUnit.getProducer());
NewCU->addUInt(Die, dwarf::DW_AT_language, dwarf::DW_FORM_data2,
DIUnit.getLanguage());
NewCU->addString(Die, dwarf::DW_AT_name, dwarf::DW_FORM_string, FN);
// Use DW_AT_entry_pc instead of DW_AT_low_pc/DW_AT_high_pc pair. This
// simplifies debug range entries.
NewCU->addUInt(Die, dwarf::DW_AT_entry_pc, dwarf::DW_FORM_addr, 0);
// DW_AT_stmt_list is a offset of line number information for this
// compile unit in debug_line section.
if (Asm->MAI->doesDwarfRequireRelocationForSectionOffset())
NewCU->addLabel(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4,
Asm->GetTempSymbol("section_line"));
else
NewCU->addUInt(Die, dwarf::DW_AT_stmt_list, dwarf::DW_FORM_data4, 0);
if (!Dir.empty())
NewCU->addString(Die, dwarf::DW_AT_comp_dir, dwarf::DW_FORM_string, Dir);
if (DIUnit.isOptimized())
NewCU->addUInt(Die, dwarf::DW_AT_APPLE_optimized, dwarf::DW_FORM_flag, 1);
StringRef Flags = DIUnit.getFlags();
if (!Flags.empty())
NewCU->addString(Die, dwarf::DW_AT_APPLE_flags, dwarf::DW_FORM_string,
Flags);
if (unsigned RVer = DIUnit.getRunTimeVersion())
NewCU->addUInt(Die, dwarf::DW_AT_APPLE_major_runtime_vers,
dwarf::DW_FORM_data1, RVer);
if (!FirstCU)
FirstCU = NewCU;
CUMap.insert(std::make_pair(N, NewCU));
return NewCU;
} | false | false | false | false | false | 0 |
ipmi_check_session_sequence_number_1_5_init (uint32_t *highest_received_sequence_number,
uint32_t *previously_received_list)
{
if (!highest_received_sequence_number
|| !previously_received_list)
{
SET_ERRNO (EINVAL);
return (-1);
}
(*highest_received_sequence_number) = 0;
(*previously_received_list) = 0xFF;
return (0);
} | false | false | false | false | false | 0 |
xfs_btree_get_bufs(
xfs_mount_t *mp, /* file system mount point */
xfs_trans_t *tp, /* transaction pointer */
xfs_agnumber_t agno, /* allocation group number */
xfs_agblock_t agbno, /* allocation group block number */
uint lock) /* lock flags for get_buf */
{
xfs_daddr_t d; /* real disk block address */
ASSERT(agno != NULLAGNUMBER);
ASSERT(agbno != NULLAGBLOCK);
d = XFS_AGB_TO_DADDR(mp, agno, agbno);
return xfs_trans_get_buf(tp, mp->m_ddev_targp, d, mp->m_bsize, lock);
} | false | false | false | false | false | 0 |
_splitAtOrBeforeThisRun(fp_Run *pCurrentRun, UT_sint32 iTrailSpace)
{
// This run is past the end of the line.
// Reminder: m_iWorkingLineWidth = Length including this run.
// Set m_iWorkingLineWidth to length minus this run since this run
// extends beyond the maximum width of the line
m_iWorkingLineWidth -= pCurrentRun->getWidth();
m_iWorkingLineWidth += iTrailSpace;
if(m_iWorkingLineWidth < 0)
{
m_iWorkingLineWidth = 0;
}
fp_Run *pOffendingRun = pCurrentRun;
fp_RunSplitInfo splitInfo;
fp_TextRun *pRunToSplit = NULL;
bool bFoundBreakAfter = false;
xxx_UT_DEBUGMSG(("Offending run is... \n"));
// pOffendingRun->printText();
xxx_UT_DEBUGMSG((" trailing space %d working width %d max is %d \n",iTrailSpace,m_iWorkingLineWidth,m_iMaxLineWidth));
xxx_UT_DEBUGMSG((" findMaxLeftFitSplitPoint space given %d \n",m_iMaxLineWidth - m_iWorkingLineWidth));
bool bFoundSplit = pOffendingRun->findMaxLeftFitSplitPoint(m_iMaxLineWidth - m_iWorkingLineWidth, splitInfo);
if (bFoundSplit)
{
UT_ASSERT(pOffendingRun->getType() == FPRUN_TEXT);
pRunToSplit = static_cast<fp_TextRun*>(pOffendingRun);
xxx_UT_DEBUGMSG(("FOund split ! final width for this line %d \n",m_iWorkingLineWidth+splitInfo.iLeftWidth));
}
else
{
xxx_UT_DEBUGMSG(("Did not Find split !\n"));
/*
The run we wanted to split (the one which pushes
this line over the limit) cannot be split. We need
to work backwards along the line to find a split
point. As we stop at each run along the way, we'll
first check to see if we can break the line after
that run. If not, we'll try to split that run.
*/
fp_Run* pRunLookingBackwards = pCurrentRun;
while (pRunLookingBackwards != m_pFirstRunToKeep)
{
pRunLookingBackwards = pRunLookingBackwards->getPrevRun();
if ( !pRunLookingBackwards )
{
bFoundBreakAfter = false;
m_pLastRunToKeep = pCurrentRun;
break;
}
else if (pRunLookingBackwards->canBreakAfter())
{
/*
OK, we can break after this
run. Move all the runs after this one
onto the next line.
*/
bFoundBreakAfter = true;
m_pLastRunToKeep = pRunLookingBackwards;
break;
}
else
{
/*
Can't break after this run. Let's
see if we can split this run to get
something which will fit.
*/
bFoundSplit = pRunLookingBackwards->findMaxLeftFitSplitPoint(pRunLookingBackwards->getWidth(), splitInfo);
if (bFoundSplit)
{
// a suitable split was found.
UT_ASSERT(pRunLookingBackwards->getType() == FPRUN_TEXT);
pRunToSplit = static_cast<fp_TextRun*>(pRunLookingBackwards);
break;
}
}
}
}
if (!(bFoundSplit || bFoundBreakAfter))
{
/*
OK. There are no valid break points on this line,
anywhere. We can't break after any of the runs, nor
can we split any of the runs. We're going to need
to force a split of the Offending Run.
*/
bFoundSplit = pOffendingRun->findMaxLeftFitSplitPoint(m_iMaxLineWidth - m_iWorkingLineWidth, splitInfo, true);
if (bFoundSplit)
{
UT_ASSERT(pOffendingRun->getType() == FPRUN_TEXT);
pRunToSplit = static_cast<fp_TextRun*>(pOffendingRun);
}
else
{
/*
Wow! This is a very resilient run. It is the
run which no longer fits, and yet it cannot be
split. It might be a single-character run.
Perhaps it's an image. Anyway, we still have to
try as hard as we can to find a line break.
*/
if (pOffendingRun != m_pFirstRunToKeep)
{
/*
Force a break right before the offending run.
*/
m_pLastRunToKeep = pOffendingRun->getPrevRun();
bFoundBreakAfter = true;
}
else
{
// nothing else we can do but this.
m_pLastRunToKeep = pOffendingRun;
bFoundBreakAfter = true;
}
}
}
if (bFoundSplit)
{
UT_ASSERT(!bFoundBreakAfter);
_splitRunAt(pRunToSplit, splitInfo);
m_pLastRunToKeep = pRunToSplit;
}
return true;
} | false | false | false | false | false | 0 |
stmmac_clean_desc3(void *priv_ptr, struct dma_desc *p)
{
if (unlikely(p->des3))
p->des3 = 0;
} | false | false | false | false | false | 0 |
smudge (int argc, const char** argv)
{
const char* key_name = 0;
const char* key_path = 0;
const char* legacy_key_path = 0;
int argi = parse_plumbing_options(&key_name, &key_path, argc, argv);
if (argc - argi == 0) {
} else if (!key_name && !key_path && argc - argi == 1) { // Deprecated - for compatibility with pre-0.4
legacy_key_path = argv[argi];
} else {
std::clog << "Usage: git-crypt smudge [--key-name=NAME] [--key-file=PATH]" << std::endl;
return 2;
}
Key_file key_file;
load_key(key_file, key_name, key_path, legacy_key_path);
// Read the header to get the nonce and make sure it's actually encrypted
unsigned char header[10 + Aes_ctr_decryptor::NONCE_LEN];
std::cin.read(reinterpret_cast<char*>(header), sizeof(header));
if (std::cin.gcount() != sizeof(header) || std::memcmp(header, "\0GITCRYPT\0", 10) != 0) {
// File not encrypted - just copy it out to stdout
std::clog << "git-crypt: Warning: file not encrypted" << std::endl;
std::clog << "git-crypt: Run 'git-crypt status' to make sure all files are properly encrypted." << std::endl;
std::clog << "git-crypt: If 'git-crypt status' reports no problems, then an older version of" << std::endl;
std::clog << "git-crypt: this file may be unencrypted in the repository's history. If this" << std::endl;
std::clog << "git-crypt: file contains sensitive information, you can use 'git filter-branch'" << std::endl;
std::clog << "git-crypt: to remove its old versions from the history." << std::endl;
std::cout.write(reinterpret_cast<char*>(header), std::cin.gcount()); // include the bytes which we already read
std::cout << std::cin.rdbuf();
return 0;
}
return decrypt_file_to_stdout(key_file, header, std::cin);
} | false | false | false | false | false | 0 |
colorInterpolationForValue(DOM::CSSPrimitiveValueImpl* primitiveValue)
{
if (!primitiveValue)
return CI_AUTO;
switch (primitiveValue->getIdent()) {
case CSS_VAL_SRGB:
return CI_SRGB;
case CSS_VAL_LINEARRGB:
return CI_LINEARRGB;
case CSS_VAL_AUTO:
default:
return CI_AUTO;
}
} | false | false | false | false | false | 0 |
generateTemplateMaterial(Perm permutation)
{
String materialName = mBaseName;
if(permutation & LightMaterialGenerator::MI_DIRECTIONAL)
{
materialName += "Quad";
}
else
{
materialName += "Geometry";
}
if(permutation & LightMaterialGenerator::MI_SHADOW_CASTER)
{
materialName += "Shadow";
}
return MaterialManager::getSingleton().getByName(materialName);
} | false | false | false | false | false | 0 |
dht_fremovexattr (call_frame_t *frame, xlator_t *this,
fd_t *fd, const char *key, dict_t *xdata)
{
xlator_t *subvol = NULL;
int op_errno = -1;
dht_local_t *local = NULL;
dht_layout_t *layout = NULL;
int call_cnt = 0;
int i;
VALIDATE_OR_GOTO (this, err);
GF_IF_NATIVE_XATTR_GOTO ("trusted.glusterfs.dht*",
key, op_errno, err);
VALIDATE_OR_GOTO (frame, err);
local = dht_local_init (frame, NULL, fd, GF_FOP_FREMOVEXATTR);
if (!local) {
op_errno = ENOMEM;
goto err;
}
subvol = local->cached_subvol;
if (!subvol) {
gf_log (this->name, GF_LOG_DEBUG,
"no cached subvolume for inode=%s",
uuid_utoa (fd->inode->gfid));
op_errno = EINVAL;
goto err;
}
layout = local->layout;
if (!local->layout) {
gf_log (this->name, GF_LOG_DEBUG,
"no layout for inode=%s", uuid_utoa (fd->inode->gfid));
op_errno = EINVAL;
goto err;
}
local->call_cnt = call_cnt = layout->cnt;
local->key = gf_strdup (key);
for (i = 0; i < call_cnt; i++) {
STACK_WIND (frame, dht_removexattr_cbk,
layout->list[i].xlator,
layout->list[i].xlator->fops->fremovexattr,
fd, key, NULL);
}
return 0;
err:
op_errno = (op_errno == -1) ? errno : op_errno;
DHT_STACK_UNWIND (fremovexattr, frame, -1, op_errno, NULL);
return 0;
} | false | false | false | false | false | 0 |
insert_seti(seq, stime, sline, voice, addr, value)
seq_type seq;
time_type stime;
int sline;
int voice;
int *addr;
int value;
{
register event_type event = event_create(seq, setisize, stime, sline);
if (seq_print) {
gprintf(TRANS,
"seti(%ld): time %ld, line %d, voice %d, addr %ld, value %d\n",
event, stime, sline, voice, addr, value);
}
if (event) {
event->nvoice = ctrl_voice(ESC_CTRL, voice);
event->value = SETI_VALUE;
event->u.seti.int_to_set = addr;
event->u.seti.value = value;
seq_ctrlcount(seq)++;
}
return event;
} | false | false | false | false | false | 0 |
qlcnic_sriov_pf_cfg_vlan_filtering(struct qlcnic_adapter *adapter,
u8 enable)
{
struct qlcnic_cmd_args cmd;
int err;
err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_SET_NIC_INFO);
if (err)
return err;
cmd.req.arg[1] = 0x4;
if (enable) {
adapter->flags |= QLCNIC_VLAN_FILTERING;
cmd.req.arg[1] |= BIT_16;
if (qlcnic_84xx_check(adapter))
cmd.req.arg[1] |= QLC_SRIOV_ALLOW_VLAN0;
} else {
adapter->flags &= ~QLCNIC_VLAN_FILTERING;
}
err = qlcnic_issue_cmd(adapter, &cmd);
if (err)
dev_err(&adapter->pdev->dev,
"Failed to configure VLAN filtering, err=%d\n", err);
qlcnic_free_mbx_args(&cmd);
return err;
} | false | false | false | false | false | 0 |
OTFAUX_State_setupThumbnail( OTFAUX_State* auxState,
uint64_t minTime,
uint64_t maxTime,
uint32_t width )
{
uint64_t timeDiff;
double timeStep;
uint32_t i;
if ( width == 0 || minTime >= maxTime || ( maxTime - minTime ) < width )
return 0;
auxState->timestamps = calloc( width, sizeof( uint64_t ) );
if ( !auxState->timestamps )
{
return 0;
}
/* callculate sample time stamps */
timeDiff = maxTime - minTime;
timeStep = ( double )timeDiff / ( double )width;
auxState->timestampsSize = width;
auxState->timestampsPosition = 0;
for ( i = 0; i < width; ++i )
{
auxState->timestamps[ i ] = minTime + i * timeStep;
}
return 1;
} | false | false | false | false | false | 0 |
pixelSize(const QString & sizeString) {
// assume all sizes are of the form Npx otherwise return -1
QString temp = sizeString;
temp.remove(" ");
if (temp.contains("px")) {
temp.remove("px");
bool ok;
int ps = temp.toInt(&ok);
if (ok) return ps;
}
return -1;
} | false | false | false | false | false | 0 |
print() const
{
int i;
std::cout << "Row cut has " << row_.getNumElements()
<< " elements";
if ( lb_ < -1.0e20 && ub_<1.0e20 )
std::cout << " with upper rhs of " << ub_;
else if ( lb_ > -1.0e20 && ub_ > 1.0e20 )
std::cout << " with lower rhs of " << lb_;
else
std::cout << " !!! with lower, upper rhs of " << lb_ << " and " << ub_;
std::cout << std::endl;
for ( i = 0; i < row_.getNumElements(); i++ ) {
int colIndx = row_.getIndices()[i];
double element = row_.getElements()[i];
if ( i > 0 && element > 0 )
std::cout << " +";
std::cout << element << " * x" << colIndx << " ";
}
std::cout << std::endl;
} | false | false | false | false | false | 0 |
count() const
{
return entryList().count();
} | false | false | false | false | false | 0 |
get_canmatch_exten(struct match_char *node)
{
/* find the exten at the end of the rope */
struct match_char *node2 = node;
for (node2 = node; node2; node2 = node2->next_char) {
if (node2->exten) {
#ifdef NEED_DEBUG_HERE
ast_log(LOG_NOTICE,"CanMatch_exten returns exten %s(%p)\n", node2->exten->exten, node2->exten);
#endif
return node2->exten;
}
}
#ifdef NEED_DEBUG_HERE
ast_log(LOG_NOTICE,"CanMatch_exten returns NULL, match_char=%s\n", node->x);
#endif
return 0;
} | false | false | false | false | false | 0 |
pet_food(struct map_session_data *sd)
{
int i, t;
nullpo_retr(1, sd);
nullpo_retr(1, sd->pd);
if(sd->petDB == NULL)
return 1;
i = pc_search_inventory(sd,sd->petDB->FoodID);
if(i < 0) {
clif_pet_food(sd,sd->petDB->FoodID,0);
return 1;
}
pc_delitem(sd,i,1,0,0);
t = sd->pet.intimate;
if(sd->pet.hungry > 90) {
sd->pet.intimate -= sd->petDB->r_full;
} else {
int k;
if(battle_config.pet_friendly_rate != 100)
k = sd->petDB->r_hungry * battle_config.pet_friendly_rate / 100;
else
k = sd->petDB->r_hungry;
if(sd->pet.hungry > 75) {
k /= 2;
if(k <= 0)
k = 1;
}
sd->pet.intimate += k;
}
if(sd->pet.intimate <= 0) {
sd->pet.intimate = 0;
if(battle_config.pet_status_support && t > 0) {
if(sd->bl.prev != NULL)
status_calc_pc(sd,0);
else
status_calc_pc(sd,2);
}
} else if(sd->pet.intimate > 1000) {
sd->pet.intimate = 1000;
}
sd->pet.hungry += sd->petDB->fullness;
if(sd->pet.hungry > 100)
sd->pet.hungry = 100;
clif_send_petdata(sd,2,sd->pet.hungry);
clif_send_petdata(sd,1,sd->pet.intimate);
clif_pet_food(sd,sd->petDB->FoodID,1);
return 0;
} | false | false | false | false | false | 0 |
check_active(struct ioatdma_chan *ioat_chan)
{
if (ioat_ring_active(ioat_chan)) {
mod_timer(&ioat_chan->timer, jiffies + COMPLETION_TIMEOUT);
return;
}
if (test_and_clear_bit(IOAT_CHAN_ACTIVE, &ioat_chan->state))
mod_timer(&ioat_chan->timer, jiffies + IDLE_TIMEOUT);
else if (ioat_chan->alloc_order > ioat_get_alloc_order()) {
/* if the ring is idle, empty, and oversized try to step
* down the size
*/
reshape_ring(ioat_chan, ioat_chan->alloc_order - 1);
/* keep shrinking until we get back to our minimum
* default size
*/
if (ioat_chan->alloc_order > ioat_get_alloc_order())
mod_timer(&ioat_chan->timer, jiffies + IDLE_TIMEOUT);
}
} | false | false | false | false | false | 0 |
v_fsck_send_msg(int msg_num, const char *file_name, int line_number, ...) {
struct fsck_message *message = &msg_defs[msg_num];
char msg_string[max_log_entry_length - 4];
char debug_detail[100];
va_list args;
va_start(args, line_number);
vsnprintf(msg_string, sizeof(msg_string), message->msg_txt, args);
va_end(args);
sprintf(debug_detail, " [%s:%d]\n", basename(file_name), line_number);
if (message->msg_level <= msg_lvl) {
printf("%s", msg_string);
if (dbg_output) {
printf("%s", debug_detail);
}
else printf("\n");
}
// append file and line number information to string for logging
strncat(msg_string, debug_detail,
max_log_entry_length - 4 - strlen(msg_string));
fsck_record_msg(msg_string);
return 0;
} | false | false | false | false | false | 0 |
iReadBwTga(TARGAHEAD *Header)
{
char ID[255];
if (iread(ID, 1, Header->IDLen) != Header->IDLen)
return IL_FALSE;
// We assume that no palette is present, but it's possible...
// Should we mess with it or not?
if (!ilTexImage(Header->Width, Header->Height, 1, (ILubyte)(Header->Bpp >> 3), IL_LUMINANCE, IL_UNSIGNED_BYTE, NULL)) {
return IL_FALSE;
}
if (Header->ImageType == TGA_BW_COMP) {
if (!iUncompressTgaData(iCurImage)) {
return IL_FALSE;
}
}
else {
if (iread(iCurImage->Data, 1, iCurImage->SizeOfData) != iCurImage->SizeOfData) {
return IL_FALSE;
}
}
return IL_TRUE;
} | false | false | false | false | false | 0 |
client_putData(struct soap *soap, int argc, char **argv)
{ int i;
struct x__DataSet data;
struct m__PutDataResponse response;
data.__size = argc - 2;
data.item = soap_malloc(soap, (argc - 2)*sizeof(struct x__Data));
for (i = 2; i < argc; i++)
open_data(soap, argv[i], &data.item[i - 2]);
if (soap_call_m__PutData(soap, endpoint, NULL, &data, &response))
soap_print_fault(soap, stderr);
else
{ printf("Data stored with keys:\n");
for (i = 0; i < response.x__keys.__size; i++)
printf("\t%s\n", response.x__keys.key[i]);
printf("Use these keys to retrieve the data with -g key1 key2 ...\n");
}
return soap->error;
} | false | false | false | false | true | 1 |
fpixAddContinuedBorder(FPIX *fpixs,
l_int32 left,
l_int32 right,
l_int32 top,
l_int32 bot)
{
l_int32 i, j, w, h;
FPIX *fpixd;
PROCNAME("fpixAddContinuedBorder");
if (!fpixs)
return (FPIX *)ERROR_PTR("fpixs not defined", procName, NULL);
fpixd = fpixAddBorder(fpixs, left, right, top, bot);
fpixGetDimensions(fpixs, &w, &h);
for (j = 0; j < left; j++)
fpixRasterop(fpixd, j, top, 1, h, fpixd, left, top);
for (j = 0; j < right; j++)
fpixRasterop(fpixd, left + w + j, top, 1, h, fpixd, left + w - 1, top);
for (i = 0; i < top; i++)
fpixRasterop(fpixd, 0, i, left + w + right, 1, fpixd, 0, top);
for (i = 0; i < bot; i++)
fpixRasterop(fpixd, 0, top + h + i, left + w + right, 1,
fpixd, 0, top + h - 1);
return fpixd;
} | false | false | false | false | false | 0 |
unit_addrs_search (const void *vkey, const void *ventry)
{
const uintptr_t *key = (const uintptr_t *) vkey;
const struct unit_addrs *entry = (const struct unit_addrs *) ventry;
uintptr_t pc;
pc = *key;
if (pc < entry->low)
return -1;
else if (pc >= entry->high)
return 1;
else
return 0;
} | false | false | false | false | false | 0 |
read_quoted_string (void)
{
int c;
while (1)
{
c = read_char (); /* Read the string */
if (c == '\\')
{
read_escape ();
continue;
}
else if (c == '"' || c == EOF)
break;
obstack_1grow (&string_obstack, c);
}
obstack_1grow (&string_obstack, 0);
return XOBFINISH (&string_obstack, char *);
} | false | false | false | false | false | 0 |
FDKaacEnc_calcSfbRelevantLines( const FIXP_DBL *const sfbFormFactorLdData,
const FIXP_DBL *const sfbEnergyLdData,
const FIXP_DBL *const sfbThresholdLdData,
const INT *const sfbOffsets,
const INT sfbCnt,
const INT sfbPerGroup,
const INT maxSfbPerGroup,
FIXP_DBL *sfbNRelevantLines)
{
INT sfbOffs, sfb;
FIXP_DBL sfbWidthLdData;
FIXP_DBL asPeFacLdData = FL2FXCONST_DBL(0.109375); /* AS_PE_FAC_SHIFT*ld64(2) */
FIXP_DBL accu;
/* sfbNRelevantLines[i] = 2^( (sfbFormFactorLdData[i] - 0.25 * (sfbEnergyLdData[i] - ld64(sfbWidth[i]/(2^7)) - AS_PE_FAC_SHIFT*ld64(2)) * 64); */
FDKmemclear(sfbNRelevantLines, sfbCnt * sizeof(FIXP_DBL));
for (sfbOffs=0; sfbOffs<sfbCnt; sfbOffs+=sfbPerGroup) {
for(sfb=0; sfb<maxSfbPerGroup; sfb++) {
/* calc sum of sqrt(spec) */
if((FIXP_DBL)sfbEnergyLdData[sfbOffs+sfb] > (FIXP_DBL)sfbThresholdLdData[sfbOffs+sfb]) {
INT sfbWidth = sfbOffsets[sfbOffs+sfb+1] - sfbOffsets[sfbOffs+sfb];
/* avgFormFactorLdData = sqrtFixp(sqrtFixp(sfbEnergyLdData[sfbOffs+sfb]/sfbWidth)); */
/* sfbNRelevantLines[sfbOffs+sfb] = sfbFormFactor[sfbOffs+sfb] / avgFormFactorLdData; */
sfbWidthLdData = (FIXP_DBL)(sfbWidth << (DFRACT_BITS-1-AS_PE_FAC_SHIFT));
sfbWidthLdData = CalcLdData(sfbWidthLdData);
accu = sfbEnergyLdData[sfbOffs+sfb] - sfbWidthLdData - asPeFacLdData;
accu = sfbFormFactorLdData[sfbOffs+sfb] - (accu >> 2);
sfbNRelevantLines[sfbOffs+sfb] = CalcInvLdData(accu) >> 1;
}
}
}
} | false | false | false | false | false | 0 |
removeAllSources()
{
QMutableHashIterator<QString, Plasma::DataContainer*> it(d->sources);
while (it.hasNext()) {
it.next();
Plasma::DataContainer *s = it.value();
const QString source = it.key();
it.remove();
s->disconnect(this);
s->deleteLater();
emit sourceRemoved(source);
}
} | false | false | false | false | false | 0 |
contentsDragLeaveEvent( QDragLeaveEvent * )
{
// Restore the current item to what it was before the dragging (#17070)
if ( isValidItem(m_currentBeforeDropItem) )
{
setSelected( m_currentBeforeDropItem, true );
ensureItemVisible( m_currentBeforeDropItem );
}
else if ( isValidItem(m_dropItem) )
setSelected( m_dropItem, false ); // no item selected
m_currentBeforeDropItem = 0;
m_dropItem = 0;
} | false | false | false | false | false | 0 |
clear_blocked(struct btd_adapter *adapter)
{
int err;
err = adapter_ops->unblock_device(adapter->dev_id, BDADDR_ANY, 0);
if (err < 0)
error("Clearing blocked list failed: %s (%d)",
strerror(-err), -err);
} | false | false | false | false | false | 0 |
GDALDestroyApproxTransformer( void * pCBData )
{
VALIDATE_POINTER0( pCBData, "GDALDestroyApproxTransformer" );
ApproxTransformInfo *psATInfo = (ApproxTransformInfo *) pCBData;
if( psATInfo->bOwnSubtransformer )
GDALDestroyTransformer( psATInfo->pBaseCBData );
CPLFree( pCBData );
} | false | false | false | false | false | 0 |
setup_item_from_info (GkmSecretItem *item, GkmSecretData *data, ItemInfo *info)
{
GkmSecretObject *obj = GKM_SECRET_OBJECT (item);
const gchar *schema_name;
GkmSecret *secret;
gkm_secret_object_set_label (obj, info->display_name);
gkm_secret_object_set_created (obj, info->ctime);
gkm_secret_object_set_modified (obj, info->mtime);
schema_name = g_hash_table_lookup (info->attributes, GKM_SECRET_FIELD_SCHEMA);
if (schema_name == NULL)
schema_name = gkm_secret_compat_format_item_type (info->type);
gkm_secret_item_set_schema (item, schema_name);
gkm_secret_item_set_fields (item, info->attributes);
/* Collection is locked */
if (!data) {
g_object_set_data (G_OBJECT (item), "compat-acl", NULL);
} else {
secret = gkm_secret_new (info->ptr_secret, info->n_secret);
gkm_secret_data_set_secret (data, gkm_secret_object_get_identifier (obj), secret);
g_object_unref (secret);
g_object_set_data_full (G_OBJECT (item), "compat-acl", info->acl, gkm_secret_compat_acl_free);
info->acl = NULL;
}
} | false | false | false | false | false | 0 |
CompareIC_Miss(Arguments args) {
NoHandleAllocation na;
ASSERT(args.length() == 3);
CompareIC ic(static_cast<Token::Value>(Smi::cast(args[2])->value()));
ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1));
return ic.target();
} | false | false | false | false | false | 0 |
load_roms_init_memory()
{
config_load_roms();
memory_ptr_init();
clk_setup_bram_version(); /* Must be after config_load_roms */
if(g_rom_version >= 3) {
g_c036_val_speed |= 0x40; /* set power-on bit */
} else {
g_c036_val_speed &= (~0x40); /* clear the bit */
}
do_reset();
/* if user booted ROM 01, switches to ROM 03, then switches back */
/* to ROM 01, then the reset routines call to Tool $0102 looks */
/* at uninitialized $e1/15fe and if it is negative it will JMP */
/* through $e1/1688 which ROM 03 left pointing to fc/0199 */
/* So set e1/15fe = 0 */
set_memory16_c(0xe115fe, 0, 0);
} | false | false | false | false | false | 0 |
svm_vcpu_reset(struct kvm_vcpu *vcpu, bool init_event)
{
struct vcpu_svm *svm = to_svm(vcpu);
u32 dummy;
u32 eax = 1;
if (!init_event) {
svm->vcpu.arch.apic_base = APIC_DEFAULT_PHYS_BASE |
MSR_IA32_APICBASE_ENABLE;
if (kvm_vcpu_is_reset_bsp(&svm->vcpu))
svm->vcpu.arch.apic_base |= MSR_IA32_APICBASE_BSP;
}
init_vmcb(svm);
kvm_cpuid(vcpu, &eax, &dummy, &dummy, &dummy);
kvm_register_write(vcpu, VCPU_REGS_RDX, eax);
} | false | false | false | false | false | 0 |
set_up_stretched_texture_for_light_radius(void)
{
#ifdef HAVE_LIBGL
static int texture_is_set_up_already = FALSE;
// In the non-open-gl case, this function shouldn't be called ever....
//
if (!use_open_gl)
return;
// Stop any image batch being constructed,
// so that struct image does not get confused.
end_image_batch();
// Some protection against creating this texture twice...
//
if (texture_is_set_up_already)
return;
texture_is_set_up_already = TRUE;
// We create an SDL surface, so that we can make the texture for the
// stretched-texture method light radius from it...
//
light_radius_stretch_surface =
SDL_CreateRGBSurface(SDL_SWSURFACE, LightRadiusConfig.texture_w, LightRadiusConfig.texture_h, 32, rmask, gmask, bmask, amask);
// Having prepared the raw image it's now time to create the real
// textures.
//
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glGenTextures(1, &light_radius_stretch_texture);
glBindTexture(GL_TEXTURE_2D, (light_radius_stretch_texture));
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Generate The Texture
glTexImage2D(GL_TEXTURE_2D, 0, 4, light_radius_stretch_surface->w,
light_radius_stretch_surface->h, 0, GL_BGRA, GL_UNSIGNED_BYTE, light_radius_stretch_surface->pixels);
#endif
} | false | false | false | false | false | 0 |
write(hsStream* S, plResManager* mgr) {
if (S->getVer().isUru() || S->getVer().isUniversal()) {
S->writeShort(fFlags);
if (fFlags & kHasAgeInfo)
fAgeInfo.write(S, mgr);
if (fFlags & kHasLinkingRules)
S->writeByte(fLinkingRules);
if (fFlags & kHasSpawnPt)
fSpawnPoint.write(S);
if (fFlags & kHasAmCCR)
S->writeByte(fAmCCR);
if (fFlags & kHasParentAgeFilename) {
S->writeShort(fParentAgeFilename.len());
S->writeStr(fParentAgeFilename);
}
} else {
hsBitVector fields;
fields[0] = true;
fields[1] = true;
fields[2] = true;
S->writeShort(fAgeInfo.getAgeFilename().len());
S->writeStr(fAgeInfo.getAgeFilename());
S->writeShort(fAgeInfo.getAgeInstanceName().len());
S->writeStr(fAgeInfo.getAgeInstanceName());
fSpawnPoint.write(S);
}
} | false | false | false | false | false | 0 |
try_recycle_socket(int fd, void *voidarg)
{
struct recycle_info *ri=(struct recycle_info *)voidarg;
union {
SOCKADDR_STORAGE ss;
struct sockaddr_in sin;
#if HAVE_SOXWRAP_IPV6
struct sockaddr_in6 sin6;
#endif
} sa;
socklen_t salen=sizeof(sa);
if (getsockname(fd, (struct sockaddr *)&sa, &salen) < 0)
return 0;
if (ri->sin->sa_family != sa.ss.SS_family)
return 0;
switch (ri->sin->sa_family) {
case AF_INET:
{
struct sockaddr_in ri_sin;
memcpy(&ri_sin, ri->sin, sizeof(ri_sin));
if (ri_sin.sin_addr.s_addr != sa.sin.sin_addr.s_addr
|| ri_sin.sin_port != sa.sin.sin_port)
return 0;
}
break;
#if HAVE_SOXWRAP_IPV6
case AF_INET6:
{
struct sockaddr_in6 ri_sin;
memcpy(&ri_sin, ri->sin, sizeof(ri_sin));
if (memcmp(&ri_sin.sin6_addr, &sa.sin6.sin6_addr,
sizeof(sa.sin6.sin6_addr)) ||
ri_sin.sin6_port != sa.sin6.sin6_port)
return 0;
}
break;
#endif
default:
return 0;
}
ri->found_socket=fd;
return 1;
} | false | true | false | false | false | 1 |
prevSegment(LiveInterval &LI,
SlotIndex S) {
LiveInterval::iterator P = LI.end();
for (LiveInterval::iterator I = LI.begin(), E = LI.end(); I != E; ++I) {
if (I->end > S)
return P;
P = I;
}
return P;
} | false | false | false | false | false | 0 |
send_fd (int sockfd, int fd)
{
char tmp[CMSG_SPACE(sizeof(int))];
struct cmsghdr *cmsg;
struct iovec iov;
struct msghdr msg;
char ch = '\0';
memset(&msg, 0, sizeof(msg));
msg.msg_control = (caddr_t) tmp;
msg.msg_controllen = CMSG_LEN(sizeof(int));
cmsg = CMSG_FIRSTHDR(&msg);
cmsg->cmsg_len = CMSG_LEN(sizeof(int));
cmsg->cmsg_level = SOL_SOCKET;
cmsg->cmsg_type = SCM_RIGHTS;
*(int *)CMSG_DATA(cmsg) = fd;
iov.iov_base = &ch;
iov.iov_len = 1;
msg.msg_iov = &iov;
msg.msg_iovlen = 1;
if (sendmsg(sockfd, &msg, 0) != 1)
return -1;
return 0;
} | 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.