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
|
---|---|---|---|---|---|---|
find_sections_buffered(section_t *section, char *start, char *key,
va_list args, char *buf, int len, array_t **sections)
{
section_t *found = NULL, *fallback;
char *pos;
int i;
if (!section)
{
return;
}
pos = strchr(key, '.');
if (pos)
{
*pos = '\0';
}
if (!print_key(buf, len, start, key, args))
{
return;
}
if (pos)
{ /* restore so we can follow fallbacks */
*pos = '.';
}
if (!strlen(buf))
{
found = section;
}
else
{
array_bsearch(section->sections, buf, settings_section_find, &found);
}
if (found)
{
if (pos)
{
find_sections_buffered(found, start, pos+1, args, buf, len,
sections);
}
else
{
array_insert_create(sections, ARRAY_TAIL, found);
for (i = 0; i < array_count(found->fallbacks); i++)
{
array_get(found->fallbacks, i, &fallback);
array_insert_create(sections, ARRAY_TAIL, fallback);
}
}
}
if (section->fallbacks)
{
for (i = 0; i < array_count(section->fallbacks); i++)
{
array_get(section->fallbacks, i, &fallback);
find_sections_buffered(fallback, start, key, args, buf, len,
sections);
}
}
}
| true | true | false | false | false | 1 |
DiagMatSolve2(void* A, int indx[], int nindx, double b[], double x[],int n){
diagmat* AA = (diagmat*)A;
double *v=AA->val;
int i,j;
memset((void*)x,0,n*sizeof(double));
for (j=0;j<nindx;j++){
i=indx[j];
x[i]=b[i]/v[i];
}
return 0;
}
| false | false | false | false | false | 0 |
games_scores_add_category (GamesScores *self,
const char *key,
const char *name)
{
GamesScoresPrivate *priv = self->priv;
GamesScoresCategoryInternal *cat;
cat = g_new (GamesScoresCategoryInternal, 1);
cat->category.key = g_strdup (key);
cat->category.name = g_strdup (name);
cat->backend = NULL;
g_hash_table_insert (priv->categories, g_strdup (key), cat);
priv->catsordered = g_slist_append (priv->catsordered, cat);
}
| false | false | false | false | false | 0 |
gdImageCreateFromWebpPtr (int size, void *data)
{
int width, height, ret;
unsigned char *Y = NULL;
unsigned char *U = NULL;
unsigned char *V = NULL;
gdImagePtr im;
ret = WebPDecode(data, size, &Y, &U, &V, &width, &height);
if (ret != webp_success) {
if (Y) free(Y);
if (U) free(U);
if (V) free(V);
gd_error("WebP decode: fail to decode input data");
return NULL;
}
im = gdImageCreateTrueColor(width, height);
if (!im) {
return NULL;
}
gd_YUV420toRGBA(Y, U, V, im);
return im;
}
| false | false | false | false | false | 0 |
init_request(struct client *client,
struct fw_cdev_send_request *request,
int destination_id, int speed)
{
struct outbound_transaction_event *e;
int ret;
if (request->tcode != TCODE_STREAM_DATA &&
(request->length > 4096 || request->length > 512 << speed))
return -EIO;
if (request->tcode == TCODE_WRITE_QUADLET_REQUEST &&
request->length < 4)
return -EINVAL;
e = kmalloc(sizeof(*e) + request->length, GFP_KERNEL);
if (e == NULL)
return -ENOMEM;
e->client = client;
e->response.length = request->length;
e->response.closure = request->closure;
if (request->data &&
copy_from_user(e->response.data,
u64_to_uptr(request->data), request->length)) {
ret = -EFAULT;
goto failed;
}
e->r.resource.release = release_transaction;
ret = add_client_resource(client, &e->r.resource, GFP_KERNEL);
if (ret < 0)
goto failed;
fw_send_request(client->device->card, &e->r.transaction,
request->tcode, destination_id, request->generation,
speed, request->offset, e->response.data,
request->length, complete_transaction, e);
return 0;
failed:
kfree(e);
return ret;
}
| false | false | false | false | false | 0 |
acpi_ns_get_attached_data(struct acpi_namespace_node * node,
acpi_object_handler handler, void **data)
{
union acpi_operand_object *obj_desc;
obj_desc = node->object;
while (obj_desc) {
if ((obj_desc->common.type == ACPI_TYPE_LOCAL_DATA) &&
(obj_desc->data.handler == handler)) {
*data = obj_desc->data.pointer;
return (AE_OK);
}
obj_desc = obj_desc->common.next_object;
}
return (AE_NOT_FOUND);
}
| false | false | false | false | false | 0 |
f_ungetc(VALUE *v1, VALUE *v2)
{
VALUE result;
NUMBER *q;
int ch;
int i;
/* initialize VALUE */
result.v_subtype = V_NOSUBTYPE;
errno = 0;
if (v1->v_type != V_FILE)
return error_value(E_UNGETC1);
switch (v2->v_type) {
case V_STR:
ch = v2->v_str->s_str[0];
break;
case V_NUM:
q = v2->v_num;
if (!qisint(q))
return error_value(E_UNGETC2);
ch = qisneg(q) ? (int)(-q->num.v[0] & 0xff) :
(int)(q->num.v[0] & 0xff);
break;
default:
return error_value(E_UNGETC2);
}
i = idungetc(v1->v_file, ch);
if (i == EOF)
return error_value(errno);
if (i == -2)
return error_value(E_UNGETC3);
result.v_type = V_NULL;
return result;
}
| false | false | false | false | false | 0 |
installedEntries() const
{
EntryInternal::List entries;
foreach (const EntryInternal& entry, mCachedEntries) {
if (entry.status() == Entry::Installed || entry.status() == Entry::Updateable) {
entries.append(entry);
}
}
return entries;
}
| false | false | false | false | false | 0 |
initializePgn()
{
m_pgn->setVariant(m_board->variant());
m_pgn->setStartingFenString(m_board->startingSide(), m_startingFen);
m_pgn->setDate(QDate::currentDate());
m_pgn->setPlayerName(Chess::Side::White, m_player[Chess::Side::White]->name());
m_pgn->setPlayerName(Chess::Side::Black, m_player[Chess::Side::Black]->name());
m_pgn->setResult(m_result);
if (m_timeControl[Chess::Side::White] == m_timeControl[Chess::Side::Black])
m_pgn->setTag("TimeControl", m_timeControl[0].toString());
else
{
m_pgn->setTag("WhiteTimeControl", m_timeControl[Chess::Side::White].toString());
m_pgn->setTag("BlackTimeControl", m_timeControl[Chess::Side::Black].toString());
}
}
| false | false | false | false | false | 0 |
next_unifiable(struct term *t,
struct context *subst_t,
struct context *subst_ret,
struct fpa_tree **pos_ptr,
struct trail **tr_ptr,
struct link_node *curr_node,
struct link_node *target,
char *target_here,
int *hit_dp_count)
{
struct term *term_to_return;
int rc;
BOOLEAN try_find_another;
term_to_return = next_term(*pos_ptr, 0);
*tr_ptr = NULL;
/*
while (term_to_return != NULL &&
(!process_this_resolution(curr_node, target, term_to_return, target_here)
||
unify(t, subst_t, term_to_return, subst_ret, tr_ptr) == 0))
term_to_return = next_term(*pos_ptr, 0);
*/
if (term_to_return == NULL)
try_find_another = FALSE;
else
{
if (process_this_resolution(curr_node, target,
term_to_return, target_here, hit_dp_count))
{
rc = unify(t, subst_t, term_to_return, subst_ret, tr_ptr);
if (rc == 0)
{
try_find_another = TRUE;
}
else
{
try_find_another = FALSE;
} /* endif */
}
else
try_find_another = TRUE;
} /* endif */
while (try_find_another)
{
term_to_return = next_term(*pos_ptr, 0);
if (term_to_return == NULL)
try_find_another = FALSE;
else
{
if (process_this_resolution(curr_node, target,
term_to_return, target_here, hit_dp_count))
{
rc = unify(t, subst_t, term_to_return, subst_ret, tr_ptr);
if (rc == 0)
{
try_find_another = TRUE;
}
else
{
try_find_another = FALSE;
} /* endif */
}
else
try_find_another = TRUE;
} /* endif */
} /* endwhile */
return(term_to_return);
}
| false | false | false | false | false | 0 |
configure(Vector<String> &conf, ErrorHandler *errh)
{
uint16_t ether_type;
click_ether ethh;
if (Args(conf, this, errh)
.read_mp("ETHERTYPE", ether_type)
.read_mp_with("SRC", EtherAddressArg(), ethh.ether_shost)
.read_mp_with("DST", EtherAddressArg(), ethh.ether_dhost)
.complete() < 0)
return -1;
ethh.ether_type = htons(ether_type);
_ethh = ethh;
return 0;
}
| false | false | false | false | false | 0 |
openssldsa_parse(dst_key_t *key, isc_lex_t *lexer, dst_key_t *pub) {
dst_private_t priv;
isc_result_t ret;
int i;
DSA *dsa = NULL;
isc_mem_t *mctx = key->mctx;
#define DST_RET(a) {ret = a; goto err;}
UNUSED(pub);
/* read private key file */
ret = dst__privstruct_parse(key, DST_ALG_DSA, lexer, mctx, &priv);
if (ret != ISC_R_SUCCESS)
return (ret);
dsa = DSA_new();
if (dsa == NULL)
DST_RET(ISC_R_NOMEMORY);
dsa->flags &= ~DSA_FLAG_CACHE_MONT_P;
key->keydata.dsa = dsa;
for (i=0; i < priv.nelements; i++) {
BIGNUM *bn;
bn = BN_bin2bn(priv.elements[i].data,
priv.elements[i].length, NULL);
if (bn == NULL)
DST_RET(ISC_R_NOMEMORY);
switch (priv.elements[i].tag) {
case TAG_DSA_PRIME:
dsa->p = bn;
break;
case TAG_DSA_SUBPRIME:
dsa->q = bn;
break;
case TAG_DSA_BASE:
dsa->g = bn;
break;
case TAG_DSA_PRIVATE:
dsa->priv_key = bn;
break;
case TAG_DSA_PUBLIC:
dsa->pub_key = bn;
break;
}
}
dst__privstruct_free(&priv, mctx);
if (key->external) {
if (pub == NULL)
DST_RET(DST_R_INVALIDPRIVATEKEY);
dsa->q = pub->keydata.dsa->q;
pub->keydata.dsa->q = NULL;
dsa->p = pub->keydata.dsa->p;
pub->keydata.dsa->p = NULL;
dsa->g = pub->keydata.dsa->g;
pub->keydata.dsa->g = NULL;
dsa->pub_key = pub->keydata.dsa->pub_key;
pub->keydata.dsa->pub_key = NULL;
}
key->key_size = BN_num_bits(dsa->p);
return (ISC_R_SUCCESS);
err:
openssldsa_destroy(key);
dst__privstruct_free(&priv, mctx);
memset(&priv, 0, sizeof(priv));
return (ret);
}
| false | false | false | false | false | 0 |
sdp_device_record_register(sdp_session_t *session, bdaddr_t *device, sdp_record_t *rec, uint8_t flags)
{
sdp_buf_t pdu;
uint32_t handle;
int err;
SDPDBG("");
if (rec->handle && rec->handle != 0xffffffff) {
uint32_t handle = rec->handle;
sdp_data_t *data = sdp_data_alloc(SDP_UINT32, &handle);
sdp_attr_replace(rec, SDP_ATTR_RECORD_HANDLE, data);
}
if (sdp_gen_record_pdu(rec, &pdu) < 0) {
errno = ENOMEM;
return -1;
}
err = sdp_device_record_register_binary(session, device,
pdu.data, pdu.data_size, flags, &handle);
free(pdu.data);
if (err == 0) {
sdp_data_t *data = sdp_data_alloc(SDP_UINT32, &handle);
rec->handle = handle;
sdp_attr_replace(rec, SDP_ATTR_RECORD_HANDLE, data);
}
return err;
}
| false | false | false | false | false | 0 |
p_cliptarget_togglebutton_toggled_cb (GtkToggleButton *togglebutton
, GapStoryClipTargetEnum *clip_target_ptr)
{
GapStbMainGlobalParams *sgpp;
if(gap_debug)
{
printf("CB: p_cliptarget_togglebutton_toggled_cb: %d\n", (int)togglebutton);
}
if(clip_target_ptr)
{
if (togglebutton->active)
{
*clip_target_ptr = GAP_STB_CLIPTARGET_STORYBOARD_APPEND;
}
else
{
*clip_target_ptr = GAP_STB_CLIPTARGET_CLIPLIST_APPEND;
}
}
sgpp = (GapStbMainGlobalParams *)g_object_get_data(G_OBJECT(togglebutton), "sgpp");
if(sgpp)
{
return; /* */
}
}
| false | false | false | false | false | 0 |
extend_info_get_description(char *buf, const extend_info_t *ei)
{
if (!ei)
return "<null>";
return format_node_description(buf,
ei->identity_digest,
0,
ei->nickname,
&ei->addr,
0);
}
| false | false | false | false | false | 0 |
adjust_stab_sections (bfd *abfd, asection *sec, void *xxx ATTRIBUTE_UNUSED)
{
char *name;
asection *strsec;
char *p;
int strsz, nsyms;
if (strncmp (".stab", sec->name, 5))
return;
if (!strcmp ("str", sec->name + strlen (sec->name) - 3))
return;
name = (char *) alloca (strlen (sec->name) + 4);
strcpy (name, sec->name);
strcat (name, "str");
strsec = bfd_get_section_by_name (abfd, name);
if (strsec)
strsz = bfd_section_size (abfd, strsec);
else
strsz = 0;
nsyms = bfd_section_size (abfd, sec) / 12 - 1;
p = seg_info (sec)->stabu.p;
gas_assert (p != 0);
bfd_h_put_16 (abfd, nsyms, p + 6);
bfd_h_put_32 (abfd, strsz, p + 8);
}
| false | false | false | false | false | 0 |
telnet_print(const u_char *sp, u_int length)
{
int first = 1;
const u_char *osp;
int l;
osp = sp;
while (length > 0 && *sp == IAC) {
l = telnet_parse(sp, length, 0);
if (l < 0)
break;
/*
* now print it
*/
if (Xflag && 2 < vflag) {
if (first)
printf("\nTelnet:");
hex_print_with_offset("\n", sp, l, sp - osp);
if (l > 8)
printf("\n\t\t\t\t");
else
printf("%*s\t", (8 - l) * 3, "");
} else
printf("%s", (first) ? " [telnet " : ", ");
(void)telnet_parse(sp, length, 1);
first = 0;
sp += l;
length -= l;
}
if (!first) {
if (Xflag && 2 < vflag)
printf("\n");
else
printf("]");
}
}
| false | false | false | false | false | 0 |
sh_SortFreq(int *freq, uchar *symb)
{
int ls[8], hs[8];
int l, h, m, p, i, j, s, n;
uchar t;
/* Mark & count actual symbols */
for (i=n=0; i<SH_MAX_ALPHA; i++)
if (freq[i]) symb[n++]=(uchar)i;
ls[0]=0; hs[0]=n-1;
for (s=0; s>=0; s--) {
/* Pop next one */
l=ls[s]; h=hs[s];
while (l<h) {
/* Choose pivot frequency */
m=(l+h)>>1; p=KEY(m);
SWP(l, m); i=l+1; j=h;
/* Partition loop */
while (1) {
while (i<=j && KEY(i)<=p) i++;
while (p<KEY(j)) j--;
if (i>=j) break;
SWP(i, j); i++; j--;
}
SWP(l, j);
/* Push largest one */
if (j-l<=h-j) {
if (j+1<h) { ls[s]=j+1; hs[s++]=h; }
h=j-1;
} else {
if (j-1>l) { ls[s]=l; hs[s++]=j-1; }
l=j+1;
}
}
}
return n;
}
| false | false | false | false | false | 0 |
p_string_set(li_object *args) {
assert_nargs(3, args);
assert_string(li_car(args));
assert_integer(li_cadr(args));
assert_character(li_caddr(args));
return li_character(li_to_string(li_car(args))[li_to_integer(li_cadr(args))] =
li_to_character(li_caddr(args)));
}
| false | false | false | false | false | 0 |
volume_id_get_buffer(struct volume_id *id, uint64_t off, size_t len)
{
info("get buffer off 0x%llx(%llu), len 0x%zx", (unsigned long long) off, (unsigned long long) off, len);
/* check if requested area fits in superblock buffer */
if (off + len <= SB_BUFFER_SIZE) {
/* check if we need to read */
if ((off + len) > id->sbbuf_len) {
if (devread (0, 0, off + len, (char*)id->sbbuf) == 0)
{
return NULL;
}
id->sbbuf_len = off + len;
}
return &(id->sbbuf[off]);
} else {
if (len > SEEK_BUFFER_SIZE) {
dbg("seek buffer too small %d", SEEK_BUFFER_SIZE);
return NULL;
}
/* check if we need to read */
if ((off < id->seekbuf_off) || ((off + len) > (id->seekbuf_off + id->seekbuf_len))) {
info("read seekbuf off:0x%llx len:0x%zx", (unsigned long long) off, len);
if (devread(off >> 9, off & 0x1ff, len, (char*)id->seekbuf) == 0)
{
return NULL;
}
id->seekbuf_off = off;
id->seekbuf_len = len;
}
return &(id->seekbuf[off - id->seekbuf_off]);
}
}
| false | false | false | false | false | 0 |
activate(bool _initial_state)
{
// If the buffer is activated already or the buffer is full,
// then we can't activate it.
if(isActive() || isFull())
return;
// Save the time for this initial event
start_time = get_cycles().get();
bInitialState = _initial_state;
index = 0; // next state gets stored at the first position in the buffer.
bActive = true;
future_cycle = start_time + (1<<31);
get_cycles().set_break(future_cycle, this);
}
| false | false | false | false | false | 0 |
pccard_store_card_pm_state(struct device *dev,
struct device_attribute *attr,
const char *buf, size_t count)
{
struct pcmcia_socket *s = to_socket(dev);
ssize_t ret = count;
if (!count)
return -EINVAL;
if (!strncmp(buf, "off", 3))
pcmcia_parse_uevents(s, PCMCIA_UEVENT_SUSPEND);
else {
if (!strncmp(buf, "on", 2))
pcmcia_parse_uevents(s, PCMCIA_UEVENT_RESUME);
else
ret = -EINVAL;
}
return ret;
}
| false | false | false | false | false | 0 |
lam_tr_commname(char *name, int cid, double t)
{
struct trsrc *psrc;
struct trrthdr *ptrr;
struct trcommname *pcomm;
int trsize;
trsize = (sizeof(struct trsrc) +
sizeof(struct trrthdr) +
sizeof(struct trcommname));
psrc = (struct trsrc *) malloc(trsize);
psrc->trs_node = ltot(getnodeid());
psrc->trs_pid = ltot(lam_getpid());
psrc->trs_listno = ltot(TRRUNTIME);
/* advance to the trrthdr struct */
ptrr = (struct trrthdr *) (psrc + 1);
ptrr->trr_type = ltot(TRCOMMNAME);
ltotf8(&t, &(ptrr->trr_time));
/* advance to the trbuoy struct */
pcomm = (struct trcommname *) (ptrr + 1);
memset(pcomm->trcomm_name, 0, sizeof(pcomm->trcomm_name));
lam_strncpy(pcomm->trcomm_name, name, 128);
pcomm->trcomm_cid = ltot(cid);
if (lam_rtrstore(LOCAL,
TRRUNTIME,
lam_myproc->p_gps.gps_pid,
(char*) psrc,
trsize)){
free((char*) psrc);
return LAMERROR;
}
free((char*) psrc);
return 0;
}
| false | false | false | false | true | 1 |
op_sparse_multiply_AB(const CSparseMatrix &M1, const CSparseMatrix &M2, CSparseMatrix &res) { res = M1*M2; }
| false | false | false | false | false | 0 |
initScript()
{
if (script && !scriptInitialized) {
setupScriptSupport();
script->init();
scriptInitialized = true;
}
}
| false | false | false | false | false | 0 |
getsample (void)
{
uae_s32 smp = 0;
int div = 0, i;
for (i = 0; i < 4; i++) {
if (currprefs.floppyslots[i].dfxclick) {
struct drvsample *ds_start = &drvs[i][DS_START];
struct drvsample *ds_spin = drv_has_disk[i] ? &drvs[i][DS_SPIN] : &drvs[i][DS_SPINND];
struct drvsample *ds_click = &drvs[i][DS_CLICK];
struct drvsample *ds_snatch = &drvs[i][DS_SNATCH];
if (drv_spinning[i] || drv_starting[i]) {
div++;
if (drv_starting[i] && drv_has_spun[i]) {
if (ds_start->p && ds_start->pos < ds_start->len) {
smp = ds_start->p[ds_start->pos >> DS_SHIFT];
ds_start->pos += sample_step;
} else {
drv_starting[i] = 0;
}
} else if (drv_starting[i] && drv_has_spun[i] == 0) {
if (ds_snatch->p && ds_snatch->pos < ds_snatch->len) {
smp = ds_snatch->p[ds_snatch->pos >> DS_SHIFT];
ds_snatch->pos += sample_step;
} else {
drv_starting[i] = 0;
ds_start->pos = ds_start->len;
drv_has_spun[i] = 1;
}
}
if (ds_spin->p && drv_starting[i] == 0) {
if (ds_spin->pos >= ds_spin->len)
ds_spin->pos -= ds_spin->len;
smp = ds_spin->p[ds_spin->pos >> DS_SHIFT];
ds_spin->pos += sample_step;
}
}
if (ds_click->p && ds_click->pos < ds_click->len) {
smp += ds_click->p[ds_click->pos >> DS_SHIFT];
div++;
ds_click->pos += sample_step;
}
}
}
if (!div)
return 0;
return smp / div;
}
| false | false | false | false | false | 0 |
gnucash_grid_find_loc_by_pixel (GnucashGrid *grid, gint x, gint y,
VirtualLocation *virt_loc)
{
SheetBlock *block;
if (virt_loc == NULL)
return FALSE;
block = gnucash_grid_find_block_by_pixel (grid, x, y,
&virt_loc->vcell_loc);
if (block == NULL)
return FALSE;
return gnucash_grid_find_cell_by_pixel (grid, x, y, virt_loc);
}
| false | false | false | false | false | 0 |
get_scint_pars(struct ccd_frame *fr, struct vs_recipy *vs, double *t, double *d, double *am)
{
FITS_row * cp;
float r;
// determine exposure time
if (fits_get_double(fr, "EXPTIME", t) <= 0 ) {
err_printf("bad exposure time, assuming 1 sec\n");
*t = 1.0;
}
// telescope aperture
cp = fits_keyword_lookup(fr, "APERT");
if (vs->aperture > 1.0 && vs->aperture < 1000) { // look in recipy
*d = vs->aperture;
} else if (cp != NULL && (sscanf((char *)cp, "%*s = %f", &r) )) {
*d = r;
} else {
err_printf("bad telescope aperture, assuming 30 cm\n");
*d = 30.0;
}
// airmass
cp = fits_keyword_lookup(fr, "OBJCTALT");
if (cp != NULL && (sscanf(((char *)cp), "%*s= %f", &r) )) {
*am = airmass(r);
return;
}
cp = fits_keyword_lookup(fr, "AIRMASS");
if (cp != NULL && (sscanf(((char *)cp), "%*s = %f", &r) )) {
*am = r;
return;
}
if (vs->airmass >= 1.0 && vs->airmass < 50.0) { // we get it from here
*am = vs->airmass;
return;
}
err_printf("could not determine airmass, assuming 1.5\n");
*am = 1.5;
}
| false | false | false | false | false | 0 |
getAddrCount(SPtr<TDUID> duid)
{
SPtr <TAddrClient> ptrClient;
ClntsLst.first();
while ( ptrClient = ClntsLst.get() ) {
if ( (*ptrClient->getDUID()) == (*duid))
break;
}
// Have we found this client?
if (!ptrClient) {
return 0;
}
unsigned long count=0;
// look at each of client's IAs
SPtr <TAddrIA> ptrIA;
ptrClient->firstIA();
while ( ptrIA = ptrClient->getIA() ) {
count += ptrIA->countAddr();
}
return count;
}
| false | false | false | false | false | 0 |
setTime(const QTime &time)
{
if (d->time == time)
return;
const int index = d->combo->findData(time);
if (index == -1) {
// custom time, not found in combo items
// QTime() is not the same as QTime(0,0)!!
d->time = time.isNull()? QTime(0, 0) : time;
d->combo->setEditText(time.toString(QLocale::system().timeFormat(QLocale::ShortFormat)));
qDebug() << "setEditText" << time;
} else {
// given time is one of the combo items
d->combo->setCurrentIndex(index);
qDebug() << "setCurrentIndex" << index << d->combo->itemData(index);
}
Q_EMIT timeChanged(d->time);
Q_EMIT dateTimeChanged(QDateTime(QDate(), d->time));
}
| false | false | false | false | false | 0 |
juldat( date )
struct ut_instant * date;
{
double frac, gyr;
long iy0, im0;
long ia, ib;
long jd;
/* decimal day fraction */
frac = (( double)date->i_hour/ 24.0)
+ ((double) date->i_minute / 1440.0)
+ (date->d_second / 86400.0);
/* convert date to format YYYY.MMDDdd */
gyr = (double) date->year
+ (0.01 * (double) date->month)
+ (0.0001 * (double) date->day)
+ (0.0001 * frac) + 1.0e-9;
/* conversion factors */
if ( date->month <= 2 )
{
iy0 = date->year - 1L;
im0 = date->month + 12;
}
else
{
iy0 = date->year;
im0 = date->month;
}
ia = iy0 / 100L;
ib = 2L - ia + (ia >> 2);
/* calculate julian date */
if ( date->year < 0L )
jd = (long) ((365.25 * (double) iy0) - 0.75)
+ (long) (30.6001 * (im0 + 1L) )
+ (long) date->day + 1720994L;
else
jd = (long) (365.25 * (double) iy0)
+ (long) (30.6001 * (double) (im0 + 1L))
+ (long) date->day + 1720994L;
if ( gyr >= 1582.1015 ) /* on or after 15 October 1582 */
jd += ib;
date->j_date = (double) jd + frac + 0.5;
jd = (long) (date->j_date + 0.5);
date->weekday = (jd + 1L) % 7L;
return( date->j_date );
}
| false | false | false | false | false | 0 |
bgav_rmff_file_header_read(bgav_rmff_chunk_t * c,
bgav_input_context_t * input,
bgav_rmff_file_header_t * ret)
{
return bgav_input_read_32_be(input, &ret->file_version) &&
bgav_input_read_32_be(input, &ret->num_headers);
}
| false | false | false | false | false | 0 |
_get_sel_state (ipmi_interpret_ctx_t ctx,
const void *record_buf,
unsigned int record_buflen,
uint8_t event_reading_type_code,
uint8_t sensor_type,
uint8_t event_direction,
uint8_t offset_from_event_reading_type_code,
unsigned int *sel_state,
struct ipmi_interpret_sel_config **sel_config)
{
int i = 0;
assert (ctx);
assert (ctx->magic == IPMI_INTERPRET_CTX_MAGIC);
assert (record_buf);
assert (record_buflen);
assert (sel_state);
assert (sel_config);
(*sel_state) = IPMI_INTERPRET_STATE_UNKNOWN;
i = 0;
while (sel_config[i]
&& i < offset_from_event_reading_type_code
&& i < IPMI_INTERPRET_MAX_SENSOR_AND_EVENT_OFFSET)
i++;
if (sel_config[i])
{
if (event_direction == IPMI_SEL_RECORD_ASSERTION_EVENT)
(*sel_state) = sel_config[i]->assertion_state;
else
(*sel_state) = sel_config[i]->deassertion_state;
}
else if (ctx->flags & IPMI_INTERPRET_FLAGS_INTERPRET_OEM_DATA)
return (_get_sel_oem_sensor_state (ctx,
record_buf,
record_buflen,
event_reading_type_code,
sensor_type,
sel_state));
return (0);
}
| false | false | false | false | false | 0 |
_save_to_uri (GESFormatter * formatter, GESTimeline * timeline,
const gchar * uri, gboolean overwrite, GError ** error)
{
GFile *file;
gboolean ret;
GString *str;
GOutputStream *stream;
GError *lerror = NULL;
g_return_val_if_fail (formatter->project, FALSE);
file = g_file_new_for_uri (uri);
stream = G_OUTPUT_STREAM (g_file_create (file, G_FILE_CREATE_NONE, NULL,
&lerror));
if (stream == NULL) {
if (overwrite && lerror->code == G_IO_ERROR_EXISTS) {
g_clear_error (&lerror);
stream = G_OUTPUT_STREAM (g_file_replace (file, NULL, FALSE,
G_FILE_CREATE_NONE, NULL, &lerror));
}
if (stream == NULL)
goto failed_opening_file;
}
str = GES_BASE_XML_FORMATTER_GET_CLASS (formatter)->save (formatter,
timeline, error);
if (str == NULL)
goto serialization_failed;
ret = g_output_stream_write_all (stream, str->str, str->len, NULL,
NULL, &lerror);
ret = g_output_stream_close (stream, NULL, &lerror);
if (ret == FALSE)
GST_WARNING_OBJECT (formatter, "Could not save %s because: %s", uri,
lerror->message);
g_string_free (str, TRUE);
gst_object_unref (file);
gst_object_unref (stream);
if (lerror)
g_propagate_error (error, lerror);
return ret;
serialization_failed:
gst_object_unref (file);
g_output_stream_close (stream, NULL, NULL);
gst_object_unref (stream);
if (lerror)
g_propagate_error (error, lerror);
return FALSE;
failed_opening_file:
gst_object_unref (file);
GST_WARNING_OBJECT (formatter, "Could not open %s because: %s", uri,
lerror->message);
if (lerror)
g_propagate_error (error, lerror);
return FALSE;
}
| false | false | false | false | false | 0 |
bvl_addgen (lastgeneric,nat_lst,nam_lst,type,left,right)
struct begen *lastgeneric; /* pointer on the last begen structure */
struct chain *nam_lst; /* generic's name list */
struct chain *nat_lst; /* generic's value list */
char *type; /* generic's type */
short left; /* array's left bound (= -1 if scalar) */
short right; /* array's right bound (= -1 if scalar) */
{
char extname[100];
char *name;
struct begen *ptgen;
struct chain *ptauxnam;
struct chain *ptauxnat;
long i;
long inc = 1;
ptgen = lastgeneric;
ptauxnam = nam_lst;
ptauxnat = nat_lst;
if ((left == -1) && (right == -1))
if ((ptauxnat != NULL) && (ptauxnat->NEXT == NULL))
while (ptauxnam != NULL)
{
name = namealloc((char *)ptauxnam->DATA);
ptgen = beh_addbegen (ptgen,name,type,(void *)ptauxnat->DATA);
ptauxnam = ptauxnam->NEXT;
}
else
bvl_error(75,NULL);
else
{
if (left >= right)
inc = -1;
while (ptauxnam != NULL)
{
for (i=left ; i!=(right+inc) ; i+=inc)
{
sprintf (extname,"%s %d",(char *)ptauxnam->DATA,i);
name = namealloc(extname);
if (ptauxnat != NULL)
{
ptgen = beh_addbegen (ptgen,name,type,(void *)ptauxnat->DATA);
ptauxnat = ptauxnat->NEXT;
}
else
bvl_error(75,NULL);
}
if (ptauxnat != NULL)
bvl_error (75,NULL);
ptauxnat = nat_lst;
ptauxnam = ptauxnam->NEXT;
}
}
return (ptgen);
}
| false | false | false | false | false | 0 |
multi_data_handle_incoming(int handle)
{
int player_index = -1;
PSNET_SOCKET_RELIABLE sock = INVALID_SOCKET;
char *fname;
// get the player who is sending us this file
sock = multi_xfer_get_sock(handle);
player_index = find_player_socket(sock);
// get the filename of the file
fname = multi_xfer_get_filename(handle);
if(fname == NULL){
nprintf(("Network", "Could not get file xfer filename! wacky...!\n"));
// kill the stream
multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_REJECT);
return;
}
// if this is not a valid data file
if(!multi_data_is_data(fname)){
nprintf(("Network", "Not accepting xfer request because its not a valid data file!\n"));
// kill the stream
multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_REJECT);
return;
}
// if we already have a copy of this file, abort the xfer
// Does file exist in \multidata?
if (cf_exists(fname, CF_TYPE_MULTI_CACHE)) {
nprintf(("Network", "Not accepting file xfer because a duplicate exists!\n"));
// kill the stream
multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_REJECT);
// if we're the server, we still need to add it to the list though
if((Net_player->flags & NETINFO_FLAG_AM_MASTER) && (player_index >= 0)){
multi_data_add_new(fname, player_index);
}
return;
}
// if I'm the server of the game, do stuff a little differently
if(Net_player->flags & NETINFO_FLAG_AM_MASTER){
if(player_index == -1){
nprintf(("Network", "Could not find player for incoming player data stream!\n"));
// kill the stream
multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_REJECT);
return;
}
// attempt to add the file
if(!multi_data_add_new(fname, player_index)){
// kill the stream
multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_REJECT);
return;
} else {
// force the file to go into the multi cache directory
multi_xfer_handle_force_dir(handle, CF_TYPE_MULTI_CACHE);
// mark it as autodestroy
multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_AUTODESTROY);
}
}
// if i'm a client, this is an incoming file from the server
else {
// if i'm not accepting pilot pics, abort
if(!(Net_player->p_info.options.flags & MLO_FLAG_ACCEPT_PIX)){
nprintf(("Network", "Client not accepting files because we don't want 'em!\n"));
// kill the stream
multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_REJECT);
return;
}
// set the xfer handle to autodestroy itself since we don't really want to have to manage all incoming pics
multi_xfer_xor_flags(handle, MULTI_XFER_FLAG_AUTODESTROY);
// force the file to go into the multi cache directory
multi_xfer_handle_force_dir(handle, CF_TYPE_MULTI_CACHE);
// begin receiving the file
nprintf(("Network", "Client receiving xfer handle %d\n",handle));
}
}
| false | false | false | false | false | 0 |
clear_groups(struct isl_factor_groups *g)
{
if (!g)
return;
free(g->pos);
free(g->group);
free(g->cnt);
free(g->rowgroup);
}
| false | false | false | false | false | 0 |
gnc_table_destroy (Table * table)
{
/* invoke destroy callback */
if (table->gui_handlers.destroy)
table->gui_handlers.destroy (table);
/* free the dynamic structures */
gnc_table_free_data (table);
/* free the cell tables */
g_table_destroy (table->virt_cells);
gnc_table_layout_destroy (table->layout);
table->layout = NULL;
gnc_table_control_destroy (table->control);
table->control = NULL;
gnc_table_model_destroy (table->model);
table->model = NULL;
/* intialize vars to null value so that any access is voided. */
gnc_table_init (table);
g_free (table);
}
| false | false | false | false | false | 0 |
io_read(void *data, char *buf, size_t size, size_t *pret)
{
struct _iostr *p = data;
if (dico_stream_read(p->in, buf, size, pret)) {
p->last_err = p->in;
return dico_stream_last_error(p->in);
}
return 0;
}
| false | false | false | false | false | 0 |
ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *lengths, MonoArray *bounds)
{
MonoClass *aklass, *klass;
MonoArray *array;
uintptr_t *sizes, i;
gboolean bounded = FALSE;
MONO_ARCH_SAVE_REGS;
MONO_CHECK_ARG_NULL (type);
MONO_CHECK_ARG_NULL (lengths);
MONO_CHECK_ARG (lengths, mono_array_length (lengths) > 0);
if (bounds)
MONO_CHECK_ARG (bounds, mono_array_length (lengths) == mono_array_length (bounds));
for (i = 0; i < mono_array_length (lengths); i++)
if (mono_array_get (lengths, gint32, i) < 0)
mono_raise_exception (mono_get_exception_argument_out_of_range (NULL));
klass = mono_class_from_mono_type (type->type);
mono_class_init_or_throw (klass);
if (bounds && (mono_array_length (bounds) == 1) && (mono_array_get (bounds, gint32, 0) != 0))
/* vectors are not the same as one dimensional arrays with no-zero bounds */
bounded = TRUE;
else
bounded = FALSE;
aklass = mono_bounded_array_class_get (klass, mono_array_length (lengths), bounded);
sizes = alloca (aklass->rank * sizeof(intptr_t) * 2);
for (i = 0; i < aklass->rank; ++i) {
sizes [i] = mono_array_get (lengths, guint32, i);
if (bounds)
sizes [i + aklass->rank] = mono_array_get (bounds, gint32, i);
else
sizes [i + aklass->rank] = 0;
}
array = mono_array_new_full (mono_object_domain (type), aklass, sizes, (intptr_t*)sizes + aklass->rank);
return array;
}
| false | false | false | false | false | 0 |
bpa10x_tx_complete(struct urb *urb)
{
struct sk_buff *skb = urb->context;
struct hci_dev *hdev = (struct hci_dev *) skb->dev;
BT_DBG("%s urb %p status %d count %d", hdev->name,
urb, urb->status, urb->actual_length);
if (!test_bit(HCI_RUNNING, &hdev->flags))
goto done;
if (!urb->status)
hdev->stat.byte_tx += urb->transfer_buffer_length;
else
hdev->stat.err_tx++;
done:
kfree(urb->setup_packet);
kfree_skb(skb);
}
| false | false | false | false | false | 0 |
process_game_info_packet( ubyte *data, header *hinfo )
{
int offset;
fix mission_time;
ubyte paused;
offset = HEADER_LENGTH;
// get the mission time -- we should examine our time and the time from the server. If off by some delta
// time, set our time to server time (should take ping time into account!!!)
GET_INT( mission_time ); // NOTE: this is a long so careful with swapping in 64-bit platforms - taylor
GET_DATA( paused );
PACKET_SET_SIZE();
}
| false | false | false | false | false | 0 |
SVGCircleElement(const QualifiedName& tagName, Document* doc)
: SVGStyledTransformableElement(tagName, doc)
, SVGTests()
, SVGLangSpace()
, SVGExternalResourcesRequired()
, m_cx(SVGLength(this, LengthModeWidth))
, m_cy(SVGLength(this, LengthModeHeight))
, m_r(SVGLength(this, LengthModeOther))
{
}
| false | false | false | false | false | 0 |
aten_read_block( PIA *pi, char * buf, int count )
{ int k, a, b, c, d;
switch (pi->mode) {
case 0: w0(0x48); w2(0xe); w2(6);
for (k=0;k<count/2;k++) {
w2(7); w2(6); w2(2);
a = r1(); w0(0x58); b = r1();
w2(0); d = r1(); w0(0x48); c = r1();
buf[2*k] = j44(c,d);
buf[2*k+1] = j44(a,b);
}
w2(0xc);
break;
case 1: w0(0x58); w2(0xe); w2(6);
for (k=0;k<count/2;k++) {
w2(0x27); w2(0x26); w2(0x22);
a = r0(); w2(0x20); b = r0();
buf[2*k] = b; buf[2*k+1] = a;
}
w2(0x26); w2(0xc);
break;
}
}
| false | false | false | false | false | 0 |
drain_mpi(int4 node, int4 pid, int fd)
{
struct _gps *world; /* GPS array */
int4 n_index, n_flags; /* node entry info */
int4 p_index, p_flags; /* pid entry info */
int4 curr_node; /* current target */
int4 r; /* length of traces ret'd */
int4 nworld; /* # GPS records */
int flush_delay; /* signal then delay */
int i;
if (fl_verbose) nodespin_init("searching for an MPI world,");
do {
do {
curr_node = node;
if (fl_verbose) nodespin_next(node);
if (ao_taken(op, "k")) {
r = lam_rtrfget(node, TRWORLD, pid, fd);
if (r < 0) lamfail("lamtrace (lam_rtrfget)");
} else {
r = lam_rtrfforget(node, TRWORLD, pid, fd);
if (r < 0) lamfail("lamtrace (lam_rtrfget)");
}
nid_get(&n_index, &node, &n_flags);
} while (n_index && (r == 0));
pid_get(&p_index, &pid, &p_flags);
} while ((p_index > 0) && (r == 0));
if (fl_verbose) nodespin_end();
if (r == 0) {
show_help("lamtrace", "nompiworld", NULL);
return;
}
VERBOSE("found an MPI world on %s\n", nid_fmt(curr_node));
/*
* Rewind and read GPS information from the file.
*/
if (lseek(fd, (off_t) sizeof(int4), SEEK_SET) < 0)
lamfail("lamtrace (lseek)");
if (read(fd, (char *) &nworld, sizeof(int4)) < 0)
lamfail("lamtrace (read)");
nworld = ttol(nworld);
VERBOSE("MPI world size is %d.\n", nworld);
world = (struct _gps *) malloc((unsigned) (sizeof(struct _gps) *
nworld));
if (world == 0) lamfail("lamtrace (malloc)");
if (read(fd, (char *) world, sizeof(struct _gps) * nworld) < 0)
lamfail("lamtrace (read)");
/*
* Convert GPS array to local byte order.
*/
for (i = 0; i < nworld; ++i) {
world[i].gps_node = ttol(world[i].gps_node);
world[i].gps_pid = ttol(world[i].gps_pid);
world[i].gps_idx = ttol(world[i].gps_idx);
world[i].gps_grank = ttol(world[i].gps_grank);
}
/*
* Determine flush delay.
*/
if (ao_taken(op, "f")) {
ao_intparam(op, "f", 0, 0, &flush_delay);
} else {
flush_delay = -1;
}
VERBOSE("draining MPI traces ...\n");
if (trdrain_mpi(fd, world, nworld, ao_taken(op, "k"), flush_delay))
lamfail("lamtrace (trdrain_mpi)");
}
| false | true | false | true | true | 1 |
setup_array (TestArray *test,
gconstpointer unused)
{
test->array = g_pkcs11_array_new ();
g_assert (test->array);
}
| false | false | false | false | false | 0 |
plugin_add_hook (hexchat_plugin *pl, int type, int pri, const char *name,
const char *help_text, void *callb, int timeout, void *userdata)
{
hexchat_hook *hook;
hook = malloc (sizeof (hexchat_hook));
memset (hook, 0, sizeof (hexchat_hook));
hook->type = type;
hook->pri = pri;
if (name)
hook->name = strdup (name);
if (help_text)
hook->help_text = strdup (help_text);
hook->callback = callb;
hook->pl = pl;
hook->userdata = userdata;
/* insert it into the linked list */
plugin_insert_hook (hook);
if (type == HOOK_TIMER)
hook->tag = fe_timeout_add (timeout, plugin_timeout_cb, hook);
return hook;
}
| false | false | false | false | false | 0 |
lg_OpenCertDB(const char * configdir, const char *prefix, PRBool readOnly,
NSSLOWCERTCertDBHandle **certdbPtr)
{
NSSLOWCERTCertDBHandle *certdb = NULL;
CK_RV crv = CKR_NETSCAPE_CERTDB_FAILED;
SECStatus rv;
char * name = NULL;
char * appName = NULL;
if (prefix == NULL) {
prefix = "";
}
configdir = lg_EvaluateConfigDir(configdir, &appName);
name = PR_smprintf("%s" PATH_SEPARATOR "%s",configdir,prefix);
if (name == NULL) goto loser;
certdb = (NSSLOWCERTCertDBHandle*)PORT_ZAlloc(sizeof(NSSLOWCERTCertDBHandle));
if (certdb == NULL)
goto loser;
certdb->ref = 1;
/* fix when we get the DB in */
rv = nsslowcert_OpenCertDB(certdb, readOnly, appName, prefix,
lg_certdb_name_cb, (void *)name, PR_FALSE);
if (rv == SECSuccess) {
crv = CKR_OK;
*certdbPtr = certdb;
certdb = NULL;
}
loser:
if (certdb) PR_Free(certdb);
if (name) PR_smprintf_free(name);
if (appName) PORT_Free(appName);
return crv;
}
| false | false | false | false | false | 0 |
smk_tskacc(struct task_smack *tsp, struct smack_known *obj_known,
u32 mode, struct smk_audit_info *a)
{
struct smack_known *sbj_known = smk_of_task(tsp);
int may;
int rc;
/*
* Check the global rule list
*/
rc = smk_access(sbj_known, obj_known, mode, NULL);
if (rc >= 0) {
/*
* If there is an entry in the task's rule list
* it can further restrict access.
*/
may = smk_access_entry(sbj_known->smk_known,
obj_known->smk_known,
&tsp->smk_rules);
if (may < 0)
goto out_audit;
if ((mode & may) == mode)
goto out_audit;
rc = -EACCES;
}
/*
* Allow for priviliged to override policy.
*/
if (rc != 0 && smack_privileged(CAP_MAC_OVERRIDE))
rc = 0;
out_audit:
#ifdef CONFIG_AUDIT
if (a)
smack_log(sbj_known->smk_known, obj_known->smk_known,
mode, rc, a);
#endif
return rc;
}
| false | false | false | false | false | 0 |
ComputeBounds()
{
vtkIdType i;
int j;
double *x;
if ( this->GetMTime() > this->ComputeTime )
{
this->Bounds[0] = this->Bounds[2] = VTK_DOUBLE_MAX;
this->Bounds[1] = this->Bounds[3] = -VTK_DOUBLE_MAX;
for (i=0; i < this->GetNumberOfPoints(); ++i)
{
x = this->GetPoint(i);
for (j=0; j < 2; ++j)
{
if ( x[j] < this->Bounds[2*j] )
{
this->Bounds[2*j] = x[j];
}
if ( x[j] > this->Bounds[2*j+1] )
{
this->Bounds[2*j+1] = x[j];
}
}
}
this->ComputeTime.Modified();
}
}
| false | false | false | false | false | 0 |
media_art_init (void)
{
GError *error = NULL;
g_return_val_if_fail (initialized == FALSE, FALSE);
media_art_plugin_init (0);
/* Cache to know if we have already handled uris */
media_art_cache = g_hash_table_new_full (g_str_hash,
g_str_equal,
(GDestroyNotify) g_free,
NULL);
/* Signal handler for new album art from the extractor */
connection = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, &error);
if (!connection) {
g_critical ("Could not connect to the D-Bus session bus, %s",
error ? error->message : "no error given.");
g_clear_error (&error);
return FALSE;
}
storage = storage_new ();
if (!storage) {
g_critical ("Could not start storage module for removable media detection");
return FALSE;
}
initialized = TRUE;
return TRUE;
}
| false | false | false | false | false | 0 |
cq_periodic_main_add(int period, cq_invoke_t event, void *arg)
{
cq_main_init();
return cq_periodic_add(callout_queue, period, event, arg);
}
| false | false | false | false | false | 0 |
ph_state_irq(struct hfc_multi *hc, u_char r_irq_statech)
{
struct dchannel *dch;
int ch;
int active;
u_char st_status, temp;
/* state machine */
for (ch = 0; ch <= 31; ch++) {
if (hc->chan[ch].dch) {
dch = hc->chan[ch].dch;
if (r_irq_statech & 1) {
HFC_outb_nodebug(hc, R_ST_SEL,
hc->chan[ch].port);
/* undocumented: delay after R_ST_SEL */
udelay(1);
/* undocumented: status changes during read */
st_status = HFC_inb_nodebug(hc, A_ST_RD_STATE);
while (st_status != (temp =
HFC_inb_nodebug(hc, A_ST_RD_STATE))) {
if (debug & DEBUG_HFCMULTI_STATE)
printk(KERN_DEBUG "%s: reread "
"STATE because %d!=%d\n",
__func__, temp,
st_status);
st_status = temp; /* repeat */
}
/* Speech Design TE-sync indication */
if (test_bit(HFC_CHIP_PLXSD, &hc->chip) &&
dch->dev.D.protocol == ISDN_P_TE_S0) {
if (st_status & V_FR_SYNC_ST)
hc->syncronized |=
(1 << hc->chan[ch].port);
else
hc->syncronized &=
~(1 << hc->chan[ch].port);
}
dch->state = st_status & 0x0f;
if (dch->dev.D.protocol == ISDN_P_NT_S0)
active = 3;
else
active = 7;
if (dch->state == active) {
HFC_outb_nodebug(hc, R_FIFO,
(ch << 1) | 1);
HFC_wait_nodebug(hc);
HFC_outb_nodebug(hc,
R_INC_RES_FIFO, V_RES_F);
HFC_wait_nodebug(hc);
dch->tx_idx = 0;
}
schedule_event(dch, FLG_PHCHANGE);
if (debug & DEBUG_HFCMULTI_STATE)
printk(KERN_DEBUG
"%s: S/T newstate %x port %d\n",
__func__, dch->state,
hc->chan[ch].port);
}
r_irq_statech >>= 1;
}
}
if (test_bit(HFC_CHIP_PLXSD, &hc->chip))
plxsd_checksync(hc, 0);
}
| false | false | false | false | false | 0 |
basic_autotools_plugin_instance_init (GObject *obj)
{
gint i;
BasicAutotoolsPlugin *ba_plugin = ANJUTA_PLUGIN_BASIC_AUTOTOOLS (obj);
for (i = 0; i < IANJUTA_BUILDABLE_N_COMMANDS; i++)
ba_plugin->commands[i] = NULL;
ba_plugin->fm_current_file = NULL;
ba_plugin->pm_current_file = NULL;
ba_plugin->current_editor_file = NULL;
ba_plugin->project_root_dir = NULL;
ba_plugin->project_build_dir = NULL;
ba_plugin->current_editor = NULL;
ba_plugin->contexts_pool = NULL;
ba_plugin->configurations = build_configuration_list_new ();
ba_plugin->program_args = NULL;
ba_plugin->run_in_terminal = TRUE;
ba_plugin->last_exec_uri = NULL;
ba_plugin->editors_created = g_hash_table_new (g_direct_hash,
g_direct_equal);
ba_plugin->settings = g_settings_new (PREF_SCHEMA);
}
| false | false | false | false | false | 0 |
check_numeric_or_string_types (expresion_result * left,
expresion_result * right)
{
if (typedef_is_array(left->type) && left->type.chunk[1].type == TYPE_CHAR && typedef_is_string(right->type))
{
left->type = typedef_new(TYPE_STRING);
left->lvalue = 0;
codeblock_add (code, MN_A2STR, 1) ;
return MN_STRING;
}
if (typedef_is_array(right->type) && right->type.chunk[1].type == TYPE_CHAR && typedef_is_string(left->type))
{
right->type = typedef_new(TYPE_STRING);
right->lvalue = 0;
codeblock_add (code, MN_A2STR, 0) ;
return MN_STRING;
}
if (typedef_is_array(right->type) && right->type.chunk[1].type == TYPE_CHAR &&
typedef_is_array(left->type) && left->type.chunk[1].type == TYPE_CHAR)
{
left->type = typedef_new(TYPE_STRING);
right->type = typedef_new(TYPE_STRING);
left->lvalue = 0;
right->lvalue = 0;
codeblock_add (code, MN_A2STR, 0) ;
codeblock_add (code, MN_A2STR, 1) ;
return MN_STRING;
}
if (typedef_is_string(left->type) && typedef_is_string(right->type))
return MN_STRING ;
if (typedef_is_string(left->type) || typedef_is_string(right->type))
compile_error (MSG_INCOMP_TYPES) ;
return check_numeric_types (left, right) ;
}
| false | false | false | false | false | 0 |
setFaceUp( bool faceUp )
{
qreal flippedness = faceUp ? 1.0 : 0.0;
if ( d->faceUp != faceUp || d->flipValue != flippedness )
{
d->faceUp = faceUp;
d->setFlippedness( flippedness );
}
}
| false | false | false | false | false | 0 |
ComputeComponentCount(NodeList const& nl)
{
int count = 2;
for(NodeList::const_iterator ni = nl.begin(); ni != nl.end(); ++ni)
{
if(cmTarget* target = this->EntryList[*ni].Target)
{
if(cmTarget::LinkInterface const* iface =
target->GetLinkInterface(this->Config, this->HeadTarget))
{
if(iface->Multiplicity > count)
{
count = iface->Multiplicity;
}
}
}
}
return count;
}
| false | false | false | false | false | 0 |
gsb_data_bank_new ( const gchar *name )
{
struct_bank *bank;
bank = g_malloc0 ( sizeof ( struct_bank ));
bank -> bank_number = gsb_data_bank_max_number () + 1;
if (name)
bank -> bank_name = my_strdup (name);
bank_list = g_slist_append ( bank_list, bank );
return bank -> bank_number;
}
| false | false | false | false | false | 0 |
strnl0(const char *s) /* replace "\\n" by "\n" in a cmd-line arg */
{
char *t,*u;
t=malloc(strlen(s)+1);
u=t;
while (*s!=0) {
if ((*s=='\\')&&(s[1]=='n')) { *u='\n'; s++; }
else *u=*s;
s++; u++;
}
*u=0;
return t;
}
| false | false | false | false | false | 0 |
r700_vm_init(struct drm_device *dev)
{
drm_radeon_private_t *dev_priv = dev->dev_private;
/* initialise the VM to use the page table we constructed up there */
u32 vm_c0, i;
u32 mc_vm_md_l1;
u32 vm_l2_cntl, vm_l2_cntl3;
/* okay set up the PCIE aperture type thingo */
RADEON_WRITE(R700_MC_VM_SYSTEM_APERTURE_LOW_ADDR, dev_priv->gart_vm_start >> 12);
RADEON_WRITE(R700_MC_VM_SYSTEM_APERTURE_HIGH_ADDR, (dev_priv->gart_vm_start + dev_priv->gart_size - 1) >> 12);
RADEON_WRITE(R700_MC_VM_SYSTEM_APERTURE_DEFAULT_ADDR, 0);
mc_vm_md_l1 = R700_ENABLE_L1_TLB |
R700_ENABLE_L1_FRAGMENT_PROCESSING |
R700_SYSTEM_ACCESS_MODE_IN_SYS |
R700_SYSTEM_APERTURE_UNMAPPED_ACCESS_PASS_THRU |
R700_EFFECTIVE_L1_TLB_SIZE(5) |
R700_EFFECTIVE_L1_QUEUE_SIZE(5);
RADEON_WRITE(R700_MC_VM_MD_L1_TLB0_CNTL, mc_vm_md_l1);
RADEON_WRITE(R700_MC_VM_MD_L1_TLB1_CNTL, mc_vm_md_l1);
RADEON_WRITE(R700_MC_VM_MD_L1_TLB2_CNTL, mc_vm_md_l1);
RADEON_WRITE(R700_MC_VM_MB_L1_TLB0_CNTL, mc_vm_md_l1);
RADEON_WRITE(R700_MC_VM_MB_L1_TLB1_CNTL, mc_vm_md_l1);
RADEON_WRITE(R700_MC_VM_MB_L1_TLB2_CNTL, mc_vm_md_l1);
RADEON_WRITE(R700_MC_VM_MB_L1_TLB3_CNTL, mc_vm_md_l1);
vm_l2_cntl = R600_VM_L2_CACHE_EN | R600_VM_L2_FRAG_PROC | R600_VM_ENABLE_PTE_CACHE_LRU_W;
vm_l2_cntl |= R700_VM_L2_CNTL_QUEUE_SIZE(7);
RADEON_WRITE(R600_VM_L2_CNTL, vm_l2_cntl);
RADEON_WRITE(R600_VM_L2_CNTL2, 0);
vm_l2_cntl3 = R700_VM_L2_CNTL3_BANK_SELECT(0) | R700_VM_L2_CNTL3_CACHE_UPDATE_MODE(2);
RADEON_WRITE(R600_VM_L2_CNTL3, vm_l2_cntl3);
vm_c0 = R600_VM_ENABLE_CONTEXT | R600_VM_PAGE_TABLE_DEPTH_FLAT;
RADEON_WRITE(R600_VM_CONTEXT0_CNTL, vm_c0);
vm_c0 &= ~R600_VM_ENABLE_CONTEXT;
/* disable all other contexts */
for (i = 1; i < 8; i++)
RADEON_WRITE(R600_VM_CONTEXT0_CNTL + (i * 4), vm_c0);
RADEON_WRITE(R700_VM_CONTEXT0_PAGE_TABLE_BASE_ADDR, dev_priv->gart_info.bus_addr >> 12);
RADEON_WRITE(R700_VM_CONTEXT0_PAGE_TABLE_START_ADDR, dev_priv->gart_vm_start >> 12);
RADEON_WRITE(R700_VM_CONTEXT0_PAGE_TABLE_END_ADDR, (dev_priv->gart_vm_start + dev_priv->gart_size - 1) >> 12);
r600_vm_flush_gart_range(dev);
}
| false | false | false | false | false | 0 |
lightdm_get_language (void)
{
const gchar *lang;
GList *link;
static const gchar *short_lang = NULL;
if (short_lang)
goto match;
lang = g_getenv ("LANG");
if (!lang)
return NULL;
/* Convert to a short form language code */
gchar *command = g_strconcat ("/usr/share/language-tools/language-validate ", lang, NULL);
gchar *out;
GError *error = NULL;
if (g_spawn_command_line_sync (command, &out, NULL, NULL, &error))
{
short_lang = g_strdup (g_strchomp (out));
g_free (out);
g_free (command);
}
else
{
g_warning ("Failed to run '%s': %s", command, error->message);
g_error_free (error);
g_free (command);
return NULL;
}
match:
for (link = lightdm_get_languages (); link; link = link->next)
{
LightDMLanguage *language = link->data;
if (lightdm_language_matches (language, short_lang))
return language;
}
return NULL;
}
| false | false | false | false | false | 0 |
utils_get_selected_row (GtkTreeView* view, GtkTreeIter* iter) {
GtkTreeIter _vala_iter = {0};
gint result = 0;
GtkTreeSelection* select = NULL;
GtkTreeView* _tmp0_ = NULL;
GtkTreeSelection* _tmp1_ = NULL;
GtkTreeSelection* _tmp2_ = NULL;
GtkTreeSelection* _tmp3_ = NULL;
GtkTreeIter _tmp4_ = {0};
gboolean _tmp5_ = FALSE;
g_return_val_if_fail (view != NULL, 0);
_tmp0_ = view;
_tmp1_ = gtk_tree_view_get_selection (_tmp0_);
_tmp2_ = _g_object_ref0 (_tmp1_);
select = _tmp2_;
_tmp3_ = select;
_tmp5_ = gtk_tree_selection_get_selected (_tmp3_, NULL, &_tmp4_);
_vala_iter = _tmp4_;
if (_tmp5_) {
GtkTreeModel* model = NULL;
GtkTreeView* _tmp6_ = NULL;
GtkTreeModel* _tmp7_ = NULL;
GtkTreeModel* _tmp8_ = NULL;
GtkTreePath* path = NULL;
GtkTreeModel* _tmp9_ = NULL;
GtkTreeIter _tmp10_ = {0};
GtkTreePath* _tmp11_ = NULL;
GtkTreePath* _tmp12_ = NULL;
gint _tmp13_ = 0;
gint* _tmp14_ = NULL;
gint _tmp15_ = 0;
_tmp6_ = view;
_tmp7_ = gtk_tree_view_get_model (_tmp6_);
_tmp8_ = _g_object_ref0 (_tmp7_);
model = _tmp8_;
_tmp9_ = model;
_tmp10_ = _vala_iter;
_tmp11_ = gtk_tree_model_get_path (_tmp9_, &_tmp10_);
path = _tmp11_;
_tmp12_ = path;
_tmp14_ = gtk_tree_path_get_indices_with_depth (_tmp12_, &_tmp13_);
_tmp15_ = _tmp14_[0];
result = _tmp15_;
_gtk_tree_path_free0 (path);
_g_object_unref0 (model);
_g_object_unref0 (select);
if (iter) {
*iter = _vala_iter;
}
return result;
}
result = -1;
_g_object_unref0 (select);
if (iter) {
*iter = _vala_iter;
}
return result;
}
| false | false | false | false | false | 0 |
scroll_idl(int n, int del, int ins, NCURSES_CH_T blank)
{
int i;
if (!((parm_delete_line || delete_line) && (parm_insert_line || insert_line)))
return ERR;
GoTo(del, 0);
UpdateAttrs(blank);
if (n == 1 && delete_line) {
TPUTS_TRACE("delete_line");
putp(delete_line);
} else if (parm_delete_line) {
TPUTS_TRACE("parm_delete_line");
tputs(TPARM_2(parm_delete_line, n, 0), n, _nc_outch);
} else { /* if (delete_line) */
for (i = 0; i < n; i++) {
TPUTS_TRACE("delete_line");
putp(delete_line);
}
}
GoTo(ins, 0);
UpdateAttrs(blank);
if (n == 1 && insert_line) {
TPUTS_TRACE("insert_line");
putp(insert_line);
} else if (parm_insert_line) {
TPUTS_TRACE("parm_insert_line");
tputs(TPARM_2(parm_insert_line, n, 0), n, _nc_outch);
} else { /* if (insert_line) */
for (i = 0; i < n; i++) {
TPUTS_TRACE("insert_line");
putp(insert_line);
}
}
return OK;
}
| false | false | false | false | false | 0 |
on_helpForumAction_activated()
{
bool tds=QDesktopServices::openUrl(QUrl("http://lalescu.ro/liviu/fet/forum/"));
if(!tds){
QMessageBox::warning(this, tr("FET warning"), tr("Could not start the default Internet browser (trying to open the link %1)."
" Maybe you can try to manually start your browser and open this link.").arg("http://lalescu.ro/liviu/fet/forum/"));
}
}
| false | false | false | false | false | 0 |
setupdsp (int audiofd, int channelCount, int frequency)
{
int format = AFMT_S16_NE;
if (ioctl(audiofd, SNDCTL_DSP_SETFMT, &format) == -1)
{
perror("set format");
exit(EXIT_FAILURE);
}
if (format != AFMT_S16_NE)
{
fprintf(stderr, "format not correct.\n");
exit(EXIT_FAILURE);
}
if (ioctl(audiofd, SNDCTL_DSP_CHANNELS, &channelCount) == -1)
{
perror("set channels");
exit(EXIT_FAILURE);
}
if (ioctl(audiofd, SNDCTL_DSP_SPEED, &frequency) == -1)
{
perror("set frequency");
exit(EXIT_FAILURE);
}
}
| false | false | false | false | false | 0 |
__lambda35_ (Block8Data* _data8_) {
UnityResultPreviewer * self;
void* result = NULL;
UnityAbstractPreview* preview = NULL;
UnityAbstractPreview* _tmp0_ = NULL;
UnityAbstractPreviewCallback _tmp1_ = NULL;
void* _tmp1__target = NULL;
self = _data8_->self;
_tmp0_ = unity_result_previewer_run (self);
preview = _tmp0_;
_tmp1_ = _data8_->async_callback;
_tmp1__target = _data8_->async_callback_target;
_tmp1_ (self, preview, _tmp1__target);
result = NULL;
_g_object_unref0 (preview);
return result;
}
| false | false | false | false | false | 0 |
mei_fw_status2str(struct mei_fw_status *fw_status,
char *buf, size_t len)
{
ssize_t cnt = 0;
int i;
buf[0] = '\0';
if (len < MEI_FW_STATUS_STR_SZ)
return -EINVAL;
for (i = 0; i < fw_status->count; i++)
cnt += scnprintf(buf + cnt, len - cnt, "%08X ",
fw_status->status[i]);
/* drop last space */
buf[cnt] = '\0';
return cnt;
}
| false | false | false | false | false | 0 |
report_iauth_stats(aClient *sptr, char *to)
{
aExtData *ectmp = iauth_stats;
while (ectmp)
{
sendto_one(sptr, ":%s %d %s :%s",
ME, RPL_STATSDEBUG, to, ectmp->line);
ectmp = ectmp->next;
}
}
| false | false | false | false | false | 0 |
GetConnectedComponents()
{
if (this->ConnectedComponents)
return (this->ConnectedComponents);
int i,j;
vtkIdType v1,v2;
std::queue<int> VQueue;
int *Visited=new int [this->GetNumberOfPoints()];
vtkIdList *Component;
vtkIdList *VList=vtkIdList::New();
this->ConnectedComponents=vtkIdListCollection::New();
for (i=0;i<this->GetNumberOfPoints();i++)
Visited[i]=0;
for (i=0;i<this->GetNumberOfPoints();i++)
{
if (Visited[i]==0)
{
// a new component is detected
VQueue.push(i);
Component=vtkIdList::New();
// Component->Allocate(this->GetNumberOfPoints());
while(VQueue.size())
{
v1=VQueue.front();
if (Visited[v1]==0)
{
Component->InsertNextId(v1);
Visited[v1]++;
this->GetVertexNeighbours(v1,VList);
for (j=0;j<VList->GetNumberOfIds();j++)
{
v2=VList->GetId(j);
if (Visited[v2]==0)
VQueue.push(v2);
}
}
VQueue.pop();
}
// Compute barycenter of region, create a new node in the PolyData
Component->Squeeze();
this->ConnectedComponents->AddItem(Component);
Component->Delete();
}
}
VList->Delete();
delete [] Visited;
return (this->ConnectedComponents);
}
| false | false | false | false | false | 0 |
ancestorScope (void)
{
tokenInfo *result = NULL;
unsigned int i;
for (i = Ancestors.count ; i > 0 && result == NULL ; --i)
{
tokenInfo *const token = Ancestors.list + i - 1;
if (token->type == TOKEN_IDENTIFIER &&
token->tag != TAG_UNDEFINED && token->tag != TAG_INTERFACE)
result = token;
}
return result;
}
| false | false | false | false | false | 0 |
SummarizeAverages()
{ int i;
DBT key,value;
Verbose(" x yN (Variable content)\n---------------------------------------------------------\n");
for (i = 0; i < CF_OBSERVABLES; i++)
{
Verbose("%2d. MAX <%-10s-in> = %10f - %10f u %10f\n",i,OBS[i][0],MIN.Q[i].expect,MAX.Q[i].expect,sqrt(MAX.Q[i].var));
}
if ((ERRNO = db_create(&DBP,NULL,0)) != 0)
{
Verbose("Couldn't open average database %s\n",FILENAME);
exit(1);
}
#ifdef CF_OLD_DB
if ((ERRNO = (DBP->open)(DBP,FILENAME,NULL,DB_BTREE,DB_RDONLY,0644)) != 0)
#else
if ((ERRNO = (DBP->open)(DBP,NULL,FILENAME,NULL,DB_BTREE,DB_RDONLY,0644)) != 0)
#endif
{
Verbose("Couldn't open average database %s\n",FILENAME);
exit(1);
}
memset(&key,0,sizeof(key));
memset(&value,0,sizeof(value));
key.data = "DATABASE_AGE";
key.size = strlen("DATABASE_AGE")+1;
if ((ERRNO = DBP->get(DBP,NULL,&key,&value,0)) != 0)
{
if (ERRNO != DB_NOTFOUND)
{
DBP->err(DBP,ERRNO,NULL);
exit(1);
}
}
if (value.data != NULL)
{
AGE = *(double *)(value.data);
Verbose("\n\nDATABASE_AGE %.1f (weeks)\n\n",AGE/CF_WEEK*CF_MEASURE_INTERVAL);
}
}
| false | false | false | false | true | 1 |
update_after_action (Sheet *sheet, WorkbookControl *wbc)
{
gnm_app_recalc ();
if (sheet != NULL) {
g_return_if_fail (IS_SHEET (sheet));
sheet_mark_dirty (sheet);
sheet_update (sheet);
if (sheet->workbook == wb_control_get_workbook (wbc))
WORKBOOK_VIEW_FOREACH_CONTROL (wb_control_view (wbc), control,
wb_control_sheet_focus (control, sheet););
} else if (wbc != NULL) {
Sheet *sheet = wb_control_cur_sheet (wbc);
if (sheet)
sheet_update (sheet);
}
}
| false | false | false | false | false | 0 |
parsed(int tok, const char* end, const char** errPos) {
if (errPos) *errPos = end;
return tok;
}
| false | false | false | false | false | 0 |
gd_notification_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
GdNotification *notification = GD_NOTIFICATION (widget);
GdNotificationPrivate *priv = notification->priv;
GtkBin *bin = GTK_BIN (widget);
GtkAllocation child_allocation;
GtkBorder padding;
GtkRequisition button_req;
GtkWidget *child;
gtk_widget_set_allocation (widget, allocation);
/* If somehow the notification changes while not hidden
and we're not animating, immediately follow the resize */
if (priv->animate_y > 0 &&
!priv->animate_timeout)
priv->animate_y = allocation->height;
get_padding_and_border (notification, &padding);
if (gtk_widget_get_realized (widget))
{
gdk_window_move_resize (gtk_widget_get_window (widget),
allocation->x,
allocation->y,
allocation->width,
allocation->height);
gdk_window_move_resize (priv->bin_window,
0,
-allocation->height + priv->animate_y,
allocation->width,
allocation->height);
}
child_allocation.x = SHADOW_OFFSET_X + padding.left;
child_allocation.y = padding.top;
if (priv->show_close_button)
gtk_widget_get_preferred_size (priv->close_button, &button_req, NULL);
else
button_req.width = button_req.height = 0;
child_allocation.height = MAX (1, allocation->height - SHADOW_OFFSET_Y - padding.top - padding.bottom);
child_allocation.width = MAX (1, (allocation->width - button_req.width -
2 * SHADOW_OFFSET_X - padding.left - padding.right));
child = gtk_bin_get_child (bin);
if (child && gtk_widget_get_visible (child))
gtk_widget_size_allocate (child, &child_allocation);
if (priv->show_close_button)
{
child_allocation.x += child_allocation.width;
child_allocation.width = button_req.width;
child_allocation.y += (child_allocation.height - button_req.height) / 2;
child_allocation.height = button_req.height;
gtk_widget_size_allocate (priv->close_button, &child_allocation);
}
}
| false | false | false | false | false | 0 |
unmarshalProfile(const IOP::TaggedProfile& profile,
IIOP::ProfileBody& body)
{
OMNIORB_ASSERT(profile.tag == IOP::TAG_INTERNET_IOP);
cdrEncapsulationStream s(profile.profile_data.get_buffer(),
profile.profile_data.length(),
1);
body.version.major = s.unmarshalOctet();
body.version.minor = s.unmarshalOctet();
if (body.version.major != 1)
OMNIORB_THROW(MARSHAL,MARSHAL_InvalidIOR,CORBA::COMPLETED_NO);
body.address.host = s.unmarshalRawString();
body.address.port <<= s;
body.object_key <<= s;
if (body.version.minor > 0) {
CORBA::ULong total;
total <<= s;
if (total) {
if (!s.checkInputOverrun(1,total))
OMNIORB_THROW(MARSHAL,MARSHAL_InvalidIOR,CORBA::COMPLETED_NO);
body.components.length(total);
for (CORBA::ULong index=0; index<total; index++) {
body.components[index] <<= s;
}
}
}
// Check that the profile body ends here.
if (s.checkInputOverrun(1,1)) {
if (orbParameters::strictIIOP) {
omniORB::logs(10, "IIOP Profile has garbage at end");
OMNIORB_THROW(MARSHAL,MARSHAL_InvalidIOR,CORBA::COMPLETED_NO);
}
else
omniORB::logs(1, "Warning: IIOP Profile has garbage at end. Ignoring.");
}
}
| false | false | false | false | false | 0 |
stb0899_release(struct dvb_frontend *fe)
{
struct stb0899_state *state = fe->demodulator_priv;
dprintk(state->verbose, FE_DEBUG, 1, "Release Frontend");
/* post process event */
stb0899_postproc(state, STB0899_POSTPROC_GPIO_POWER, 0);
kfree(state);
}
| false | false | false | false | false | 0 |
Reset()
{
m_nLastAllocatedBlock = -1;
// Flush list of garbage blocks
while (m_psGarbageBlocks != NULL)
{
TABBlockRef *psNext = m_psGarbageBlocks->psNext;
CPLFree(m_psGarbageBlocks);
m_psGarbageBlocks = psNext;
}
}
| false | false | false | false | false | 0 |
dupablchain(chain_list* ablchain)
{
chain_list* chain,*res=NULL;
for (chain=ablchain;chain;chain=chain->NEXT) {
res=addchain(res,dupablexpr(chain->DATA));
}
return res;
}
| false | false | false | false | false | 0 |
nocustom (void)
{
if (picasso_on && currprefs.picasso96_nocustom)
return true;
return false;
}
| false | false | false | false | false | 0 |
AddFormInfo(char *value,
char *contenttype,
FormInfo *parent_form_info)
{
FormInfo *form_info;
form_info = (FormInfo *)malloc(sizeof(FormInfo));
if(form_info) {
memset(form_info, 0, sizeof(FormInfo));
if (value)
form_info->value = value;
if (contenttype)
form_info->contenttype = contenttype;
form_info->flags = HTTPPOST_FILENAME;
}
else
return NULL;
if (parent_form_info) {
/* now, point our 'more' to the original 'more' */
form_info->more = parent_form_info->more;
/* then move the original 'more' to point to ourselves */
parent_form_info->more = form_info;
}
else
return NULL;
return form_info;
}
| false | false | false | false | false | 0 |
_Pickler_GetString(PicklerObject *self)
{
PyObject *output_buffer = self->output_buffer;
assert(self->output_buffer != NULL);
self->output_buffer = NULL;
/* Resize down to exact size */
if (_PyBytes_Resize(&output_buffer, self->output_len) < 0)
return NULL;
return output_buffer;
}
| false | false | false | false | false | 0 |
_vala_string_array_contains (gchar** stack, int stack_length, gchar* needle) {
int i;
for (i = 0; i < stack_length; i++) {
if (g_strcmp0 (stack[i], needle) == 0) {
return TRUE;
}
}
return FALSE;
}
| false | false | false | false | false | 0 |
write_phy_reg(struct brcms_phy *pi, u16 addr, u16 val)
{
#ifdef CONFIG_BCM47XX
bcma_wflush16(pi->d11core, D11REGOFFS(phyregaddr), addr);
bcma_write16(pi->d11core, D11REGOFFS(phyregdata), val);
if (addr == 0x72)
(void)bcma_read16(pi->d11core, D11REGOFFS(phyregdata));
#else
bcma_write32(pi->d11core, D11REGOFFS(phyregaddr), addr | (val << 16));
if ((pi->d11core->bus->hosttype == BCMA_HOSTTYPE_PCI) &&
(++pi->phy_wreg >= pi->phy_wreg_limit)) {
pi->phy_wreg = 0;
(void)bcma_read16(pi->d11core, D11REGOFFS(phyversion));
}
#endif
}
| false | false | false | false | false | 0 |
table_values(register tableobject *self)
{
PyObject *v;
const apr_array_header_t *ah;
apr_table_entry_t *elts;
int i, j;
ah = apr_table_elts(self->table);
elts = (apr_table_entry_t *) ah->elts;
/* PYTHON 2.5: 'PyList_New' uses Py_ssize_t for input parameters */
v = PyList_New(ah->nelts);
for (i = 0, j = 0; i < ah->nelts; i++)
{
if (elts[i].key)
{
PyObject *val = NULL;
if (elts[i].val != NULL) {
val = PyString_FromString(elts[i].val);
} else {
val = Py_None;
Py_INCREF(val);
}
/* PYTHON 2.5: 'PyList_SetItem' uses Py_ssize_t for input parameters */
PyList_SetItem(v, j, val);
j++;
}
}
return v;
}
| false | false | false | false | false | 0 |
ff_snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width){
int i;
for(i=0; i<width; i++){
b4[i] -= (W_DM*(b3[i] + b5[i])+W_DO)>>W_DS;
b3[i] -= (W_CM*(b2[i] + b4[i])+W_CO)>>W_CS;
#ifdef liftS
b2[i] += (W_BM*(b1[i] + b3[i])+W_BO)>>W_BS;
#else
b2[i] += (W_BM*(b1[i] + b3[i])+4*b2[i]+W_BO)>>W_BS;
#endif
b1[i] += (W_AM*(b0[i] + b2[i])+W_AO)>>W_AS;
}
}
| false | false | false | false | false | 0 |
gda_tree_node_get_parent (GdaTreeNode *node)
{
GdaTreeNode *parent;
g_return_val_if_fail (GDA_IS_TREE_NODE (node), NULL);
parent = node->priv->parent;
if (parent && !parent->priv->parent)
return NULL; /* avoid returning the private GdaTree's ROOT node */
else
return parent;
}
| false | false | false | false | false | 0 |
ai_is_troop_need_new_camp()
{
//--- check whether the current military force is already big enough ---//
if( ai_has_too_many_camp() )
return 0;
//----- expand if it has enough cash -----//
if( !ai_should_spend(50+pref_military_development/2) )
return 0;
//----- if existing camps can already host all units ----//
int neededSoldierSpace = total_human_count+total_weapon_count - ai_camp_count*MAX_WORKER;
int neededGeneralSpace = total_general_count - ai_camp_count;
return neededSoldierSpace >= 9 + 20 * (100-pref_military_development) / 200 &&
neededGeneralSpace >= 2 + 4 * (100-pref_military_development) / 200;
}
| false | false | false | false | false | 0 |
lo_read_simple(struct loop_device *lo, struct request *rq,
loff_t pos)
{
struct bio_vec bvec;
struct req_iterator iter;
struct iov_iter i;
ssize_t len;
rq_for_each_segment(bvec, rq, iter) {
iov_iter_bvec(&i, ITER_BVEC, &bvec, 1, bvec.bv_len);
len = vfs_iter_read(lo->lo_backing_file, &i, &pos);
if (len < 0)
return len;
flush_dcache_page(bvec.bv_page);
if (len != bvec.bv_len) {
struct bio *bio;
__rq_for_each_bio(bio, rq)
zero_fill_bio(bio);
break;
}
cond_resched();
}
return 0;
}
| false | false | false | false | false | 0 |
work_area_style_free(void *that)
{
work_area_style_ty *this_thing;
this_thing = (work_area_style_ty *)that;
if (!this_thing)
return;
this_thing->reference_count--;
assert(this_thing->reference_count >= 0);
if (this_thing->reference_count > 0)
return;
trace(("work_area_style_free(this_thing = %08lX)\n{\n", (long)this_thing));
if (this_thing->errpos)
{
str_free(this_thing->errpos);
this_thing->errpos = 0;
}
mem_free(this_thing);
trace(("}\n"));
}
| false | false | false | false | false | 0 |
non_ecm_put_bit(void *user_data, int bit)
{
t31_state_t *s;
s = (t31_state_t *) user_data;
if (bit < 0)
{
/* Special conditions */
switch (bit)
{
case PUTBIT_TRAINING_IN_PROGRESS:
break;
case PUTBIT_TRAINING_FAILED:
s->at_state.rx_trained = FALSE;
break;
case PUTBIT_TRAINING_SUCCEEDED:
/* The modem is now trained */
at_put_response_code(&s->at_state, AT_RESPONSE_CODE_CONNECT);
s->at_state.rx_signal_present = TRUE;
s->at_state.rx_trained = TRUE;
break;
case PUTBIT_CARRIER_UP:
break;
case PUTBIT_CARRIER_DOWN:
if (s->at_state.rx_signal_present)
{
s->at_state.rx_data[s->at_state.rx_data_bytes++] = DLE;
s->at_state.rx_data[s->at_state.rx_data_bytes++] = ETX;
s->at_state.at_tx_handler(&s->at_state, s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes);
s->at_state.rx_data_bytes = 0;
at_put_response_code(&s->at_state, AT_RESPONSE_CODE_NO_CARRIER);
t31_set_at_rx_mode(s, AT_MODE_OFFHOOK_COMMAND);
}
s->at_state.rx_signal_present = FALSE;
s->at_state.rx_trained = FALSE;
break;
default:
if (s->at_state.p.result_code_format)
span_log(&s->logging, SPAN_LOG_FLOW, "Eh!\n");
break;
}
return;
}
s->audio.current_byte = (s->audio.current_byte >> 1) | (bit << 7);
if (++s->audio.bit_no >= 8)
{
if (s->audio.current_byte == DLE)
s->at_state.rx_data[s->at_state.rx_data_bytes++] = DLE;
s->at_state.rx_data[s->at_state.rx_data_bytes++] = (uint8_t) s->audio.current_byte;
if (s->at_state.rx_data_bytes >= 250)
{
s->at_state.at_tx_handler(&s->at_state, s->at_state.at_tx_user_data, s->at_state.rx_data, s->at_state.rx_data_bytes);
s->at_state.rx_data_bytes = 0;
}
s->audio.bit_no = 0;
s->audio.current_byte = 0;
}
}
| false | false | false | false | false | 0 |
hostap_set_string(struct net_device *dev, int rid, const char *val)
{
struct hostap_interface *iface;
char buf[MAX_SSID_LEN + 2];
int len;
iface = netdev_priv(dev);
len = strlen(val);
if (len > MAX_SSID_LEN)
return -1;
memset(buf, 0, sizeof(buf));
buf[0] = len; /* little endian 16 bit word */
memcpy(buf + 2, val, len);
return iface->local->func->set_rid(dev, rid, &buf, MAX_SSID_LEN + 2);
}
| false | false | false | false | false | 0 |
printTransformations()
{
llvm::outs() << "Registered Transformations:\n";
std::map<std::string, Transformation *>::iterator I, E;
for (I = TransformationsMap.begin(),
E = TransformationsMap.end();
I != E; ++I) {
llvm::outs() << " [" << (*I).first << "]: ";
llvm::outs() << (*I).second->getDescription() << "\n";
}
}
| false | false | false | false | false | 0 |
parse_timezone(const char *tz)
{
const char *rfc822_timezones[][4] = {
{ "M", NULL }, /* UTC-12 */
{ "L", NULL },
{ "K", NULL },
{ "I", NULL },
{ "H", "PST", NULL }, /* UTC-8 */
{ "G", "MST", "PDT", NULL }, /* UTC-7 */
{ "F", "CST", "MDT", NULL }, /* UTC-6 */
{ "E", "EST", "CDT", NULL }, /* UTC-5 */
{ "D", "EDT", NULL }, /* UTC-4 */
{ "C", NULL },
{ "B", NULL },
{ "A", NULL },
{ "Z", "UT", "GMT", NULL }, /* UTC */
{ "N", NULL },
{ "O", NULL },
{ "P", NULL },
{ "Q", NULL },
{ "R", NULL },
{ "S", NULL },
{ "T", NULL },
{ "U", NULL },
{ "V", NULL },
{ "W", NULL },
{ "X", NULL },
{ "Y", NULL }, /* UTC+12 */
{ NULL },
};
unsigned int i, j;
if ((*tz == '+' || *tz == '-') && strlen(tz) == 5) {
i = atoi(tz);
return ((i/100)*60 + i%100) * 60;
}
for (i = 0; i < nitems(rfc822_timezones); ++i)
for (j = 0; rfc822_timezones[i][j] != NULL; ++j)
if (strcmp(rfc822_timezones[i][j], tz) == 0)
return (i - 12) * 3600;
return 0;
}
| false | false | false | false | false | 0 |
ptnd_probe_delete_all_but(PT_pdc *pdc, int count)
{
PT_tprobes *tprobe;
int i;
for (i=0,tprobe = pdc->tprobes;
tprobe && i< count;
i++,tprobe = tprobe->next ) ;
if (tprobe) {
while(tprobe->next) {
destroy_PT_tprobes( tprobe->next );
}
}
}
| false | false | false | false | false | 0 |
trans_createMessage(const QByteArray &transactionId)
{
// ChannelBind
StunMessage message;
message.setMethod(StunTypes::ChannelBind);
message.setId((const quint8 *)transactionId.data());
QList<StunMessage::Attribute> list;
{
StunMessage::Attribute a;
a.type = StunTypes::CHANNEL_NUMBER;
a.value = StunTypes::createChannelNumber(channelId);
list += a;
}
{
StunMessage::Attribute a;
a.type = StunTypes::XOR_PEER_ADDRESS;
a.value = StunTypes::createXorPeerAddress(addr, port, message.magic(), message.id());
list += a;
}
message.setAttributes(list);
trans->setMessage(message);
}
| false | false | false | false | false | 0 |
cmath_rect(PyObject *self, PyObject *args)
{
Py_complex z;
double r, phi;
if (!PyArg_ParseTuple(args, "dd:rect", &r, &phi))
return NULL;
errno = 0;
PyFPE_START_PROTECT("rect function", return 0)
/* deal with special values */
if (!Py_IS_FINITE(r) || !Py_IS_FINITE(phi)) {
/* if r is +/-infinity and phi is finite but nonzero then
result is (+-INF +-INF i), but we need to compute cos(phi)
and sin(phi) to figure out the signs. */
if (Py_IS_INFINITY(r) && (Py_IS_FINITE(phi)
&& (phi != 0.))) {
if (r > 0) {
z.real = copysign(INF, cos(phi));
z.imag = copysign(INF, sin(phi));
}
else {
z.real = -copysign(INF, cos(phi));
z.imag = -copysign(INF, sin(phi));
}
}
else {
z = rect_special_values[special_type(r)]
[special_type(phi)];
}
/* need to set errno = EDOM if r is a nonzero number and phi
is infinite */
if (r != 0. && !Py_IS_NAN(r) && Py_IS_INFINITY(phi))
errno = EDOM;
else
errno = 0;
}
else if (phi == 0.0) {
/* Workaround for buggy results with phi=-0.0 on OS X 10.8. See
bugs.python.org/issue18513. */
z.real = r;
z.imag = r * phi;
errno = 0;
}
else {
z.real = r * cos(phi);
z.imag = r * sin(phi);
errno = 0;
}
PyFPE_END_PROTECT(z)
if (errno != 0)
return math_error();
else
return PyComplex_FromCComplex(z);
}
| false | false | false | false | false | 0 |
toggleDrugSelector()
{
if (m_CurrentView && m_CurrentView->drugSelector()) {
bool setToVisible = !m_CurrentView->drugSelector()->isVisible();
m_CurrentView->setMinimumHeight(setToVisible ? 600 : 200);
m_CurrentView->drugSelector()->setVisible(setToVisible);
aToggleDrugSelector->setChecked(setToVisible);
}
}
| false | false | false | false | false | 0 |
get_discard_block(Stasche_lm_dt *sld, const int pgno)
{
int i;
Block *ret = NULL;
for (i = 0; i < sld->mt_num * 2; i++) {
if (sld->seclock[i].pp == PRE) {
Block *b = sld->seclock[i].b;
int mtno = b->no;
if (in_IntSet(sld->startf, mtno)
&& sld->taskexepro[b->no] == pgno) {
ret = b;
}
}
}
return ret;
}
| false | false | false | false | false | 0 |
camel_folder_change_info_add_update_list (CamelFolderChangeInfo *info,
const GPtrArray *list)
{
gint i;
g_return_if_fail (info != NULL);
g_return_if_fail (list != NULL);
for (i = 0; i < list->len; i++)
camel_folder_change_info_add_update (info, list->pdata[i]);
}
| false | false | false | false | false | 0 |
folks_debug_print_heading (FolksDebug* self, const gchar* domain, GLogLevelFlags level, const gchar* format, ...) {
static const gint heading_colours[] = {31, 32, 34};
gchar* wrapper_format = NULL;
gchar* _tmp0_ = NULL;
gboolean _tmp1_ = FALSE;
gboolean _tmp2_ = FALSE;
va_list valist = {0};
gchar* output = NULL;
const gchar* _tmp8_ = NULL;
gchar* _tmp9_ = NULL;
const gchar* _tmp10_ = NULL;
GLogLevelFlags _tmp11_ = 0;
const gchar* _tmp12_ = NULL;
g_return_if_fail (self != NULL);
g_return_if_fail (domain != NULL);
g_return_if_fail (format != NULL);
_tmp0_ = g_strdup ("%s");
wrapper_format = _tmp0_;
_tmp1_ = folks_debug_get_colour_enabled (self);
_tmp2_ = _tmp1_;
if (_tmp2_ == TRUE) {
guint indentation = 0U;
guint _tmp3_ = 0U;
guint _tmp4_ = 0U;
guint _tmp5_ = 0U;
gint _tmp6_ = 0;
gchar* _tmp7_ = NULL;
_tmp3_ = self->priv->_indentation;
_tmp4_ = CLAMP (_tmp3_, (guint) 0, (guint) (G_N_ELEMENTS (heading_colours) - 1));
indentation = _tmp4_;
_tmp5_ = indentation;
_tmp6_ = heading_colours[_tmp5_];
_tmp7_ = g_strdup_printf ("\033[1;%im%%s\033[0m", _tmp6_);
_g_free0 (wrapper_format);
wrapper_format = _tmp7_;
}
va_start (valist, format);
_tmp8_ = format;
_tmp9_ = g_strdup_vprintf (_tmp8_, valist);
output = _tmp9_;
_tmp10_ = domain;
_tmp11_ = level;
_tmp12_ = wrapper_format;
folks_debug_print_line (self, _tmp10_, _tmp11_, _tmp12_, output);
_g_free0 (output);
va_end (valist);
_g_free0 (wrapper_format);
}
| 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.