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 |
|---|---|---|---|---|---|---|
tt_suite_add_test(tt_testsuite_t *suite, const char *name,
void (*function)(void))
{
tt_test_t *test = calloc(1, sizeof(tt_test_t));
test->name = strdup(name);
test->function = function;
if(suite->last_test != NULL)
suite->last_test->next = test;
suite->last_test = test;
if(suite->first_test == NULL)
suite->first_test = test;
++suite->num_tests;
} | false | false | false | false | false | 0 |
GetNthKey( unsigned int n )
{
if (n >= this->Tags.size())
{
return NULL;
}
return this->Tags[n].c_str();
} | false | false | false | false | false | 0 |
inter4pol (short* buf, float index, long size){
double frac, a, b, c, d, cminusb;
short* fp;
long lindex = (long)index;
/* 4 point interpolation taken from tabread4~ of pd (pure-data.org) */
if ((float)lindex == index) // no need to interpolate:
return (*(buf + lindex) / 32767.);
if (!size) return 0.;
if (lindex < 1){
lindex = 1, frac = .0;
}else if (lindex > (size - 3)){
lindex = size - 3;
frac = 1.;
}else{
frac = (double)index - lindex;
}
fp = buf + lindex;
a = (double)(fp[-1]) / 32767.;
b = (double)(fp[0]) / 32767.;
c = (double)(fp[1]) / 32767.;
d = (double)(fp[2]) / 32767.;
cminusb = c-b;
return (float)(b + frac * (cminusb - 0.5f * (frac - 1.) *
((a - d + 3.0f * cminusb) * frac + (b - a - cminusb))));
} | false | false | false | false | false | 0 |
read_line (GstRTSPConnection * conn, guint8 * buffer, guint * idx, guint size)
{
while (TRUE) {
guint8 c;
gint r;
if (conn->read_ahead == READ_AHEAD_EOH) {
/* the last call to read_line() already determined that we have reached
* the end of the headers, so convey that information now */
conn->read_ahead = 0;
break;
} else if (conn->read_ahead == READ_AHEAD_CRLF) {
/* the last call to read_line() left off after having read \r\n */
c = '\n';
} else if (conn->read_ahead == READ_AHEAD_CRLFCR) {
/* the last call to read_line() left off after having read \r\n\r */
c = '\r';
} else if (conn->read_ahead != 0) {
/* the last call to read_line() left us with a character to start with */
c = (guint8) conn->read_ahead;
conn->read_ahead = 0;
} else {
/* read the next character */
r = fill_bytes (conn, &c, 1);
if (G_UNLIKELY (r == 0)) {
return GST_RTSP_EEOF;
} else if (G_UNLIKELY (r < 0)) {
if (ERRNO_IS_EAGAIN)
return GST_RTSP_EINTR;
if (!ERRNO_IS_EINTR)
return GST_RTSP_ESYS;
continue;
}
}
/* special treatment of line endings */
if (c == '\r' || c == '\n') {
guint8 read_ahead;
retry:
/* need to read ahead one more character to know what to do... */
r = fill_bytes (conn, &read_ahead, 1);
if (G_UNLIKELY (r == 0)) {
return GST_RTSP_EEOF;
} else if (G_UNLIKELY (r < 0)) {
if (ERRNO_IS_EAGAIN) {
/* remember the original character we read and try again next time */
if (conn->read_ahead == 0)
conn->read_ahead = c;
return GST_RTSP_EINTR;
}
if (!ERRNO_IS_EINTR)
return GST_RTSP_ESYS;
goto retry;
}
if (read_ahead == ' ' || read_ahead == '\t') {
if (conn->read_ahead == READ_AHEAD_CRLFCR) {
/* got \r\n\r followed by whitespace, treat it as a normal line
* followed by one starting with LWS */
conn->read_ahead = read_ahead;
break;
} else {
/* got LWS, change the line ending to a space and continue */
c = ' ';
conn->read_ahead = read_ahead;
}
} else if (conn->read_ahead == READ_AHEAD_CRLFCR) {
if (read_ahead == '\r' || read_ahead == '\n') {
/* got \r\n\r\r or \r\n\r\n, treat it as the end of the headers */
conn->read_ahead = READ_AHEAD_EOH;
break;
} else {
/* got \r\n\r followed by something else, this is not really
* supported since we have probably just eaten the first character
* of the body or the next message, so just ignore the second \r
* and live with it... */
conn->read_ahead = read_ahead;
break;
}
} else if (conn->read_ahead == READ_AHEAD_CRLF) {
if (read_ahead == '\r') {
/* got \r\n\r so far, need one more character... */
conn->read_ahead = READ_AHEAD_CRLFCR;
goto retry;
} else if (read_ahead == '\n') {
/* got \r\n\n, treat it as the end of the headers */
conn->read_ahead = READ_AHEAD_EOH;
break;
} else {
/* found the end of a line, keep read_ahead for the next line */
conn->read_ahead = read_ahead;
break;
}
} else if (c == read_ahead) {
/* got double \r or \n, treat it as the end of the headers */
conn->read_ahead = READ_AHEAD_EOH;
break;
} else if (c == '\r' && read_ahead == '\n') {
/* got \r\n so far, still need more to know what to do... */
conn->read_ahead = READ_AHEAD_CRLF;
goto retry;
} else {
/* found the end of a line, keep read_ahead for the next line */
conn->read_ahead = read_ahead;
break;
}
}
if (G_LIKELY (*idx < size - 1))
buffer[(*idx)++] = c;
}
buffer[*idx] = '\0';
return GST_RTSP_OK;
} | false | false | false | false | false | 0 |
GetValue(NPPVariable aVariable, void *aValue)
{
if (aVariable == NPPVpluginScriptableNPObject) {
if (_scriptObject) {
void **v = (void **)aValue;
NPN_RetainObject(_scriptObject);
*v = _scriptObject;
} else {
gnash::log_debug("_scriptObject is not assigned");
}
}
// log_debug("SCRIPT OBJECT getValue: %x, ns: %x", (void *)_scriptObject, (void *)this);
return NS_PluginGetValue(aVariable, aValue);
} | false | false | false | false | false | 0 |
configure(Vector<String> &conf, ErrorHandler *errh)
{
errh->warning("SetAnnoByte(ANNO, VALUE) is obsolete, use Paint(VALUE, ANNO) instead");
return Args(conf, this, errh)
.read_mp("ANNO", AnnoArg(1), _offset)
.read_mp("VALUE", _value).complete();
} | false | false | false | false | false | 0 |
APar_ReturnChildrenAtoms(short this_atom, uint8_t atom_index) {
short child_atom = 0;
uint8_t total_children = 0;
short iter = parsedAtoms[this_atom].NextAtomNumber;
while (true) {
if ((parsedAtoms[iter].AtomicLevel == parsedAtoms[this_atom].AtomicLevel + 1 && this_atom > 0)
|| (this_atom == 0 && parsedAtoms[iter].AtomicLevel == 1)) {
total_children++;
if (atom_index == total_children) {
child_atom = iter;
break;
}
}
if (parsedAtoms[iter].AtomicLevel <= parsedAtoms[this_atom].AtomicLevel && this_atom != 0) {
break;
}
else {
iter = parsedAtoms[iter].NextAtomNumber;
}
if (iter == 0) {
break;
}
}
if (atom_index == 0) {
child_atom = (short) total_children;
}
return child_atom;
} | false | false | false | false | false | 0 |
IsInSelection(const wxPoint2DDouble &pt) const
{
register int n, count = m_blocks.GetCount();
for (n=0; n<count; n++)
{
if (m_blocks[n].Contains(pt))
return true;
}
return false;
} | false | false | false | false | false | 0 |
main(int argc, char **argv) {
wavSound*s;
FILE *fin;
FILE *fout;
if (argc < 4 || argc > 6) {
printf("Usage 1: %s <file.wav> <output.c> <soundname>\n", argv[0]);
printf("Usage 2: %s <file.wav> <output.c> <soundname> <amount of samples>\n", argv[0]);
exit(0);
}
fin = fopen(argv[1], "r");
s = loadWaveHeader(fin);
if (s == NULL) {
printf("Invalid wave !\n");
exit(0);
}
fout = fopen(argv[2], "w");
switch (argc) {
case 4:
saveWave(fin, s, fout, argv[3]);
break;
case 5:
saveWave_(fin, s, fout, argv[3], atoi(argv[4]));
break;
default:
break;
}
return 0;
} | false | false | false | false | true | 1 |
gfire_filetransfer_data_packet_request(gfire_filetransfer *p_transfer, guint64 p_offset,
guint32 p_size, guint32 p_msgid)
{
if(!p_transfer || purple_xfer_get_type(p_transfer->xfer) != PURPLE_XFER_SEND ||
p_offset >= p_transfer->size || p_size > 0x01E00000 /* 30 MB */)
return;
guint8 *data = g_malloc(p_size);
lseek64(p_transfer->file, p_offset, SEEK_SET);
int size = read(p_transfer->file, data, p_size);
if(size <= 0)
{
g_free(data);
purple_xfer_error(PURPLE_XFER_SEND, purple_xfer_get_account(p_transfer->xfer),
purple_xfer_get_remote_user(p_transfer->xfer),
_("Reading a data segment failed! Make sure you have appropriate permissions!"));
// Abort the transfer
gfire_p2p_session_remove_file_transfer(p_transfer->session, p_transfer, TRUE);
return;
}
gfire_p2p_dl_proto_send_file_data_packet(p_transfer->session, p_transfer->fileid, p_offset,
size, data, p_msgid);
g_free(data);
// Update GUI
if((purple_xfer_get_bytes_sent(p_transfer->xfer) + size) > purple_xfer_get_size(p_transfer->xfer))
purple_xfer_set_size(p_transfer->xfer, purple_xfer_get_bytes_sent(p_transfer->xfer) + size);
purple_xfer_set_bytes_sent(p_transfer->xfer, purple_xfer_get_bytes_sent(p_transfer->xfer) + size);
purple_xfer_update_progress(p_transfer->xfer);
} | false | true | false | false | true | 1 |
hybrid_account_set_connection_string(HybridAccount *account,
const gchar *string)
{
g_return_if_fail(account != NULL);
gtk_label_set_markup(GTK_LABEL(account->login_tips), string);
} | false | false | false | false | false | 0 |
zero_extended_scalar_load_operand_1 (rtx op, enum machine_mode mode ATTRIBUTE_UNUSED)
#line 738 "../../src/gcc/config/i386/predicates.md"
{
unsigned n_elts;
op = maybe_get_pool_constant (op);
if (!(op && GET_CODE (op) == CONST_VECTOR))
return false;
n_elts = CONST_VECTOR_NUNITS (op);
for (n_elts--; n_elts > 0; n_elts--)
{
rtx elt = CONST_VECTOR_ELT (op, n_elts);
if (elt != CONST0_RTX (GET_MODE_INNER (GET_MODE (op))))
return false;
}
return true;
} | false | false | false | false | false | 0 |
bus_matchmaker_unref (BusMatchmaker *matchmaker)
{
_dbus_assert (matchmaker->refcount > 0);
matchmaker->refcount -= 1;
if (matchmaker->refcount == 0)
{
int i;
for (i = DBUS_MESSAGE_TYPE_INVALID; i < DBUS_NUM_MESSAGE_TYPES; i++)
{
RulePool *p = matchmaker->rules_by_type + i;
_dbus_hash_table_unref (p->rules_by_iface);
rule_list_free (&p->rules_without_iface);
}
dbus_free (matchmaker);
}
} | false | false | false | false | false | 0 |
lookup(unsigned VR) {
unsigned RInd = TargetRegisterInfo::virtReg2Index(VR);
// Grow the vector to at least 32 elements.
if (RInd >= CVect.size())
CVect.resize(std::max(RInd+16, 32U), 0);
const BitTracker::RegisterCell *CP = CVect[RInd];
if (CP == 0)
CP = CVect[RInd] = &BT.lookup(VR);
return *CP;
} | false | false | false | false | false | 0 |
show_bios_limit(struct cpufreq_policy *policy, char *buf)
{
unsigned int limit;
int ret;
if (cpufreq_driver->bios_limit) {
ret = cpufreq_driver->bios_limit(policy->cpu, &limit);
if (!ret)
return sprintf(buf, "%u\n", limit);
}
return sprintf(buf, "%u\n", policy->cpuinfo.max_freq);
} | false | true | false | false | false | 1 |
dump_scs_line(Boolean reset_pp, Boolean always_nl)
{
int i;
Boolean any_data = False;
/* Find the last non-space character in the line buffer. */
for (i = mpp; i >= 1; i--) {
if (trnbuf[i].data_len != 0 || linebuf[i] != ' ')
break;
}
/*
* If there is data there, print it with a trailing newline and
* clear out the line buffer for next time. If not, just print the
* newline.
*/
if (i >= 1) {
int j;
int n_data = 0;
int n_trn = 0;
int k;
for (j = 1; j <= i; j++) {
/*
* Dump and transparent data that precedes this
* character.
*/
if (trnbuf[j].data_len) {
unsigned k;
n_trn += trnbuf[j].data_len;
for (k = 0; k < trnbuf[j].data_len; k++) {
if (stash(trnbuf[j].buf[k]) < 0)
return -1;
}
trnbuf[j].data_len = 0;
}
if (j < i || linebuf[j] != ' ') {
char mb[16];
int len;
if (linebuf[j] == FCORDER_NOP)
continue;
n_data++;
any_data = True;
scs_any = True;
#if !defined(_WIN32) /*[*/
len = unicode_to_multibyte(linebuf[j],
mb, sizeof(mb));
#else /*][*/
len = unicode_to_printer(linebuf[j],
mb, sizeof(mb));
#endif /*]*/
if (len == 0) {
mb[0] = ' ';
len = 1;
} else
len--;
for (k = 0; k < len; k++)
if (stash(mb[k]) < 0)
return -1;
}
}
#if defined(DEBUG_FF) /*[*/
trace_ds(" [dumping %d+%dt]", n_data, n_trn);
#endif /*]*/
for (k = 0; k < MAX_MPP+1; k++)
linebuf[k] = ' ';
}
if (any_data || always_nl) {
if (crlf) {
if (stash('\r') < 0)
return -1;
}
if (stash('\n') < 0)
return -1;
line++;
}
#if defined(DEBUG_FF) /*[*/
trace_ds(" [line=%d]", line);
#endif /*]*/
if (reset_pp)
pp = lm;
any_scs_output = False;
return 0;
} | false | false | false | false | false | 0 |
inspect_load(GKeyFile *config, const char *section)
{
char *name = utils_key_file_get_string(config, section, "name");
gchar *expr = utils_key_file_get_string(config, section, "expr");
gint hb_mode = utils_get_setting_integer(config, section, "hbit", HB_DEFAULT);
char *frame = utils_key_file_get_string(config, section, "frame");
gboolean run_apply = utils_get_setting_boolean(config, section, "run_apply", FALSE);
gint start = utils_get_setting_integer(config, section, "start", 0);
gint count = utils_get_setting_integer(config, section, "count", option_inspect_count);
gboolean expand = utils_get_setting_boolean(config, section, "expand",
option_inspect_expand);
gint format = utils_get_setting_integer(config, section, "format", FORMAT_NATURAL);
gboolean valid = FALSE;
if (name && inspect_name_valid(name) && expr && (unsigned) hb_mode < HB_COUNT &&
frame && inspect_frame_valid(frame) && (unsigned) start <= EXPAND_MAX &&
(unsigned) count <= EXPAND_MAX && (unsigned) format < FORMAT_COUNT)
{
GtkTreeIter iter;
gtk_tree_store_append(store, &iter, NULL);
gtk_tree_store_set(store, &iter, INSPECT_EXPR, expr, INSPECT_PATH_EXPR, expr,
INSPECT_HB_MODE, hb_mode, INSPECT_SCID, ++scid_gen, INSPECT_NAME, name,
INSPECT_FRAME, frame, INSPECT_RUN_APPLY, run_apply, INSPECT_START, start,
INSPECT_COUNT, count, INSPECT_EXPAND, expand, INSPECT_FORMAT, format, -1);
valid = TRUE;
}
g_free(frame);
g_free(expr);
g_free(name);
return valid;
} | false | false | false | false | false | 0 |
plugin_configure(GtkDialog * dialog)
{
gint i;
GtkWidget *label, *vbox, *author_label;
vbox = gtk_vbox_new(FALSE, 6);
label = gtk_label_new(_("Select a pastebin:"));
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
author_label = gtk_label_new(_("Enter the author name:"));
gtk_misc_set_alignment(GTK_MISC(author_label), 0, 0.5);
widgets.author_entry = gtk_entry_new();
if(author_name == NULL)
author_name = g_strdup(USERNAME);
gtk_entry_set_text(GTK_ENTRY(widgets.author_entry), author_name);
widgets.combo = gtk_combo_box_text_new();
for (i = 0; i < G_N_ELEMENTS(websites); i++)
gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(widgets.combo), websites[i]);
widgets.check_button = gtk_check_button_new_with_label(_("Show your paste in a new browser tab"));
gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), widgets.combo, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), author_label, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), widgets.author_entry, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(vbox), widgets.check_button, FALSE, FALSE, 0);
gtk_combo_box_set_active(GTK_COMBO_BOX(widgets.combo), website_selected);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(widgets.check_button), check_button_is_checked);
gtk_widget_show_all(vbox);
g_signal_connect(dialog, "response", G_CALLBACK(on_configure_response), NULL);
return vbox;
} | false | false | false | false | false | 0 |
parseCommonRQ(DcmDataset *obj, Uint16 *command, Uint16 *messageID,
Uint16 *dataSetType)
{
OFCondition cond = getAndDeleteUS(obj, DCM_CommandField, command); RET(cond);
cond = getAndDeleteUS(obj, DCM_MessageID, messageID); RET(cond);
cond = getAndDeleteUS(obj, DCM_DataSetType, dataSetType); RET(cond);
return EC_Normal;
} | false | false | false | false | false | 0 |
AcceptServerConnect(struct connectdata *conn)
{
struct SessionHandle *data = conn->data;
curl_socket_t sock = conn->sock[SECONDARYSOCKET];
curl_socket_t s = CURL_SOCKET_BAD;
#ifdef ENABLE_IPV6
struct Curl_sockaddr_storage add;
#else
struct sockaddr_in add;
#endif
curl_socklen_t size = (curl_socklen_t) sizeof(add);
if(0 == getsockname(sock, (struct sockaddr *) &add, &size)) {
size = sizeof(add);
s=accept(sock, (struct sockaddr *) &add, &size);
}
Curl_closesocket(conn, sock); /* close the first socket */
if(CURL_SOCKET_BAD == s) {
failf(data, "Error accept()ing server connect");
return CURLE_FTP_PORT_FAILED;
}
infof(data, "Connection accepted from server\n");
conn->sock[SECONDARYSOCKET] = s;
curlx_nonblock(s, TRUE); /* enable non-blocking */
conn->sock_accepted[SECONDARYSOCKET] = TRUE;
if(data->set.fsockopt) {
int error = 0;
/* activate callback for setting socket options */
error = data->set.fsockopt(data->set.sockopt_client,
s,
CURLSOCKTYPE_ACCEPT);
if(error) {
Curl_closesocket(conn, s); /* close the socket and bail out */
conn->sock[SECONDARYSOCKET] = CURL_SOCKET_BAD;
return CURLE_ABORTED_BY_CALLBACK;
}
}
return CURLE_OK;
} | false | false | false | false | false | 0 |
fetch_validx(struct gspca_dev *gspca_dev, struct validx *tbl, int len)
{
int n;
for (n = 0; n < len; n++) {
if (tbl[n].idx != 0xffff)
ctrl_out(gspca_dev, 0x40, 1, tbl[n].val,
tbl[n].idx, 0, NULL);
else if (tbl[n].val == 0xffff)
break;
else
msleep(tbl[n].val);
}
return n;
} | false | false | false | false | false | 0 |
ChooseIndexColumnNames(List *indexElems)
{
List *result = NIL;
ListCell *lc;
foreach(lc, indexElems)
{
IndexElem *ielem = (IndexElem *) lfirst(lc);
const char *origname;
const char *curname;
int i;
char buf[NAMEDATALEN];
/* Get the preliminary name from the IndexElem */
if (ielem->indexcolname)
origname = ielem->indexcolname; /* caller-specified name */
else if (ielem->name)
origname = ielem->name; /* simple column reference */
else
origname = "expr"; /* default name for expression */
/* If it conflicts with any previous column, tweak it */
curname = origname;
for (i = 1;; i++)
{
ListCell *lc2;
char nbuf[32];
int nlen;
foreach(lc2, result)
{
if (strcmp(curname, (char *) lfirst(lc2)) == 0)
break;
}
if (lc2 == NULL)
break; /* found nonconflicting name */
sprintf(nbuf, "%d", i);
/* Ensure generated names are shorter than NAMEDATALEN */
nlen = pg_mbcliplen(origname, strlen(origname),
NAMEDATALEN - 1 - strlen(nbuf));
memcpy(buf, origname, nlen);
strcpy(buf + nlen, nbuf);
curname = buf;
}
/* And attach to the result list */
result = lappend(result, pstrdup(curname));
}
return result;
} | false | false | false | false | false | 0 |
nfs3_fdcache_remove (struct nfs3_state *nfs3, fd_t *fd)
{
struct nfs3_fd_entry *fde = NULL;
uint64_t ctxaddr = 0;
if ((!nfs3) || (!fd))
return -1;
LOCK (&nfs3->fdlrulock);
{
fd_ctx_get (fd, nfs3->nfsx, &ctxaddr);
fde = (struct nfs3_fd_entry *)(long)ctxaddr;
__nfs3_fdcache_remove_entry (nfs3, fde);
}
UNLOCK (&nfs3->fdlrulock);
return 0;
} | false | false | false | false | false | 0 |
sjlj_build_landing_pads (void)
{
int num_dispatch;
num_dispatch = vec_safe_length (cfun->eh->lp_array);
if (num_dispatch == 0)
return;
sjlj_lp_call_site_index.safe_grow_cleared (num_dispatch);
num_dispatch = sjlj_assign_call_site_values ();
if (num_dispatch > 0)
{
rtx dispatch_label = gen_label_rtx ();
int align = STACK_SLOT_ALIGNMENT (sjlj_fc_type_node,
TYPE_MODE (sjlj_fc_type_node),
TYPE_ALIGN (sjlj_fc_type_node));
crtl->eh.sjlj_fc
= assign_stack_local (TYPE_MODE (sjlj_fc_type_node),
int_size_in_bytes (sjlj_fc_type_node),
align);
sjlj_mark_call_sites ();
sjlj_emit_function_enter (dispatch_label);
sjlj_emit_dispatch_table (dispatch_label, num_dispatch);
sjlj_emit_function_exit ();
}
/* If we do not have any landing pads, we may still need to register a
personality routine and (empty) LSDA to handle must-not-throw regions. */
else if (function_needs_eh_personality (cfun) != eh_personality_none)
{
int align = STACK_SLOT_ALIGNMENT (sjlj_fc_type_node,
TYPE_MODE (sjlj_fc_type_node),
TYPE_ALIGN (sjlj_fc_type_node));
crtl->eh.sjlj_fc
= assign_stack_local (TYPE_MODE (sjlj_fc_type_node),
int_size_in_bytes (sjlj_fc_type_node),
align);
sjlj_mark_call_sites ();
sjlj_emit_function_enter (NULL_RTX);
sjlj_emit_function_exit ();
}
sjlj_lp_call_site_index.release ();
} | false | false | false | true | false | 1 |
hc55516_clock_w(int num, int state)
{
struct hc55516_data *chip = &hc55516[num];
int clock = state & 1, diffclock;
/* update the clock */
diffclock = clock ^ chip->last_clock;
chip->last_clock = clock;
/* speech clock changing (active on rising edge) */
if (diffclock && clock)
{
double integrator = chip->integrator, temp;
/* clear the update count */
chip->update_count = 0;
/* move the estimator up or down a step based on the bit */
if (chip->databit)
{
chip->shiftreg = ((chip->shiftreg << 1) | 1) & 7;
integrator += chip->filter;
}
else
{
chip->shiftreg = (chip->shiftreg << 1) & 7;
integrator -= chip->filter;
}
/* simulate leakage */
integrator *= leak;
/* if we got all 0's or all 1's in the last n bits, bump the step up */
if (chip->shiftreg == 0 || chip->shiftreg == 7)
{
chip->filter = FILTER_MAX - ((FILTER_MAX - chip->filter) * charge);
if (chip->filter > FILTER_MAX)
chip->filter = FILTER_MAX;
}
/* simulate decay */
else
{
chip->filter *= decay;
if (chip->filter < FILTER_MIN)
chip->filter = FILTER_MIN;
}
/* compute the sample as a 32-bit word */
temp = integrator * SAMPLE_GAIN;
chip->integrator = integrator;
/* compress the sample range to fit better in a 16-bit word */
if (temp < 0)
chip->next_value = (int)(temp / (-temp * (1.0 / 32768.0) + 1.0));
else
chip->next_value = (int)(temp / (temp * (1.0 / 32768.0) + 1.0));
/* update the output buffer before changing the registers */
stream_update(chip->channel, 0);
}
} | false | false | false | false | false | 0 |
add_hidden_capitalized_word(char * word, int wbl, int wcl,
unsigned short * flags, int al, char * dp, int captype)
{
// add inner capitalized forms to handle the following allcap forms:
// Mixed caps: OpenOffice.org -> OPENOFFICE.ORG
// Allcaps with suffixes: CIA's -> CIA'S
if (((captype == HUHCAP) || (captype == HUHINITCAP) ||
((captype == ALLCAP) && (flags != NULL))) &&
!((flags != NULL) && TESTAFF(flags, forbiddenword, al))) {
unsigned short * flags2 = (unsigned short *) malloc (sizeof(unsigned short) * (al+1));
if (!flags2) return 1;
if (al) memcpy(flags2, flags, al * sizeof(unsigned short));
flags2[al] = ONLYUPCASEFLAG;
if (utf8) {
char st[BUFSIZE];
w_char w[BUFSIZE];
int wlen = u8_u16(w, BUFSIZE, word);
mkallsmall_utf(w, wlen, langnum);
mkallcap_utf(w, 1, langnum);
u16_u8(st, BUFSIZE, w, wlen);
return add_word(st,wbl,wcl,flags2,al+1,dp, true);
} else {
mkallsmall(word, csconv);
mkinitcap(word, csconv);
return add_word(word,wbl,wcl,flags2,al+1,dp, true);
}
}
return 0;
} | false | true | false | false | false | 1 |
mr_shift(_MIPD_ big x,int n,big w)
{ /* set w=x.(mr_base^n) by shifting */
mr_lentype s;
int i,bl;
mr_small *gw=w->w;
#ifdef MR_OS_THREADS
miracl *mr_mip=get_mip();
#endif
if (mr_mip->ERNUM) return;
copy(x,w);
if (w->len==0 || n==0) return;
MR_IN(33)
if (mr_notint(w)) mr_berror(_MIPP_ MR_ERR_INT_OP);
s=(w->len&(MR_MSBIT));
bl=(int)(w->len&(MR_OBITS))+n;
if (bl<=0)
{
zero(w);
MR_OUT
return;
}
if (bl>mr_mip->nib && mr_mip->check) mr_berror(_MIPP_ MR_ERR_OVERFLOW);
if (mr_mip->ERNUM)
{
MR_OUT
return;
}
if (n>0)
{
for (i=bl-1;i>=n;i--)
gw[i]=gw[i-n];
for (i=0;i<n;i++)
gw[i]=0;
}
else
{
n=(-n);
for (i=0;i<bl;i++)
gw[i]=gw[i+n];
for (i=0;i<n;i++)
gw[bl+i]=0;
}
w->len=(bl|s);
MR_OUT
} | false | false | false | false | false | 0 |
_content_set(Evas_Object *obj, Evas_Object *content)
{
ELM_CHECK_WIDTYPE(obj, widtype);
Evas_Object *prev_content;
Widget_Data *wd = elm_widget_data_get(obj);
if (!wd) return;
if (wd->content && wd->content == content) return;
if (wd->items)
{
_remove_items(wd);
_list_del(wd);
}
prev_content = elm_object_part_content_get(wd->content_area,
"elm.swallow.content");
if (prev_content)
evas_object_del(prev_content);
wd->content = content;
if (content)
{
elm_object_part_content_set(wd->base, "elm.swallow.content",
wd->content_area);
elm_object_part_content_set(wd->content_area, "elm.swallow.content",
content);
evas_object_show(content);
}
_sizing_eval(obj);
} | false | false | false | false | false | 0 |
gzip_bidder_init(struct archive_read_filter *self)
{
struct private_data *state;
static const size_t out_block_size = 64 * 1024;
void *out_block;
self->code = ARCHIVE_COMPRESSION_GZIP;
self->name = "gzip";
state = (struct private_data *)calloc(sizeof(*state), 1);
out_block = (unsigned char *)malloc(out_block_size);
if (state == NULL || out_block == NULL) {
free(out_block);
free(state);
archive_set_error(&self->archive->archive, ENOMEM,
"Can't allocate data for gzip decompression");
return (ARCHIVE_FATAL);
}
self->data = state;
state->out_block_size = out_block_size;
state->out_block = out_block;
self->read = gzip_filter_read;
self->skip = NULL; /* not supported */
self->close = gzip_filter_close;
state->in_stream = 0; /* We're not actually within a stream yet. */
return (ARCHIVE_OK);
} | false | false | false | false | false | 0 |
ide_wait_not_busy(ide_hwif_t *hwif, unsigned long timeout)
{
u8 stat = 0;
while (timeout--) {
/*
* Turn this into a schedule() sleep once I'm sure
* about locking issues (2.5 work ?).
*/
mdelay(1);
stat = hwif->tp_ops->read_status(hwif);
if ((stat & ATA_BUSY) == 0)
return 0;
/*
* Assume a value of 0xff means nothing is connected to
* the interface and it doesn't implement the pull-down
* resistor on D7.
*/
if (stat == 0xff)
return -ENODEV;
touch_softlockup_watchdog();
touch_nmi_watchdog();
}
return -EBUSY;
} | false | false | false | false | false | 0 |
save()
{
if( _quest ) {
_quest->setName( _name->getValue() );
_quest->setDescription( _description->getValue() );
_quest->setType( (Quest::QuestType)_type->currentItem() );
_quest->setConfirmationNeeded( _needConfirmation->getValue() );
_quest->setConfirmationQuestion( _confirmationQuestion->getValue() );
_quest->setStartCondition( _editStartCondition->getCondition() );
_quest->setFailCondition( _editFailCondition->getCondition() );
_quest->setSuccessCondition( _editSuccessCondition->getCondition() );
}
} | false | false | false | false | false | 0 |
addRenderSystemToName( const String & name )
{
// Use the current render system
RenderSystem* rs = Root::getSingleton().getRenderSystem();
return rs->getName() + "_" + name;
} | false | false | false | false | false | 0 |
fcoe_str_to_dev_loss(const char *buf, unsigned long *val)
{
int ret;
ret = kstrtoul(buf, 0, val);
if (ret)
return -EINVAL;
/*
* Check for overflow; dev_loss_tmo is u32
*/
if (*val > UINT_MAX)
return -EINVAL;
return 0;
} | false | false | false | false | false | 0 |
nemo_undo_register_full (GList *atoms,
GObject *undo_manager_search_start_object,
const char *operation_name,
const char *undo_menu_item_label,
const char *undo_menu_item_hint,
const char *redo_menu_item_label,
const char *redo_menu_item_hint)
{
NemoUndoTransaction *transaction;
GList *p;
g_return_if_fail (atoms != NULL);
g_return_if_fail (G_IS_OBJECT (undo_manager_search_start_object));
/* Create an undo transaction */
transaction = nemo_undo_transaction_new (operation_name,
undo_menu_item_label,
undo_menu_item_hint,
redo_menu_item_label,
redo_menu_item_hint);
for (p = atoms; p != NULL; p = p->next) {
nemo_undo_transaction_add_atom (transaction, p->data);
}
nemo_undo_transaction_add_to_undo_manager
(transaction,
nemo_undo_get_undo_manager (undo_manager_search_start_object));
/* Now we are done with the transaction.
* If the undo manager is holding it, then this will not destroy it.
*/
g_object_unref (transaction);
} | false | false | false | false | false | 0 |
transport_remove_classdev(struct attribute_container *cont,
struct device *dev,
struct device *classdev)
{
struct transport_container *tcont =
attribute_container_to_transport_container(cont);
struct transport_class *tclass = class_to_transport_class(cont->class);
if (tclass->remove)
tclass->remove(tcont, dev, classdev);
if (tclass->remove != anon_transport_dummy_function) {
if (tcont->statistics)
sysfs_remove_group(&classdev->kobj, tcont->statistics);
attribute_container_class_device_del(classdev);
}
return 0;
} | false | false | false | false | false | 0 |
cursorcmd()
{
#ifdef KANJI
int i;
int col = 1;
int row = 0;
for (i = 0; col < cmdspos && i < cmdpos; ++i)
{
if (ISkanji(cmdbuff[i]))
{
if (col >= (Columns - 1))
{
col = 2;
row++;
}
else if (col >= (Columns - 2))
{
col = 0;
row++;
}
else
col += 2;
i++;
}
else
{
col += charsize(cmdbuff[i]);
if (col >= Columns)
{
col -= Columns;
row++;
}
}
}
msg_pos(cmdline_row + row, col);
#else
msg_pos(cmdline_row + (cmdspos / (int)Columns), cmdspos % (int)Columns);
#endif
windgoto(msg_row, msg_col);
} | true | true | false | false | true | 1 |
posix_file_xfer_deliver_iob ( struct xfer_interface *xfer,
struct io_buffer *iobuf,
struct xfer_metadata *meta ) {
struct posix_file *file =
container_of ( xfer, struct posix_file, xfer );
/* Keep track of file position solely for the filesize */
if ( meta->whence != SEEK_CUR )
file->pos = 0;
file->pos += meta->offset;
if ( file->filesize < file->pos )
file->filesize = file->pos;
if ( iob_len ( iobuf ) ) {
list_add_tail ( &iobuf->list, &file->data );
} else {
free_iob ( iobuf );
}
return 0;
} | false | false | false | false | false | 0 |
any_external_decl (tree id)
{
tree decl = IDENTIFIER_SYMBOL_VALUE (id);
tree t;
if (decl == 0 || TREE_CODE (decl) == ERROR_MARK)
return 0;
else if (TREE_CODE (decl) != TYPE_DECL && DECL_EXTERNAL (decl))
return decl;
t = purpose_member (id, truly_local_externals);
if (t)
return TREE_VALUE (t);
return 0;
} | false | false | false | false | false | 0 |
readi(struct inode *ip, char *dst, uint off, uint n)
{
uint tot, m;
struct buf *bp;
if(ip->type == T_DEV){
if(ip->major < 0 || ip->major >= NDEV || !devsw[ip->major].read)
return -1;
return devsw[ip->major].read(ip, dst, n);
}
if(off > ip->size || off + n < off)
return -1;
if(off + n > ip->size)
n = ip->size - off;
for(tot=0; tot<n; tot+=m, off+=m, dst+=m){
bp = bread(ip->dev, bmap(ip, off/BSIZE, 0));
m = min(n - tot, BSIZE - off%BSIZE);
memmove(dst, bp->data + off%BSIZE, m);
brelse(bp);
}
return n;
} | false | true | false | false | true | 1 |
diag(DiagonalMatrix& m, const ColumnVector& diagvals)
{
Tracer tr("diag");
m.ReSize(diagvals.Nrows());
m=0.0;
for (int j=1; j<=diagvals.Nrows(); j++)
m(j)=diagvals(j);
return 0;
} | false | false | false | false | false | 0 |
vim_version_dir(vimdir)
char_u *vimdir;
{
char_u *p;
if (vimdir == NULL || *vimdir == NUL)
return NULL;
p = concat_fnames(vimdir, (char_u *)VIM_VERSION_NODOT, TRUE);
if (p != NULL && mch_isdir(p))
return p;
vim_free(p);
p = concat_fnames(vimdir, (char_u *)RUNTIME_DIRNAME, TRUE);
if (p != NULL && mch_isdir(p))
return p;
vim_free(p);
return NULL;
} | false | false | false | false | false | 0 |
fromQuadrilaterals(AnnotQuadrilaterals *hlquads) const
{
QList< HighlightAnnotation::Quad > quads;
if ( !hlquads || !hlquads->getQuadrilateralsLength() )
return quads;
const int quadsCount = hlquads->getQuadrilateralsLength();
double MTX[6];
fillTransformationMTX(MTX);
for (int q = 0; q < quadsCount; ++q)
{
HighlightAnnotation::Quad quad;
XPDFReader::transform( MTX, hlquads->getX1( q ), hlquads->getY1( q ), quad.points[ 0 ] );
XPDFReader::transform( MTX, hlquads->getX2( q ), hlquads->getY2( q ), quad.points[ 1 ] );
XPDFReader::transform( MTX, hlquads->getX3( q ), hlquads->getY3( q ), quad.points[ 2 ] );
XPDFReader::transform( MTX, hlquads->getX4( q ), hlquads->getY4( q ), quad.points[ 3 ] );
// ### PDF1.6 specs says that point are in ccw order, but in fact
// points 3 and 4 are swapped in every PDF around!
QPointF tmpPoint = quad.points[ 2 ];
quad.points[ 2 ] = quad.points[ 3 ];
quad.points[ 3 ] = tmpPoint;
// initialize other properties and append quad
quad.capStart = true; // unlinked quads are always capped
quad.capEnd = true; // unlinked quads are always capped
quad.feather = 0.1; // default feather
quads.append( quad );
}
return quads;
} | false | false | false | false | false | 0 |
substitute_pseudo (rtx *loc, int old_regno, rtx new_reg)
{
rtx x = *loc;
bool result = false;
enum rtx_code code;
const char *fmt;
int i, j;
if (x == NULL_RTX)
return false;
code = GET_CODE (x);
if (code == REG && (int) REGNO (x) == old_regno)
{
enum machine_mode mode = GET_MODE (*loc);
enum machine_mode inner_mode = GET_MODE (new_reg);
if (mode != inner_mode)
{
if (GET_MODE_SIZE (mode) >= GET_MODE_SIZE (inner_mode)
|| ! SCALAR_INT_MODE_P (inner_mode))
new_reg = gen_rtx_SUBREG (mode, new_reg, 0);
else
new_reg = gen_lowpart_SUBREG (mode, new_reg);
}
*loc = new_reg;
return true;
}
/* Scan all the operand sub-expressions. */
fmt = GET_RTX_FORMAT (code);
for (i = GET_RTX_LENGTH (code) - 1; i >= 0; i--)
{
if (fmt[i] == 'e')
{
if (substitute_pseudo (&XEXP (x, i), old_regno, new_reg))
result = true;
}
else if (fmt[i] == 'E')
{
for (j = XVECLEN (x, i) - 1; j >= 0; j--)
if (substitute_pseudo (&XVECEXP (x, i, j), old_regno, new_reg))
result = true;
}
}
return result;
} | false | false | false | false | false | 0 |
rsa_key_check (struct rsa_secret_key_s *skey)
{
int err = 0;
gcry_mpi_t t = gcry_mpi_snew (0);
gcry_mpi_t t1 = gcry_mpi_snew (0);
gcry_mpi_t t2 = gcry_mpi_snew (0);
gcry_mpi_t phi = gcry_mpi_snew (0);
/* check that n == p * q */
gcry_mpi_mul (t, skey->p, skey->q);
if (gcry_mpi_cmp( t, skey->n) )
{
log_error ("RSA oops: n != p * q\n");
err++;
}
/* check that p is less than q */
if (gcry_mpi_cmp (skey->p, skey->q) > 0)
{
gcry_mpi_t tmp;
log_info ("swapping secret primes\n");
tmp = gcry_mpi_copy (skey->p);
gcry_mpi_set (skey->p, skey->q);
gcry_mpi_set (skey->q, tmp);
gcry_mpi_release (tmp);
/* and must recompute u of course */
gcry_mpi_invm (skey->u, skey->p, skey->q);
}
/* check that e divides neither p-1 nor q-1 */
gcry_mpi_sub_ui (t, skey->p, 1 );
gcry_mpi_div (NULL, t, t, skey->e, 0);
if (!gcry_mpi_cmp_ui( t, 0) )
{
log_error ("RSA oops: e divides p-1\n");
err++;
}
gcry_mpi_sub_ui (t, skey->q, 1);
gcry_mpi_div (NULL, t, t, skey->e, 0);
if (!gcry_mpi_cmp_ui( t, 0))
{
log_info ( "RSA oops: e divides q-1\n" );
err++;
}
/* check that d is correct. */
gcry_mpi_sub_ui (t1, skey->p, 1);
gcry_mpi_sub_ui (t2, skey->q, 1);
gcry_mpi_mul (phi, t1, t2);
gcry_mpi_invm (t, skey->e, phi);
if (gcry_mpi_cmp (t, skey->d))
{ /* no: try universal exponent. */
gcry_mpi_gcd (t, t1, t2);
gcry_mpi_div (t, NULL, phi, t, 0);
gcry_mpi_invm (t, skey->e, t);
if (gcry_mpi_cmp (t, skey->d))
{
log_error ("RSA oops: bad secret exponent\n");
err++;
}
}
/* check for correctness of u */
gcry_mpi_invm (t, skey->p, skey->q);
if (gcry_mpi_cmp (t, skey->u))
{
log_info ( "RSA oops: bad u parameter\n");
err++;
}
if (err)
log_info ("RSA secret key check failed\n");
gcry_mpi_release (t);
gcry_mpi_release (t1);
gcry_mpi_release (t2);
gcry_mpi_release (phi);
return err? -1:0;
} | false | false | false | false | false | 0 |
_print_pn_min_memory(job_info_t * job, int width, bool right_justify,
char* suffix)
{
char min_mem[10];
char tmp_char[21];
if (job == NULL) /* Print the Header instead */
_print_str("MIN_MEMORY", width, right_justify, true);
else {
tmp_char[0] = '\0';
job->pn_min_memory &= (~MEM_PER_CPU);
convert_num_unit((float)job->pn_min_memory, min_mem,
sizeof(min_mem), UNIT_NONE);
strcat(tmp_char, min_mem);
_print_str(tmp_char, width, right_justify, true);
}
if (suffix)
printf("%s", suffix);
return SLURM_SUCCESS;
} | false | false | false | false | false | 0 |
sodium_memcmp(const void * const b1_, const void * const b2_, size_t len)
{
const unsigned char *b1 = (const unsigned char *) b1_;
const unsigned char *b2 = (const unsigned char *) b2_;
size_t i;
unsigned char d = (unsigned char) 0U;
for (i = 0U; i < len; i++) {
d |= b1[i] ^ b2[i];
}
return (int) ((1 & ((d - 1) >> 8)) - 1);
} | false | false | false | false | false | 0 |
sdb_query_result_validate_field (SymbolDBQueryResult *result,
IAnjutaSymbolField field,
GError **err)
{
g_return_val_if_fail (err == NULL || *err == NULL, FALSE);
if (field >= IANJUTA_SYMBOL_FIELD_END)
{
g_set_error (err, SYMBOL_DB_QUERY_RESULT_ERROR,
SYMBOL_DB_QUERY_RESULT_ERROR_INVALID_FIELD,
"Invalid symbol query field '%d'. It should be less than '%d'",
field, IANJUTA_SYMBOL_FIELD_END);
g_warning ("Invalid symbol query field '%d'. It should be less than '%d'",
field, IANJUTA_SYMBOL_FIELD_END);
return FALSE;
}
if (result->priv->col_map [field] == -1)
{
g_set_error (err, SYMBOL_DB_QUERY_RESULT_ERROR,
SYMBOL_DB_QUERY_RESULT_ERROR_FIELD_NOT_PRESENT,
"Symbol field '%d' is not present in the query. Make sure to "
"include it during query creation.", field);
g_warning ("Symbol field '%d' is not present in the query. Make sure to "
"include it during query creation.", field);
return FALSE;
}
return TRUE;
} | false | false | false | false | false | 0 |
lam_ssi_coll_lam_basic_allreduce_inter(void *sbuf, void *rbuf, int count,
MPI_Datatype dtype, MPI_Op op,
MPI_Comm intercomm)
{
int local_rank, root;
MPI_Comm local_comm;
int is_low;
local_comm = intercomm->c_ssi_coll_lam_basic_data->local_comm;
is_low = intercomm->c_ssi_coll_lam_basic_data->is_low;
/* Do a intercommunicator Reduce and then do a local broadcast. This does
not need temporary buffer */
MPI_Comm_rank(intercomm, &local_rank);
if (is_low) {
/* Lower group */
root = (local_rank == 0) ? MPI_ROOT : MPI_PROC_NULL;
if (MPI_Reduce(sbuf, rbuf, count, dtype, op, root, intercomm)
!= MPI_SUCCESS) {
return LAMERROR;
}
root = 0;
if (MPI_Reduce(sbuf, rbuf, count, dtype, op, root, intercomm)
!= MPI_SUCCESS) {
return LAMERROR;
}
} else {
/* Higher group */
root = 0;
if (MPI_Reduce(sbuf, rbuf, count, dtype, op, root, intercomm)
!= MPI_SUCCESS) {
return LAMERROR;
}
root = (local_rank == 0) ? MPI_ROOT : MPI_PROC_NULL;
if (MPI_Reduce(sbuf, rbuf, count, dtype, op, root, intercomm)
!= MPI_SUCCESS) {
return LAMERROR;
}
}
/* Now Broadcast the result to all processes in the local comm */
if ((MPI_Bcast(rbuf, count, dtype, 0, local_comm)) != MPI_SUCCESS) {
return LAMERROR;
}
return MPI_SUCCESS;
} | false | false | false | false | false | 0 |
tcp_start(int port)
{
int ret;
struct sockaddr_in saddr;
int fd;
fd = socket(AF_INET, SOCK_STREAM, 0);
if (fd < 0) {
clog(CL_ERROR, "Create socket failed\n");
return -1;
}
set_server_socket(fd);
saddr.sin_family = AF_INET;
saddr.sin_addr.s_addr = htonl(INADDR_ANY);
saddr.sin_port = htons(port);
ret = bind(fd, (struct sockaddr *)&saddr, sizeof(saddr));
if (ret < 0) {
clog(CL_ERROR, "Bind to socket failed\n");
goto bad_fd;
}
ret = listen(fd, 5);
if (ret < 0) {
clog(CL_ERROR, "Listen on socket failed\n");
goto bad_fd;
}
return fd;
bad_fd:
close(fd);
return -1;
} | false | false | false | false | false | 0 |
JustReachedHome() override
{
if (m_pInstance)
{
if (Creature* pEmperor = m_pInstance->GetSingleCreatureFromStorage(NPC_EMPEROR))
{
// if evade, then check if he is alive. If not, start make portal
if (!pEmperor->IsAlive())
{
m_creature->CastSpell(m_creature, SPELL_OPEN_PORTAL, false);
}
}
}
} | false | false | false | false | false | 0 |
luaI_openlib(lua_State*L,const char*libname,
const luaL_Reg*l,int nup){
if(libname){
int size=libsize(l);
luaL_findtable(L,(-10000),"_LOADED",1);
lua_getfield(L,-1,libname);
if(!lua_istable(L,-1)){
lua_pop(L,1);
if(luaL_findtable(L,(-10002),libname,size)!=NULL)
luaL_error(L,"name conflict for module "LUA_QL("%s"),libname);
lua_pushvalue(L,-1);
lua_setfield(L,-3,libname);
}
lua_remove(L,-2);
lua_insert(L,-(nup+1));
}
for(;l->name;l++){
int i;
for(i=0;i<nup;i++)
lua_pushvalue(L,-nup);
lua_pushcclosure(L,l->func,nup);
lua_setfield(L,-(nup+2),l->name);
}
lua_pop(L,nup);
} | false | false | false | false | false | 0 |
is_send_from_grf()
{
switch (opcode) {
case SHADER_OPCODE_SHADER_TIME_ADD:
case VS_OPCODE_PULL_CONSTANT_LOAD_GEN7:
return true;
default:
return false;
}
} | false | false | false | false | false | 0 |
kfd_event_destroy(struct kfd_process *p, uint32_t event_id)
{
struct kfd_event *ev;
int ret = 0;
mutex_lock(&p->event_mutex);
ev = lookup_event_by_id(p, event_id);
if (ev)
destroy_event(p, ev);
else
ret = -EINVAL;
mutex_unlock(&p->event_mutex);
return ret;
} | false | false | false | false | false | 0 |
systemIdFilename(const StringC &systemId, StringC &filename)
{
if (systemId.size() == 0)
return -1;
Owner<InputSource> in(EntityManager->open(systemId,
*SystemCharset,
InputSourceOrigin::make(),
0,
*App));
if (!in)
return 0;
Xchar c = in->get(*App);
StorageObjectLocation soLoc;
ParsedSystemId parsedBuf;
if (c == InputSource::eE && in->accessError()) {
if (!EntityManager->parseSystemId(systemId, *SystemCharset, 0, 0, *App, parsedBuf))
return 0;
if (parsedBuf.size() != 1 || parsedBuf[0].baseId.size())
return 0;
soLoc.storageObjectSpec = &parsedBuf[0];
soLoc.actualStorageId = parsedBuf[0].specId;
}
else {
const Location &loc = in->currentLocation();
if (loc.origin().isNull())
return -1;
const InputSourceOrigin *tem = loc.origin()->asInputSourceOrigin();
if (!tem)
return -1;
const ParsedSystemId *psi
= ExtendEntityManager::externalInfoParsedSystemId(tem->externalInfo());
if (!psi || psi->size() != 1)
return -1;
if (!ExtendEntityManager::externalize(tem->externalInfo(), 0, soLoc))
return -1;
}
if (strcmp(soLoc.storageObjectSpec->storageManager->type(), "OSFILE") != 0)
return -1;
filename = soLoc.actualStorageId;
return 1;
} | false | false | false | false | false | 0 |
cmd_cd(const char *data)
{
char *str;
g_return_if_fail(data != NULL);
if (*data == '\0') return;
str = convert_home(data);
chdir(str);
g_free(str);
} | false | false | false | false | false | 0 |
ensure_bus_data (DBusConnection *connection)
{
BusData *bd;
if (!dbus_connection_allocate_data_slot (&bus_data_slot))
return NULL;
bd = dbus_connection_get_data (connection, bus_data_slot);
if (bd == NULL)
{
bd = dbus_new0 (BusData, 1);
if (bd == NULL)
{
dbus_connection_free_data_slot (&bus_data_slot);
return NULL;
}
bd->connection = connection;
if (!dbus_connection_set_data (connection, bus_data_slot, bd,
bus_data_free))
{
dbus_free (bd);
dbus_connection_free_data_slot (&bus_data_slot);
return NULL;
}
/* Data slot refcount now held by the BusData */
}
else
{
dbus_connection_free_data_slot (&bus_data_slot);
}
return bd;
} | false | false | false | false | false | 0 |
bind_transfer_to_peer (FileteaNode *self, EvdPeer *peer, FileTransfer *transfer)
{
GQueue *peer_transfers;
peer_transfers = g_hash_table_lookup (self->priv->transfers_by_peer, peer);
if (peer_transfers == NULL)
{
peer_transfers = g_queue_new ();
g_hash_table_insert (self->priv->transfers_by_peer, peer, peer_transfers);
}
g_queue_push_head (peer_transfers, transfer);
} | false | false | false | false | false | 0 |
write_state_files_list (void)
{
int i = 0;
/* Write the list of files with their lang_bitmap. */
fprintf (state_file, "\n(!fileslist %d\n", (int) num_gt_files);
for (i = 0; i < (int) num_gt_files; i++)
{
const char *cursrcrelpath = NULL;
const input_file *curfil = gt_files[i];
/* Most of the files are inside $(srcdir) so it is worth to
handle them specially. */
cursrcrelpath = get_file_srcdir_relative_path (curfil);
if (cursrcrelpath)
{
fprintf (state_file, "(!srcfile %d ", get_lang_bitmap (curfil));
write_state_a_string (cursrcrelpath);
}
else
{
fprintf (state_file, "(!file %d ", get_lang_bitmap (curfil));
write_state_a_string (get_input_file_name (curfil));
}
fprintf (state_file, ")\n");
}
fprintf (state_file, ")\n");
} | false | false | false | false | false | 0 |
ata_sas_port_init(struct ata_port *ap)
{
int rc = ap->ops->port_start(ap);
if (rc)
return rc;
ap->print_id = atomic_inc_return(&ata_print_id);
return 0;
} | false | false | false | false | false | 0 |
print(iter_type f, iter_type l)
{
for (iter_type i = f; i != l; ++i)
print(*i);
} | false | false | false | false | false | 0 |
handle_trickle(MSG_FROM_HOST& mfh) {
int retval;
printf(
"got trickle-up \n%s\n\n",
mfh.xml
);
DB_MSG_TO_HOST mth;
mth.clear();
mth.create_time = time(0);
mth.hostid = mfh.hostid;
safe_strcpy(mth.variety, mfh.variety);
mth.handled = false;
sprintf(mth.xml,
"<trickle_down>\n"
"%s"
"</trickle_down>\n",
mfh.xml
);
retval = mth.insert();
if (retval) {
printf("insert failed: %s\n", boincerror(retval));
}
return 0;
} | false | false | false | false | false | 0 |
real_arithmetic (REAL_VALUE_TYPE *r, int icode, const REAL_VALUE_TYPE *op0,
const REAL_VALUE_TYPE *op1)
{
enum tree_code code = (enum tree_code) icode;
if (op0->decimal || (op1 && op1->decimal))
return decimal_real_arithmetic (r, code, op0, op1);
switch (code)
{
case PLUS_EXPR:
/* Clear any padding areas in *r if it isn't equal to one of the
operands so that we can later do bitwise comparisons later on. */
if (r != op0 && r != op1)
memset (r, '\0', sizeof (*r));
return do_add (r, op0, op1, 0);
case MINUS_EXPR:
if (r != op0 && r != op1)
memset (r, '\0', sizeof (*r));
return do_add (r, op0, op1, 1);
case MULT_EXPR:
if (r != op0 && r != op1)
memset (r, '\0', sizeof (*r));
return do_multiply (r, op0, op1);
case RDIV_EXPR:
if (r != op0 && r != op1)
memset (r, '\0', sizeof (*r));
return do_divide (r, op0, op1);
case MIN_EXPR:
if (op1->cl == rvc_nan)
*r = *op1;
else if (do_compare (op0, op1, -1) < 0)
*r = *op0;
else
*r = *op1;
break;
case MAX_EXPR:
if (op1->cl == rvc_nan)
*r = *op1;
else if (do_compare (op0, op1, 1) < 0)
*r = *op1;
else
*r = *op0;
break;
case NEGATE_EXPR:
*r = *op0;
r->sign ^= 1;
break;
case ABS_EXPR:
*r = *op0;
r->sign = 0;
break;
case FIX_TRUNC_EXPR:
do_fix_trunc (r, op0);
break;
default:
gcc_unreachable ();
}
return false;
} | false | false | false | false | false | 0 |
min_max(PyObject *args, PyObject *kwds, int op)
{
PyObject *v, *it, *item, *val, *maxitem, *maxval, *keyfunc=NULL;
const char *name = op == Py_LT ? "min" : "max";
if (PyTuple_Size(args) > 1)
v = args;
else if (!PyArg_UnpackTuple(args, (char *)name, 1, 1, &v))
return NULL;
if (kwds != NULL && PyDict_Check(kwds) && PyDict_Size(kwds)) {
keyfunc = PyDict_GetItemString(kwds, "key");
if (PyDict_Size(kwds)!=1 || keyfunc == NULL) {
PyErr_Format(PyExc_TypeError,
"%s() got an unexpected keyword argument", name);
return NULL;
}
Py_INCREF(keyfunc);
}
it = PyObject_GetIter(v);
if (it == NULL) {
Py_XDECREF(keyfunc);
return NULL;
}
maxitem = NULL; /* the result */
maxval = NULL; /* the value associated with the result */
while (( item = PyIter_Next(it) )) {
/* get the value from the key function */
if (keyfunc != NULL) {
val = PyObject_CallFunctionObjArgs(keyfunc, item, NULL);
if (val == NULL)
goto Fail_it_item;
}
/* no key function; the value is the item */
else {
val = item;
Py_INCREF(val);
}
/* maximum value and item are unset; set them */
if (maxval == NULL) {
maxitem = item;
maxval = val;
}
/* maximum value and item are set; update them as necessary */
else {
int cmp = PyObject_RichCompareBool(val, maxval, op);
if (cmp < 0)
goto Fail_it_item_and_val;
else if (cmp > 0) {
Py_DECREF(maxval);
Py_DECREF(maxitem);
maxval = val;
maxitem = item;
}
else {
Py_DECREF(item);
Py_DECREF(val);
}
}
}
if (PyErr_Occurred())
goto Fail_it;
if (maxval == NULL) {
PyErr_Format(PyExc_ValueError,
"%s() arg is an empty sequence", name);
assert(maxitem == NULL);
}
else
Py_DECREF(maxval);
Py_DECREF(it);
Py_XDECREF(keyfunc);
return maxitem;
Fail_it_item_and_val:
Py_DECREF(val);
Fail_it_item:
Py_DECREF(item);
Fail_it:
Py_XDECREF(maxval);
Py_XDECREF(maxitem);
Py_DECREF(it);
Py_XDECREF(keyfunc);
return NULL;
} | false | false | false | false | false | 0 |
Curses_clear_window(Window * window)
{
int y, x;
if (!inited)
return 1;
for (y = window->top + 1; y < window->bottom; y++) {
move(y, x = window->left + 1);
while (x++ < window->right)
addch(' ');
}
Curses_outline_window(window);
refresh();
return 0;
} | false | false | false | false | false | 0 |
brcmf_ops_sdio_resume(struct device *dev)
{
struct brcmf_bus *bus_if = dev_get_drvdata(dev);
struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
struct sdio_func *func = container_of(dev, struct sdio_func, dev);
brcmf_dbg(SDIO, "Enter: F%d\n", func->num);
if (func->num != SDIO_FUNC_2)
return 0;
brcmf_sdiod_freezer_off(sdiodev);
return 0;
} | false | false | false | false | false | 0 |
dlm_callback_work(struct work_struct *work)
{
struct dlm_lkb *lkb = container_of(work, struct dlm_lkb, lkb_cb_work);
struct dlm_ls *ls = lkb->lkb_resource->res_ls;
void (*castfn) (void *astparam);
void (*bastfn) (void *astparam, int mode);
struct dlm_callback callbacks[DLM_CALLBACKS_SIZE];
int i, rv, resid;
memset(&callbacks, 0, sizeof(callbacks));
mutex_lock(&lkb->lkb_cb_mutex);
if (!lkb->lkb_callbacks[0].seq) {
/* no callback work exists, shouldn't happen */
log_error(ls, "dlm_callback_work %x no work", lkb->lkb_id);
dlm_print_lkb(lkb);
dlm_dump_lkb_callbacks(lkb);
}
for (i = 0; i < DLM_CALLBACKS_SIZE; i++) {
rv = dlm_rem_lkb_callback(ls, lkb, &callbacks[i], &resid);
if (rv < 0)
break;
}
if (resid) {
/* cbs remain, loop should have removed all, shouldn't happen */
log_error(ls, "dlm_callback_work %x resid %d", lkb->lkb_id,
resid);
dlm_print_lkb(lkb);
dlm_dump_lkb_callbacks(lkb);
}
mutex_unlock(&lkb->lkb_cb_mutex);
castfn = lkb->lkb_astfn;
bastfn = lkb->lkb_bastfn;
for (i = 0; i < DLM_CALLBACKS_SIZE; i++) {
if (!callbacks[i].seq)
break;
if (callbacks[i].flags & DLM_CB_SKIP) {
continue;
} else if (callbacks[i].flags & DLM_CB_BAST) {
bastfn(lkb->lkb_astparam, callbacks[i].mode);
} else if (callbacks[i].flags & DLM_CB_CAST) {
lkb->lkb_lksb->sb_status = callbacks[i].sb_status;
lkb->lkb_lksb->sb_flags = callbacks[i].sb_flags;
castfn(lkb->lkb_astparam);
}
}
/* undo kref_get from dlm_add_callback, may cause lkb to be freed */
dlm_put_lkb(lkb);
} | false | false | false | false | false | 0 |
pdb_decode_acct_ctrl(const char *p)
{
int acct_ctrl = 0;
int done = 0;
/*
* Check if the account type bits have been encoded after the
* NT password (in the form [NDHTUWSLXI]).
*/
if (*p != '[') return 0;
for (p++; *p && !done; p++) {
switch (*p) {
case 'N': /* 'N'o password. */
acct_ctrl |= ACB_PWNOTREQ;
break;
case 'D': /* 'D'isabled. */
acct_ctrl |= ACB_DISABLED ;
break;
case 'H': /* 'H'omedir required. */
acct_ctrl |= ACB_HOMDIRREQ;
break;
case 'T': /* 'T'emp account. */
acct_ctrl |= ACB_TEMPDUP;
break;
case 'U': /* 'U'ser account (normal). */
acct_ctrl |= ACB_NORMAL;
break;
case 'M': /* 'M'NS logon user account. What is this? */
acct_ctrl |= ACB_MNS;
break;
case 'W': /* 'W'orkstation account. */
acct_ctrl |= ACB_WSTRUST;
break;
case 'S': /* 'S'erver account. */
acct_ctrl |= ACB_SVRTRUST;
break;
case 'L': /* 'L'ocked account. */
acct_ctrl |= ACB_AUTOLOCK;
break;
case 'X': /* No 'X'piry on password */
acct_ctrl |= ACB_PWNOEXP;
break;
case 'I': /* 'I'nterdomain trust account. */
acct_ctrl |= ACB_DOMTRUST;
break;
case 'e': /* 'e'xpired, the password has */
acct_ctrl |= ACB_PW_EXPIRED;
break;
case ' ': /* ignore spaces */
break;
case ':':
case '\n':
case '\0':
case ']':
default:
done = 1;
break;
}
}
return acct_ctrl;
} | false | false | false | false | false | 0 |
clear(void)
{
set(INVALID, "", "");
myIntType = INT_NOT;
myOwnPointedTo = false;
if (myOwnPointedTo && myIntPointer != NULL)
delete myIntPointer;
myIntPointer = NULL;
if (myOwnPointedTo && myIntShortPointer != NULL)
delete myIntShortPointer;
myIntShortPointer = NULL;
if (myOwnPointedTo && myIntUnsignedShortPointer != NULL)
delete myIntUnsignedShortPointer;
myIntUnsignedShortPointer = NULL;
if (myOwnPointedTo && myIntUnsignedCharPointer != NULL)
delete myIntUnsignedCharPointer;
myIntUnsignedCharPointer = NULL;
if (myOwnPointedTo && myDoublePointer != NULL)
delete myDoublePointer;
myDoublePointer = NULL;
if (myOwnPointedTo && myBoolPointer != NULL)
delete myBoolPointer;
myBoolPointer = NULL;
myStringPointer = NULL;
myUsingOwnedString = false;
myString = "";
myMinInt = INT_MIN;
myMaxInt = INT_MAX;
myMinDouble = -HUGE_VAL;
myMaxDouble = HUGE_VAL;
myMaxStrLen = 0;
mySetFunctor = NULL;
myGetFunctor = NULL;
myConfigPriority = ArPriority::NORMAL;
myIgnoreBounds = false;
myDisplayHint = "";
myValueSet = false;
} | false | false | false | false | false | 0 |
brasero_volume_finalize (GObject *object)
{
BraseroVolumePrivate *priv;
priv = BRASERO_VOLUME_PRIVATE (object);
BRASERO_MEDIA_LOG ("Finalizing Volume object");
if (priv->cancel) {
g_cancellable_cancel (priv->cancel);
g_object_unref (priv->cancel);
priv->cancel = NULL;
}
G_OBJECT_CLASS (brasero_volume_parent_class)->finalize (object);
} | false | false | false | false | false | 0 |
remove_custom_shortcut (GtkTreeModel *model, GtkTreeIter *iter)
{
CcKeyboardItem *item;
GPtrArray *keys_array;
GVariantBuilder builder;
char **settings_paths;
int i;
gtk_tree_model_get (model, iter,
DETAIL_KEYENTRY_COLUMN, &item,
-1);
/* not a custom shortcut */
g_assert (item->type == CC_KEYBOARD_ITEM_TYPE_GSETTINGS_PATH);
g_settings_delay (item->settings);
g_settings_reset (item->settings, "name");
g_settings_reset (item->settings, "command");
g_settings_reset (item->settings, "binding");
g_settings_apply (item->settings);
g_settings_sync ();
settings_paths = g_settings_get_strv (binding_settings, "custom-keybindings");
g_variant_builder_init (&builder, G_VARIANT_TYPE ("as"));
for (i = 0; settings_paths[i]; i++)
if (strcmp (settings_paths[i], item->gsettings_path) != 0)
g_variant_builder_add (&builder, "s", settings_paths[i]);
g_settings_set_value (binding_settings,
"custom-keybindings", g_variant_builder_end (&builder));
g_strfreev (settings_paths);
g_object_unref (item);
keys_array = g_hash_table_lookup (get_hash_for_group (BINDING_GROUP_USER), CUSTOM_SHORTCUTS_ID);
g_ptr_array_remove (keys_array, item);
gtk_list_store_remove (GTK_LIST_STORE (model), iter);
return TRUE;
} | false | false | false | false | false | 0 |
addcheckresult(int rc, char type, char *param, int total,
int warn, int crit, int min, int max) {
struct checkresult *res=malloc(sizeof(struct checkresult)), *temp;
res->rc=rc;
res->checktype=type;
res->checkoption=strdup(param);
res->value=total;
res->warn=warn;
res->crit=crit;
res->min=min;
res->max=max;
res->next=NULL;
if (head==NULL)
head=res;
else {
temp=head;
while (temp->next)
temp=temp->next;
temp->next=res;
}
if (rc>exitcode)
exitcode=rc;
} | false | false | false | false | false | 0 |
write_player_track(track) {
register unsigned int iteration;
playerCount = track;
memset(melop, 0, MAX_RECURSION*2);
if(!globalWritten) {
if(!mf_write_meta_event(0, copyright_notice, copyright, strlen(copyright))) {
fprintf(stderr, "Error writing midi file!\n");
return -1;
}
mf_write_tempo((long)60000000/tempo);
globalWritten++;
}
prev_duration=0;
if(!debugOption)
printf("Player %s is generating...\n", players[playerCount]->identifier);
players[playerCount]->num?(data[0]=players[playerCount]->num):(data[0]=glob_num);
players[playerCount]->den?(data[1]=log10(players[playerCount]->den)/log10(2)):(data[1]=log10(glob_den)/log10(2));
data[2]=24;
data[3]=8;
if(!mf_write_meta_event(0, time_signature, data, 4)) {
fprintf(stderr, "Error writing midi file!\n");
return -1;
}
players[playerCount]->local_params[DEFINSTR]?(data[0]=players[playerCount]->local_params[DEFINSTR]):(data[0]=global_params[DEFINSTR]);
if(!mf_write_midi_event(0, program_chng, players[playerCount]->local_params[CHN], data, 1)) {
fprintf(stderr, "Error writing midi file!\n");
return -1;
}
players[playerCount]->iterations?(iteration=players[playerCount]->iterations):(iteration=global_iterations);
switch(players[playerCount]->grammar) {
case 1:
if(debugOption)
print_local_params(playerCount); //debug
chomsky_generator(hash("@composition", 0), 0);
break;
case 2:
if(debugOption)
print_local_params(playerCount); //debug
lindenmayer_generator(hash("axiom", 0), iteration);
break;
default:
if(debugOption)
print_local_params(playerCount); //debug
switch(grammarOption) {
case 1:
chomsky_generator(hash("@composition", 0), 0);
break;
case 2:
lindenmayer_generator(hash("axiom", 0), iteration);
}
}
if(!debugOption)
printf("\n...ok\n");
return 1;
} | false | false | false | false | false | 0 |
init_layer3_gainpow2_mmx(mpg123_handle *fr, int i)
{
if(!fr->p.down_sample) return DOUBLE_TO_REAL(16384.0 * pow((double)2.0,-0.25 * (double) (i+210) ));
else return DOUBLE_TO_REAL(pow((double)2.0,-0.25 * (double) (i+210)));
} | false | false | false | false | false | 0 |
parseAttributes(int p0, NodePtr node, bool *quickClose)
{
*quickClose = false;
int p = p0;
NamedNodeMap attributes;
while (p<len)
{
/*printf("ch:%c\n",ch);*/
p = skipwhite(p);
int ch = get(p);
/*printf("ch:%c\n",ch);*/
if (ch == '?' || ch == '>')//done
break;
else if (ch=='/' && p<len+1)
{
p++;
p = skipwhite(p);
ch = peek(p);
if (ch == '>')
{
p++;
*quickClose = true;
/*printf("quick close\n");*/
return p;
}
}
DOMString shortName;
DOMString prefix;
DOMString qualifiedName;
int p2 = getPrefixedWord(p, prefix, shortName, qualifiedName);
if (p2 <= p)
break;
/*printf("name:%s",buf);*/
p = p2;
p = skipwhite(p);
ch = get(p);
/*printf("ch:%c\n",ch);*/
if (ch != '=')
break;
p++;
p = skipwhite(p);
/*ch = parsebuf[p];*/
/*printf("ch:%c\n",ch);*/
DOMString attrValue;
p2 = getQuoted(p, attrValue);
p = p2;
/*printf("name:'%s' value:'%s'\n",buf,buf2);*/
DOMString namespaceURI = "";
if (prefix == "xmlns" || shortName == "xmlns")
namespaceURI = XMLNSNAME;
//## Now let us make the attribute and give it to the node
AttrPtr attr = document->createAttributeNS(namespaceURI, qualifiedName);
attr->setValue(attrValue);
node->getAttributes().setNamedItemNS(attr);
}//while p<len
return p;
} | false | false | false | false | false | 0 |
doDuties()
{
SPtr<TIfaceIface> iface = ClntIfaceMgr().getIfaceByID(this->Iface);
if (!MRD)
{
ostringstream iaLst;
ostringstream pdLst;
SPtr<TOpt> ptrOpt;
firstOption();
while(ptrOpt=getOption())
{
switch( ptrOpt->getOptType()) {
case OPTION_IA_NA:
{
SPtr<TClntOptIA_NA> ptrIA=(Ptr*)ptrOpt;
iaLst << ptrIA->getIAID() << " ";
releaseIA(ptrIA->getIAID());
break;
}
case OPTION_IA_PD:
{
SPtr<TClntOptIA_PD> ptrPD = (Ptr*)ptrOpt;
ptrPD->setContext(0, 0, this);
ptrPD->delPrefixes();
break;
}
};
}
Log(Warning) << "REBIND for the IA(s):" << iaLst.str()
<< ", PD(s):" << pdLst.str()
<< " failed on the " << iface->getFullName()
<< " interface." << LogEnd;
Log(Warning) << "Restarting server discovery process." << LogEnd;
IsDone=true;
}
else
this->send();
} | false | false | false | false | false | 0 |
rehash(Hashtable *old, unsigned long size, Memman *treespace) {
/* Construct a new hash table out of an old one, using same buckets */
unsigned long i, magic;
Hashindex *p, *nextp;
Hashtable *ans;
char *c;
if (treespace != NULL && size * sizeof(Hashindex *) < BLOCKSIZE) {
ans = (Hashtable *)submalloc(treespace, sizeof(Hashtable));
ans->head = (Hashindex **)submalloc(treespace, size * sizeof(Hashindex *));
}
else {
ans = (Hashtable *)xmalloc(sizeof(Hashtable));
ans->head = (Hashindex **)xmalloc(size * sizeof(Hashindex *));
}
ans->size = size;
ans->n = 0;
for (i = 0; i < size; i++)
ans->head[i] = NULL;
if (old != NULL) {
if (treespace != NULL) /* i.e. is tree */
ans->head[0] = old->head[0];
for (i = (unsigned long)(treespace != NULL); i < old->size; i++) {
/* run through items in old table */
for (p = old->head[i]; p != NULL; p = nextp) {
nextp = p->next; /* rehash p into new table */
if (treespace != NULL) {
c = strchr(p->name, '\0');
MAGICNOTREE(magic, p->name, c, size);
}
else
MAGICNO(magic, p->name, size);
p->next = ans->head[magic];
ans->head[magic] = p;
ans->n++;
}
}
if (treespace == NULL || old->size * sizeof(Hashindex *) >= BLOCKSIZE) {
/* free old table, if originally xmalloc'ed */
free((void *)(old->head));
free((void *)old);
}
}
return(ans);
} | false | false | false | false | false | 0 |
coverage() const throw ()
{
if (_d[1] == 3)
return Coverage(_d.offset_subtable(F3_HSIZE), 0, false);
else
return Coverage();
} | false | false | false | false | false | 0 |
open_tsfile(job_rec *jr)
/* Open the timestamp file for job jr */
{
jr->timestamp_fd = open(jr->ident, O_RDWR | O_CREAT, S_IRUSR | S_IWUSR);
if (jr->timestamp_fd == -1)
die_e("Can't open timestamp file for job %s", jr->ident);
fcntl(jr->timestamp_fd, F_SETFD, 1); /* set close-on-exec flag */
/* We want to own this file, and set its mode to 0600. This is necessary
* in order to prevent other users from putting locks on it. */
if (fchown(jr->timestamp_fd, getuid(), getgid()))
die_e("Can't chown timestamp file %s", jr->ident);
if (fchmod(jr->timestamp_fd, S_IRUSR | S_IWUSR))
die_e("Can't chmod timestamp file %s", jr->ident);
} | false | false | false | false | false | 0 |
DumpLSRSendEvent(GF_SceneDumper *sdump, GF_Command *com)
{
char szID[1024];
char *lsrns = sd_get_lsr_namespace(com->in_scene);
DUMP_IND(sdump);
fprintf(sdump->trace, "<%sSendEvent ref=\"%s\" event=\"%s\"", lsrns,
lsr_format_node_id(com->node, com->RouteID, szID),
gf_dom_event_get_name(com->send_event_name)
);
if (com->send_event_name <= GF_EVENT_MOUSEWHEEL)
fprintf(sdump->trace, " pointvalue=\"%g %g\"", FIX2FLT(com->send_event_x), FIX2FLT(com->send_event_y) );
switch (com->send_event_name) {
case GF_EVENT_KEYDOWN:
case GF_EVENT_LONGKEYPRESS:
case GF_EVENT_REPEAT_KEY:
case GF_EVENT_SHORT_ACCESSKEY:
if (com->send_event_integer) {
fprintf(sdump->trace, " stringvalue=\"%s\"", gf_dom_get_key_name(com->send_event_integer) );
break;
}
default:
if (com->send_event_integer)
fprintf(sdump->trace, " intvalue=\"%d\"", com->send_event_integer);
if (com->send_event_string)
fprintf(sdump->trace, " stringvalue=\"%s\"", com->send_event_string);
break;
}
fprintf(sdump->trace, "/>\n");
return GF_OK;
} | true | true | false | false | false | 1 |
knh_Bytes_ensureZero(CTX ctx, kBytes *ba)
{
size_t size = BA_size(ba);
size_t capacity = ba->dim->capacity;
if(size == capacity) {
knh_Bytes_expands(ctx, ba, k_grow(capacity));
}
ba->bu.ubuf[BA_size(ba)] = 0;
return ba->bu.text;
} | false | false | false | false | false | 0 |
stringToFrameImageComponent(const String& str)
{
if (str == "TopLeftCorner")
{
return FIC_TOP_LEFT_CORNER;
}
if (str == "TopRightCorner")
{
return FIC_TOP_RIGHT_CORNER;
}
if (str == "BottomLeftCorner")
{
return FIC_BOTTOM_LEFT_CORNER;
}
if (str == "BottomRightCorner")
{
return FIC_BOTTOM_RIGHT_CORNER;
}
if (str == "LeftEdge")
{
return FIC_LEFT_EDGE;
}
if (str == "RightEdge")
{
return FIC_RIGHT_EDGE;
}
if (str == "TopEdge")
{
return FIC_TOP_EDGE;
}
if (str == "BottomEdge")
{
return FIC_BOTTOM_EDGE;
}
else
{
return FIC_BACKGROUND;
}
} | false | false | false | false | false | 0 |
em28xx_dvb_fini(struct em28xx *dev)
{
struct em28xx_dvb *dvb;
struct i2c_client *client;
if (dev->is_audio_only) {
/* Shouldn't initialize IR for this interface */
return 0;
}
if (!dev->board.has_dvb) {
/* This device does not support the extension */
return 0;
}
if (!dev->dvb)
return 0;
em28xx_info("Closing DVB extension\n");
dvb = dev->dvb;
em28xx_uninit_usb_xfer(dev, EM28XX_DIGITAL_MODE);
if (dev->disconnected) {
/* We cannot tell the device to sleep
* once it has been unplugged. */
if (dvb->fe[0]) {
prevent_sleep(&dvb->fe[0]->ops);
dvb->fe[0]->exit = DVB_FE_DEVICE_REMOVED;
}
if (dvb->fe[1]) {
prevent_sleep(&dvb->fe[1]->ops);
dvb->fe[1]->exit = DVB_FE_DEVICE_REMOVED;
}
}
/* remove I2C SEC */
client = dvb->i2c_client_sec;
if (client) {
module_put(client->dev.driver->owner);
i2c_unregister_device(client);
}
/* remove I2C tuner */
client = dvb->i2c_client_tuner;
if (client) {
module_put(client->dev.driver->owner);
i2c_unregister_device(client);
}
/* remove I2C demod */
client = dvb->i2c_client_demod;
if (client) {
module_put(client->dev.driver->owner);
i2c_unregister_device(client);
}
em28xx_unregister_dvb(dvb);
kfree(dvb);
dev->dvb = NULL;
kref_put(&dev->ref, em28xx_free_device);
return 0;
} | false | false | false | false | false | 0 |
send_join_packet(net_addr* addr,join_request *jr)
{
ubyte data[MAX_PACKET_SIZE];
int packet_size;
// build the header and add the request
BUILD_HEADER(JOIN);
add_join_request(data, &packet_size, jr);
psnet_send(addr, data, packet_size);
} | false | false | false | false | false | 0 |
genConvert(VnCharset & incs, VnCharset & outcs, ByteInStream & input, ByteOutStream & output)
{
StdVnChar stdChar;
int bytesRead, bytesWritten;
incs.startInput();
outcs.startOutput();
int ret = 1;
while (!input.eos()) {
stdChar = 0;
if (incs.nextInput(input, stdChar, bytesRead)) {
if (stdChar != INVALID_STD_CHAR) {
if (VnCharsetLibObj.m_options.toLower)
stdChar = StdVnToLower(stdChar);
else if (VnCharsetLibObj.m_options.toUpper)
stdChar = StdVnToUpper(stdChar);
if (VnCharsetLibObj.m_options.removeTone)
stdChar = StdVnGetRoot(stdChar);
ret = outcs.putChar(output, stdChar, bytesWritten);
}
}
else break;
}
return (ret? 0 : VNCONV_OUT_OF_MEMORY);
} | false | false | false | false | false | 0 |
dmi_sel_raw_read_io(struct dmi_sysfs_entry *entry,
const struct dmi_system_event_log *sel,
char *buf, loff_t pos, size_t count)
{
ssize_t wrote = 0;
sel_io_reader io_reader = sel_io_readers[sel->access_method];
while (count && pos < sel->area_length) {
count--;
*(buf++) = io_reader(sel, pos++);
wrote++;
}
return wrote;
} | false | false | false | false | false | 0 |
diagram_lua_new_from_array(lua_State *L)
{
GtDiagram **diagram;
GtArray *nodes;
GtRange range;
GtStyle *style;
/* get array */
nodes = genome_node_table_to_array(L);
/* get range */
range.start = luaL_checklong(L, 2);
range.end = luaL_checklong(L, 3);
luaL_argcheck(L, range.start > 0, 2, "must be > 0");
luaL_argcheck(L, range.end > 0, 3, "must be > 0");
luaL_argcheck(L, range.start <= range.end, 2, "must be <= endpos");
/* create diagram */
style = gt_lua_get_style_from_registry(L);
diagram = lua_newuserdata(L, sizeof (GtDiagram*));
gt_assert(diagram);
*diagram = gt_diagram_new_from_array(nodes, &range, style);
gt_array_delete(nodes);
luaL_getmetatable(L, DIAGRAM_METATABLE);
lua_setmetatable(L, -2);
return 1;
} | false | false | false | false | false | 0 |
ensMapperunitNewCpy(const EnsPMapperunit mu)
{
EnsPMapperunit pthis = NULL;
if (!mu)
return NULL;
AJNEW0(pthis);
pthis->Objectidentifier = mu->Objectidentifier;
pthis->Start = mu->Start;
pthis->End = mu->End;
pthis->Use = 1U;
return pthis;
} | false | false | false | false | false | 0 |
BK_hess_project(S,B,x)
struct linsys *S; /* factored and constrained system */
REAL *B; /* incoming vector */
REAL *x; /* solution, may be incoming */
{ REAL *T1,*T2,*T3;
int i;
if ( S->CN == 0 ) return;
T1 = (REAL *)temp_calloc(2*S->CN+S->N,sizeof(REAL));
T2 = T1 + S->CN;
T3 = T2 + S->CN;
sp_aug_solve(S,B,NULL,T1,T2,T3);
for ( i = 0 ; i < S->N ; i++ )
x[i] = B[i] - T3[i];
temp_free((char*)T1);
} | false | false | false | false | false | 0 |
shmem_mapping(struct address_space *mapping)
{
if (!mapping->host)
return false;
return mapping->host->i_sb->s_op == &shmem_ops;
} | false | false | false | false | false | 0 |
unit_duplicate( Unit *unit )
{
Unit *new = calloc(1,sizeof(Unit));
memcpy(new,unit,sizeof(Unit));
unit_set_generic_name(new, units->count + 1, unit->prop.name);
if (unit->sel_prop==&unit->prop)
new->sel_prop=&new->prop;
else
new->sel_prop=&new->trsp_prop;
new->backup = calloc( 1, sizeof( Unit ) );
/* terrain can't be updated here */
return new;
} | false | false | false | false | false | 0 |
ec_GFp_mont_group_set_curve(EC_GROUP *group, const BIGNUM *p, const BIGNUM *a, const BIGNUM *b, BN_CTX *ctx)
{
BN_CTX *new_ctx = NULL;
BN_MONT_CTX *mont = NULL;
BIGNUM *one = NULL;
int ret = 0;
if (group->field_data1 != NULL)
{
BN_MONT_CTX_free(group->field_data1);
group->field_data1 = NULL;
}
if (group->field_data2 != NULL)
{
BN_free(group->field_data2);
group->field_data2 = NULL;
}
if (ctx == NULL)
{
ctx = new_ctx = BN_CTX_new();
if (ctx == NULL)
return 0;
}
mont = BN_MONT_CTX_new();
if (mont == NULL) goto err;
if (!BN_MONT_CTX_set(mont, p, ctx))
{
ECerr(EC_F_EC_GFP_MONT_GROUP_SET_CURVE, ERR_R_BN_LIB);
goto err;
}
one = BN_new();
if (one == NULL) goto err;
if (!BN_to_montgomery(one, BN_value_one(), mont, ctx)) goto err;
group->field_data1 = mont;
mont = NULL;
group->field_data2 = one;
one = NULL;
ret = ec_GFp_simple_group_set_curve(group, p, a, b, ctx);
if (!ret)
{
BN_MONT_CTX_free(group->field_data1);
group->field_data1 = NULL;
BN_free(group->field_data2);
group->field_data2 = NULL;
}
err:
if (new_ctx != NULL)
BN_CTX_free(new_ctx);
if (mont != NULL)
BN_MONT_CTX_free(mont);
return ret;
} | false | false | false | false | false | 0 |
select( int sel_start, int sel_end ) const
{
QList<LineChunk> list;
if ( ( sel_start < start_ ) && ( sel_end < start_ ) ) {
// Selection BEFORE this chunk: no change
list << LineChunk( *this );
}
else if ( sel_start > end_ ) {
// Selection AFTER this chunk: no change
list << LineChunk( *this );
}
else /* if ( ( sel_start >= start_ ) && ( sel_end <= end_ ) ) */
{
// We only want to consider what's inside THIS chunk
sel_start = qMax( sel_start, start_ );
sel_end = qMin( sel_end, end_ );
if ( sel_start > start_ )
list << LineChunk( start_, sel_start - 1, type_ );
list << LineChunk( sel_start, sel_end, Selected );
if ( sel_end < end_ )
list << LineChunk( sel_end + 1, end_, type_ );
}
return list;
} | false | false | false | false | false | 0 |
clone_payload(const unsigned char *pkt_ptr, size_t bytes_left) {
struct isakmp_generic hdr;
unsigned char *clone_ptr;
size_t payload_len;
/*
* Ensure that there is sufficient data to fill the generic
* header.
*/
if (bytes_left < sizeof(struct isakmp_generic)) {
return NULL;
}
/*
* Fill in the generic header from the packet. We must do this
* by copying rather than overlaying because we cannot be sure
* that "pkt_ptr" is suitably aligned.
*/
memcpy(&hdr, pkt_ptr, sizeof(hdr));
/*
* Determine the length of the payload.
*/
payload_len = ntohs(hdr.isag_length);
if (payload_len > bytes_left)
payload_len = bytes_left;
/*
* Allocate memory and copy payload.
*/
clone_ptr = Malloc(payload_len);
memcpy(clone_ptr, pkt_ptr, payload_len);
return clone_ptr;
} | false | false | false | false | false | 0 |
vlv_psr_disable(struct intel_dp *intel_dp)
{
struct intel_digital_port *intel_dig_port = dp_to_dig_port(intel_dp);
struct drm_device *dev = intel_dig_port->base.base.dev;
struct drm_i915_private *dev_priv = dev->dev_private;
struct intel_crtc *intel_crtc =
to_intel_crtc(intel_dig_port->base.base.crtc);
uint32_t val;
if (dev_priv->psr.active) {
/* Put VLV PSR back to PSR_state 0 that is PSR Disabled. */
if (wait_for((I915_READ(VLV_PSRSTAT(intel_crtc->pipe)) &
VLV_EDP_PSR_IN_TRANS) == 0, 1))
WARN(1, "PSR transition took longer than expected\n");
val = I915_READ(VLV_PSRCTL(intel_crtc->pipe));
val &= ~VLV_EDP_PSR_ACTIVE_ENTRY;
val &= ~VLV_EDP_PSR_ENABLE;
val &= ~VLV_EDP_PSR_MODE_MASK;
I915_WRITE(VLV_PSRCTL(intel_crtc->pipe), val);
dev_priv->psr.active = false;
} else {
WARN_ON(vlv_is_psr_active_on_pipe(dev, intel_crtc->pipe));
}
} | false | false | false | false | false | 0 |
FDKaacEnc_CalcAutoCorrValue(
const FIXP_DBL *spectrum,
const INT startLine,
const INT stopLine,
const INT lag,
const INT scale
)
{
int i;
FIXP_DBL result = FL2FXCONST_DBL(0.f);
if (lag==0) {
for (i=startLine; i<stopLine; i++) {
result += (fPow2(spectrum[i])>>scale);
}
}
else {
for (i=startLine; i<(stopLine-lag); i++) {
result += (fMult(spectrum[i], spectrum[i+lag])>>scale);
}
}
return result;
} | false | false | false | false | false | 0 |
element_path (const GList *elements)
{
GString *string;
const GList *node;
string = g_string_new(NULL);
for (node = elements; node; node = g_list_next(node)) {
g_string_append(string, "/");
g_string_append(string, node->data);
}
return g_string_free(string, FALSE);
} | false | false | false | false | false | 0 |
print_init_quad(char *buf, RfmQuad q)
{
if (q == NULL) {
return buf;
}
buf += sprintf(buf, "\n quadruple {\n");
for (; q != NULL; q = q->next) {
buf += sprintf(buf, " ");
PrintQuad(buf, q);
NEW_LINE(buf);
}
buf += sprintf(buf, " } %% quadruple\n");
return buf;
} | false | false | false | false | false | 0 |
iruserok_af (raddr, superuser, ruser, luser, af)
const void *raddr;
int superuser;
const char *ruser, *luser;
sa_family_t af;
{
struct sockaddr_storage ra;
size_t ralen;
memset (&ra, '\0', sizeof(ra));
switch (af){
case AF_INET:
ra.ss_family = AF_INET;
memcpy (&(((struct sockaddr_in *)&ra)->sin_addr), raddr,
sizeof(struct in_addr));
ralen = sizeof(struct sockaddr_in);
break;
case AF_INET6:
ra.ss_family = AF_INET6;
memcpy (&(((struct sockaddr_in6 *)&ra)->sin6_addr), raddr,
sizeof(struct in6_addr));
ralen = sizeof(struct sockaddr_in6);
break;
default:
return 0;
}
return ruserok_sa ((struct sockaddr *)&ra, ralen, superuser, ruser, luser);
} | false | false | false | false | false | 0 |
xenbus_free_evtchn(struct xenbus_device *dev, int port)
{
struct evtchn_close close;
int err;
close.port = port;
err = HYPERVISOR_event_channel_op(EVTCHNOP_close, &close);
if (err)
xenbus_dev_error(dev, err, "freeing event channel %d", port);
return err;
} | false | false | false | false | false | 0 |
get_client_host(aClient *cptr)
{
static char nbuf[HOSTLEN * 2 + USERLEN + 5];
if (!MyConnect(cptr))
return cptr->name;
if (!cptr->user)
return get_client_name(cptr, TRUE);
#ifdef UNIXPORT
if (IsUnixSocket(cptr))
sprintf(nbuf, "%s[%s]", cptr->name, ME);
else
#endif
(void)sprintf(nbuf, "%s[%-.*s@%-.*s]",
cptr->name, USERLEN,
(!(cptr->flags & FLAGS_GOTID)) ? "" : cptr->auth,
HOSTLEN, cptr->user->sip);
return nbuf;
} | 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.