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 |
|---|---|---|---|---|---|---|
sha256_init(sha256_ctx *ctx)
{
#ifndef UNROLL_LOOPS
int i;
for (i = 0; i < 8; i++) {
ctx->h[i] = sha256_h0[i];
}
#else
ctx->h[0] = sha256_h0[0]; ctx->h[1] = sha256_h0[1];
ctx->h[2] = sha256_h0[2]; ctx->h[3] = sha256_h0[3];
ctx->h[4] = sha256_h0[4]; ctx->h[5] = sha256_h0[5];
ctx->h[6] = sha256_h0[6]; ctx->h[7] = sha256_h0[7];
#endif /* !UNROLL_LOOPS */
ctx->len = 0;
ctx->tot_len = 0;
} | false | false | false | false | false | 0 |
snippets_editor_set_snippet_new (SnippetsEditor *snippets_editor)
{
SnippetsEditorPrivate *priv = NULL;
/* Assertions */
g_return_if_fail (ANJUTA_IS_SNIPPETS_EDITOR (snippets_editor));
priv = ANJUTA_SNIPPETS_EDITOR_GET_PRIVATE (snippets_editor);
/* Delete the old snippet */
if (ANJUTA_IS_SNIPPET (priv->snippet))
g_object_unref (priv->snippet);
priv->backup_snippet = NULL;
/* Initialize a new empty snippet */
priv->snippet = snippet_new ("", NULL, "", "", NULL, NULL, NULL, NULL);
init_sensitivity (snippets_editor);
/* Initialize the entries and content */
gtk_entry_set_text (priv->name_entry, "");
gtk_entry_set_text (priv->trigger_entry, "");
gtk_entry_set_text (priv->keywords_entry, "");
load_content_to_editor (snippets_editor);
reload_snippets_group_combo_box (snippets_editor);
focus_snippets_group_combo_box (snippets_editor);
load_languages_combo_box (snippets_editor);
snippet_vars_store_unload (priv->vars_store);
if (ANJUTA_IS_SNIPPET (priv->snippet))
snippet_vars_store_load (priv->vars_store, priv->snippets_db, priv->snippet);
init_input_errors (snippets_editor);
} | false | false | false | false | false | 0 |
solve (CoinWorkDouble * region)
{
if (!whichDense_) {
solve(region, 3);
} else {
// dense columns
int i;
solve(region, 1);
// do change;
int numberDense = dense_->numberRows();
CoinWorkDouble * change = new CoinWorkDouble[numberDense];
for (i = 0; i < numberDense; i++) {
const longDouble * a = denseColumn_ + i * numberRows_;
CoinWorkDouble value = 0.0;
for (int iRow = 0; iRow < numberRows_; iRow++)
value += a[iRow] * region[iRow];
change[i] = value;
}
// solve
dense_->solve(change);
for (i = 0; i < numberDense; i++) {
const longDouble * a = denseColumn_ + i * numberRows_;
CoinWorkDouble value = change[i];
for (int iRow = 0; iRow < numberRows_; iRow++)
region[iRow] -= value * a[iRow];
}
delete [] change;
// and finish off
solve(region, 2);
}
} | false | false | false | false | false | 0 |
ext_xml_parse(const char **retp, int len, extvec_t *exv, int exvcnt)
{
const char *p = *retp;
const char *end = &p[len];
const char *lastp = p; /* Last parsed point */
extdesc_t *d;
g_assert(exvcnt > 0);
g_assert(exv->opaque == NULL);
for (/* NOTHING */; p != end; p++) {
uchar c = *p;
if (c == '\0' || c == HUGE_FS) {
break;
}
}
/*
* We don't analyze the XML, encapsulate as one big opaque chunk.
*/
WALLOC(d);
d->ext_phys_payload = lastp;
d->ext_phys_len = d->ext_phys_paylen = p - lastp;
d->ext_payload = d->ext_phys_payload;
d->ext_paylen = d->ext_phys_paylen;
exv->opaque = d;
exv->ext_type = EXT_XML;
exv->ext_name = NULL;
exv->ext_token = EXT_T_XML;
g_assert(p - lastp == d->ext_phys_len);
if (p != end)
p++; /* Swallow separator as well */
*retp = p; /* Points to first byte after what we parsed */
return 1;
} | false | false | false | false | false | 0 |
cycleColors(const MSUnsignedLongVector& colors_)
{
MSBoolean redrawNecessary=MSFalse;
if (cycle()!=0&&cycle()->count()<cycle()->numCycles())
{
redrawNecessary=MSTrue;
}
removeCycle();
_cycleColors=colors_;
if (redrawNecessary==MSTrue) drawFieldValue();
} | false | false | false | false | false | 0 |
ompi_rb_tree_traverse(ompi_rb_tree_t *tree,
ompi_rb_tree_condition_fn_t cond,
ompi_rb_tree_action_fn_t action)
{
if ((cond == NULL) || (action == NULL)) {
return(OMPI_ERROR);
}
inorder_traversal(tree, cond, action, tree->root_ptr->left);
return(OMPI_SUCCESS);
} | false | false | false | false | false | 0 |
gth_file_store_get_prev_visible (GthFileStore *file_store,
GtkTreeIter *iter)
{
GthFileRow *row;
if ((iter == NULL) || (iter->user_data == NULL))
return FALSE;
g_return_val_if_fail (VALID_ITER (iter, file_store), FALSE);
row = (GthFileRow*) iter->user_data;
if (row->pos == 0)
return FALSE;
if (iter != NULL) {
iter->stamp = file_store->priv->stamp;
iter->user_data = file_store->priv->rows[row->pos - 1];
}
return TRUE;
} | false | false | false | false | false | 0 |
cp_parser_objc_declaration (cp_parser* parser, tree attributes)
{
/* Try to figure out what kind of declaration is present. */
cp_token *kwd = cp_lexer_peek_token (parser->lexer);
if (attributes)
switch (kwd->keyword)
{
case RID_AT_ALIAS:
case RID_AT_CLASS:
case RID_AT_END:
error_at (kwd->location, "attributes may not be specified before"
" the %<@%D%> Objective-C++ keyword",
kwd->u.value);
attributes = NULL;
break;
case RID_AT_IMPLEMENTATION:
warning_at (kwd->location, OPT_Wattributes,
"prefix attributes are ignored before %<@%D%>",
kwd->u.value);
attributes = NULL;
default:
break;
}
switch (kwd->keyword)
{
case RID_AT_ALIAS:
cp_parser_objc_alias_declaration (parser);
break;
case RID_AT_CLASS:
cp_parser_objc_class_declaration (parser);
break;
case RID_AT_PROTOCOL:
cp_parser_objc_protocol_declaration (parser, attributes);
break;
case RID_AT_INTERFACE:
cp_parser_objc_class_interface (parser, attributes);
break;
case RID_AT_IMPLEMENTATION:
cp_parser_objc_class_implementation (parser);
break;
case RID_AT_END:
cp_parser_objc_end_implementation (parser);
break;
default:
error_at (kwd->location, "misplaced %<@%D%> Objective-C++ construct",
kwd->u.value);
cp_parser_skip_to_end_of_block_or_statement (parser);
}
} | false | false | false | false | false | 0 |
ffs_embed (int *start_sector, int needed_sectors)
{
/* XXX: I don't know if this is really correct. Someone who is
familiar with BSD should check for this. */
if (needed_sectors > 14)
return 0;
*start_sector = 1;
#if 1
/* FIXME: Disable the embedding in FFS until someone checks if
the code above is correct. */
return 0;
#else
return 1;
#endif
} | false | false | false | false | false | 0 |
evalvargs(parms,argptr,n)
truc parms;
truc *argptr;
int n;
{
int i, flg;
unsigned depth;
truc *ptr;
depth = basePtr - ArgStack;
WORKpush(parms);
for(i=0; i<n; i++) {
ptr = VECTORPTR(workStkPtr) + i;
if(*FLAGPTR(ptr) == fSPECIAL1) {
/* es handelt sich um einen Variable-Parameter */
if((*argptr = vsymaux(argptr,depth)) == breaksym) {
error(funcsym,err_vasym,voidsym);
n = aERROR;
goto cleanup;
}
else {
argptr++;
continue;
}
}
if((flg = *FLAGPTR(argptr)) >= fBOOL) {
argptr++;
continue;
}
else if(flg < fFUNEXPR) {
*argptr = eval0(argptr,flg);
}
if(*FLAGPTR(argptr) < fRECORD) {
if((*argptr = eval(argptr)) == breaksym) {
n = aERROR;
break;
}
}
if((flg = *FLAGPTR(argptr)) >= fRECORD && flg <= fVECTLIKE1) {
*argptr = mkarrcopy(argptr);
}
argptr++;
}
cleanup:
WORKpop();
return(n);
} | false | false | false | false | false | 0 |
ide_acpi_exec_tfs(ide_drive_t *drive)
{
int ret;
unsigned int gtf_length;
unsigned long gtf_address;
unsigned long obj_loc;
DEBPRINT("call get_GTF, drive=%s port=%d\n", drive->name, drive->dn);
ret = do_drive_get_GTF(drive, >f_length, >f_address, &obj_loc);
if (ret < 0) {
DEBPRINT("get_GTF error (%d)\n", ret);
return ret;
}
DEBPRINT("call set_taskfiles, drive=%s\n", drive->name);
ret = do_drive_set_taskfiles(drive, gtf_length, gtf_address);
kfree((void *)obj_loc);
if (ret < 0) {
DEBPRINT("set_taskfiles error (%d)\n", ret);
}
DEBPRINT("ret=%d\n", ret);
return ret;
} | false | false | false | false | false | 0 |
tab_completion_get_text(TabCompData *td)
{
gchar *text;
text = g_strdup(gtk_entry_get_text(GTK_ENTRY(td->entry)));
if (text[0] == '~')
{
gchar *t = text;
text = expand_tilde(text);
g_free(t);
}
return text;
} | false | false | false | false | false | 0 |
camel_lock_helper_unlock (gint lockid)
{
struct _CamelLockHelperMsg *msg;
gint res = -1;
gint retry = 3;
gint len;
d (printf ("unlocking lock id %d\n", lockid));
LOCK ();
/* impossible to unlock if we haven't locked yet */
if (lock_helper_pid == -1) {
UNLOCK ();
return -1;
}
msg = alloca (sizeof (*msg));
again:
msg->magic = CAMEL_LOCK_HELPER_MAGIC;
msg->seq = lock_sequence;
msg->id = CAMEL_LOCK_HELPER_UNLOCK;
msg->data = lockid;
write_n (lock_stdin_pipe[1], msg, sizeof (*msg));
do {
/* should also have a timeout here? cancellation? */
len = read_n (lock_stdout_pipe[0], msg, sizeof (*msg));
if (len == 0) {
/* child quit, do we try ressurect it? */
res = CAMEL_LOCK_HELPER_STATUS_PROTOCOL;
if (waitpid (lock_helper_pid, NULL, WNOHANG) > 0) {
lock_helper_pid = -1;
close (lock_stdout_pipe[0]);
close (lock_stdin_pipe[1]);
lock_stdout_pipe[0] = -1;
lock_stdin_pipe[1] = -1;
}
goto fail;
}
if (msg->magic != CAMEL_LOCK_HELPER_RETURN_MAGIC
|| msg->seq > lock_sequence) {
goto fail;
}
} while (msg->seq < lock_sequence);
if (msg->seq == lock_sequence) {
switch (msg->id) {
case CAMEL_LOCK_HELPER_STATUS_OK:
d (printf ("lock child unlocked ok\n"));
res = 0;
break;
default:
d (printf ("locking failed !\n"));
break;
}
} else if (retry > 0) {
d (printf ("sequence failure, lost message? retry?\n"));
lock_sequence++;
retry--;
goto again;
}
fail:
lock_sequence++;
UNLOCK ();
return res;
} | false | false | false | false | false | 0 |
contour (double x[], int i, int j, int rows, int cols,
double v[], int nv)
/***** contour
x1 is lower left edge, x2 upper left, x3 upper right, x4 lower
right value at a square.
does contour plot of the nv values in v.
r and c is needed to compute the position of the square.
*****/
{ int k,n,m;
double sr[5],sc[5];
double val;
sr[4]=sr[0]=sr[3]=(lowerr-((long)i*(lowerr-upperr))/cols);
sr[1]=sr[2]=(lowerr-((long)(i+1)*(lowerr-upperr))/cols);
sc[4]=sc[0]=sc[1]=(upperc+((long)j*(lowerc-upperc))/rows);
sc[2]=sc[3]=(upperc+((long)(j+1)*(lowerc-upperc))/rows);
for (k=0; k<nv; k++)
{ val=v[k];
for (n=0; n<3; n++)
for (m=n+1; m<4; m++)
hcontour(val,n,m,x,sr,sc);
}
} | false | false | false | false | false | 0 |
emboss_initprobcat(AjPFloat arrayvals, long categs, double *probcat)
{ /* input probabilities of rate categories for HMM rates */
long i;
long maxi;
double probsum = 0.0;
if (!categs)
return probsum;
maxi = ajFloatLen(arrayvals);
if (maxi != categs)
ajWarn("Category probabilities read %d values, expected %d values",
maxi, categs);
for (i=0; i < categs; i++)
{
if (i > maxi)
probcat[i] = 0.0;
else
probcat[i] = ajFloatGet(arrayvals, i);
probsum += probcat[i];
}
return probsum;
} | false | false | false | false | false | 0 |
ast_security_event_get_required_ies(
const enum ast_security_event_type event_type)
{
if (check_event_type(event_type)) {
return NULL;
}
return sec_events[event_type].required_ies;
} | false | false | false | false | false | 0 |
icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, const std::string::value_type* ptr)
{
poco_check_ptr (ptr);
std::string::size_type sz = str.size();
if (pos > sz) pos = sz;
if (pos + n > sz) n = sz - pos;
TextIterator uit(str.begin() + pos, str.begin() + pos + n, utf8);
TextIterator uend(str.begin() + pos + n);
while (uit != uend && *ptr)
{
int c1 = Unicode::toLower(*uit);
int c2 = Unicode::toLower(*ptr);
if (c1 < c2)
return -1;
else if (c1 > c2)
return 1;
++uit; ++ptr;
}
if (uit == uend)
return *ptr == 0 ? 0 : -1;
else
return 1;
} | false | false | false | false | false | 0 |
get_chip_type(struct pci_dev *pdev, u32 pl_rev)
{
u16 device_id;
/* Retrieve adapter's device ID */
pci_read_config_word(pdev, PCI_DEVICE_ID, &device_id);
switch (device_id >> 12) {
case CHELSIO_T4:
return CHELSIO_CHIP_CODE(CHELSIO_T4, pl_rev);
case CHELSIO_T5:
return CHELSIO_CHIP_CODE(CHELSIO_T5, pl_rev);
case CHELSIO_T6:
return CHELSIO_CHIP_CODE(CHELSIO_T6, pl_rev);
default:
dev_err(&pdev->dev, "Device %d is not supported\n",
device_id);
}
return -EINVAL;
} | false | false | false | false | false | 0 |
PyInit__lsprof(void)
{
PyObject *module, *d;
module = PyModule_Create(&_lsprofmodule);
if (module == NULL)
return NULL;
d = PyModule_GetDict(module);
if (PyType_Ready(&PyProfiler_Type) < 0)
return NULL;
PyDict_SetItemString(d, "Profiler", (PyObject *)&PyProfiler_Type);
if (!initialized) {
PyStructSequence_InitType(&StatsEntryType,
&profiler_entry_desc);
PyStructSequence_InitType(&StatsSubEntryType,
&profiler_subentry_desc);
}
Py_INCREF((PyObject*) &StatsEntryType);
Py_INCREF((PyObject*) &StatsSubEntryType);
PyModule_AddObject(module, "profiler_entry",
(PyObject*) &StatsEntryType);
PyModule_AddObject(module, "profiler_subentry",
(PyObject*) &StatsSubEntryType);
empty_tuple = PyTuple_New(0);
initialized = 1;
return module;
} | false | false | false | false | false | 0 |
meh_update_cipher(MehCipher cipher, const unsigned char* in,
unsigned char* out, size_t len, size_t* got)
{
meh_error_t error;
switch (cipher->id)
{
case MEH_RC4:
error = meh_update_rc4(cipher->state.rc4, in, out, len, got);
break;
case MEH_SALSA20:
error = meh_update_salsa20(cipher->state.salsa20,
in,
out,
len,
got);
break;
default: /* shouldn't happen, but just in case */
return meh_error("invalid cipher id passed to meh_update_cipher",
MEH_INVALID_CIPHER);
}
return error;
} | false | false | false | false | false | 0 |
InitTextDisplay (const char* sample, int samplen) {
_display = new TextDisplay(true);
_display->LineHeight(_lineHt);
_display->TabWidth(_tabWidth);
if (samplen > 0) {
int beg, end, lineSize, nextBeg, line = 0;
for (beg = 0; beg < samplen; beg = nextBeg) {
GetLine(sample, samplen, beg, end, lineSize, nextBeg);
_display->ReplaceText(line, &sample[beg], lineSize);
++line;
}
}
} | false | false | false | false | false | 0 |
mpfr_divhigh_n_basecase (mpfr_limb_ptr qp, mpfr_limb_ptr np,
mpfr_limb_srcptr dp, mp_size_t n)
{
mp_limb_t qh, d1, d0, dinv, q2, q1, q0;
mpfr_pi1_t dinv2;
np += n;
if ((qh = (mpn_cmp (np, dp, n) >= 0)))
mpn_sub_n (np, np, dp, n);
/* now {np, n} is less than D={dp, n}, which implies np[n-1] <= dp[n-1] */
d1 = dp[n - 1];
if (n == 1)
{
invert_limb (dinv, d1);
umul_ppmm (q1, q0, np[0], dinv);
qp[0] = np[0] + q1;
return qh;
}
/* now n >= 2 */
d0 = dp[n - 2];
invert_pi1 (dinv2, d1, d0);
/* dinv2.inv32 = floor ((B^3 - 1) / (d0 + d1 B)) - B */
while (n > 1)
{
/* Invariant: it remains to reduce n limbs from N (in addition to the
initial low n limbs).
Since n >= 2 here, necessarily we had n >= 2 initially, which means
that in addition to the limb np[n-1] to reduce, we have at least 2
extra limbs, thus accessing np[n-3] is valid. */
/* warning: we can have np[n-1]=d1 and np[n-2]=d0, but since {np,n} < D,
the largest possible partial quotient is B-1 */
if (MPFR_UNLIKELY(np[n - 1] == d1 && np[n - 2] == d0))
q2 = ~ (mp_limb_t) 0;
else
udiv_qr_3by2 (q2, q1, q0, np[n - 1], np[n - 2], np[n - 3],
d1, d0, dinv2.inv32);
/* since q2 = floor((np[n-1]*B^2+np[n-2]*B+np[n-3])/(d1*B+d0)),
we have q2 <= (np[n-1]*B^2+np[n-2]*B+np[n-3])/(d1*B+d0),
thus np[n-1]*B^2+np[n-2]*B+np[n-3] >= q2*(d1*B+d0)
and {np-1, n} >= q2*D - q2*B^(n-2) >= q2*D - B^(n-1)
thus {np-1, n} - (q2-1)*D >= D - B^(n-1) >= 0
which proves that at most one correction is needed */
q0 = mpn_submul_1 (np - 1, dp, n, q2);
if (MPFR_UNLIKELY(q0 > np[n - 1]))
{
mpn_add_n (np - 1, np - 1, dp, n);
q2 --;
}
qp[--n] = q2;
dp ++;
}
/* we have B+dinv2 = floor((B^3-1)/(d1*B+d0)) < B^2/d1
q1 = floor(np[0]*(B+dinv2)/B) <= floor(np[0]*B/d1)
<= floor((np[0]*B+np[1])/d1)
thus q1 is not larger than the true quotient.
q1 > np[0]*(B+dinv2)/B - 1 > np[0]*(B^3-1)/(d1*B+d0)/B - 2
For d1*B+d0 <> B^2/2, we have B+dinv2 = floor(B^3/(d1*B+d0))
thus q1 > np[0]*B^2/(d1*B+d0) - 2, i.e.,
(d1*B+d0)*q1 > np[0]*B^2 - 2*(d1*B+d0)
d1*B*q1 > np[0]*B^2 - 2*d1*B - 2*d0 - d0*q1 >= np[0]*B^2 - 2*d1*B - B^2
thus q1 > np[0]*B/d1 - 2 - B/d1 > np[0]*B/d1 - 4.
For d1*B+d0 = B^2/2, dinv2 = B-1 thus q1 > np[0]*(2B-1)/B - 1 >
np[0]*B/d1 - 2.
In all cases, if q = floor((np[0]*B+np[1])/d1), we have:
q - 4 <= q1 <= q
*/
umul_ppmm (q1, q0, np[0], dinv2.inv32);
qp[0] = np[0] + q1;
return qh;
} | false | false | false | false | false | 0 |
Irun (int argc, lvar_t *argv) {
Psrc_t src;
char *s;
Tobj co;
if ((s = Tgetstring (argv[0].o))) {
src.flag = CHARSRC, src.s = s, src.fp = NULL;
src.tok = -1, src.lnum = 1;
while ((co = Punit (&src)))
Eoktorun = TRUE, Eunit (co);
}
return L_SUCCESS;
} | false | false | false | false | false | 0 |
cd_client_get_devices_by_kind (CdClient *client,
CdDeviceKind kind,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
GSimpleAsyncResult *res;
g_return_if_fail (CD_IS_CLIENT (client));
g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
g_return_if_fail (client->priv->proxy != NULL);
res = g_simple_async_result_new (G_OBJECT (client),
callback,
user_data,
cd_client_get_devices_by_kind);
g_dbus_proxy_call (client->priv->proxy,
"GetDevicesByKind",
g_variant_new ("(s)",
cd_device_kind_to_string (kind)),
G_DBUS_CALL_FLAGS_NONE,
-1,
cancellable,
cd_client_get_devices_by_kind_cb,
res);
} | false | false | false | false | false | 0 |
acl_create_entry(acl_t *acl_p, acl_entry_t *entry_p)
{
acl_obj *acl_obj_p;
acl_entry_obj *entry_obj_p;
if (!acl_p || !entry_p) {
if (entry_p)
*entry_p = NULL;
errno = EINVAL;
return -1;
}
acl_obj_p = ext2int(acl, *acl_p);
if (!acl_obj_p)
return -1;
entry_obj_p = __acl_create_entry_obj(acl_obj_p);
if (entry_obj_p == NULL)
return -1;
*entry_p = int2ext(entry_obj_p);
return 0;
} | false | false | false | false | false | 0 |
createGraph()
{
if (!_item)
return;
if (_graphCreated)
return;
_graphCreated = true;
if ((_item->type() == ProfileContext::Function) ||(_item->type()
== ProfileContext::FunctionCycle)) {
TraceFunction* f = (TraceFunction*) _item;
double incl = f->inclusive()->subCost(_eventType);
_realFuncLimit = incl * _go->funcLimit();
_realCallLimit = _realFuncLimit * _go->callLimit();
buildGraph(f, 0, true, 1.0); // down to callees
// set costs of function back to 0, as it will be added again
GraphNode& n = _nodeMap[f];
n.self = n.incl = 0.0;
buildGraph(f, 0, false, 1.0); // up to callers
} else {
TraceCall* c = (TraceCall*) _item;
double incl = c->subCost(_eventType);
_realFuncLimit = incl * _go->funcLimit();
_realCallLimit = _realFuncLimit * _go->callLimit();
// create edge
TraceFunction *caller, *called;
caller = c->caller(false);
called = c->called(false);
QPair<TraceFunction*,TraceFunction*> p(caller, called);
GraphEdge& e = _edgeMap[p];
e.setCall(c);
e.setCaller(p.first);
e.setCallee(p.second);
e.cost = c->subCost(_eventType);
e.count = c->callCount();
SubCost s = called->inclusive()->subCost(_eventType);
buildGraph(called, 0, true, e.cost / s); // down to callees
s = caller->inclusive()->subCost(_eventType);
buildGraph(caller, 0, false, e.cost / s); // up to callers
}
} | false | false | false | false | false | 0 |
maybe_duplicate_eh_stmt_fn (struct function *new_fun, gimple new_stmt,
struct function *old_fun, gimple old_stmt,
struct pointer_map_t *map, int default_lp_nr)
{
int old_lp_nr, new_lp_nr;
void **slot;
if (!stmt_could_throw_p (new_stmt))
return false;
old_lp_nr = lookup_stmt_eh_lp_fn (old_fun, old_stmt);
if (old_lp_nr == 0)
{
if (default_lp_nr == 0)
return false;
new_lp_nr = default_lp_nr;
}
else if (old_lp_nr > 0)
{
eh_landing_pad old_lp, new_lp;
old_lp = (*old_fun->eh->lp_array)[old_lp_nr];
slot = pointer_map_contains (map, old_lp);
new_lp = (eh_landing_pad) *slot;
new_lp_nr = new_lp->index;
}
else
{
eh_region old_r, new_r;
old_r = (*old_fun->eh->region_array)[-old_lp_nr];
slot = pointer_map_contains (map, old_r);
new_r = (eh_region) *slot;
new_lp_nr = -new_r->index;
}
add_stmt_to_eh_lp_fn (new_fun, new_stmt, new_lp_nr);
return true;
} | false | false | false | false | false | 0 |
ReflectSimPointer(G_Synset ss, G_Synset tss,
short wdnum, int fanss)
{
Pointer p;
Synonym syn;
/* 'fanss' is used to make sure we've found a pointer to the
right synset. In a cluster structure, head synsets have
similar pointers to all fan synsets, and all fan synsets have
a similar pointer to the cluster head. These pointers are
specified in lower case. When ReflectSimPointer is called,
fanss is FALSE when trying to match head/fan pointers within
a single cluster. It is TRUE when trying to match a pointer
from a fan to a different cluster head. */
syn = tss->syns; /* look for pointer to head word */
for (p = ss->ptrs; p; p = p->pnext) {
if (syn->word == p->pword &&
p->phead == fanss &&
syn->sensenum == p->psensenum &&
tss->filenum == p->pfilenum &&
p->ptype == SIMPTR) {
if (wdnum == ALLWORDS || syn->sswdnum == wdnum) {
p->psynset = tss; /* point to target synset */
p->towdnum = wdnum; /* set target word number */
p->status = RESOLVED;
return(p);
}
}
}
return(NULL);
} | false | false | false | false | false | 0 |
click_static_initialize()
{
String::static_initialize();
cp_va_static_initialize();
ErrorHandler::static_initialize(new FileErrorHandler(stderr, ""));
} | false | false | false | false | false | 0 |
min (const cl_SF& x, const cl_SF& y)
{
return (x <= y ? x : y);
}
} | false | false | false | false | false | 0 |
utf8_to_ucs4_oneatatime(int c, CBUF_S *cb, UCS *obuf, int *obufwidth)
{
int width = 0, outchars = 0;
if(!(cb && cb->cbufp))
return(0);
if(cb->cbufp < cb->cbuf+sizeof(cb->cbuf)){
unsigned char *inputp;
unsigned long remaining_octets;
UCS ucs;
*cb->cbufp++ = (unsigned char) c;
inputp = cb->cbuf;
remaining_octets = (cb->cbufp - cb->cbuf) * sizeof(unsigned char);
ucs = (UCS) utf8_get(&inputp, &remaining_octets);
switch(ucs){
case U8G_ENDSTRG: /* incomplete character, wait */
case U8G_ENDSTRI: /* incomplete character, wait */
break;
default:
if(ucs & U8G_ERROR || ucs == UBOGON){
/*
* None of these cases is supposed to happen. If it
* does happen then the input stream isn't UTF-8
* so something is wrong.
*/
outchars++;
*obuf = '?';
cb->cbufp = cb->cbuf;
width = 1;
}
else{
outchars++;
if(ucs < 0x80 && ucs >= 0x20)
width = 1;
if(ucs >= 0x80 && (width=wcellwidth(ucs)) < 0){
/*
* This happens when we have a UTF-8 character that
* we aren't able to print in our locale. For example,
* if the locale is setup with the terminal
* expecting ISO-8859-1 characters then there are
* lots of UTF-8 characters that can't be printed.
* Print a '?' instead.
* Don't think this should happen in Windows.
*/
*obuf = '?';
}
else{
*obuf = ucs;
}
/* update the input buffer */
if(inputp >= cb->cbufp) /* this should be the case */
cb->cbufp = cb->cbuf;
else{ /* extra chars for some reason? */
unsigned char *q, *newcbufp;
newcbufp = (cb->cbufp - inputp) + cb->cbuf;
q = cb->cbuf;
while(inputp < cb->cbufp)
*q++ = *inputp++;
cb->cbufp = newcbufp;
}
}
break;
}
}
else{ /* error */
*obuf = '?';
outchars = 1;
width = 1;
cb->cbufp = cb->cbuf; /* start over */
}
if(obufwidth)
*obufwidth = width;
return(outchars);
} | false | false | false | false | false | 0 |
lgl_template_dup (const lglTemplate *orig_template)
{
lglTemplate *template;
GList *p;
lglTemplateFrame *frame;
g_return_val_if_fail (orig_template, NULL);
template = lgl_template_new (orig_template->brand,
orig_template->part,
orig_template->description,
orig_template->paper_id,
orig_template->page_width,
orig_template->page_height);
template->equiv_part = g_strdup (orig_template->equiv_part);
template->product_url = g_strdup (orig_template->product_url);
for ( p=orig_template->category_ids; p != NULL; p=p->next )
{
lgl_template_add_category (template, p->data);
}
for ( p=orig_template->frames; p != NULL; p=p->next )
{
frame = (lglTemplateFrame *)p->data;
lgl_template_add_frame (template, lgl_template_frame_dup (frame));
}
return template;
} | false | false | false | false | false | 0 |
setUsefulStuff (CbcModel * model, int deterministic, CbcModel * baseModel,
CbcThread * master,
void *& masterMutex)
{
baseModel_ = baseModel;
thisModel_ = model;
deterministic_ = deterministic;
threadStuff_.setUsefulStuff(&master->threadStuff_, masterMutex);
node_ = NULL;
createdNode_ = NULL;
master_ = master;
returnCode_ = -1;
timeLocked_ = 0.0;
timeWaitingToLock_ = 0.0;
timeWaitingToStart_ = 0.0;
timeInThread_ = 0.0;
numberTimesLocked_ = 0;
numberTimesUnlocked_ = 0;
numberTimesWaitingToStart_ = 0;
dantzigState_ = 0; // 0 unset, -1 waiting to be set, 1 set
locked_ = false;
delNode_ = NULL;
maxDeleteNode_ = 0;
nDeleteNode_ = 0;
nodesThisTime_ = 0;
iterationsThisTime_ = 0;
if (model != baseModel) {
// thread
thisModel_->setInfoInChild(-3, this);
if (deterministic_ >= 0)
thisModel_->moveToModel(baseModel, -1);
if (deterministic == -1)
threadStuff_.startThread( doCutsThread, this);
else
threadStuff_.startThread( doNodesThread, this);
}
} | false | false | false | false | false | 0 |
cmd_erase(char **arg)
{
const char *type_text = get_arg(arg);
const char *seg_text = get_arg(arg);
device_erase_type_t type = DEVICE_ERASE_MAIN;
address_t segment = 0;
if (seg_text && expr_eval(stab_default, seg_text, &segment) < 0) {
printc_err("erase: invalid expression: %s\n", seg_text);
return -1;
}
if (type_text) {
if (!strcasecmp(type_text, "all")) {
type = DEVICE_ERASE_ALL;
} else if (!strcasecmp(type_text, "segment")) {
type = DEVICE_ERASE_SEGMENT;
if (!seg_text) {
printc_err("erase: expected segment "
"address\n");
return -1;
}
} else {
printc_err("erase: unknown erase type: %s\n",
type_text);
return -1;
}
}
if (device_default->ctl(device_default, DEVICE_CTL_HALT) < 0)
return -1;
printc("Erasing...\n");
return device_default->erase(device_default, type, segment);
} | false | false | false | false | false | 0 |
get_plain_pw(request_rec *r, char *user, char *auth_pwfile)
{
ap_configfile_t *f;
char l[MAX_STRING_LEN];
const char *rpw, *w;
apr_status_t status;
if ((status = ap_pcfg_openfile(&f, r->pool, auth_pwfile)) != APR_SUCCESS) {
ap_log_rerror(APLOG_MARK, APLOG_ERR, status, r,
"Could not open password file: %s", auth_pwfile);
return NULL;
}
while (!(ap_cfg_getline(l, MAX_STRING_LEN, f))) {
if ((l[0] == '#') || (!l[0])) {
continue;
}
rpw = l;
w = ap_getword(r->pool, &rpw, ':');
if (!strcmp(user, w)) {
ap_cfg_closefile(f);
return ap_getword(r->pool, &rpw, ':');
}
}
ap_cfg_closefile(f);
return NULL;
} | false | false | false | false | false | 0 |
sh_eth_dev_exit(struct net_device *ndev)
{
struct sh_eth_private *mdp = netdev_priv(ndev);
int i;
/* Deactivate all TX descriptors, so DMA should stop at next
* packet boundary if it's currently running
*/
for (i = 0; i < mdp->num_tx_ring; i++)
mdp->tx_ring[i].status &= ~cpu_to_edmac(mdp, TD_TACT);
/* Disable TX FIFO egress to MAC */
sh_eth_rcv_snd_disable(ndev);
/* Stop RX DMA at next packet boundary */
sh_eth_write(ndev, 0, EDRRR);
/* Aside from TX DMA, we can't tell when the hardware is
* really stopped, so we need to reset to make sure.
* Before doing that, wait for long enough to *probably*
* finish transmitting the last packet and poll stats.
*/
msleep(2); /* max frame time at 10 Mbps < 1250 us */
sh_eth_get_stats(ndev);
sh_eth_reset(ndev);
/* Set MAC address again */
update_mac_address(ndev);
} | false | false | false | false | false | 0 |
glade_widget_dup_properties (GladeWidget * dest_widget, GList * template_props,
gboolean as_load, gboolean copy_parentless,
gboolean exact)
{
GList *list, *properties = NULL;
for (list = template_props; list && list->data; list = list->next)
{
GladeProperty *prop = list->data;
GladePropertyClass *pclass = glade_property_get_class (prop);
if (glade_property_class_save (pclass) == FALSE && as_load)
continue;
if (glade_property_class_parentless_widget (pclass) && copy_parentless)
{
GObject *object = NULL;
GladeWidget *parentless;
glade_property_get (prop, &object);
prop = glade_property_dup (prop, NULL);
if (object)
{
parentless = glade_widget_get_from_gobject (object);
parentless = glade_widget_dup (parentless, exact);
glade_widget_set_project (parentless, dest_widget->priv->project);
glade_property_set (prop, parentless->priv->object);
}
}
else
prop = glade_property_dup (prop, NULL);
properties = g_list_prepend (properties, prop);
}
return g_list_reverse (properties);
} | false | false | false | false | false | 0 |
print_version( int die )
{
const char **p = fd_version;
for ( ; *p; p++ )
fprintf( stderr, "%s\n", rm_rcs_kw( *p ) );
if ( die )
exit( 0 );
} | false | false | false | false | false | 0 |
elm_6node_triangle_shape_functions()
{
double u,v;
int i,j;
for( i=0; i<6; i++ )
{
u = NodeU[i];
v = NodeV[i];
A[i][0] = 1;
A[i][1] = u;
A[i][2] = v;
A[i][3] = u*v;
A[i][4] = u*u;
A[i][5] = v*v;
}
lu_mtrinv( (double *)A,6 );
for( i=0; i<6; i++ )
for( j=0; j<6; j++ ) N[i][j] = A[j][i];
} | false | false | false | false | false | 0 |
bmg160_read_event(struct iio_dev *indio_dev,
const struct iio_chan_spec *chan,
enum iio_event_type type,
enum iio_event_direction dir,
enum iio_event_info info,
int *val, int *val2)
{
struct bmg160_data *data = iio_priv(indio_dev);
*val2 = 0;
switch (info) {
case IIO_EV_INFO_VALUE:
*val = data->slope_thres & BMG160_SLOPE_THRES_MASK;
break;
default:
return -EINVAL;
}
return IIO_VAL_INT;
} | false | false | false | false | false | 0 |
qtrle_encode_frame(AVCodecContext *avctx, uint8_t *buf, int buf_size, void *data)
{
QtrleEncContext * const s = avctx->priv_data;
AVFrame *pict = data;
AVFrame * const p = &s->frame;
int chunksize;
*p = *pict;
if (buf_size < s->max_buf_size) {
/* Upper bound check for compressed data */
av_log(avctx, AV_LOG_ERROR, "buf_size %d < %d\n", buf_size, s->max_buf_size);
return -1;
}
if (avctx->gop_size == 0 || (s->avctx->frame_number % avctx->gop_size) == 0) {
/* I-Frame */
p->pict_type = FF_I_TYPE;
p->key_frame = 1;
} else {
/* P-Frame */
p->pict_type = FF_P_TYPE;
p->key_frame = 0;
}
chunksize = encode_frame(s, pict, buf);
/* save the current frame */
av_picture_copy(&s->previous_frame, (AVPicture *)p, avctx->pix_fmt, avctx->width, avctx->height);
return chunksize;
} | false | false | false | false | false | 0 |
brasero_file_chooser_set_context (BraseroLayoutObject *object,
BraseroLayoutType type)
{
BraseroFileChooser *self;
self = BRASERO_FILE_CHOOSER (object);
if (type == self->priv->type)
return;
if (type == BRASERO_LAYOUT_AUDIO)
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (self->priv->chooser),
self->priv->filter_audio);
else if (type == BRASERO_LAYOUT_VIDEO)
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (self->priv->chooser),
self->priv->filter_video);
else
gtk_file_chooser_set_filter (GTK_FILE_CHOOSER (self->priv->chooser),
self->priv->filter_any);
self->priv->type = type;
} | false | false | false | false | false | 0 |
RequestUpdateExtent (
vtkInformation * vtkNotUsed(request),
vtkInformationVector **inputVector,
vtkInformationVector *outputVector)
{
// get the info objects
vtkInformation* outInfo = outputVector->GetInformationObject(0);
vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
int idx;
int wholeExtent[6], inUExt[6];
inInfo->Get(vtkStreamingDemandDrivenPipeline::WHOLE_EXTENT(), wholeExtent);
outInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), inUExt);
// update and Clip
for (idx = 0; idx < 3; ++idx)
{
--inUExt[idx*2];
++inUExt[idx*2+1];
if (inUExt[idx*2] < wholeExtent[idx*2])
{
inUExt[idx*2] = wholeExtent[idx*2];
}
if (inUExt[idx*2] > wholeExtent[idx*2 + 1])
{
inUExt[idx*2] = wholeExtent[idx*2 + 1];
}
if (inUExt[idx*2+1] < wholeExtent[idx*2])
{
inUExt[idx*2+1] = wholeExtent[idx*2];
}
if (inUExt[idx*2 + 1] > wholeExtent[idx*2 + 1])
{
inUExt[idx*2 + 1] = wholeExtent[idx*2 + 1];
}
}
inInfo->Set(vtkStreamingDemandDrivenPipeline::UPDATE_EXTENT(), inUExt, 6);
return 1;
} | false | false | false | false | false | 0 |
strtrim(char *str, char *trim_chars, int limit)
{
int n;
char *p;
p = str + strlen(str) - 1;
n = 0;
#ifdef NOTDEF
while ((!limit || n < limit) && p >= str
&& strchr(trim_chars, (int) *p) != NULL)
p--, n++;
#else
while ((!limit || n < limit) && p >= str
&& strtr_char((int) *p, trim_chars, 0))
p--, n++;
#endif
*(p + 1) = '\0';
return(str);
} | false | false | false | false | false | 0 |
_rtl92d_phy_patha_fill_iqk_matrix(struct ieee80211_hw *hw,
bool iqk_ok, long result[][8],
u8 final_candidate, bool txonly)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
struct rtl_hal *rtlhal = &(rtlpriv->rtlhal);
u32 oldval_0, val_x, tx0_a, reg;
long val_y, tx0_c;
bool is2t = IS_92D_SINGLEPHY(rtlhal->version) ||
rtlhal->macphymode == DUALMAC_DUALPHY;
RTPRINT(rtlpriv, FINIT, INIT_IQK,
"Path A IQ Calibration %s !\n", iqk_ok ? "Success" : "Failed");
if (final_candidate == 0xFF) {
return;
} else if (iqk_ok) {
oldval_0 = (rtl_get_bbreg(hw, ROFDM0_XATxIQIMBALANCE,
MASKDWORD) >> 22) & 0x3FF; /* OFDM0_D */
val_x = result[final_candidate][0];
if ((val_x & 0x00000200) != 0)
val_x = val_x | 0xFFFFFC00;
tx0_a = (val_x * oldval_0) >> 8;
RTPRINT(rtlpriv, FINIT, INIT_IQK,
"X = 0x%x, tx0_a = 0x%x, oldval_0 0x%x\n",
val_x, tx0_a, oldval_0);
rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, 0x3FF, tx0_a);
rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(24),
((val_x * oldval_0 >> 7) & 0x1));
val_y = result[final_candidate][1];
if ((val_y & 0x00000200) != 0)
val_y = val_y | 0xFFFFFC00;
/* path B IQK result + 3 */
if (rtlhal->interfaceindex == 1 &&
rtlhal->current_bandtype == BAND_ON_5G)
val_y += 3;
tx0_c = (val_y * oldval_0) >> 8;
RTPRINT(rtlpriv, FINIT, INIT_IQK,
"Y = 0x%lx, tx0_c = 0x%lx\n",
val_y, tx0_c);
rtl_set_bbreg(hw, ROFDM0_XCTxAFE, 0xF0000000,
((tx0_c & 0x3C0) >> 6));
rtl_set_bbreg(hw, ROFDM0_XATxIQIMBALANCE, 0x003F0000,
(tx0_c & 0x3F));
if (is2t)
rtl_set_bbreg(hw, ROFDM0_ECCATHRESHOLD, BIT(26),
((val_y * oldval_0 >> 7) & 0x1));
RTPRINT(rtlpriv, FINIT, INIT_IQK, "0xC80 = 0x%x\n",
rtl_get_bbreg(hw, ROFDM0_XATxIQIMBALANCE,
MASKDWORD));
if (txonly) {
RTPRINT(rtlpriv, FINIT, INIT_IQK, "only Tx OK\n");
return;
}
reg = result[final_candidate][2];
rtl_set_bbreg(hw, ROFDM0_XARXIQIMBALANCE, 0x3FF, reg);
reg = result[final_candidate][3] & 0x3F;
rtl_set_bbreg(hw, ROFDM0_XARXIQIMBALANCE, 0xFC00, reg);
reg = (result[final_candidate][3] >> 6) & 0xF;
rtl_set_bbreg(hw, 0xca0, 0xF0000000, reg);
}
} | false | false | false | false | false | 0 |
via_driver_load(struct drm_device *dev, unsigned long chipset)
{
drm_via_private_t *dev_priv;
int ret = 0;
dev_priv = kzalloc(sizeof(drm_via_private_t), GFP_KERNEL);
if (dev_priv == NULL)
return -ENOMEM;
idr_init(&dev_priv->object_idr);
dev->dev_private = (void *)dev_priv;
dev_priv->chipset = chipset;
pci_set_master(dev->pdev);
ret = drm_vblank_init(dev, 1);
if (ret) {
kfree(dev_priv);
return ret;
}
return 0;
} | false | false | false | false | false | 0 |
restoreDialogSize()
{
Plasma::Dialog *dialog = dialogPtr.data();
if (!dialog) {
return;
}
Corona *corona = qobject_cast<Corona *>(q->scene());
if (!corona) {
return;
}
KConfigGroup sizeGroup = popupConfigGroup();
int preferredWidth = 0;
int preferredHeight = 0;
QGraphicsWidget *gWidget = dialog->graphicsWidget();
if (gWidget) {
preferredWidth = gWidget->preferredSize().width();
preferredHeight = gWidget->preferredSize().height();
}
const int width = qMin(sizeGroup.readEntry("DialogWidth", preferredWidth),
corona->screenGeometry(-1).width() - 50);
const int height = qMin(sizeGroup.readEntry("DialogHeight", preferredHeight),
corona->screenGeometry(-1).height() - 50);
QSize saved(width, height);
if (saved.isNull()) {
saved = dialog->sizeHint();
} else {
saved = saved.expandedTo(dialog->minimumSizeHint());
}
if (saved.width() != dialog->width() || saved.height() != dialog->height()) {
dialog->resize(saved);
/*if (gWidget) {
gWidget->resize(saved);
}*/
}
} | false | false | false | false | false | 0 |
activate_lvs(struct cmd_context *cmd, struct dm_list *lvs, unsigned exclusive)
{
struct dm_list *lvh;
struct lv_list *lvl;
dm_list_iterate_items(lvl, lvs) {
if (!exclusive && !lv_is_active_exclusive(lvl->lv)) {
if (!activate_lv(cmd, lvl->lv)) {
log_error("Failed to activate %s", lvl->lv->name);
return 0;
}
} else if (!activate_lv_excl(cmd, lvl->lv)) {
log_error("Failed to activate %s", lvl->lv->name);
dm_list_uniterate(lvh, lvs, &lvl->list) {
lvl = dm_list_item(lvh, struct lv_list);
if (!activate_lv(cmd, lvl->lv))
stack;
}
return 0;
}
}
return 1;
} | false | false | false | false | false | 0 |
codetestset (CompileState *compst, Charset *cs, int e) {
if (e) return NOINST; /* no test */
else {
int c = 0;
Opcode op = charsettype(cs->cs, &c);
switch (op) {
case IFail: return addoffsetinst(compst, IJmp); /* always jump */
case IAny: return addoffsetinst(compst, ITestAny);
case IChar: {
int i = addoffsetinst(compst, ITestChar);
getinstr(compst, i).i.aux = c;
return i;
}
case ISet: {
int i = addoffsetinst(compst, ITestSet);
addcharset(compst, cs->cs);
return i;
}
default: assert(0); return 0;
}
}
} | false | false | false | false | false | 0 |
spoil_artifact(const char *fname)
{
int i, j;
object_type *i_ptr;
object_type object_type_body;
char buf[1024];
/* Build the filename */
path_build(buf, sizeof(buf), ANGBAND_DIR_USER, fname);
fh = file_open(buf, MODE_WRITE, FTYPE_TEXT);
/* Oops */
if (!fh)
{
msg("Cannot create spoiler file.");
return;
}
/* Dump to the spoiler file */
text_out_hook = text_out_to_file;
text_out_file = fh;
/* Dump the header */
spoiler_underline(format("Artifact Spoilers for %s", buildid), '=');
text_out("\n Randart seed is %u\n", seed_randart);
/* List the artifacts by tval */
for (i = 0; group_artifact[i].tval; i++)
{
/* Write out the group title */
if (group_artifact[i].name)
{
spoiler_blanklines(2);
spoiler_underline(group_artifact[i].name, '=');
spoiler_blanklines(1);
}
/* Now search through all of the artifacts */
for (j = 1; j < z_info->a_max; ++j)
{
artifact_type *a_ptr = &a_info[j];
char buf[80];
/* We only want objects in the current group */
if (a_ptr->tval != group_artifact[i].tval) continue;
/* Get local object */
i_ptr = &object_type_body;
/* Wipe the object */
object_wipe(i_ptr);
/* Attempt to "forge" the artifact */
if (!make_fake_artifact(i_ptr, a_ptr)) continue;
/* Grab artifact name */
object_desc(buf, sizeof(buf), i_ptr, ODESC_PREFIX |
ODESC_COMBAT | ODESC_EXTRA | ODESC_SPOIL);
/* Print name and underline */
spoiler_underline(buf, '-');
/* Write out the artifact description to the spoiler file */
object_info_spoil(fh, i_ptr, 80);
/*
* Determine the minimum and maximum depths an
* artifact can appear, its rarity, its weight, and
* its power rating.
*/
text_out("\nMin Level %u, Max Level %u, Generation chance %u, Power %d, %d.%d lbs\n",
a_ptr->alloc_min, a_ptr->alloc_max,
a_ptr->alloc_prob, object_power(i_ptr, FALSE,
NULL, TRUE), (a_ptr->weight / 10),
(a_ptr->weight % 10));
if (OPT(birth_randarts)) text_out("%s.\n", a_ptr->text);
/* Terminate the entry */
spoiler_blanklines(2);
}
}
/* Check for errors */
if (!file_close(fh))
{
msg("Cannot close spoiler file.");
return;
}
/* Message */
msg("Successfully created a spoiler file.");
} | false | false | false | false | false | 0 |
setup_waterlevel()
{
register int x, y;
register int xskip, yskip;
register int water_glyph = cmap_to_glyph(S_water);
/* ouch, hardcoded... */
xmin = 3;
ymin = 1;
xmax = 78;
ymax = 20;
/* set hero's memory to water */
for (x = xmin; x <= xmax; x++)
for (y = ymin; y <= ymax; y++)
levl[x][y].glyph = water_glyph;
/* make bubbles */
xskip = 10 + rn2(10);
yskip = 4 + rn2(4);
for (x = bxmin; x <= bxmax; x += xskip)
for (y = bymin; y <= bymax; y += yskip)
mk_bubble(x,y,rn2(7));
} | false | false | false | false | false | 0 |
compute_nucleotides_values(GT_UNUSED void *key, void *value,
void *data, GT_UNUSED GtError *err)
{
GtStreamEvaluator *se = (GtStreamEvaluator*) data;
Slot *slot = (Slot*) value;
GtBittab *tmp;
gt_error_check(err);
gt_assert(key && value && data);
/* add ``out of range'' FPs */
se->mRNA_nucleotides.FP += slot->FP_mRNA_nucleotides_forward;
se->mRNA_nucleotides.FP += slot->FP_mRNA_nucleotides_reverse;
se->CDS_nucleotides.FP += slot->FP_CDS_nucleotides_forward;
se->CDS_nucleotides.FP += slot->FP_CDS_nucleotides_reverse;
/* add other values */
tmp = gt_bittab_new(gt_range_length(&slot->real_range));
add_nucleotide_values(&se->mRNA_nucleotides,
slot->real_mRNA_nucleotides_forward,
slot->pred_mRNA_nucleotides_forward, tmp,
"mRNA forward");
add_nucleotide_values(&se->mRNA_nucleotides,
slot->real_mRNA_nucleotides_reverse,
slot->pred_mRNA_nucleotides_reverse, tmp,
"mRNA reverse");
add_nucleotide_values(&se->CDS_nucleotides,
slot->real_CDS_nucleotides_forward,
slot->pred_CDS_nucleotides_forward, tmp,
"CDS forward");
add_nucleotide_values(&se->CDS_nucleotides,
slot->real_CDS_nucleotides_reverse,
slot->pred_CDS_nucleotides_reverse, tmp,
"CDS reverse");
gt_bittab_delete(tmp);
return 0;
} | false | false | false | false | false | 0 |
skeleton_open ( struct net_device *netdev ) {
struct skeleton_nic *skel = netdev->priv;
DBGC ( skel, "SKELETON %p does not yet support open\n", skel );
return -ENOTSUP;
} | false | false | false | false | false | 0 |
regrename_init (bool insn_info)
{
gcc_obstack_init (&rename_obstack);
insn_rr.create (0);
if (insn_info)
insn_rr.safe_grow_cleared (get_max_uid ());
} | false | false | false | false | false | 0 |
ab_account_longname(const AB_ACCOUNT *ab_acc)
{
gchar *bankname;
gchar *result;
const char *ab_bankname, *bankcode;
g_return_val_if_fail(ab_acc, NULL);
ab_bankname = AB_Account_GetBankName(ab_acc);
bankname = ab_bankname ? gnc_utf8_strip_invalid_strdup(ab_bankname) : NULL;
bankcode = AB_Account_GetBankCode(ab_acc);
/* Translators: Strings are 1. Account code, 2. Bank name, 3. Bank code. */
if (bankname && *bankname)
result = g_strdup_printf(_("%s at %s (code %s)"),
AB_Account_GetAccountNumber(ab_acc),
bankname,
bankcode);
else
result = g_strdup_printf(_("%s at bank code %s"),
AB_Account_GetAccountNumber(ab_acc),
bankcode);
g_free(bankname);
return result;
} | false | false | false | false | false | 0 |
LogCheckpointStart(int flags, bool restartpoint)
{
elog(LOG, "%s starting:%s%s%s%s%s%s%s%s",
restartpoint ? "restartpoint" : "checkpoint",
(flags & CHECKPOINT_IS_SHUTDOWN) ? " shutdown" : "",
(flags & CHECKPOINT_END_OF_RECOVERY) ? " end-of-recovery" : "",
(flags & CHECKPOINT_IMMEDIATE) ? " immediate" : "",
(flags & CHECKPOINT_FORCE) ? " force" : "",
(flags & CHECKPOINT_WAIT) ? " wait" : "",
(flags & CHECKPOINT_CAUSE_XLOG) ? " xlog" : "",
(flags & CHECKPOINT_CAUSE_TIME) ? " time" : "",
(flags & CHECKPOINT_FLUSH_ALL) ? " flush-all" : "");
} | false | false | false | false | false | 0 |
genie_file_mode (NODE_T * p)
{
A68_REF name;
char *buffer;
RESET_ERRNO;
POP_REF (p, &name);
CHECK_INIT (p, INITIALISED (&name), MODE (STRING));
buffer = (char *) malloc ((size_t) (1 + a68_string_size (p, name)));
if (buffer == NO_TEXT) {
diagnostic_node (A68_RUNTIME_ERROR, p, ERROR_OUT_OF_CORE);
exit_genie (p, A68_RUNTIME_ERROR);
} else {
struct stat status;
if (stat (a_to_c_string (p, buffer, name), &status) == 0) {
PUSH_PRIMITIVE (p, (unsigned) (ST_MODE (&status)), A68_BITS);
} else {
PUSH_PRIMITIVE (p, 0x0, A68_BITS);
}
free (buffer);
}
} | false | false | false | false | false | 0 |
no_bus_new_connection_callback (DBusServer *server,
DBusConnection *new_connection,
void *user_data)
{
ServerData *sd = user_data;
dbus_connection_ref (new_connection);
dbus_connection_setup_with_g_main (new_connection, NULL);
if (!dbus_connection_add_filter (new_connection,
no_bus_server_filter, sd, NULL))
g_error ("no memory");
sd->n_clients += 1;
/* FIXME we leak the handler */
} | false | false | false | false | false | 0 |
_dxfCopySearchGrid(Grid src)
{
int i;
Grid dst;
dst = (Grid)DXAllocate(sizeof(struct grid));
if (! dst)
return NULL;
memcpy((char *)dst, (char *)src, sizeof(struct grid));
for (i = 0; i < MAXGRID; i++)
if (dst->gridlevels[i].bucketArray)
DXReference((Object)dst->gridlevels[i].bucketArray);
DXReference((Object)dst->itemArray);
return dst;
} | false | true | false | false | false | 1 |
build_x_arrow (location_t loc, tree expr, tsubst_flags_t complain)
{
tree orig_expr = expr;
tree type = TREE_TYPE (expr);
tree last_rval = NULL_TREE;
vec<tree, va_gc> *types_memoized = NULL;
if (type == error_mark_node)
return error_mark_node;
if (processing_template_decl)
{
if (type_dependent_expression_p (expr))
return build_min_nt_loc (loc, ARROW_EXPR, expr);
expr = build_non_dependent_expr (expr);
}
if (MAYBE_CLASS_TYPE_P (type))
{
struct tinst_level *actual_inst = current_instantiation ();
tree fn = NULL;
while ((expr = build_new_op (loc, COMPONENT_REF,
LOOKUP_NORMAL, expr, NULL_TREE, NULL_TREE,
&fn, complain)))
{
if (expr == error_mark_node)
return error_mark_node;
if (fn && DECL_USE_TEMPLATE (fn))
push_tinst_level (fn);
fn = NULL;
if (vec_member (TREE_TYPE (expr), types_memoized))
{
if (complain & tf_error)
error ("circular pointer delegation detected");
return error_mark_node;
}
vec_safe_push (types_memoized, TREE_TYPE (expr));
last_rval = expr;
}
while (current_instantiation () != actual_inst)
pop_tinst_level ();
if (last_rval == NULL_TREE)
{
if (complain & tf_error)
error ("base operand of %<->%> has non-pointer type %qT", type);
return error_mark_node;
}
if (TREE_CODE (TREE_TYPE (last_rval)) == REFERENCE_TYPE)
last_rval = convert_from_reference (last_rval);
}
else
last_rval = decay_conversion (expr, complain);
if (TREE_CODE (TREE_TYPE (last_rval)) == POINTER_TYPE)
{
if (processing_template_decl)
{
expr = build_min (ARROW_EXPR, TREE_TYPE (TREE_TYPE (last_rval)),
orig_expr);
TREE_SIDE_EFFECTS (expr) = TREE_SIDE_EFFECTS (last_rval);
return expr;
}
return cp_build_indirect_ref (last_rval, RO_NULL, complain);
}
if (complain & tf_error)
{
if (types_memoized)
error ("result of %<operator->()%> yields non-pointer result");
else
error ("base operand of %<->%> is not a pointer");
}
return error_mark_node;
} | false | false | false | false | false | 0 |
translate_tiling(bool old_tiled_w, bool new_tiled_w)
{
if (old_tiled_w == new_tiled_w)
return;
/* In the code that follows, we can safely assume that S = 0, because W
* tiling formats always use IMS layout.
*/
assert(s_is_zero);
if (new_tiled_w) {
/* Given X and Y coordinates that describe an address using Y tiling,
* translate to the X and Y coordinates that describe the same address
* using W tiling.
*
* If we break down the low order bits of X and Y, using a
* single letter to represent each low-order bit:
*
* X = A << 7 | 0bBCDEFGH
* Y = J << 5 | 0bKLMNP (1)
*
* Then we can apply the Y tiling formula to see the memory offset being
* addressed:
*
* offset = (J * tile_pitch + A) << 12 | 0bBCDKLMNPEFGH (2)
*
* If we apply the W detiling formula to this memory location, that the
* corresponding X' and Y' coordinates are:
*
* X' = A << 6 | 0bBCDPFH (3)
* Y' = J << 6 | 0bKLMNEG
*
* Combining (1) and (3), we see that to transform (X, Y) to (X', Y'),
* we need to make the following computation:
*
* X' = (X & ~0b1011) >> 1 | (Y & 0b1) << 2 | X & 0b1 (4)
* Y' = (Y & ~0b1) << 1 | (X & 0b1000) >> 2 | (X & 0b10) >> 1
*/
emit_and(t1, X, brw_imm_uw(0xfff4)); /* X & ~0b1011 */
emit_shr(t1, t1, brw_imm_uw(1)); /* (X & ~0b1011) >> 1 */
emit_and(t2, Y, brw_imm_uw(1)); /* Y & 0b1 */
emit_shl(t2, t2, brw_imm_uw(2)); /* (Y & 0b1) << 2 */
emit_or(t1, t1, t2); /* (X & ~0b1011) >> 1 | (Y & 0b1) << 2 */
emit_and(t2, X, brw_imm_uw(1)); /* X & 0b1 */
emit_or(Xp, t1, t2);
emit_and(t1, Y, brw_imm_uw(0xfffe)); /* Y & ~0b1 */
emit_shl(t1, t1, brw_imm_uw(1)); /* (Y & ~0b1) << 1 */
emit_and(t2, X, brw_imm_uw(8)); /* X & 0b1000 */
emit_shr(t2, t2, brw_imm_uw(2)); /* (X & 0b1000) >> 2 */
emit_or(t1, t1, t2); /* (Y & ~0b1) << 1 | (X & 0b1000) >> 2 */
emit_and(t2, X, brw_imm_uw(2)); /* X & 0b10 */
emit_shr(t2, t2, brw_imm_uw(1)); /* (X & 0b10) >> 1 */
emit_or(Yp, t1, t2);
SWAP_XY_AND_XPYP();
} else {
/* Applying the same logic as above, but in reverse, we obtain the
* formulas:
*
* X' = (X & ~0b101) << 1 | (Y & 0b10) << 2 | (Y & 0b1) << 1 | X & 0b1
* Y' = (Y & ~0b11) >> 1 | (X & 0b100) >> 2
*/
emit_and(t1, X, brw_imm_uw(0xfffa)); /* X & ~0b101 */
emit_shl(t1, t1, brw_imm_uw(1)); /* (X & ~0b101) << 1 */
emit_and(t2, Y, brw_imm_uw(2)); /* Y & 0b10 */
emit_shl(t2, t2, brw_imm_uw(2)); /* (Y & 0b10) << 2 */
emit_or(t1, t1, t2); /* (X & ~0b101) << 1 | (Y & 0b10) << 2 */
emit_and(t2, Y, brw_imm_uw(1)); /* Y & 0b1 */
emit_shl(t2, t2, brw_imm_uw(1)); /* (Y & 0b1) << 1 */
emit_or(t1, t1, t2); /* (X & ~0b101) << 1 | (Y & 0b10) << 2
| (Y & 0b1) << 1 */
emit_and(t2, X, brw_imm_uw(1)); /* X & 0b1 */
emit_or(Xp, t1, t2);
emit_and(t1, Y, brw_imm_uw(0xfffc)); /* Y & ~0b11 */
emit_shr(t1, t1, brw_imm_uw(1)); /* (Y & ~0b11) >> 1 */
emit_and(t2, X, brw_imm_uw(4)); /* X & 0b100 */
emit_shr(t2, t2, brw_imm_uw(2)); /* (X & 0b100) >> 2 */
emit_or(Yp, t1, t2);
SWAP_XY_AND_XPYP();
}
} | false | false | false | false | false | 0 |
initio_sync_done(struct initio_host * host)
{
int i;
host->active_tc->flags |= TCF_SYNC_DONE;
if (host->msg[3]) {
host->active_tc->js_period |= host->msg[3];
for (i = 0; i < 8; i++) {
if (initio_rate_tbl[i] >= host->msg[2]) /* pick the big one */
break;
}
host->active_tc->js_period |= (i << 4);
host->active_tc->sconfig0 |= TSC_ALT_PERIOD;
}
outb(host->active_tc->sconfig0, host->addr + TUL_SConfig);
outb(host->active_tc->js_period, host->addr + TUL_SPeriod);
return -1;
} | false | false | false | false | false | 0 |
Java_ncsa_hdf_hdf5lib_H5_H5Pmodify_1filter
(JNIEnv *env, jclass clss, jint plist, jint filter, jint flags,
jlong cd_nelmts, jintArray cd_values)
{
herr_t status;
jint *cd_valuesP;
jboolean isCopy;
if (cd_values == NULL) {
h5nullArgument(env, "H5Pmodify_filter: cd_values is NULL");
return -1;
}
cd_valuesP = ENVPTR->GetIntArrayElements(ENVPAR cd_values,&isCopy);
if (cd_valuesP == NULL) {
h5JNIFatalError(env, "H5Pmodify_filter: cd_values not pinned");
return -1;
}
status = H5Pmodify_filter((hid_t)plist, (H5Z_filter_t)filter,(const unsigned int)flags,
(size_t)cd_nelmts, (unsigned int *)cd_valuesP);
ENVPTR->ReleaseIntArrayElements(ENVPAR cd_values, cd_valuesP, 0);
if (status < 0) {
h5libraryError(env);
}
return (jint)status;
} | false | false | false | false | false | 0 |
vx_query_hbuffer_size(struct vx_core *chip, struct vx_pipe *pipe)
{
int result;
struct vx_rmh rmh;
vx_init_rmh(&rmh, CMD_SIZE_HBUFFER);
vx_set_pipe_cmd_params(&rmh, pipe->is_capture, pipe->number, 0);
if (pipe->is_capture)
rmh.Cmd[0] |= 0x00000001;
result = vx_send_msg(chip, &rmh);
if (! result)
result = rmh.Stat[0] & 0xffff;
return result;
} | false | false | false | false | false | 0 |
SubnMgtAssignLids (IBPort *p_smNodePort, unsigned int lmc = 0)
{
list<IBPort *> thisStepPorts;
list<IBPort *> nextStepNodePorts;
set<IBNode *, less<IBNode *> > visited;
unsigned int i;
IBFabric *p_fabric = p_smNodePort->p_node->p_fabric;
IBPort *p_port;
IBNode *p_node;
IBPort *p_remPort;
IBNode *p_remNode;
unsigned int numLidsPerPort = (1 << lmc);
thisStepPorts.push_back(p_smNodePort);
unsigned int lid = 1, l;
int step = 0;
// BFS Style ...
while (thisStepPorts.size() > 0) {
nextStepNodePorts.clear();
step++;
// go over all this step ports
while (! thisStepPorts.empty()) {
p_port = thisStepPorts.front();
thisStepPorts.pop_front();
// get the node
p_node = p_port->p_node;
// just making sure since we can get on the BFS from several sides ...
if (visited.find(p_node) != visited.end())
continue;
// mark as visited
visited.insert(p_node);
// based on the node type we do the recursion and assignment
switch (p_node->type) {
case IB_CA_NODE:
// simple as we stop here
p_port->base_lid = lid;
for (l = lid ; l <= lid + numLidsPerPort; l ++)
p_fabric->setLidPort(l, p_port);
//We do not assign all the lids - just the base lid
//for (l = lid ; l <= lid + numLidsPerPort; l ++)
// p_fabric->setLidPort(l, p_port);
break;
case IB_SW_NODE:
// go over all ports of the node:
for (i = 0; i < p_node->numPorts; i++)
if (p_node->Ports[i]) {
p_node->Ports[i]->base_lid = lid;
for (l = lid ; l <= lid + numLidsPerPort; l ++)
p_fabric->setLidPort(l, p_node->Ports[i]);
}
break;
default:
cout << "-E- Un recognized node type: " << p_node->type
<< " name:" << endl;
}
// do not forget to increment the lids
lid = lid + numLidsPerPort;
// now recurse
for (i = 0; i < p_node->numPorts; i++) {
if (p_node->Ports[i] == NULL) continue;
// if we have a remote port that is not visited
p_remPort = p_node->Ports[i]->p_remotePort;
if (p_remPort != NULL) {
p_remNode = p_remPort->p_node;
// if the node was not visited and not included in
// next steps already
if ( (visited.find(p_remNode) == visited.end()) &&
(find(nextStepNodePorts.begin(),
nextStepNodePorts.end(),p_remPort)
== nextStepNodePorts.end()) )
nextStepNodePorts.push_back(p_remPort);
}
}
}
thisStepPorts = nextStepNodePorts;
}
lid = lid - numLidsPerPort;
p_fabric->maxLid = lid;
p_fabric->minLid = 1;
p_fabric->lmc = lmc;
cout << "-I- Assigned " << lid << " LIDs (lmc=" << lmc
<< ") in " << step << " steps" << endl;
return 0;
} | false | false | false | false | false | 0 |
add_chains(const std::vector<string>& new_chains)
{
// --------
DBC_REQUIRE(is_selected() == true);
DBC_REQUIRE(connected_chainsetup() != selected_chainsetup());
// --------
selected_chainsetup_repp->add_new_chains(new_chains);
selected_chainsetup_repp->select_chains(new_chains);
ECA_LOG_MSG(ECA_LOGGER::info, "Added chains: " + kvu_vector_to_string(new_chains, ", ") + ".");
// --------
DBC_ENSURE(selected_chains().size() == new_chains.size());
// --------
} | false | false | false | false | false | 0 |
virtio_pci_remove(struct pci_dev *pci_dev)
{
struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev);
struct device *dev = get_device(&vp_dev->vdev.dev);
unregister_virtio_device(&vp_dev->vdev);
if (vp_dev->ioaddr)
virtio_pci_legacy_remove(vp_dev);
else
virtio_pci_modern_remove(vp_dev);
pci_disable_device(pci_dev);
put_device(dev);
} | false | false | false | false | false | 0 |
PushRootPath(const fstring& path)
{
fstring absolutePath = GetCurrentUri().MakeAbsolute(path);
if (absolutePath.length() > 0 && absolutePath.back() != '\\' && absolutePath.back() != '/') absolutePath.append((fchar) '/');
pathStack.push_back(FUUri(absolutePath));
} | false | false | false | false | false | 0 |
ApiNamedPropertyAccess(const char* tag,
JSObject* holder,
Object* name) {
ASSERT(name->IsString());
if (!log_->IsEnabled() || !FLAG_log_api) return;
String* class_name_obj = holder->class_name();
SmartArrayPointer<char> class_name =
class_name_obj->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
SmartArrayPointer<char> property_name =
String::cast(name)->ToCString(DISALLOW_NULLS, ROBUST_STRING_TRAVERSAL);
ApiEvent("api,%s,\"%s\",\"%s\"\n", tag, *class_name, *property_name);
} | false | false | false | false | false | 0 |
pool_valid (void* item)
{
Pool *pool;
char *ptr, *beg, *end;
ptr = item;
/* Find which block this one belongs to */
for (pool = EGG_SECURE_GLOBALS.pool_data; pool; pool = pool->next) {
beg = (char*)pool->items;
end = (char*)pool + pool->length - sizeof (Item);
if (ptr >= beg && ptr <= end)
return (pool->used && (ptr - beg) % sizeof (Item) == 0);
}
return 0;
} | false | false | false | false | false | 0 |
do_checkpoint(MFILE& mf, int nchars) {
int retval;
string resolved_name;
FILE* f = fopen("temp", "w");
if (!f) return 1;
fprintf(f, "%d", nchars);
fclose(f);
retval = mf.flush();
if (retval) return retval;
boinc_resolve_filename_s(CHECKPOINT_FILE, resolved_name);
retval = boinc_rename("temp", resolved_name.c_str());
if (retval) return retval;
return 0;
} | false | false | false | false | false | 0 |
eni_send(struct atm_vcc *vcc,struct sk_buff *skb)
{
enum enq_res res;
DPRINTK(">eni_send\n");
if (!ENI_VCC(vcc)->tx) {
if (vcc->pop) vcc->pop(vcc,skb);
else dev_kfree_skb(skb);
return -EINVAL;
}
if (!skb) {
printk(KERN_CRIT "!skb in eni_send ?\n");
if (vcc->pop) vcc->pop(vcc,skb);
return -EINVAL;
}
if (vcc->qos.aal == ATM_AAL0) {
if (skb->len != ATM_CELL_SIZE-1) {
if (vcc->pop) vcc->pop(vcc,skb);
else dev_kfree_skb(skb);
return -EINVAL;
}
*(u32 *) skb->data = htonl(*(u32 *) skb->data);
}
submitted++;
ATM_SKB(skb)->vcc = vcc;
tasklet_disable(&ENI_DEV(vcc->dev)->task);
res = do_tx(skb);
tasklet_enable(&ENI_DEV(vcc->dev)->task);
if (res == enq_ok) return 0;
skb_queue_tail(&ENI_VCC(vcc)->tx->backlog,skb);
backlogged++;
tasklet_schedule(&ENI_DEV(vcc->dev)->task);
return 0;
} | false | false | false | false | false | 0 |
stoi (unsigned char* s, int len)
{
unsigned long val = 0;
unsigned long Cnt = 0;
if (len > 4)
return 0;
while (Cnt < len)
val = (val << 8) + s[Cnt++];
return val;
} | true | true | false | false | false | 1 |
load_debug_section (enum dwarf_section_display_enum debug, void *file)
{
struct dwarf_section *section = &debug_displays [debug].section;
bfd *abfd = (bfd *) file;
asection *sec;
/* If it is already loaded, do nothing. */
if (section->start != NULL)
return 1;
/* Locate the debug section. */
sec = bfd_get_section_by_name (abfd, section->uncompressed_name);
if (sec != NULL)
section->name = section->uncompressed_name;
else
{
sec = bfd_get_section_by_name (abfd, section->compressed_name);
if (sec != NULL)
section->name = section->compressed_name;
}
if (sec == NULL)
return 0;
return load_specific_debug_section (debug, sec, file);
} | false | false | false | false | false | 0 |
RecoverPreparedTransactions(void)
{
char dir[MAXPGPATH];
DIR *cldir;
struct dirent *clde;
snprintf(dir, MAXPGPATH, "%s", TWOPHASE_DIR);
cldir = AllocateDir(dir);
while ((clde = ReadDir(cldir, dir)) != NULL)
{
if (strlen(clde->d_name) == 8 &&
strspn(clde->d_name, "0123456789ABCDEF") == 8)
{
TransactionId xid;
char *buf;
char *bufptr;
TwoPhaseFileHeader *hdr;
TransactionId *subxids;
GlobalTransaction gxact;
int i;
xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
/* Already processed? */
if (TransactionIdDidCommit(xid) || TransactionIdDidAbort(xid))
{
ereport(WARNING,
(errmsg("removing stale two-phase state file \"%s\"",
clde->d_name)));
RemoveTwoPhaseFile(xid, true);
continue;
}
/* Read and validate file */
buf = ReadTwoPhaseFile(xid);
if (buf == NULL)
{
ereport(WARNING,
(errmsg("removing corrupt two-phase state file \"%s\"",
clde->d_name)));
RemoveTwoPhaseFile(xid, true);
continue;
}
ereport(LOG,
(errmsg("recovering prepared transaction %u", xid)));
/* Deconstruct header */
hdr = (TwoPhaseFileHeader *) buf;
Assert(TransactionIdEquals(hdr->xid, xid));
bufptr = buf + MAXALIGN(sizeof(TwoPhaseFileHeader));
subxids = (TransactionId *) bufptr;
bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
bufptr += MAXALIGN(hdr->ncommitrels * sizeof(RelFileNode));
bufptr += MAXALIGN(hdr->nabortrels * sizeof(RelFileNode));
/*
* Reconstruct subtrans state for the transaction --- needed
* because pg_subtrans is not preserved over a restart. Note that
* we are linking all the subtransactions directly to the
* top-level XID; there may originally have been a more complex
* hierarchy, but there's no need to restore that exactly.
*/
for (i = 0; i < hdr->nsubxacts; i++)
SubTransSetParent(subxids[i], xid);
/*
* Recreate its GXACT and dummy PGPROC
*
* Note: since we don't have the PREPARE record's WAL location at
* hand, we leave prepare_lsn zeroes. This means the GXACT will
* be fsync'd on every future checkpoint. We assume this
* situation is infrequent enough that the performance cost is
* negligible (especially since we know the state file has already
* been fsynced).
*/
gxact = MarkAsPreparing(xid, hdr->gid,
hdr->prepared_at,
hdr->owner, hdr->database);
GXactLoadSubxactData(gxact, hdr->nsubxacts, subxids);
MarkAsPrepared(gxact);
/*
* Recover other state (notably locks) using resource managers
*/
ProcessRecords(bufptr, xid, twophase_recover_callbacks);
pfree(buf);
}
}
FreeDir(cldir);
} | false | false | false | false | false | 0 |
array_get_isnull(const bits8 *nullbitmap, int offset)
{
if (nullbitmap == NULL)
return false; /* assume not null */
if (nullbitmap[offset / 8] & (1 << (offset % 8)))
return false; /* not null */
return true;
} | false | false | false | false | false | 0 |
bpmnode_compare(const void* a, const void* b)
{
int wa = ((const BPMNode*)a)->weight;
int wb = ((const BPMNode*)b)->weight;
if(wa < wb) return -1;
if(wa > wb) return 1;
/*make the qsort a stable sort*/
return ((const BPMNode*)a)->index < ((const BPMNode*)b)->index ? 1 : -1;
} | false | false | false | false | false | 0 |
entry_in_cache(H5C_t * cache_ptr,
int32_t type,
int32_t idx)
{
hbool_t in_cache = FALSE; /* will set to TRUE if necessary */
test_entry_t * base_addr;
test_entry_t * entry_ptr;
H5C_cache_entry_t * test_ptr = NULL;
HDassert( cache_ptr );
HDassert( ( 0 <= type ) && ( type < NUMBER_OF_ENTRY_TYPES ) );
HDassert( ( 0 <= idx ) && ( idx <= max_indices[type] ) );
base_addr = entries[type];
entry_ptr = &(base_addr[idx]);
HDassert( entry_ptr->index == idx );
HDassert( entry_ptr->type == type );
HDassert( entry_ptr == entry_ptr->self );
H5C_TEST__SEARCH_INDEX(cache_ptr, entry_ptr->addr, test_ptr)
if ( test_ptr != NULL ) {
in_cache = TRUE;
HDassert( test_ptr == (H5C_cache_entry_t *)entry_ptr );
HDassert( entry_ptr->addr == entry_ptr->header.addr );
}
return(in_cache);
} | false | false | false | true | false | 1 |
calc_hist(const float4 *hist, int nhist, int n)
{
float *hist_part;
int k,
i = 0;
float prev_interval = 0,
next_interval;
float frac;
hist_part = (float *) palloc((n + 1) * sizeof(float));
/*
* frac is a probability contribution for each interval between histogram
* values. We have nhist - 1 intervals, so contribution of each one will
* be 1 / (nhist - 1).
*/
frac = 1.0f / ((float) (nhist - 1));
for (k = 0; k <= n; k++)
{
int count = 0;
/*
* Count the histogram boundaries equal to k. (Although the histogram
* should theoretically contain only exact integers, entries are
* floats so there could be roundoff error in large values. Treat any
* fractional value as equal to the next larger k.)
*/
while (i < nhist && hist[i] <= k)
{
count++;
i++;
}
if (count > 0)
{
/* k is an exact bound for at least one histogram box. */
float val;
/* Find length between current histogram value and the next one */
if (i < nhist)
next_interval = hist[i] - hist[i - 1];
else
next_interval = 0;
/*
* count - 1 histogram boxes contain k exclusively. They
* contribute a total of (count - 1) * frac probability. Also
* factor in the partial histogram boxes on either side.
*/
val = (float) (count - 1);
if (next_interval > 0)
val += 0.5f / next_interval;
if (prev_interval > 0)
val += 0.5f / prev_interval;
hist_part[k] = frac * val;
prev_interval = next_interval;
}
else
{
/* k does not appear as an exact histogram bound. */
if (prev_interval > 0)
hist_part[k] = frac / prev_interval;
else
hist_part[k] = 0.0f;
}
}
return hist_part;
} | false | false | false | false | false | 0 |
brcmf_flowring_delete_peer(struct brcmf_flowring *flow, int ifidx,
u8 peer[ETH_ALEN])
{
struct brcmf_bus *bus_if = dev_get_drvdata(flow->dev);
struct brcmf_pub *drvr = bus_if->drvr;
struct brcmf_flowring_hash *hash;
struct brcmf_flowring_tdls_entry *prev;
struct brcmf_flowring_tdls_entry *search;
u32 i;
u8 flowid;
bool sta;
sta = (flow->addr_mode[ifidx] == ADDR_INDIRECT);
search = flow->tdls_entry;
prev = NULL;
while (search) {
if (memcmp(search->mac, peer, ETH_ALEN) == 0) {
sta = false;
break;
}
prev = search;
search = search->next;
}
hash = flow->hash;
for (i = 0; i < BRCMF_FLOWRING_HASHSIZE; i++) {
if ((sta || (memcmp(hash[i].mac, peer, ETH_ALEN) == 0)) &&
(hash[i].ifidx == ifidx)) {
flowid = flow->hash[i].flowid;
if (flow->rings[flowid]->status == RING_OPEN) {
flow->rings[flowid]->status = RING_CLOSING;
brcmf_msgbuf_delete_flowring(drvr, flowid);
}
}
}
if (search) {
if (prev)
prev->next = search->next;
else
flow->tdls_entry = search->next;
kfree(search);
if (flow->tdls_entry == NULL)
flow->tdls_active = false;
}
} | false | false | false | false | false | 0 |
build_addr(struct ipv6db_addr_t *a, uint64_t intf_id, struct in6_addr *addr)
{
memcpy(addr, &a->addr, sizeof(*addr));
if (a->prefix_len <= 64)
*(uint64_t *)(addr->s6_addr + 8) = intf_id;
else
*(uint64_t *)(addr->s6_addr + 8) |= intf_id & ((1 << (128 - a->prefix_len)) - 1);
} | false | false | false | false | false | 0 |
rsi_usb_rx_thread(struct rsi_common *common)
{
struct rsi_hw *adapter = common->priv;
struct rsi_91x_usbdev *dev = (struct rsi_91x_usbdev *)adapter->rsi_dev;
int status;
do {
rsi_wait_event(&dev->rx_thread.event, EVENT_WAIT_FOREVER);
if (atomic_read(&dev->rx_thread.thread_done))
goto out;
mutex_lock(&common->tx_rxlock);
status = rsi_read_pkt(common, 0);
if (status) {
rsi_dbg(ERR_ZONE, "%s: Failed To read data", __func__);
mutex_unlock(&common->tx_rxlock);
return;
}
mutex_unlock(&common->tx_rxlock);
rsi_reset_event(&dev->rx_thread.event);
if (adapter->rx_urb_submit(adapter)) {
rsi_dbg(ERR_ZONE,
"%s: Failed in urb submission", __func__);
return;
}
} while (1);
out:
rsi_dbg(INFO_ZONE, "%s: Terminated thread\n", __func__);
complete_and_exit(&dev->rx_thread.completion, 0);
} | false | false | false | false | false | 0 |
BilinearInterpFloat(const cmsFloat32Number Input[],
cmsFloat32Number Output[],
const cmsInterpParams* p)
{
# define LERP(a,l,h) (cmsFloat32Number) ((l)+(((h)-(l))*(a)))
# define DENS(i,j) (LutTable[(i)+(j)+OutChan])
const cmsFloat32Number* LutTable = (cmsFloat32Number*) p ->Table;
cmsFloat32Number px, py;
int x0, y0,
X0, Y0, X1, Y1;
int TotalOut, OutChan;
cmsFloat32Number fx, fy,
d00, d01, d10, d11,
dx0, dx1,
dxy;
TotalOut = p -> nOutputs;
px = Input[0] * p->Domain[0];
py = Input[1] * p->Domain[1];
x0 = (int) _cmsQuickFloor(px); fx = px - (cmsFloat32Number) x0;
y0 = (int) _cmsQuickFloor(py); fy = py - (cmsFloat32Number) y0;
X0 = p -> opta[1] * x0;
X1 = X0 + (Input[0] >= 1.0 ? 0 : p->opta[1]);
Y0 = p -> opta[0] * y0;
Y1 = Y0 + (Input[1] >= 1.0 ? 0 : p->opta[0]);
for (OutChan = 0; OutChan < TotalOut; OutChan++) {
d00 = DENS(X0, Y0);
d01 = DENS(X0, Y1);
d10 = DENS(X1, Y0);
d11 = DENS(X1, Y1);
dx0 = LERP(fx, d00, d10);
dx1 = LERP(fx, d01, d11);
dxy = LERP(fy, dx0, dx1);
Output[OutChan] = dxy;
}
# undef LERP
# undef DENS
} | false | false | false | false | false | 0 |
DumpAddressMap(string* result) {
*result += "\nMAPPED_LIBRARIES:\n";
// We keep doubling until we get a fit
const size_t old_resultlen = result->size();
for (int amap_size = 10240; amap_size < 10000000; amap_size *= 2) {
result->resize(old_resultlen + amap_size);
bool wrote_all = false;
const int bytes_written =
tcmalloc::FillProcSelfMaps(&((*result)[old_resultlen]), amap_size,
&wrote_all);
if (wrote_all) { // we fit!
(*result)[old_resultlen + bytes_written] = '\0';
result->resize(old_resultlen + bytes_written);
return;
}
}
result->reserve(old_resultlen); // just don't print anything
} | false | false | false | false | false | 0 |
isValidCV(ConSeq c, VowelSeq v)
{
if (c == cs_nil || v == vs_nil)
return true;
VowelSeqInfo & vInfo = VSeqList[v];
if ((c == cs_gi && vInfo.v[0] == vnl_i) ||
(c == cs_qu && vInfo.v[0] == vnl_u))
return false; // gi doesn't go with i, qu doesn't go with u
if (c == cs_k) {
// k can only go with the following vowel sequences
static VowelSeq kVseq[] = {vs_e, vs_i, vs_y, vs_er, vs_eo, vs_eu,
vs_eru, vs_ia, vs_ie, vs_ier, vs_ieu, vs_ieru, vs_nil};
int i;
for (i=0; kVseq[i] != vs_nil && kVseq[i] != v; i++);
return (kVseq[i] != vs_nil);
}
//More checks
return true;
} | false | false | false | false | false | 0 |
tracker_ontologies_get_uri_by_id (gint id)
{
g_return_val_if_fail (id != -1, NULL);
return g_hash_table_lookup (id_uri_pairs, GINT_TO_POINTER (id));
} | false | false | false | false | false | 0 |
__alloc_1instdce_prevval(struct dcevnt_t *dcep)
{
int32 dcewid, totchars;
struct net_t *np;
struct mod_t *ref_mdp;
/* SJM 05/08/03 - dce expr can never be 1 inst - always var and never XMR */
/* DBG remove -- */
if (dcep->dce_expr != NULL) __misc_terr(__FILE__, __LINE__);
/* --- */
np = dcep->dce_np;
/* always need prevval for PLI, multiple change at same time possible */
if (dcep->dce_typ < ST_ND_PREVVAL)
{
/* no previous value for arrays or non edge entire wire regs */
/* but needed for all others and always build if nd prev val T */
if (np->n_isarr || (np->ntyp >= NONWIRE_ST && dcep->dci1 == -1
&& !dcep->dce_edge)) return;
}
dcewid = __get_dcewid(dcep, np);
if (np->n_stren) dcep->prevval.bp = (byte *) __my_malloc(dcewid);
else
{
ref_mdp = dcep_ref_mod(dcep);
totchars = __get_pcku_chars(dcewid, ref_mdp->flatinum);
dcep->prevval.wp = (word32 *) __my_malloc(totchars);
}
} | false | false | false | false | false | 0 |
afr_sh_set_timestamps (call_frame_t *frame, xlator_t *this)
{
afr_local_t *local = NULL;
afr_private_t *priv = NULL;
afr_self_heal_t *sh = NULL;
local = frame->local;
sh = &local->self_heal;
priv = this->private;
STACK_WIND_COOKIE (frame, afr_sh_data_setattr_fstat_cbk,
(void *) (long) sh->source,
priv->children[sh->source],
priv->children[sh->source]->fops->fstat,
sh->healing_fd, NULL);
return 0;
} | false | false | false | false | false | 0 |
H5Iget_name(hid_t id, char *name/*out*/, size_t size)
{
H5G_loc_t loc; /* Object location */
ssize_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("Zs", "ixz", id, name, size);
/* Get object location */
if(H5G_loc(id, &loc) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object location")
/* Call internal group routine to retrieve object's name */
if((ret_value = H5G_get_name(&loc, name, size, NULL, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name")
done:
FUNC_LEAVE_API(ret_value)
} | false | false | false | false | false | 0 |
ikt_object_end(void)
{
if (track) {
track->rte_name = name;
track_add_head(track);
name = NULL;
} else if (waypt) {
waypt->shortname = name;
waypt->description = text;
waypt_add(waypt);
name = NULL;
text = NULL;
}
if (name) {
xfree(name);
name = NULL;
}
if (text) {
xfree(text);
text = NULL;
}
track = NULL;
waypt = NULL;
} | false | false | false | false | false | 0 |
nfs3_fill_readdirp3res (readdirp3res *res, nfsstat3 stat,
struct nfs3_fh *dirfh, uint64_t cverf,
struct iatt *dirstat, gf_dirent_t *entries,
count3 dircount, count3 maxcount, int is_eof,
uint64_t deviceid)
{
post_op_attr dirattr;
entryp3 *ent = NULL;
entryp3 *headentry = NULL;
entryp3 *preventry = NULL;
count3 filled = 0;
gf_dirent_t *listhead = NULL;
int fhlen = 0;
memset (res, 0, sizeof (*res));
res->status = stat;
if (stat != NFS3_OK)
return;
nfs3_map_deviceid_to_statdev (dirstat, deviceid);
dirattr = nfs3_stat_to_post_op_attr (dirstat);
res->readdirp3res_u.resok.dir_attributes = dirattr;
res->readdirp3res_u.resok.reply.eof = (bool_t)is_eof;
memcpy (res->readdirp3res_u.resok.cookieverf, &cverf, sizeof (cverf));
filled = NFS3_READDIR_RESOK_SIZE;
/* First entry is just the list head */
listhead = entries;
entries = entries->next;
while (((entries) && (entries != listhead)) && (filled < maxcount)) {
/* Linux does not display . and .. entries unless we provide
* these entries here.
*/
/* if ((strcmp (entries->d_name, ".") == 0) ||
(strcmp (entries->d_name, "..") == 0))
goto nextentry;
*/
ent = nfs3_fill_entryp3 (entries, dirfh, deviceid);
if (!ent)
break;
if (!headentry)
headentry = ent;
if (preventry) {
preventry->nextentry = ent;
preventry = ent;
} else
preventry = ent;
fhlen = ent->name_handle.post_op_fh3_u.handle.data.data_len;
filled += NFS3_ENTRYP3_FIXED_SIZE + fhlen + strlen (ent->name);
//nextentry:
entries = entries->next;
}
res->readdirp3res_u.resok.reply.entries = headentry;
return;
} | false | false | false | false | false | 0 |
system_get_full_string (const equation_system *sys,
int tex)
{
static char sysstr[128];
const char *lstr = gretl_system_long_strings[sys->method];
if (sys->flags & SYSTEM_ITERATE) {
if (tex) {
sprintf(sysstr, A_("iterated %s"), A_(lstr));
} else {
sprintf(sysstr, _("iterated %s"), _(lstr));
}
} else if (tex) {
strcpy(sysstr, A_(lstr));
} else {
strcpy(sysstr, _(lstr));
}
return sysstr;
} | false | false | false | false | false | 0 |
_tor_memdup(const void *mem, size_t len DMALLOC_PARAMS)
{
char *dup;
tor_assert(len < SIZE_T_CEILING);
tor_assert(mem);
dup = _tor_malloc(len DMALLOC_FN_ARGS);
memcpy(dup, mem, len);
return dup;
} | false | true | false | false | false | 1 |
on_content_read (GObject *obj,
GAsyncResult *result,
gpointer user_data)
{
GSimpleAsyncResult *res = G_SIMPLE_ASYNC_RESULT (user_data);
EvdHttpConnection *conn = EVD_HTTP_CONNECTION (obj);
GError *error = NULL;
gchar *content;
gssize size;
CallData *data;
data = g_simple_async_result_get_op_res_gpointer (res);
content = evd_http_connection_read_all_content_finish (conn,
result,
&size,
&error);
/* recycle connection if keep-alive */
if (evd_http_connection_get_keepalive (conn))
evd_connection_pool_recycle (EVD_CONNECTION_POOL (data->self),
EVD_CONNECTION (conn));
if (content == NULL)
{
/* notify JSON-RPC of transport error */
evd_jsonrpc_transport_error (data->self->priv->rpc,
data->invocation_id,
error);
g_error_free (error);
}
else
{
if (! evd_jsonrpc_transport_receive (data->self->priv->rpc,
content,
res,
data->invocation_id,
NULL))
{
/* Server responded with invalid JSON-RPC data. EvdJsonrpc already
handles the transport error internally, within transport_receive(). */
}
g_free (content);
}
} | false | false | false | false | false | 0 |
color_map_load_from_uri (char const *uri)
{
struct color_map_load_state state;
GsfInput *input = go_file_open (uri, NULL);
if (input == NULL) {
g_warning ("[GogAxisColorMap]: Could not open %s", uri);
return;
}
state.map = NULL;
state.name = NULL;
state.lang = NULL;
state.langs = g_get_language_names ();
state.name_lang_score = G_MAXINT;
state.color_stops = NULL;
if (!xml)
xml = gsf_xml_in_doc_new (color_map_dtd, NULL);
if (!gsf_xml_in_doc_parse (xml, input, &state))
g_warning ("[GogAxisColorMap]: Could not parse %s", uri);
if (state.map != NULL) {
if (!go_file_access (uri, GO_W_OK)) {
state.map->uri = g_strdup (uri);
state.map->type = GO_RESOURCE_RW;
} else
state.map->type = GO_RESOURCE_RO;
color_map_loaded (&state, uri, TRUE);
if (state.map)
gog_axis_color_map_registry_add (state.map);
} else
g_free (state.name);
g_object_unref (input);
} | false | false | false | false | false | 0 |
allocate()
{
allocated = 1;
int n = atom->ntypes;
memory->create(setflag,n+1,n+1,"pair:setflag");
for (int i = 1; i <= n; i++)
for (int j = i; j <= n; j++)
setflag[i][j] = 0;
memory->create(cutsq,n+1,n+1,"pair:cutsq");
memory->create(cut_lj_read,n+1,n+1,"pair:cut_lj_read");
memory->create(cut_lj,n+1,n+1,"pair:cut_lj");
memory->create(cut_ljsq,n+1,n+1,"pair:cut_ljsq");
memory->create(epsilon_read,n+1,n+1,"pair:epsilon_read");
memory->create(epsilon,n+1,n+1,"pair:epsilon");
memory->create(sigma_read,n+1,n+1,"pair:sigma_read");
memory->create(sigma,n+1,n+1,"pair:sigma");
memory->create(lj1,n+1,n+1,"pair:lj1");
memory->create(lj2,n+1,n+1,"pair:lj2");
memory->create(lj3,n+1,n+1,"pair:lj3");
memory->create(lj4,n+1,n+1,"pair:lj4");
memory->create(offset,n+1,n+1,"pair:offset");
} | false | false | false | false | false | 0 |
_dbus_string_insert_byte (DBusString *str,
int i,
unsigned char byte)
{
DBUS_STRING_PREAMBLE (str);
_dbus_assert (i <= real->len);
_dbus_assert (i >= 0);
if (!open_gap (1, real, i))
return FALSE;
real->str[i] = byte;
return TRUE;
} | false | false | false | true | false | 1 |
drop_privileges()
{
struct passwd *userp = 0;
string user = option(OPT_USER);
if (!user.empty()) {
userp = getpwnam(user.c_str());
if (!userp) {
Log::get(Log::ERROR) << "Unknown user \"" << user << "\"" << endl;
return false;
}
}
struct group *groupp = 0;
string group = option(OPT_GROUP);
if (!group.empty()) {
groupp = getgrnam(group.c_str());
if (!groupp) {
Log::get(Log::ERROR) << "Unknown group \"" << group << "\"" << endl;
return false;
}
}
if (userp && setuid(userp->pw_uid) < 0) {
Log::get(Log::ERROR) << "Could not setuid to " << userp->pw_uid
<< " (user \"" << user << "\")" << endl;
return false;
}
if (groupp && setgid(groupp->gr_gid) < 0) {
Log::get(Log::ERROR) << "Could not setgid to " << groupp->gr_gid
<< " (group \"" << group << "\")" << endl;
return false;
}
return true;
} | false | false | false | false | false | 0 |
LoadFrom (Storage & storage) {
unsigned int N=GetNFlags();
for (unsigned int i=0; i<N; i++) {
SetFlag(i,false);
}
do {
std::string flagName;
XMLAdapter<std::string> adapter(flagName);
if (!storage.Load(adapter)) break;
unsigned int i = GetFlagPosition(flagName);
SetFlag(i,true);
}
while (true);
} | false | false | false | false | false | 0 |
gfs2_qd_shrink_scan(struct shrinker *shrink,
struct shrink_control *sc)
{
LIST_HEAD(dispose);
unsigned long freed;
if (!(sc->gfp_mask & __GFP_FS))
return SHRINK_STOP;
freed = list_lru_shrink_walk(&gfs2_qd_lru, sc,
gfs2_qd_isolate, &dispose);
gfs2_qd_dispose(&dispose);
return freed;
} | 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.