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 |
|---|---|---|---|---|---|---|
uwb_rc_neh_match(struct uwb_rc_neh *neh, const struct uwb_rceb *rceb)
{
return neh->evt_type == rceb->bEventType
&& neh->evt == rceb->wEvent
&& neh->context == rceb->bEventContext;
} | false | false | false | false | false | 0 |
Resize(const vtkIdType sz)
{
vtkPriorityQueue::Item *newArray;
vtkIdType newSize;
if (sz >= this->Size)
{
newSize = this->Size + sz;
}
else
{
newSize = sz;
}
if (newSize <= 0)
{
newSize = 1;
}
newArray = new vtkPriorityQueue::Item[newSize];
if (this->Array)
{
memcpy(newArray, this->Array,
(sz < this->Size ? sz : this->Size) * sizeof(vtkPriorityQueue::Item));
delete [] this->Array;
}
this->Size = newSize;
this->Array = newArray;
return this->Array;
} | false | false | false | false | false | 0 |
ddf_GetNumberType(const char *line)
{
ddf_NumberType nt;
if (strncmp(line, "integer", 7)==0) {
nt = ddf_Integer;
}
else if (strncmp(line, "rational", 8)==0) {
nt = ddf_Rational;
}
else if (strncmp(line, "real", 4)==0) {
nt = ddf_Real;
}
else {
nt=ddf_Unknown;
}
return nt;
} | false | false | false | false | false | 0 |
brasero_iso9660_get_susp (BraseroIsoCtx *ctx,
BraseroIsoDirRec *record,
guint *susp_len)
{
gchar *susp_block;
gint start;
gint len;
start = sizeof (BraseroIsoDirRec) + record->id_size;
/* padding byte when id_size is an even number */
if (start & 1)
start ++;
if (ctx->susp_skip)
start += ctx->susp_skip;
/* we don't want to go beyond end of buffer */
if (start >= record->record_size)
return NULL;
len = record->record_size - start;
if (len <= 0)
return NULL;
if (susp_len)
*susp_len = len;
susp_block = ((gchar *) record) + start;
BRASERO_MEDIA_LOG ("Got susp block");
return susp_block;
} | false | false | false | true | false | 1 |
verify(chunk_t chunk)
{
container_t *container;
pkcs7_t *pkcs7;
enumerator_t *enumerator;
certificate_t *cert;
auth_cfg_t *auth;
chunk_t data;
time_t t;
bool verified = FALSE;
container = lib->creds->create(lib->creds, CRED_CONTAINER, CONTAINER_PKCS7,
BUILD_BLOB_ASN1_DER, chunk, BUILD_END);
if (!container)
{
return 1;
}
if (container->get_type(container) != CONTAINER_PKCS7_SIGNED_DATA)
{
fprintf(stderr, "verification failed, container is %N\n",
container_type_names, container->get_type(container));
container->destroy(container);
return 1;
}
pkcs7 = (pkcs7_t*)container;
enumerator = container->create_signature_enumerator(container);
while (enumerator->enumerate(enumerator, &auth))
{
verified = TRUE;
cert = auth->get(auth, AUTH_RULE_SUBJECT_CERT);
if (cert)
{
fprintf(stderr, "signed by '%Y'", cert->get_subject(cert));
if (pkcs7->get_attribute(pkcs7, OID_PKCS9_SIGNING_TIME,
enumerator, &data))
{
t = asn1_to_time(&data, ASN1_UTCTIME);
if (t != UNDEFINED_TIME)
{
fprintf(stderr, " at %T", &t, FALSE);
}
free(data.ptr);
}
fprintf(stderr, "\n");
}
}
enumerator->destroy(enumerator);
if (!verified)
{
fprintf(stderr, "no trusted signature found\n");
}
if (verified)
{
if (container->get_data(container, &data))
{
write_to_stream(stdout, data);
free(data.ptr);
}
else
{
verified = FALSE;
}
}
container->destroy(container);
return verified ? 0 : 1;
} | false | false | false | false | false | 0 |
load_config_from_buf(const gchar *buf, gsize size, gboolean startup)
{
GMarkupParseContext *context;
gboolean ret = TRUE;
GQParserData *parser_data;
parser_data = g_new0(GQParserData, 1);
parser_data->startup = startup;
options_parse_func_push(parser_data, options_parse_toplevel, NULL, NULL);
context = g_markup_parse_context_new(&parser, 0, parser_data, NULL);
if (g_markup_parse_context_parse(context, buf, size, NULL) == FALSE)
{
ret = FALSE;
DEBUG_1("Parse failed");
}
g_free(parser_data);
g_markup_parse_context_free(context);
return ret;
} | false | false | false | false | false | 0 |
acot(const RCP<const Basic> &arg)
{
if (eq(arg, zero)) return div(pi, i2);
else if (eq(arg, one)) return div(pi, mul(i2, i2));
else if (eq(arg, minus_one)) return mul(i3, div(pi, mul(i2, i2)));
RCP<const Basic> index;
bool b = inverse_lookup(inverse_tct, arg, outArg(index));
if (b) {
if (could_extract_minus(index)) {
return add(pi, div(pi, index));
}
else {
return sub(div(pi, i2), div(pi, index));
}
} else {
return rcp(new ACot(arg));
}
} | false | false | false | false | false | 0 |
trim_zeros_after_decimal( char* src )
{
char * end = src + strlen( src ) - 1;
while( end != src )
{
if( *end == '0' )
*end = 0;
else if( *end == '.' )
{
*end = 0;
break;
}
else
break;
end--;
}
} | false | false | false | false | false | 0 |
getMaxCalleeSavedReg(const std::vector<CalleeSavedInfo> &CSI,
const TargetRegisterInfo &TRI) {
assert(Hexagon::R1 > 0 &&
"Assume physical registers are encoded as positive integers");
if (CSI.empty())
return 0;
unsigned Max = getMax32BitSubRegister(CSI[0].getReg(), TRI);
for (unsigned I = 1, E = CSI.size(); I < E; ++I) {
unsigned Reg = getMax32BitSubRegister(CSI[I].getReg(), TRI);
if (Reg > Max)
Max = Reg;
}
return Max;
} | false | false | false | false | false | 0 |
clk_mux_get_parent(struct clk_hw *hw)
{
struct clk_mux *mux = to_clk_mux(hw);
int num_parents = clk_hw_get_num_parents(hw);
u32 val;
/*
* FIXME need a mux-specific flag to determine if val is bitwise or numeric
* e.g. sys_clkin_ck's clksel field is 3 bits wide, but ranges from 0x1
* to 0x7 (index starts at one)
* OTOH, pmd_trace_clk_mux_ck uses a separate bit for each clock, so
* val = 0x4 really means "bit 2, index starts at bit 0"
*/
val = clk_readl(mux->reg) >> mux->shift;
val &= mux->mask;
if (mux->table) {
int i;
for (i = 0; i < num_parents; i++)
if (mux->table[i] == val)
return i;
return -EINVAL;
}
if (val && (mux->flags & CLK_MUX_INDEX_BIT))
val = ffs(val) - 1;
if (val && (mux->flags & CLK_MUX_INDEX_ONE))
val--;
if (val >= num_parents)
return -EINVAL;
return val;
} | false | false | false | false | false | 0 |
videomode_from_timings(const struct display_timings *disp,
struct videomode *vm, unsigned int index)
{
struct display_timing *dt;
dt = display_timings_get(disp, index);
if (!dt)
return -EINVAL;
videomode_from_timing(dt, vm);
return 0;
} | false | false | false | false | false | 0 |
multi_join_create_game()
{
// maybe warn the player about possible crappy server conditions
if(!multi_join_maybe_warn()){
return;
}
// make sure to flag ourself as being the master
Net_player->flags |= (NETINFO_FLAG_AM_MASTER | NETINFO_FLAG_GAME_HOST);
Net_player->state = NETPLAYER_STATE_HOST_SETUP;
// if we're in PXO mode, mark it down in our player struct
if(MULTI_IS_TRACKER_GAME){
Player->flags |= PLAYER_FLAGS_HAS_PLAYED_PXO;
Player->save_flags |= PLAYER_FLAGS_HAS_PLAYED_PXO;
}
// otherwise, if he's already played PXO games, warn him
else {
if(Player->flags & PLAYER_FLAGS_HAS_PLAYED_PXO){
if(!multi_join_warn_pxo()){
return;
}
}
}
gameseq_post_event(GS_EVENT_MULTI_START_GAME);
gamesnd_play_iface(SND_USER_SELECT);
} | false | false | false | false | false | 0 |
getUL(DcmDataset *obj, DcmTagKey t, Uint32 *ul)
{
DcmElement *elem;
DcmStack stack;
OFCondition ec = EC_Normal;
ec = obj->search(t, stack);
elem = (DcmElement*)stack.top();
if (ec == EC_Normal && elem != NULL) {
ec = elem->getUint32(*ul, 0);
}
return (ec == EC_Normal)?(EC_Normal):(DIMSE_PARSEFAILED);
} | false | false | false | false | false | 0 |
is_associated_namespace (tree current, tree scope)
{
vec<tree, va_gc> *seen = make_tree_vector ();
vec<tree, va_gc> *todo = make_tree_vector ();
tree t;
bool ret;
while (1)
{
if (scope == current)
{
ret = true;
break;
}
vec_safe_push (seen, scope);
for (t = DECL_NAMESPACE_ASSOCIATIONS (scope); t; t = TREE_CHAIN (t))
if (!vec_member (TREE_PURPOSE (t), seen))
vec_safe_push (todo, TREE_PURPOSE (t));
if (!todo->is_empty ())
{
scope = todo->last ();
todo->pop ();
}
else
{
ret = false;
break;
}
}
release_tree_vector (seen);
release_tree_vector (todo);
return ret;
} | false | false | false | false | false | 0 |
qlcnic_83xx_config_hw_lro(struct qlcnic_adapter *adapter, int mode)
{
int err;
u32 temp, arg1;
struct qlcnic_cmd_args cmd;
int lro_bit_mask;
lro_bit_mask = (mode ? (BIT_0 | BIT_1 | BIT_2 | BIT_3) : 0);
if (adapter->recv_ctx->state == QLCNIC_HOST_CTX_STATE_FREED)
return 0;
err = qlcnic_alloc_mbx_args(&cmd, adapter, QLCNIC_CMD_CONFIGURE_HW_LRO);
if (err)
return err;
temp = adapter->recv_ctx->context_id << 16;
arg1 = lro_bit_mask | temp;
cmd.req.arg[1] = arg1;
err = qlcnic_issue_cmd(adapter, &cmd);
if (err)
dev_info(&adapter->pdev->dev, "LRO config failed\n");
qlcnic_free_mbx_args(&cmd);
return err;
} | false | false | false | false | false | 0 |
OTF_File_size( OTF_File* file ) {
struct stat st;
if ( NULL != file->iofsl ) {
return OTF_File_iofsl_size( file );
}
if ( NULL != file->externalbuffer ) {
OTF_Error( "ERROR in function %s, file: %s, line: %i:\n "
"not yet supported in 'external buffer' mode.\n",
__FUNCTION__, __FILE__, __LINE__ );
return (uint64_t) -1;
}
if ( stat( file->filename, &st ) == -1 ) {
OTF_Error( "ERROR in function %s, file: %s, line: %i:\n "
"stat() failed: %s\n",
__FUNCTION__, __FILE__, __LINE__,
strerror(errno) );
return 0;
} else {
return st.st_size;
}
} | false | false | false | false | false | 0 |
dsgw_change( char *s, dsgwsubst *changes )
{
auto dsgwsubst *ch;
if ( changes == NULL ) return s;
for ( ch = changes; ch; ch = ch->dsgwsubst_next ) {
if ( strstr( s, ch->dsgwsubst_from ) ) {
break;
}
}
if ( ch != NULL ) {
auto char *cs = dsgw_ch_strdup( s );
for ( ch = changes; ch; ch = ch->dsgwsubst_next ) {
auto const size_t from_len = strlen( ch->dsgwsubst_from );
auto const size_t to_len = strlen( ch->dsgwsubst_to );
auto const long change_len = to_len - from_len;
auto char *p;
for ( p = cs; (p = strstr( p, ch->dsgwsubst_from )) != NULL; p += to_len ) {
if ( change_len ) {
if ( change_len > 0 ) { /* allocate more space: */
auto const size_t offset = p - cs;
cs = dsgw_ch_realloc( cs, strlen( cs ) + change_len + 1 );
p = cs + offset;
}
memmove( p + to_len, p + from_len, strlen( p + from_len ) + 1 );
}
if ( to_len != 0 ) {
memcpy( p, ch->dsgwsubst_to, to_len );
}
}
}
return cs;
}
return s;
} | false | true | false | false | false | 1 |
remove_field(const Glib::ustring& parent_table_name, const Glib::ustring& table_name, const Glib::ustring& field_name)
{
//Look at each item:
LayoutGroup::type_list_items::iterator iterItem = m_list_items.begin();
while(iterItem != m_list_items.end())
{
sharedptr<LayoutItem> item = *iterItem;
sharedptr<LayoutItem_Field> field_item = sharedptr<LayoutItem_Field>::cast_dynamic(item);
if(field_item)
{
if(field_item->get_table_used(parent_table_name) == table_name)
{
if(field_item->get_name() == field_name)
{
m_list_items.erase(iterItem);
iterItem = m_list_items.begin(); //Start again, because we changed the container.AddDel
continue;
}
}
}
else
{
sharedptr<LayoutGroup> sub_group = sharedptr<LayoutGroup>::cast_dynamic(item);
if(sub_group)
sub_group->remove_field(parent_table_name, table_name, field_name);
}
++iterItem;
}
} | false | false | false | false | false | 0 |
formatNumeric(
UDate date, // Time since epoch 1:30:00 would be 5400000
const DateFormat &dateFmt, // h:mm, m:ss, or h:mm:ss
UDateFormatField smallestField, // seconds in 5:37:23.5
const Formattable &smallestAmount, // 23.5 for 5:37:23.5
UnicodeString &appendTo,
UErrorCode &status) const {
if (U_FAILURE(status)) {
return appendTo;
}
// Format the smallest amount with this object's NumberFormat
UnicodeString smallestAmountFormatted;
// We keep track of the integer part of smallest amount so that
// we can replace it later so that we get '0:00:09.3' instead of
// '0:00:9.3'
FieldPosition intFieldPosition(UNUM_INTEGER_FIELD);
(*numberFormat)->format(
smallestAmount, smallestAmountFormatted, intFieldPosition, status);
if (
intFieldPosition.getBeginIndex() == 0 &&
intFieldPosition.getEndIndex() == 0) {
status = U_INTERNAL_PROGRAM_ERROR;
return appendTo;
}
// Format time. draft becomes something like '5:30:45'
FieldPosition smallestFieldPosition(smallestField);
UnicodeString draft;
dateFmt.format(date, draft, smallestFieldPosition, status);
// If we find field for smallest amount replace it with the formatted
// smallest amount from above taking care to replace the integer part
// with what is in original time. For example, If smallest amount
// is 9.35s and the formatted time is 0:00:09 then 9.35 becomes 09.35
// and replacing yields 0:00:09.35
if (smallestFieldPosition.getBeginIndex() != 0 ||
smallestFieldPosition.getEndIndex() != 0) {
appendRange(draft, 0, smallestFieldPosition.getBeginIndex(), appendTo);
appendRange(
smallestAmountFormatted,
0,
intFieldPosition.getBeginIndex(),
appendTo);
appendRange(
draft,
smallestFieldPosition.getBeginIndex(),
smallestFieldPosition.getEndIndex(),
appendTo);
appendRange(
smallestAmountFormatted,
intFieldPosition.getEndIndex(),
appendTo);
appendRange(
draft,
smallestFieldPosition.getEndIndex(),
appendTo);
} else {
appendTo.append(draft);
}
return appendTo;
} | false | false | false | false | false | 0 |
printRequiredAttributeMessage(const DcmTagKey &key,
const OFFilename &filename,
const OFBool emptyMsg)
{
OFString str;
if (!filename.isEmpty())
{
str = " in file: ";
str += OFSTRING_GUARD(filename.getCharPointer());
}
DCMDATA_ERROR("required attribute " << DcmTag(key).getTagName() << " " << key << " "
<< (emptyMsg ? "empty" : "missing") << str);
} | false | false | false | false | false | 0 |
rad_continuation2vp(const RADIUS_PACKET *packet,
const RADIUS_PACKET *original,
const char *secret, int attribute,
int length, /* CANNOT be zero */
uint8_t *data, size_t packet_length,
int flag, DICT_ATTR *da)
{
size_t tlv_length, left;
uint8_t *ptr;
uint8_t *tlv_data;
VALUE_PAIR *vp, *head, **tail;
/*
* Ensure we have data that hasn't been split across
* multiple attributes.
*/
if (flag) {
tlv_data = rad_coalesce(attribute, length,
data, packet_length, &tlv_length);
if (!tlv_data) return NULL;
} else {
tlv_data = data;
tlv_length = length;
}
/*
* Non-TLV types cannot be continued across multiple
* attributes. This is true even of keys that are
* encrypted with the tunnel-password method. The spec
* says that they can be continued... but also that the
* keys are 160 bits, which means that they CANNOT be
* continued. <sigh>
*
* Note that we don't check "flag" here. The calling
* code ensures that
*/
if (!da || (da->type != PW_TYPE_TLV)) {
not_well_formed:
if (tlv_data == data) { /* true if we had 'goto' */
tlv_data = malloc(tlv_length);
if (!tlv_data) return NULL;
memcpy(tlv_data, data, tlv_length);
}
vp = paircreate(attribute, PW_TYPE_OCTETS);
if (!vp) return NULL;
vp->type = PW_TYPE_TLV;
vp->flags.encrypt = FLAG_ENCRYPT_NONE;
vp->flags.has_tag = 0;
vp->flags.is_tlv = 0;
vp->vp_tlv = tlv_data;
vp->length = tlv_length;
return vp;
} /* else it WAS a TLV, go decode the sub-tlv's */
/*
* Now (sigh) we walk over the TLV, seeing if it is
* well-formed.
*/
left = tlv_length;
for (ptr = tlv_data;
ptr != (tlv_data + tlv_length);
ptr += ptr[1]) {
if ((left < 2) ||
(ptr[1] < 2) ||
(ptr[1] > left)) {
goto not_well_formed;
}
left -= ptr[1];
}
/*
* Now we walk over the TLV *again*, creating sub-tlv's.
*/
head = NULL;
tail = &head;
for (ptr = tlv_data;
ptr != (tlv_data + tlv_length);
ptr += ptr[1]) {
vp = paircreate(attribute | (ptr[0] << 8), PW_TYPE_OCTETS);
if (!vp) {
pairfree(&head);
goto not_well_formed;
}
vp = data2vp(packet, original, secret,
ptr[0], ptr[1] - 2, ptr + 2, vp);
if (!vp) { /* called frees vp */
pairfree(&head);
goto not_well_formed;
}
*tail = vp;
tail = &(vp->next);
}
/*
* TLV's MAY be continued, but sometimes they're not.
*/
if (tlv_data != data) free(tlv_data);
if (head->next) rad_sortvp(&head);
return head;
} | false | false | false | true | true | 1 |
example_4()
{
static const char* xml =
"<information>"
" <attributeApproach v='2' />"
" <textApproach>"
" <v>2</v>"
" </textApproach>"
"</information>";
XMLDocument doc;
doc.Parse( xml );
int v0 = 0;
int v1 = 0;
XMLElement* attributeApproachElement = doc.FirstChildElement()->FirstChildElement( "attributeApproach" );
attributeApproachElement->QueryIntAttribute( "v", &v0 );
XMLElement* textApproachElement = doc.FirstChildElement()->FirstChildElement( "textApproach" );
textApproachElement->FirstChildElement( "v" )->QueryIntText( &v1 );
printf( "Both values are the same: %d and %d\n", v0, v1 );
return !doc.Error() && ( v0 == v1 );
} | false | false | false | false | false | 0 |
vacuum_heap(VRelStats *vacrelstats, Relation onerel, VacPageList vacuum_pages)
{
Buffer buf;
VacPage *vacpage;
BlockNumber relblocks;
int nblocks;
int i;
nblocks = vacuum_pages->num_pages;
nblocks -= vacuum_pages->empty_end_pages; /* nothing to do with them */
for (i = 0, vacpage = vacuum_pages->pagedesc; i < nblocks; i++, vacpage++)
{
vacuum_delay_point();
if ((*vacpage)->offsets_free > 0)
{
buf = ReadBufferExtended(onerel, MAIN_FORKNUM, (*vacpage)->blkno,
RBM_NORMAL, vac_strategy);
LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE);
vacuum_page(onerel, buf, *vacpage);
UnlockReleaseBuffer(buf);
}
}
/* Truncate relation if there are some empty end-pages */
Assert(vacrelstats->rel_pages >= vacuum_pages->empty_end_pages);
if (vacuum_pages->empty_end_pages > 0)
{
relblocks = vacrelstats->rel_pages - vacuum_pages->empty_end_pages;
ereport(elevel,
(errmsg("\"%s\": truncated %u to %u pages",
RelationGetRelationName(onerel),
vacrelstats->rel_pages, relblocks)));
RelationTruncate(onerel, relblocks);
/* force relcache inval so all backends reset their rd_targblock */
CacheInvalidateRelcache(onerel);
vacrelstats->rel_pages = relblocks; /* set new number of blocks */
}
} | false | false | false | false | false | 0 |
usbdev_read(struct file *file, char __user *buf, size_t nbytes,
loff_t *ppos)
{
struct usb_dev_state *ps = file->private_data;
struct usb_device *dev = ps->dev;
ssize_t ret = 0;
unsigned len;
loff_t pos;
int i;
pos = *ppos;
usb_lock_device(dev);
if (!connected(ps)) {
ret = -ENODEV;
goto err;
} else if (pos < 0) {
ret = -EINVAL;
goto err;
}
if (pos < sizeof(struct usb_device_descriptor)) {
/* 18 bytes - fits on the stack */
struct usb_device_descriptor temp_desc;
memcpy(&temp_desc, &dev->descriptor, sizeof(dev->descriptor));
le16_to_cpus(&temp_desc.bcdUSB);
le16_to_cpus(&temp_desc.idVendor);
le16_to_cpus(&temp_desc.idProduct);
le16_to_cpus(&temp_desc.bcdDevice);
len = sizeof(struct usb_device_descriptor) - pos;
if (len > nbytes)
len = nbytes;
if (copy_to_user(buf, ((char *)&temp_desc) + pos, len)) {
ret = -EFAULT;
goto err;
}
*ppos += len;
buf += len;
nbytes -= len;
ret += len;
}
pos = sizeof(struct usb_device_descriptor);
for (i = 0; nbytes && i < dev->descriptor.bNumConfigurations; i++) {
struct usb_config_descriptor *config =
(struct usb_config_descriptor *)dev->rawdescriptors[i];
unsigned int length = le16_to_cpu(config->wTotalLength);
if (*ppos < pos + length) {
/* The descriptor may claim to be longer than it
* really is. Here is the actual allocated length. */
unsigned alloclen =
le16_to_cpu(dev->config[i].desc.wTotalLength);
len = length - (*ppos - pos);
if (len > nbytes)
len = nbytes;
/* Simply don't write (skip over) unallocated parts */
if (alloclen > (*ppos - pos)) {
alloclen -= (*ppos - pos);
if (copy_to_user(buf,
dev->rawdescriptors[i] + (*ppos - pos),
min(len, alloclen))) {
ret = -EFAULT;
goto err;
}
}
*ppos += len;
buf += len;
nbytes -= len;
ret += len;
}
pos += length;
}
err:
usb_unlock_device(dev);
return ret;
} | false | false | false | false | false | 0 |
sftp_recvdata(char *buf, int len)
{
outptr = (unsigned char *) buf;
outlen = len;
/*
* See if the pending-input block contains some of what we
* need.
*/
if (pendlen > 0) {
unsigned pendused = pendlen;
if (pendused > outlen)
pendused = outlen;
memcpy(outptr, pending, pendused);
memmove(pending, pending + pendused, pendlen - pendused);
outptr += pendused;
outlen -= pendused;
pendlen -= pendused;
if (pendlen == 0) {
pendsize = 0;
sfree(pending);
pending = NULL;
}
if (outlen == 0)
return 1;
}
while (outlen > 0) {
if (back->exitcode(backhandle) >= 0 || ssh_sftp_loop_iteration() < 0)
return 0; /* doom */
}
return 1;
} | false | true | false | false | false | 1 |
egg_list_box_reseparate (EggListBox *list_box)
{
EggListBoxPrivate *priv = list_box->priv;
GSequenceIter *iter;
g_return_if_fail (list_box != NULL);
for (iter = g_sequence_get_begin_iter (priv->children);
!g_sequence_iter_is_end (iter);
iter = g_sequence_iter_next (iter))
egg_list_box_update_separator (list_box, iter);
gtk_widget_queue_resize (GTK_WIDGET (list_box));
} | false | false | false | false | false | 0 |
test_comment_query_async_progress_closure (QueryCommentsData *query_data, gconstpointer service)
{
GDataAsyncProgressClosure *data = g_slice_new0 (GDataAsyncProgressClosure);
gdata_test_mock_server_start_trace (mock_server, "comment-query-async-progress-closure");
data->main_loop = g_main_loop_new (NULL, TRUE);
gdata_commentable_query_comments_async (GDATA_COMMENTABLE (query_data->parent.file1), GDATA_SERVICE (service), NULL, NULL,
(GDataQueryProgressCallback) gdata_test_async_progress_callback,
data, (GDestroyNotify) gdata_test_async_progress_closure_free,
(GAsyncReadyCallback) gdata_test_async_progress_finish_callback, data);
g_main_loop_run (data->main_loop);
g_main_loop_unref (data->main_loop);
/* Check that both callbacks were called exactly once */
g_assert_cmpuint (data->progress_destroy_notify_count, ==, 1);
g_assert_cmpuint (data->async_ready_notify_count, ==, 1);
g_slice_free (GDataAsyncProgressClosure, data);
gdata_mock_server_end_trace (mock_server);
} | false | false | false | false | false | 0 |
RAND_write_file(const char *file)
{
unsigned char buf[BUFSIZE];
int i,ret=0,rand_err=0;
FILE *out = NULL;
int n;
#ifndef OPENSSL_NO_POSIX_IO
struct stat sb;
i=stat(file,&sb);
if (i != -1) {
#if defined(S_ISBLK) && defined(S_ISCHR)
if (S_ISBLK(sb.st_mode) || S_ISCHR(sb.st_mode)) {
/* this file is a device. we don't write back to it.
* we "succeed" on the assumption this is some sort
* of random device. Otherwise attempting to write to
* and chmod the device causes problems.
*/
return(1);
}
#endif
}
#endif
#if defined(O_CREAT) && !defined(OPENSSL_NO_POSIX_IO) && !defined(OPENSSL_SYS_VMS)
{
#ifndef O_BINARY
#define O_BINARY 0
#endif
/* chmod(..., 0600) is too late to protect the file,
* permissions should be restrictive from the start */
int fd = open(file, O_WRONLY|O_CREAT|O_BINARY, 0600);
if (fd != -1)
out = fdopen(fd, "wb");
}
#endif
#ifdef OPENSSL_SYS_VMS
/* VMS NOTE: Prior versions of this routine created a _new_
* version of the rand file for each call into this routine, then
* deleted all existing versions named ;-1, and finally renamed
* the current version as ';1'. Under concurrent usage, this
* resulted in an RMS race condition in rename() which could
* orphan files (see vms message help for RMS$_REENT). With the
* fopen() calls below, openssl/VMS now shares the top-level
* version of the rand file. Note that there may still be
* conditions where the top-level rand file is locked. If so, this
* code will then create a new version of the rand file. Without
* the delete and rename code, this can result in ascending file
* versions that stop at version 32767, and this routine will then
* return an error. The remedy for this is to recode the calling
* application to avoid concurrent use of the rand file, or
* synchronize usage at the application level. Also consider
* whether or not you NEED a persistent rand file in a concurrent
* use situation.
*/
out = vms_fopen(file,"rb+",VMS_OPEN_ATTRS);
if (out == NULL)
out = vms_fopen(file,"wb",VMS_OPEN_ATTRS);
#else
if (out == NULL)
out = fopen(file,"wb");
#endif
if (out == NULL) goto err;
#ifndef NO_CHMOD
chmod(file,0600);
#endif
n=RAND_DATA;
for (;;)
{
i=(n > BUFSIZE)?BUFSIZE:n;
n-=BUFSIZE;
if (RAND_bytes(buf,i) <= 0)
rand_err=1;
i=fwrite(buf,1,i,out);
if (i <= 0)
{
ret=0;
break;
}
ret+=i;
if (n <= 0) break;
}
fclose(out);
OPENSSL_cleanse(buf,BUFSIZE);
err:
return (rand_err ? -1 : ret);
} | true | true | false | false | true | 1 |
highlight_get_color(int highlight, bool is_background)
{
size_t idx=0;
rgb_color_t result;
if (highlight < 0)
return rgb_color_t::normal();
if (highlight > (1<<VAR_COUNT))
return rgb_color_t::normal();
for (size_t i=0; i<VAR_COUNT; i++)
{
if (highlight & (1<<i))
{
idx = i;
break;
}
}
env_var_t val_wstr = env_get_string(highlight_var[idx]);
// debug( 1, L"%d -> %d -> %ls", highlight, idx, val );
if (val_wstr.missing())
val_wstr = env_get_string(highlight_var[0]);
if (! val_wstr.missing())
result = parse_color(val_wstr, is_background);
if (highlight & HIGHLIGHT_VALID_PATH)
{
env_var_t val2_wstr = env_get_string(L"fish_color_valid_path");
const wcstring val2 = val2_wstr.missing() ? L"" : val2_wstr.c_str();
rgb_color_t result2 = parse_color(val2, is_background);
if (result.is_normal())
result = result2;
else
{
if (result2.is_bold())
result.set_bold(true);
if (result2.is_underline())
result.set_underline(true);
}
}
return result;
} | false | false | false | false | false | 0 |
parse_cat_blob(void)
{
const char *p;
struct object_entry *oe = oe;
unsigned char sha1[20];
/* cat-blob SP <object> LF */
p = command_buf.buf + strlen("cat-blob ");
if (*p == ':') {
char *x;
oe = find_mark(strtoumax(p + 1, &x, 10));
if (x == p + 1)
die("Invalid mark: %s", command_buf.buf);
if (!oe)
die("Unknown mark: %s", command_buf.buf);
if (*x)
die("Garbage after mark: %s", command_buf.buf);
hashcpy(sha1, oe->idx.sha1);
} else {
if (get_sha1_hex(p, sha1))
die("Invalid SHA1: %s", command_buf.buf);
if (p[40])
die("Garbage after SHA1: %s", command_buf.buf);
oe = find_object(sha1);
}
cat_blob(oe, sha1);
} | true | true | false | false | true | 1 |
sinfo_new_fit_params( int n_params )
{
FitParams ** new_params =NULL;
FitParams * temp_params =NULL;
float * temp_fit_mem =NULL;
float * temp_derv_mem=NULL;
int i ;
if ( n_params <= 0 )
{
sinfo_msg_error (" wrong number of lines to fit\n") ;
return NULL ;
}
if (NULL==(new_params=(FitParams **) cpl_calloc ( n_params ,
sizeof (FitParams*) ) ) )
{
sinfo_msg_error (" could not allocate memory\n") ;
return NULL ;
}
if ( NULL == (temp_params = cpl_calloc ( n_params , sizeof (FitParams) ) ) )
{
sinfo_msg_error (" could not allocate memory\n") ;
return NULL ;
}
if ( NULL == (temp_fit_mem = (float *) cpl_calloc( n_params*MAXPAR,
sizeof (float) ) ) )
{
sinfo_msg_error (" could not allocate memory\n") ;
return NULL ;
}
if ( NULL == (temp_derv_mem =
(float *) cpl_calloc( n_params*MAXPAR, sizeof (float) ) ) )
{
sinfo_msg_error (" could not allocate memory\n") ;
return NULL ;
}
for ( i = 0 ; i < n_params ; i ++ )
{
new_params[i] = temp_params+i;
new_params[i] -> fit_par = temp_fit_mem+i*MAXPAR;
new_params[i] -> derv_par = temp_derv_mem+i*MAXPAR;
new_params[i] -> column = 0 ;
new_params[i] -> line = 0 ;
new_params[i] -> wavelength = 0. ;
new_params[i] -> n_params = n_params ;
}
return new_params ;
} | false | false | false | false | false | 0 |
ReadMeshInformation()
{
// Define input file stream and attach it to input file
OpenFile();
// Read and analyze the first line in the file
SizeValueType numberOfCellPoints = 0;
this->m_NumberOfPoints = 0;
this->m_NumberOfCells = 0;
this->m_NumberOfPointPixels = 0;
std::string line;
std::string inputLine;
std::string type;
std::locale loc;
while ( std::getline(m_InputFile, line, '\n') )
{
inputLine.clear();
for ( unsigned int ii = 0; ii < line.size(); ii++ )
{
if ( !std::isspace(line[ii], loc) )
{
type = line[ii];
inputLine = line.substr(ii + 1);
break;
}
}
if ( !inputLine.empty() )
{
if ( type == "v" )
{
this->m_NumberOfPoints++;
}
else if ( type == "f" )
{
this->m_NumberOfCells++;
std::stringstream ss(inputLine);
std::string item;
while ( ss >> item )
{
numberOfCellPoints++;
}
}
else if ( type == "vn" )
{
this->m_NumberOfPointPixels++;
this->m_UpdatePointData = true;
}
}
}
this->m_PointDimension = 3;
// If number of points is not equal zero, update points
if ( this->m_NumberOfPoints )
{
this->m_UpdatePoints = true;
}
else
{
this->m_UpdatePoints = false;
}
// If number of cells is not equal zero, update points
if ( this->m_NumberOfCells )
{
this->m_UpdateCells = true;
}
else
{
this->m_UpdateCells = false;
}
// Set default point component type
this->m_PointComponentType = FLOAT;
// Set default cell component type
this->m_CellComponentType = LONG;
this->m_CellBufferSize = this->m_NumberOfCells * 2 + numberOfCellPoints;
// Set default point pixel component and point pixel type
this->m_PointPixelComponentType = FLOAT;
this->m_PointPixelType = VECTOR;
this->m_NumberOfPointPixelComponents = 3;
this->m_NumberOfPointPixels = this->m_NumberOfPoints;
// this->m_UpdatePointData = true;
// Set default cell pixel component and point pixel type
this->m_CellPixelComponentType = FLOAT;
this->m_CellPixelType = SCALAR;
this->m_NumberOfCellPixelComponents = itk::NumericTraits< unsigned int >::OneValue();
this->m_UpdateCellData = false;
CloseFile();
} | false | false | false | false | false | 0 |
upClicked()
{
if (fields->currentItem()) {
int index = fields->invisibleRootItem()->indexOfChild(fields->currentItem());
if (index == 0) return; // its at the top already
// movin on up!
QWidget *button = fields->itemWidget(fields->currentItem(),2);
QWidget *check = fields->itemWidget(fields->currentItem(),4);
QComboBox *comboButton = new QComboBox(this);
addFieldTypes(comboButton);
comboButton->setCurrentIndex(((QComboBox*)button)->currentIndex());
QCheckBox *checkBox = new QCheckBox("", this);
checkBox->setChecked(((QCheckBox*)check)->isChecked());
QTreeWidgetItem* moved = fields->invisibleRootItem()->takeChild(index);
fields->invisibleRootItem()->insertChild(index-1, moved);
fields->setItemWidget(moved, 2, comboButton);
fields->setItemWidget(moved, 4, checkBox);
fields->setCurrentItem(moved);
}
} | false | false | false | false | false | 0 |
TryReconnect() {
if(!Open(m_hostname))
return false;
EnableStatusInterface(m_statusinterface);
ChannelFilter(m_ftachannels, m_nativelang, m_caids);
SetUpdateChannels(m_updatechannels);
SupportChannelScan();
m_connectionLost = false;
OnReconnect();
return true;
} | false | false | false | false | false | 0 |
mainwindow_progressindicator_hook(gpointer source, gpointer userdata)
{
ProgressData *data = (ProgressData *) source;
MainWindow *mainwin = (MainWindow *) userdata;
switch (data->cmd) {
case PROGRESS_COMMAND_START:
case PROGRESS_COMMAND_STOP:
gtk_progress_bar_set_fraction
(GTK_PROGRESS_BAR(mainwin->progressbar), 0.0);
break;
case PROGRESS_COMMAND_SET_PERCENTAGE:
gtk_progress_bar_set_fraction
(GTK_PROGRESS_BAR(mainwin->progressbar), data->value);
break;
}
while (gtk_events_pending()) gtk_main_iteration ();
return FALSE;
} | false | false | false | false | false | 0 |
do_cmd_walk_test(int y, int x)
{
/* Allow attack on visible monsters if unafraid */
if ((cave_m_idx[y][x] > 0) && (mon_list[cave_m_idx[y][x]].ml))
{
/* Handle player fear */
if(p_ptr->state.afraid)
{
/* Extract monster name (or "it") */
char m_name[80];
monster_type *m_ptr;
m_ptr = &mon_list[cave_m_idx[y][x]];
monster_desc(m_name, sizeof(m_name), m_ptr, 0);
/* Message */
message_format(MSG_AFRAID, 0,
"You are too afraid to attack %s!", m_name);
/* Nope */
return (FALSE);
}
return (TRUE);
}
/* Hack -- walking obtains knowledge XXX XXX */
if (!(cave_info[y][x] & (CAVE_MARK))) return (TRUE);
/* Require open space */
if (!cave_floor_bold(y, x))
{
/* Rubble */
if (cave_feat[y][x] == FEAT_RUBBLE)
{
/* Message */
message(MSG_HITWALL, 0, "There is a pile of rubble in the way!");
}
/* Door */
else if (cave_feat[y][x] < FEAT_SECRET)
{
/* Hack -- Handle "OPT(easy_alter)" */
if (OPT(easy_alter)) return (TRUE);
/* Message */
message(MSG_HITWALL, 0, "There is a door in the way!");
}
/* Wall */
else
{
/* Message */
message(MSG_HITWALL, 0, "There is a wall in the way!");
}
/* Cancel repeat */
disturb(0, 0);
/* Nope */
return (FALSE);
}
/* Okay */
return (TRUE);
} | false | false | false | false | false | 0 |
append(const NvjLogSeverity& l, const std::string& message, const std::string& details)
{
if (file!=NULL)
(*file) << message << endl;
} | false | false | false | false | false | 0 |
alloc_use (void)
{
struct use_optype_d *ret;
if (gimple_ssa_operands (cfun)->free_uses)
{
ret = gimple_ssa_operands (cfun)->free_uses;
gimple_ssa_operands (cfun)->free_uses
= gimple_ssa_operands (cfun)->free_uses->next;
}
else
ret = (struct use_optype_d *)
ssa_operand_alloc (sizeof (struct use_optype_d));
return ret;
} | false | false | false | false | false | 0 |
_nrrdDDBCN_d(double *f, const double *x, size_t len, const double *parm) {
double S;
double t, B, C;
size_t i;
S = parm[0]; B = parm[1]; C = parm[2];
for (i=0; i<len; i++) {
t = x[i];
t = AIR_ABS(t)/S;
f[i] = _DDBCCUBIC(t, B, C)/(S*S*S);
}
} | false | false | false | false | false | 0 |
visit_enter(ir_expression *ir)
{
if (this->shader_stage == MESA_SHADER_FRAGMENT &&
ir->operation == ir_unop_dFdy) {
gl_fragment_program *fprog = (gl_fragment_program *) prog;
fprog->UsesDFdy = true;
}
return visit_continue;
} | false | false | false | false | false | 0 |
find_smc_chip_model(struct smc_chip_model
*chips, int version_id)
{
int i;
for (i = 0; chips[i].name != NULL; i++) {
if (chips[i].version_id == version_id)
return &chips[i];
}
return NULL;
} | false | false | false | false | false | 0 |
bio_disable(bio_source_t *bio)
{
bio_check(bio);
g_assert(bio->io_tag);
g_assert(bio->io_callback); /* "passive" sources not concerned */
g_assert(0 == (bio->flags & BIO_F_PASSIVE));
inputevt_remove(&bio->io_tag);
} | false | false | false | false | false | 0 |
_equalArrayRef(ArrayRef *a, ArrayRef *b)
{
COMPARE_SCALAR_FIELD(refarraytype);
COMPARE_SCALAR_FIELD(refelemtype);
COMPARE_SCALAR_FIELD(reftypmod);
COMPARE_SCALAR_FIELD(refcollid);
COMPARE_NODE_FIELD(refupperindexpr);
COMPARE_NODE_FIELD(reflowerindexpr);
COMPARE_NODE_FIELD(refexpr);
COMPARE_NODE_FIELD(refassgnexpr);
return true;
} | false | false | false | false | false | 0 |
push_false() { if (!top) return 0; if (!top->value) top = new n(top,0,1); return !top->value; } | false | false | false | false | false | 0 |
CloseWaveFile2()
/******************/
{
unsigned int pos;
if((f_wave == NULL) || (f_wave == stdout))
return;
fflush(f_wave);
pos = ftell(f_wave);
fseek(f_wave,4,SEEK_SET);
Write4Bytes(f_wave,pos - 8);
fseek(f_wave,40,SEEK_SET);
Write4Bytes(f_wave,pos - 44);
fclose(f_wave);
f_wave = NULL;
} | false | false | false | false | false | 0 |
parse_field_count (char const *string, size_t *val, char const *msgid)
{
char *suffix;
uintmax_t n;
switch (xstrtoumax (string, &suffix, 10, &n, ""))
{
case LONGINT_OK:
case LONGINT_INVALID_SUFFIX_CHAR:
*val = n;
if (*val == n)
break;
/* Fall through. */
case LONGINT_OVERFLOW:
case LONGINT_OVERFLOW | LONGINT_INVALID_SUFFIX_CHAR:
*val = SIZE_MAX;
break;
case LONGINT_INVALID:
if (msgid)
error (SORT_FAILURE, 0, _("%s: invalid count at start of %s"),
_(msgid), quote (string));
return NULL;
}
return suffix;
} | false | false | false | false | false | 0 |
core_get_turbo_pstate(void)
{
u64 value;
int nont, ret;
rdmsrl(MSR_NHM_TURBO_RATIO_LIMIT, value);
nont = core_get_max_pstate();
ret = (value) & 255;
if (ret <= nont)
ret = nont;
return ret;
} | false | false | false | false | false | 0 |
parse_skipped_msg( const string & msg,
string & first_dir, string & second_dir )
{
string::size_type pos = parse_skipped_msg_aux(msg, 0, first_dir);
if (pos == string::npos)
return;
parse_skipped_msg_aux(msg, pos, second_dir);
} | false | false | false | false | false | 0 |
GetAttributeLocation(const char *attributeName)
{
vtkGLSLShaderProgram* glslProgram =
vtkGLSLShaderProgram::SafeDownCast(this->ShaderProgram);
if (glslProgram && glslProgram->GetProgram())
{
GLSL_SHADER_DEVICE_ADAPTER(
"GetAttributeLocation Program " << glslProgram->GetProgram());
return vtkgl::GetAttribLocation(glslProgram->GetProgram(), attributeName);
}
return -1;
} | false | false | false | false | false | 0 |
writeHeaders(void *ptr, size_t size,
size_t nmemb, void *stream)
{
CMPIStatus *status=(CMPIStatus*)stream;
char *str=ptr;
char *colonidx;
if (str[nmemb-1] != 0) {
/* make sure the string is zero-terminated */
str = malloc(nmemb + 1);
memcpy(str,ptr,nmemb);
str[nmemb] = 0;
} else {
str = strdup(ptr);
}
colonidx=strchr(str,':');
if (colonidx) {
*colonidx=0;
if (strcasecmp(str,"cimstatuscode") == 0) {
/* set status code */
status->rc = atoi(colonidx+1);
} else {
if (strcasecmp(str, "cimstatuscodedescription") == 0) {
status->msg=newCMPIString(colonidx+1,NULL);
}
}
}
free(str);
return nmemb;
} | false | false | false | false | false | 0 |
GetStatusString(RESULT* result) {
wxString s = wxEmptyString;
wxString str = wxEmptyString;
if (result == NULL) {
s = m_sNotAvailableString;
} else {
s = result_description(result, false);
}
str.Printf(_("Status: %s"), s.c_str());
return str;
} | false | false | false | false | false | 0 |
zeitgeist_data_sources_registry_from_variant (GVariant* sources_variant, gboolean reset_running, GError** error) {
GHashTable* result = NULL;
GHashTable* registry = NULL;
GHashFunc _tmp0_ = NULL;
GEqualFunc _tmp1_ = NULL;
GHashTable* _tmp2_ = NULL;
GVariant* _tmp3_ = NULL;
const gchar* _tmp4_ = NULL;
GError * _inner_error_ = NULL;
g_return_val_if_fail (sources_variant != NULL, NULL);
_tmp0_ = g_str_hash;
_tmp1_ = g_str_equal;
_tmp2_ = g_hash_table_new_full (_tmp0_, _tmp1_, _g_free0_, _g_object_unref0_);
registry = _tmp2_;
_tmp3_ = sources_variant;
_tmp4_ = g_variant_get_type_string (_tmp3_);
g_warn_if_fail (g_strcmp0 (_tmp4_, ZEITGEIST_DATA_SOURCES_SIG_DATASOURCES) == 0);
{
GVariantIter* _ds_variant_it = NULL;
GVariant* _tmp5_ = NULL;
GVariantIter* _tmp6_ = NULL;
GVariant* ds_variant = NULL;
_tmp5_ = sources_variant;
_tmp6_ = g_variant_iter_new (_tmp5_);
_ds_variant_it = _tmp6_;
while (TRUE) {
GVariantIter* _tmp7_ = NULL;
GVariant* _tmp8_ = NULL;
GVariant* _tmp9_ = NULL;
ZeitgeistDataSource* ds = NULL;
GVariant* _tmp10_ = NULL;
gboolean _tmp11_ = FALSE;
ZeitgeistDataSource* _tmp12_ = NULL;
GHashTable* _tmp13_ = NULL;
ZeitgeistDataSource* _tmp14_ = NULL;
const gchar* _tmp15_ = NULL;
const gchar* _tmp16_ = NULL;
gchar* _tmp17_ = NULL;
ZeitgeistDataSource* _tmp18_ = NULL;
ZeitgeistDataSource* _tmp19_ = NULL;
_tmp7_ = _ds_variant_it;
_tmp8_ = g_variant_iter_next_value (_tmp7_);
_g_variant_unref0 (ds_variant);
ds_variant = _tmp8_;
_tmp9_ = ds_variant;
if (!(_tmp9_ != NULL)) {
break;
}
_tmp10_ = ds_variant;
_tmp11_ = reset_running;
_tmp12_ = zeitgeist_data_source_new_from_variant (_tmp10_, _tmp11_, &_inner_error_);
ds = _tmp12_;
if (_inner_error_ != NULL) {
if (_inner_error_->domain == ZEITGEIST_DATA_MODEL_ERROR) {
g_propagate_error (error, _inner_error_);
_g_variant_unref0 (ds_variant);
_g_variant_iter_free0 (_ds_variant_it);
_g_hash_table_unref0 (registry);
return NULL;
} else {
_g_variant_unref0 (ds_variant);
_g_variant_iter_free0 (_ds_variant_it);
_g_hash_table_unref0 (registry);
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return NULL;
}
}
_tmp13_ = registry;
_tmp14_ = ds;
_tmp15_ = zeitgeist_data_source_get_unique_id (_tmp14_);
_tmp16_ = _tmp15_;
_tmp17_ = g_strdup (_tmp16_);
_tmp18_ = ds;
_tmp19_ = _g_object_ref0 (_tmp18_);
g_hash_table_insert (_tmp13_, _tmp17_, _tmp19_);
_g_object_unref0 (ds);
}
_g_variant_unref0 (ds_variant);
_g_variant_iter_free0 (_ds_variant_it);
}
result = registry;
return result;
} | false | false | false | false | false | 0 |
DuplicateOrigAtom( ORIG_ATOM_DATA *new_orig_atom, ORIG_ATOM_DATA *orig_atom )
{
inp_ATOM *at = NULL;
AT_NUMB *nCurAtLen = NULL;
AT_NUMB *nOldCompNumber = NULL;
if ( new_orig_atom->at && new_orig_atom->num_inp_atoms >= orig_atom->num_inp_atoms ) {
at = new_orig_atom->at;
} else {
at = (inp_ATOM *)inchi_calloc(orig_atom->num_inp_atoms+1, sizeof(at[0]));
}
if ( new_orig_atom->nOldCompNumber && new_orig_atom->num_components >= orig_atom->num_components ) {
nCurAtLen = new_orig_atom->nCurAtLen;
} else {
nCurAtLen = (AT_NUMB *)inchi_calloc(orig_atom->num_components+1, sizeof(nCurAtLen[0]));
}
if ( new_orig_atom->nCurAtLen && new_orig_atom->num_components >= orig_atom->num_components ) {
nOldCompNumber = new_orig_atom->nOldCompNumber;
} else {
nOldCompNumber = (AT_NUMB *)inchi_calloc(orig_atom->num_components+1, sizeof(nOldCompNumber[0]));
}
if ( at && nCurAtLen && nOldCompNumber ) {
/* copy */
if ( orig_atom->at )
memcpy( at, orig_atom->at, orig_atom->num_inp_atoms * sizeof(new_orig_atom->at[0]) );
if ( orig_atom->nCurAtLen )
memcpy( nCurAtLen, orig_atom->nCurAtLen, orig_atom->num_components*sizeof(nCurAtLen[0]) );
if ( orig_atom->nOldCompNumber )
memcpy( nOldCompNumber, orig_atom->nOldCompNumber, orig_atom->num_components*sizeof(nOldCompNumber[0]) );
/* deallocate */
if ( new_orig_atom->at && new_orig_atom->at != at )
inchi_free( new_orig_atom->at );
if ( new_orig_atom->nCurAtLen && new_orig_atom->nCurAtLen != nCurAtLen )
inchi_free( new_orig_atom->nCurAtLen );
if ( new_orig_atom->nOldCompNumber && new_orig_atom->nOldCompNumber != nOldCompNumber )
inchi_free( new_orig_atom->nOldCompNumber );
*new_orig_atom = *orig_atom;
new_orig_atom->at = at;
new_orig_atom->nCurAtLen = nCurAtLen;
new_orig_atom->nOldCompNumber = nOldCompNumber;
/* data that are not to be copied */
new_orig_atom->nNumEquSets = 0;
memset(new_orig_atom->bSavedInINCHI_LIB, 0, sizeof(new_orig_atom->bSavedInINCHI_LIB));
memset(new_orig_atom->bPreprocessed, 0, sizeof(new_orig_atom->bPreprocessed));
/* arrays that are not to be copied */
new_orig_atom->szCoord = NULL;
new_orig_atom->nEquLabels = NULL;
new_orig_atom->nSortedOrder = NULL;
return 0;
}
/* deallocate */
if ( at && new_orig_atom->at != at )
inchi_free( at );
if ( nCurAtLen && new_orig_atom->nCurAtLen != nCurAtLen )
inchi_free( nCurAtLen );
if ( nOldCompNumber && new_orig_atom->nOldCompNumber != nOldCompNumber )
inchi_free( nOldCompNumber );
return -1; /* failed */
} | false | true | false | false | false | 1 |
ir_doc_freq(IndexReader *ir, const char *field, const char *term)
{
int field_num = fis_get_field_num(ir->fis, field);
if (field_num >= 0) {
return ir->doc_freq(ir, field_num, term);
}
else {
return 0;
}
} | false | false | false | false | false | 0 |
SwizzleInput(MachineInstr &MI,
const std::vector<std::pair<unsigned, unsigned> > &RemapChan) const {
unsigned Offset;
if (TII->get(MI.getOpcode()).TSFlags & R600_InstFlag::TEX_INST)
Offset = 2;
else
Offset = 3;
for (unsigned i = 0; i < 4; i++) {
unsigned Swizzle = MI.getOperand(i + Offset).getImm() + 1;
for (unsigned j = 0, e = RemapChan.size(); j < e; j++) {
if (RemapChan[j].first == Swizzle) {
MI.getOperand(i + Offset).setImm(RemapChan[j].second - 1);
break;
}
}
}
} | false | false | false | false | false | 0 |
mousePressEvent(QGraphicsSceneMouseEvent *event)
{
//close a toolbox if exists, to emulate qmenu behavior
if (d->toolBox) {
d->toolBox.data()->setShowing(false);
}
event->ignore();
if (d->appletAt(event->scenePos())) {
return; //no unexpected click-throughs
}
if (d->wallpaper && d->wallpaper->isInitialized() && !event->isAccepted()) {
d->wallpaper->mousePressEvent(event);
}
if (event->isAccepted()) {
setFocus(Qt::MouseFocusReason);
} else if (event->button() == Qt::RightButton && event->modifiers() == Qt::NoModifier) {
// we'll catch this in the context menu even
Applet::mousePressEvent(event);
} else {
QString trigger = ContainmentActions::eventToString(event);
if (d->prepareContainmentActions(trigger, event->screenPos())) {
d->actionPlugins()->value(trigger)->contextEvent(event);
}
if (!event->isAccepted()) {
Applet::mousePressEvent(event);
}
}
} | false | false | false | false | false | 0 |
__fc_linkup(struct fc_lport *lport)
{
if (!lport->link_up) {
lport->link_up = 1;
if (lport->state == LPORT_ST_RESET)
fc_lport_enter_flogi(lport);
}
} | false | false | false | false | false | 0 |
rp5c01_nvram_write(struct file *filp, struct kobject *kobj,
struct bin_attribute *bin_attr,
char *buf, loff_t pos, size_t size)
{
struct device *dev = container_of(kobj, struct device, kobj);
struct rp5c01_priv *priv = dev_get_drvdata(dev);
ssize_t count;
spin_lock_irq(&priv->lock);
for (count = 0; count < size; count++) {
u8 data = *buf++;
rp5c01_write(priv,
RP5C01_MODE_TIMER_EN | RP5C01_MODE_RAM_BLOCK10,
RP5C01_MODE);
rp5c01_write(priv, data >> 4, pos);
rp5c01_write(priv,
RP5C01_MODE_TIMER_EN | RP5C01_MODE_RAM_BLOCK11,
RP5C01_MODE);
rp5c01_write(priv, data & 0xf, pos++);
rp5c01_write(priv, RP5C01_MODE_TIMER_EN | RP5C01_MODE_MODE01,
RP5C01_MODE);
}
spin_unlock_irq(&priv->lock);
return count;
} | false | false | false | false | false | 0 |
ipw_set_random_seed(struct ipw_priv *priv)
{
u32 val;
if (!priv) {
IPW_ERROR("Invalid args\n");
return -1;
}
get_random_bytes(&val, sizeof(val));
return ipw_send_cmd_pdu(priv, IPW_CMD_SEED_NUMBER, sizeof(val), &val);
} | false | false | false | false | false | 0 |
tls_process_error(void) {
unsigned long err;
err = ERR_get_error();
if (err != 0) {
logger.msg(Arc::ERROR, "OpenSSL Error -- %s", ERR_error_string(err, NULL));
logger.msg(Arc::ERROR, "Library : %s", ERR_lib_error_string(err));
logger.msg(Arc::ERROR, "Function : %s", ERR_func_error_string(err));
logger.msg(Arc::ERROR, "Reason : %s", ERR_reason_error_string(err));
}
return;
} | false | false | false | false | false | 0 |
caml_ml_input(value vchannel, value buff, value vstart,
value vlength)
{
CAMLparam4 (vchannel, buff, vstart, vlength);
struct channel * channel = Channel(vchannel);
intnat start, len;
int n, avail, nread;
Lock(channel);
/* We cannot call caml_getblock here because buff may move during
caml_do_read */
start = Long_val(vstart);
len = Long_val(vlength);
n = len >= INT_MAX ? INT_MAX : (int) len;
avail = channel->max - channel->curr;
if (n <= avail) {
memmove(&Byte(buff, start), channel->curr, n);
channel->curr += n;
} else if (avail > 0) {
memmove(&Byte(buff, start), channel->curr, avail);
channel->curr += avail;
n = avail;
} else {
nread = caml_do_read(channel->fd, channel->buff,
channel->end - channel->buff);
channel->offset += nread;
channel->max = channel->buff + nread;
if (n > nread) n = nread;
memmove(&Byte(buff, start), channel->buff, n);
channel->curr = channel->buff + n;
}
Unlock(channel);
CAMLreturn (Val_long(n));
} | false | false | false | false | true | 1 |
loadFromCache(const QString& h)
{
// printf("Loading avatar from cache\n");
hash_ = h;
setImage(QImage(QDir(AvatarFactory::getCacheDir()).filePath(h)));
if (pixmap().isNull()) {
qWarning("CachedAvatar::loadFromCache(): Null pixmap. Unsupported format ?");
}
} | false | false | false | false | false | 0 |
build_suggestion_menu (GeditAutomaticSpellChecker *spell, const gchar *word)
{
GtkWidget *topmenu, *menu;
GtkWidget *mi;
GSList *suggestions;
GSList *list;
gchar *label_text;
topmenu = menu = gtk_menu_new();
suggestions = gedit_spell_checker_get_suggestions (spell->spell_checker, word, -1);
list = suggestions;
if (suggestions == NULL)
{
/* no suggestions. put something in the menu anyway... */
GtkWidget *label;
/* Translators: Displayed in the "Check Spelling" dialog if there are no suggestions for the current misspelled word */
label = gtk_label_new (_("(no suggested words)"));
mi = gtk_menu_item_new ();
gtk_widget_set_sensitive (mi, FALSE);
gtk_container_add (GTK_CONTAINER(mi), label);
gtk_widget_show_all (mi);
gtk_menu_shell_prepend (GTK_MENU_SHELL (menu), mi);
}
else
{
gint count = 0;
/* build a set of menus with suggestions. */
while (suggestions != NULL)
{
GtkWidget *label;
if (count == 10)
{
/* Separator */
mi = gtk_separator_menu_item_new ();
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
mi = gtk_menu_item_new_with_mnemonic (_("_More..."));
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
menu = gtk_menu_new ();
gtk_menu_item_set_submenu (GTK_MENU_ITEM (mi), menu);
count = 0;
}
label_text = g_strdup_printf ("<b>%s</b>", (gchar*) suggestions->data);
label = gtk_label_new (label_text);
gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
gtk_widget_set_halign (label, GTK_ALIGN_START);
mi = gtk_menu_item_new ();
gtk_container_add (GTK_CONTAINER(mi), label);
gtk_widget_show_all (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (menu), mi);
g_object_set_qdata_full (G_OBJECT (mi),
suggestion_id,
g_strdup (suggestions->data),
(GDestroyNotify)g_free);
g_free (label_text);
g_signal_connect (mi,
"activate",
G_CALLBACK (replace_word),
spell);
count++;
suggestions = g_slist_next (suggestions);
}
}
/* free the suggestion list */
suggestions = list;
while (list)
{
g_free (list->data);
list = g_slist_next (list);
}
g_slist_free (suggestions);
/* Separator */
mi = gtk_separator_menu_item_new ();
gtk_widget_show (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
/* Ignore all */
mi = gtk_image_menu_item_new_with_mnemonic (_("_Ignore All"));
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
gtk_image_new_from_stock (GTK_STOCK_GOTO_BOTTOM,
GTK_ICON_SIZE_MENU));
g_signal_connect (mi,
"activate",
G_CALLBACK(ignore_all),
spell);
gtk_widget_show_all (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
/* + Add to Dictionary */
mi = gtk_image_menu_item_new_with_mnemonic (_("_Add"));
gtk_image_menu_item_set_image (GTK_IMAGE_MENU_ITEM (mi),
gtk_image_new_from_stock (GTK_STOCK_ADD,
GTK_ICON_SIZE_MENU));
g_signal_connect (mi,
"activate",
G_CALLBACK (add_to_dictionary),
spell);
gtk_widget_show_all (mi);
gtk_menu_shell_append (GTK_MENU_SHELL (topmenu), mi);
return topmenu;
} | false | false | false | false | false | 0 |
globus_error_construct_error(
globus_module_descriptor_t * base_source,
globus_object_t * base_cause,
int type,
const char * source_file,
const char * source_func,
int source_line,
const char * short_desc_format,
...)
{
globus_object_t * error;
globus_object_t * newerror;
va_list ap;
va_start(ap, short_desc_format);
newerror = globus_object_construct(GLOBUS_ERROR_TYPE_GLOBUS);
error = globus_error_initialize_error(
newerror,
base_source,
base_cause,
type,
source_file,
source_func,
source_line,
short_desc_format,
ap);
va_end(ap);
if (error == NULL)
{
globus_object_free(newerror);
}
return error;
} | false | false | false | false | false | 0 |
_c_udivMod256(struct u256* n, struct u256* d){
struct u256_divRet ret;
struct u256 q = {{0}};
struct u256 r = {{0}};
for(int i = 255; i >= 0; i--){
r = _c_lshift256(&r,1);
type256bitSet(&r,0,type256bitGet(n,i));
if(ucmp256(&r,d) >= 0){
r = usub256(&r,d);
type256bitSet(&q,i,1);
}
}
ret.q = q;
ret.r = r;
return ret;
} | false | false | false | false | false | 0 |
getNonCompileUnitScope(MDNode *N) {
if (DIDescriptor(N).isCompileUnit())
return NULL;
return N;
} | false | false | false | false | false | 0 |
get_comb_box_widget (GNCSearchWindow *sw, struct _crit_data *data)
{
GtkWidget *combo_box;
GtkListStore *store;
GtkTreeIter iter;
GtkCellRenderer *cell;
GList *l;
int index = 0, current = 0;
store = gtk_list_store_new(NUM_SEARCH_COLS, G_TYPE_STRING, G_TYPE_POINTER);
combo_box = gtk_combo_box_new_with_model(GTK_TREE_MODEL(store));
g_object_unref(store);
cell = gtk_cell_renderer_text_new ();
gtk_cell_layout_pack_start(GTK_CELL_LAYOUT (combo_box), cell, TRUE);
gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo_box), cell,
"text", SEARCH_COL_NAME,
NULL);
for (l = sw->params_list; l; l = l->next)
{
GNCSearchParam *param = l->data;
gtk_list_store_append(store, &iter);
gtk_list_store_set(store, &iter,
SEARCH_COL_NAME, _(param->title),
SEARCH_COL_POINTER, param,
-1);
if (param == sw->last_param) /* is this the right parameter to start? */
current = index;
index++;
}
gtk_combo_box_set_active (GTK_COMBO_BOX(combo_box), current);
g_signal_connect (combo_box, "changed", G_CALLBACK (combo_box_changed), data);
return combo_box;
} | false | false | false | false | false | 0 |
storeGetMemSpace(int size)
{
StoreEntry *e = NULL;
int released = 0;
static time_t last_check = 0;
int pages_needed;
RemovalPurgeWalker *walker;
if (squid_curtime == last_check)
return;
last_check = squid_curtime;
pages_needed = (size / SM_PAGE_SIZE) + 1;
if (memInUse(MEM_MEM_NODE) + pages_needed < store_pages_max)
return;
debug(20, 3) ("storeGetMemSpace: Starting, need %d pages\n", pages_needed);
/* XXX what to set as max_scan here? */
walker = mem_policy->PurgeInit(mem_policy, 100000);
while ((e = walker->Next(walker))) {
debug(20, 3) ("storeGetMemSpace: purging %p\n", e);
storePurgeMem(e);
released++;
if (memInUse(MEM_MEM_NODE) + pages_needed < store_pages_max) {
debug(20, 3) ("storeGetMemSpace: we finally have enough free memory!\n");
break;
}
}
walker->Done(walker);
debug(20, 3) ("storeGetMemSpace stats:\n");
debug(20, 3) (" %6d HOT objects\n", hot_obj_count);
debug(20, 3) (" %6d were released\n", released);
} | false | false | false | false | false | 0 |
mpfr_get_z (mpz_ptr z, mpfr_srcptr f, mpfr_rnd_t rnd)
{
int inex;
mpfr_t r;
mpfr_exp_t exp;
if (MPFR_UNLIKELY (MPFR_IS_SINGULAR (f)))
{
if (MPFR_UNLIKELY (MPFR_NOTZERO (f)))
MPFR_SET_ERANGE ();
mpz_set_ui (z, 0);
/* The ternary value is 0 even for infinity. Giving the rounding
direction in this case would not make much sense anyway, and
the direction would not necessarily match rnd. */
return 0;
}
exp = MPFR_GET_EXP (f);
/* if exp <= 0, then |f|<1, thus |o(f)|<=1 */
MPFR_ASSERTN (exp < 0 || exp <= MPFR_PREC_MAX);
mpfr_init2 (r, (exp < (mpfr_exp_t) MPFR_PREC_MIN ?
MPFR_PREC_MIN : (mpfr_prec_t) exp));
inex = mpfr_rint (r, f, rnd);
MPFR_ASSERTN (inex != 1 && inex != -1); /* integral part of f is
representable in r */
MPFR_ASSERTN (MPFR_IS_FP (r));
exp = mpfr_get_z_2exp (z, r);
if (exp >= 0)
mpz_mul_2exp (z, z, exp);
else
mpz_fdiv_q_2exp (z, z, -exp);
mpfr_clear (r);
return inex;
} | false | false | false | false | false | 0 |
blockContents(int block)
{
if(!openDataFile()) {
return QList<QChar>();
}
const uchar* data = reinterpret_cast<const uchar*>(dataFile.constData());
const quint32 offsetBegin = qFromLittleEndian<quint32>(data+20);
const quint32 offsetEnd = qFromLittleEndian<quint32>(data+24);
int max = ((offsetEnd - offsetBegin) / 4) - 1;
QList<QChar> res;
if(block > max)
return res;
quint16 unicodeBegin = qFromLittleEndian<quint16>(data + offsetBegin + block*4);
quint16 unicodeEnd = qFromLittleEndian<quint16>(data + offsetBegin + block*4 + 2);
while(unicodeBegin < unicodeEnd) {
res.append(unicodeBegin);
unicodeBegin++;
}
res.append(unicodeBegin); // Be carefull when unicodeEnd==0xffff
return res;
} | false | false | false | false | false | 0 |
numaJoin(NUMA *nad,
NUMA *nas,
l_int32 istart,
l_int32 iend)
{
l_int32 n, i;
l_float32 val;
PROCNAME("numaJoin");
if (!nad)
return ERROR_INT("nad not defined", procName, 1);
if (!nas)
return 0;
if (istart < 0)
istart = 0;
n = numaGetCount(nas);
if (iend < 0 || iend >= n)
iend = n - 1;
if (istart > iend)
return ERROR_INT("istart > iend; nothing to add", procName, 1);
for (i = istart; i <= iend; i++) {
numaGetFValue(nas, i, &val);
numaAddNumber(nad, val);
}
return 0;
} | false | false | false | false | false | 0 |
pixSetUnderTransparency(PIX *pixs,
l_uint32 val,
l_int32 debug)
{
PIX *pixg, *pixm, *pixt, *pixd;
PROCNAME("pixSetUnderTransparency");
if (!pixs || pixGetDepth(pixs) != 32)
return (PIX *)ERROR_PTR("pixs not defined or not 32 bpp",
procName, NULL);
if (pixGetSpp(pixs) != 4) {
L_WARNING("no alpha channel; returning a copy\n", procName);
return pixCopy(NULL, pixs);
}
/* Make a mask from the alpha component with ON pixels
* wherever the alpha component is fully transparent (0).
* The hard way:
* l_int32 *lut = (l_int32 *)CALLOC(256, sizeof(l_int32));
* lut[0] = 1;
* pixg = pixGetRGBComponent(pixs, L_ALPHA_CHANNEL);
* pixm = pixMakeMaskFromLUT(pixg, lut);
* FREE(lut);
* But there's an easier way to set pixels in a mask where
* the alpha component is 0 ... */
pixg = pixGetRGBComponent(pixs, L_ALPHA_CHANNEL);
pixm = pixThresholdToBinary(pixg, 1);
if (debug) {
pixt = pixDisplayLayersRGBA(pixs, 0xffffff00, 600);
pixDisplay(pixt, 0, 0);
pixDestroy(&pixt);
}
pixd = pixCopy(NULL, pixs);
pixSetMasked(pixd, pixm, (val & 0xffffff00));
pixDestroy(&pixg);
pixDestroy(&pixm);
return pixd;
} | false | false | false | false | false | 0 |
get_timespec_val( gpointer pObject )
{
slot_info_t* pInfo = (slot_info_t*)pObject;
g_return_val_if_fail( pObject != NULL, gnc_dmy2timespec( 1, 1, 1970 ) );
//if( kvp_value_get_type( pInfo->pKvpValue ) == KVP_TYPE_TIMESPEC ) {
return kvp_value_get_timespec( pInfo->pKvpValue );
} | false | false | false | false | false | 0 |
modulus_result_type(const struct glsl_type *type_a,
const struct glsl_type *type_b,
struct _mesa_glsl_parse_state *state, YYLTYPE *loc)
{
if (!state->check_version(130, 300, loc, "operator '%%' is reserved")) {
return glsl_type::error_type;
}
/* From GLSL 1.50 spec, page 56:
* "The operator modulus (%) operates on signed or unsigned integers or
* integer vectors. The operand types must both be signed or both be
* unsigned."
*/
if (!type_a->is_integer()) {
_mesa_glsl_error(loc, state, "LHS of operator %% must be an integer");
return glsl_type::error_type;
}
if (!type_b->is_integer()) {
_mesa_glsl_error(loc, state, "RHS of operator %% must be an integer");
return glsl_type::error_type;
}
if (type_a->base_type != type_b->base_type) {
_mesa_glsl_error(loc, state,
"operands of %% must have the same base type");
return glsl_type::error_type;
}
/* "The operands cannot be vectors of differing size. If one operand is
* a scalar and the other vector, then the scalar is applied component-
* wise to the vector, resulting in the same type as the vector. If both
* are vectors of the same size, the result is computed component-wise."
*/
if (type_a->is_vector()) {
if (!type_b->is_vector()
|| (type_a->vector_elements == type_b->vector_elements))
return type_a;
} else
return type_b;
/* "The operator modulus (%) is not defined for any other data types
* (non-integer types)."
*/
_mesa_glsl_error(loc, state, "type mismatch");
return glsl_type::error_type;
} | false | false | false | false | false | 0 |
gst_rtp_mux_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
{
GstRTPMux *mux = GST_RTP_MUX (parent);
gboolean is_pad;
gboolean ret;
switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_CAPS:
{
GstCaps *caps;
gst_event_parse_caps (event, &caps);
ret = gst_rtp_mux_setcaps (pad, mux, caps);
gst_event_unref (event);
return ret;
}
case GST_EVENT_FLUSH_STOP:
{
GST_OBJECT_LOCK (mux);
mux->last_stop = GST_CLOCK_TIME_NONE;
GST_OBJECT_UNLOCK (mux);
break;
}
case GST_EVENT_SEGMENT:
{
GstRTPMuxPadPrivate *padpriv;
GST_OBJECT_LOCK (mux);
padpriv = gst_pad_get_element_private (pad);
if (padpriv) {
gst_event_copy_segment (event, &padpriv->segment);
}
GST_OBJECT_UNLOCK (mux);
break;
}
default:
break;
}
GST_OBJECT_LOCK (mux);
is_pad = (pad == mux->last_pad);
GST_OBJECT_UNLOCK (mux);
if (is_pad) {
return gst_pad_push_event (mux->srcpad, event);
} else {
gst_event_unref (event);
return TRUE;
}
} | false | false | false | false | false | 0 |
cbf_calculate_initial_position (cbf_positioner positioner,
unsigned int reserved,
double ratio,
double final1,
double final2,
double final3,
double *initial1,
double *initial2,
double *initial3)
{
double delta [3];
if (reserved != 0)
return CBF_ARGUMENT;
/* Update the matrix */
cbf_failnez (cbf_calculate_position (positioner, reserved, ratio, 0, 0, 0,
NULL, NULL, NULL))
delta [0] = final1 - positioner->matrix [0][3];
delta [1] = final2 - positioner->matrix [1][3];
delta [2] = final3 - positioner->matrix [2][3];
if (initial1)
*initial1 = positioner->matrix [0][0] * delta [0] +
positioner->matrix [1][0] * delta [1] +
positioner->matrix [2][0] * delta [2];
if (initial2)
*initial2 = positioner->matrix [0][1] * delta [0] +
positioner->matrix [1][1] * delta [1] +
positioner->matrix [2][1] * delta [2];
if (initial3)
*initial3 = positioner->matrix [0][2] * delta [0] +
positioner->matrix [1][2] * delta [1] +
positioner->matrix [2][2] * delta [2];
return 0;
} | false | false | false | false | false | 0 |
ion_client_destroy(struct ion_client *client)
{
struct ion_device *dev = client->dev;
struct rb_node *n;
pr_debug("%s: %d\n", __func__, __LINE__);
while ((n = rb_first(&client->handles))) {
struct ion_handle *handle = rb_entry(n, struct ion_handle,
node);
ion_handle_destroy(&handle->ref);
}
idr_destroy(&client->idr);
down_write(&dev->lock);
if (client->task)
put_task_struct(client->task);
rb_erase(&client->node, &dev->clients);
debugfs_remove_recursive(client->debug_root);
up_write(&dev->lock);
kfree(client->display_name);
kfree(client->name);
kfree(client);
} | false | false | false | false | false | 0 |
nautilus_file_get_emblem_icons (NautilusFile *file)
{
GList *keywords, *l;
GList *icons;
char *icon_names[2];
char *keyword;
GIcon *icon;
if (file == NULL) {
return NULL;
}
g_return_val_if_fail (NAUTILUS_IS_FILE (file), NULL);
keywords = nautilus_file_get_keywords (file);
keywords = prepend_automatic_keywords (file, keywords);
icons = NULL;
for (l = keywords; l != NULL; l = l->next) {
keyword = l->data;
icon_names[0] = g_strconcat ("emblem-", keyword, NULL);
icon_names[1] = keyword;
icon = g_themed_icon_new_from_names (icon_names, 2);
g_free (icon_names[0]);
icons = g_list_prepend (icons, icon);
}
g_list_free_full (keywords, g_free);
return icons;
} | true | true | false | false | false | 1 |
buffered_tell(buffered *self, PyObject *args)
{
Py_off_t pos;
CHECK_INITIALIZED(self)
pos = _buffered_raw_tell(self);
if (pos == -1)
return NULL;
pos -= RAW_OFFSET(self);
/* TODO: sanity check (pos >= 0) */
return PyLong_FromOff_t(pos);
} | false | false | false | false | false | 0 |
widget_destroyed (GtkWidget *obj, gpointer widget_pointer)
{
DrawspacesConfigureWidget *widget = (DrawspacesConfigureWidget *)widget_pointer;
gedit_debug (DEBUG_PLUGINS);
g_object_unref (widget->settings);
g_slice_free (DrawspacesConfigureWidget, widget_pointer);
gedit_debug_message (DEBUG_PLUGINS, "END");
} | false | false | false | false | false | 0 |
tcl_idx2hand STDVAR
{
int idx;
BADARGS(2, 2, " idx");
idx = findidx(atoi(argv[1]));
if (idx < 0) {
Tcl_AppendResult(irp, "invalid idx", NULL);
return TCL_ERROR;
}
Tcl_AppendResult(irp, dcc[idx].nick, NULL);
return TCL_OK;
} | false | false | false | false | false | 0 |
pageset_init(struct per_cpu_pageset *p)
{
struct per_cpu_pages *pcp;
int migratetype;
memset(p, 0, sizeof(*p));
pcp = &p->pcp;
pcp->count = 0;
for (migratetype = 0; migratetype < MIGRATE_PCPTYPES; migratetype++)
INIT_LIST_HEAD(&pcp->lists[migratetype]);
} | false | false | false | false | false | 0 |
ReadTagFallback() {
if (BufferSize() >= kMaxVarintBytes ||
// Optimization: If the varint ends at exactly the end of the buffer,
// we can detect that and still use the fast path.
(buffer_end_ > buffer_ && !(buffer_end_[-1] & 0x80))) {
uint32 tag;
const uint8* end = ReadVarint32FromArray(buffer_, &tag);
if (end == NULL) {
return 0;
}
buffer_ = end;
return tag;
} else {
// We are commonly at a limit when attempting to read tags. Try to quickly
// detect this case without making another function call.
if (buffer_ == buffer_end_ && buffer_size_after_limit_ > 0 &&
// Make sure that the limit we hit is not total_bytes_limit_, since
// in that case we still need to call Refresh() so that it prints an
// error.
total_bytes_read_ - buffer_size_after_limit_ < total_bytes_limit_) {
// We hit a byte limit.
legitimate_message_end_ = true;
return 0;
}
return ReadTagSlow();
}
} | false | false | false | false | true | 1 |
tabWidget_currentChanged(int index) {
SketchAreaWidget * widgetParent = dynamic_cast<SketchAreaWidget *>(currentTabWidget());
if (widgetParent == NULL) return;
m_currentWidget = widgetParent;
if (m_locationLabel) {
m_locationLabel->setText("");
}
QStatusBar *sb = statusBar();
connect(sb, SIGNAL(messageChanged(const QString &)), this, SLOT(showStatusMessage(const QString &)));
widgetParent->addStatusBar(m_statusBar);
if(sb != m_statusBar) sb->hide();
if (m_breadboardGraphicsView) m_breadboardGraphicsView->setCurrent(false);
if (m_schematicGraphicsView) m_schematicGraphicsView->setCurrent(false);
if (m_pcbGraphicsView) m_pcbGraphicsView->setCurrent(false);
SketchWidget *widget = qobject_cast<SketchWidget *>(widgetParent->contentView());
if(m_currentGraphicsView) {
m_currentGraphicsView->saveZoom(m_zoomSlider->value());
disconnect(
m_currentGraphicsView,
SIGNAL(selectionChangedSignal()),
this,
SLOT(updateTransformationActions())
);
}
m_currentGraphicsView = widget;
if (m_programView) {
hideShowProgramMenu();
}
hideShowTraceMenu();
if (m_showBreadboardAct) {
QList<QAction *> actions;
if (m_welcomeView) actions << m_showWelcomeAct;
actions << m_showBreadboardAct << m_showSchematicAct << m_showPCBAct;
if (m_programView) actions << m_showProgramAct;
setActionsIcons(index, actions);
}
if (widget == NULL) {
m_firstTimeHelpAct->setEnabled(false);
return;
}
m_zoomSlider->setValue(m_currentGraphicsView->retrieveZoom());
FirstTimeHelpDialog::setViewID(m_currentGraphicsView->viewID());
m_firstTimeHelpAct->setEnabled(true);
connect(
m_currentGraphicsView, // don't connect directly to the scene here, connect to the widget's signal
SIGNAL(selectionChangedSignal()),
this,
SLOT(updateTransformationActions())
);
updateActiveLayerButtons();
m_currentGraphicsView->setCurrent(true);
// !!!!!! hack alert !!!!!!!
// this item update loop seems to deal with a qt update bug:
// if one view is visible and you change something in another view,
// the change might not appear when you switch views until you move the item in question
foreach(QGraphicsItem * item, m_currentGraphicsView->items()) {
item->update();
}
updateLayerMenu(true);
updateTraceMenu();
updateTransformationActions();
setTitle();
if (m_infoView) {
m_currentGraphicsView->updateInfoView();
}
// update issue with 4.5.1?: is this still valid (4.6.x?)
m_currentGraphicsView->updateConnectors();
QTimer::singleShot(10, this, SLOT(initZoom()));
} | false | false | false | false | false | 0 |
SetOriginalDataArray(MeasureType *setOriginalDataArray)
{
// Set the original data array.
m_OriginalDataArray->SetSize(m_RangeDimension);
for ( int i = 0; i < (int)( setOriginalDataArray->GetNumberOfElements() ); i++ )
{
m_OriginalDataArray->put( i, setOriginalDataArray->get(i) );
}
} | false | false | false | false | false | 0 |
crypto_gcm_init_common(struct aead_request *req)
{
struct crypto_gcm_req_priv_ctx *pctx = crypto_gcm_reqctx(req);
__be32 counter = cpu_to_be32(1);
struct scatterlist *sg;
memset(pctx->auth_tag, 0, sizeof(pctx->auth_tag));
memcpy(pctx->iv, req->iv, 12);
memcpy(pctx->iv + 12, &counter, 4);
sg_init_table(pctx->src, 3);
sg_set_buf(pctx->src, pctx->auth_tag, sizeof(pctx->auth_tag));
sg = scatterwalk_ffwd(pctx->src + 1, req->src, req->assoclen);
if (sg != pctx->src + 1)
sg_chain(pctx->src, 2, sg);
if (req->src != req->dst) {
sg_init_table(pctx->dst, 3);
sg_set_buf(pctx->dst, pctx->auth_tag, sizeof(pctx->auth_tag));
sg = scatterwalk_ffwd(pctx->dst + 1, req->dst, req->assoclen);
if (sg != pctx->dst + 1)
sg_chain(pctx->dst, 2, sg);
}
} | false | true | false | false | false | 1 |
PyObject_LengthHint(PyObject *o, Py_ssize_t defaultvalue)
{
PyObject *hint, *result;
Py_ssize_t res;
_Py_IDENTIFIER(__length_hint__);
if (_PyObject_HasLen(o)) {
res = PyObject_Length(o);
if (res < 0 && PyErr_Occurred()) {
if (!PyErr_ExceptionMatches(PyExc_TypeError)) {
return -1;
}
PyErr_Clear();
}
else {
return res;
}
}
hint = _PyObject_LookupSpecial(o, &PyId___length_hint__);
if (hint == NULL) {
if (PyErr_Occurred()) {
return -1;
}
return defaultvalue;
}
result = PyObject_CallFunctionObjArgs(hint, NULL);
Py_DECREF(hint);
if (result == NULL) {
if (PyErr_ExceptionMatches(PyExc_TypeError)) {
PyErr_Clear();
return defaultvalue;
}
return -1;
}
else if (result == Py_NotImplemented) {
Py_DECREF(result);
return defaultvalue;
}
if (!PyLong_Check(result)) {
PyErr_Format(PyExc_TypeError, "__length_hint__ must be an integer, not %.100s",
Py_TYPE(result)->tp_name);
Py_DECREF(result);
return -1;
}
res = PyLong_AsSsize_t(result);
Py_DECREF(result);
if (res < 0 && PyErr_Occurred()) {
return -1;
}
if (res < 0) {
PyErr_Format(PyExc_ValueError, "__length_hint__() should return >= 0");
return -1;
}
return res;
} | false | false | false | false | false | 0 |
rkcomp(char *probe) /* A,C,G,T/U, N probe string, 0-8 nt long */
{
Hashseq hashprobe = 0;
char coded[RK_HASHSIZE + 1];
int len;
int i;
/* check bounds violation on probe */
if ((len = strlen(probe)) > RK_HASHSIZE) return 0;
/* encode the probe */
if (seqencode(coded, probe) == 0) return 0;
/* pack the probe into a Hashseq */
for (i = 0; i < len; i++)
{
hashprobe <<= 4;
hashprobe |= (Hashseq) coded[i];
}
/* left adjust as needed */
for (; i < RK_HASHSIZE; i++)
{
hashprobe <<= 4;
hashprobe |= (Hashseq) NTN;
}
/* return the compiled probe */
return hashprobe;
} | false | false | false | false | false | 0 |
mwifiex_pcie_host_to_card(struct mwifiex_adapter *adapter, u8 type,
struct sk_buff *skb,
struct mwifiex_tx_param *tx_param)
{
if (!skb) {
mwifiex_dbg(adapter, ERROR,
"Passed NULL skb to %s\n", __func__);
return -1;
}
if (type == MWIFIEX_TYPE_DATA)
return mwifiex_pcie_send_data(adapter, skb, tx_param);
else if (type == MWIFIEX_TYPE_CMD)
return mwifiex_pcie_send_cmd(adapter, skb);
return 0;
} | false | false | false | false | false | 0 |
free_lang_data (void)
{
unsigned i;
/* If we are the LTO frontend we have freed lang-specific data already. */
if (in_lto_p
|| !flag_generate_lto)
return 0;
/* Allocate and assign alias sets to the standard integer types
while the slots are still in the way the frontends generated them. */
for (i = 0; i < itk_none; ++i)
if (integer_types[i])
TYPE_ALIAS_SET (integer_types[i]) = get_alias_set (integer_types[i]);
/* Traverse the IL resetting language specific information for
operands, expressions, etc. */
free_lang_data_in_cgraph ();
/* Create gimple variants for common types. */
ptrdiff_type_node = integer_type_node;
fileptr_type_node = ptr_type_node;
/* Reset some langhooks. Do not reset types_compatible_p, it may
still be used indirectly via the get_alias_set langhook. */
lang_hooks.dwarf_name = lhd_dwarf_name;
lang_hooks.decl_printable_name = gimple_decl_printable_name;
/* We do not want the default decl_assembler_name implementation,
rather if we have fixed everything we want a wrapper around it
asserting that all non-local symbols already got their assembler
name and only produce assembler names for local symbols. Or rather
make sure we never call decl_assembler_name on local symbols and
devise a separate, middle-end private scheme for it. */
/* Reset diagnostic machinery. */
tree_diagnostics_defaults (global_dc);
return 0;
} | false | false | false | false | false | 0 |
binary_iop(PyObject *v, PyObject *w, const int iop_slot, const int op_slot,
const char *op_name)
{
PyObject *result = binary_iop1(v, w, iop_slot, op_slot);
if (result == Py_NotImplemented) {
Py_DECREF(result);
return binop_type_error(v, w, op_name);
}
return result;
} | false | false | false | false | false | 0 |
put_1d_span(t4_state_t *s, int32_t span, const t4_run_table_entry_t *tab)
{
const t4_run_table_entry_t *te;
te = &tab[63 + (2560 >> 6)];
while (span >= 2560 + 64)
{
if (put_encoded_bits(s, te->code, te->length))
return -1;
span -= te->run_length;
}
te = &tab[63 + (span >> 6)];
if (span >= 64)
{
if (put_encoded_bits(s, te->code, te->length))
return -1;
span -= te->run_length;
}
if (put_encoded_bits(s, tab[span].code, tab[span].length))
return -1;
return 0;
} | false | false | false | false | false | 0 |
uv_remove_ares_handle(uv_ares_task_t* handle) {
uv_loop_t* loop = handle->loop;
if (handle == loop->uv_ares_handles_) {
loop->uv_ares_handles_ = handle->ares_next;
}
if (handle->ares_next) {
handle->ares_next->ares_prev = handle->ares_prev;
}
if (handle->ares_prev) {
handle->ares_prev->ares_next = handle->ares_next;
}
} | false | false | false | false | false | 0 |
test_composePoint(double x1,double y1,double z1, double yaw1,double pitch1,double roll1,
double x,double y,double z)
{
const CPose3D p1(x1,y1,z1,yaw1,pitch1,roll1);
const CPoint3D p(x,y,z);
CPoint3D p1_plus_p = p1 + p;
CPoint3D p1_plus_p2;
p1.composePoint(p.x(),p.y(),p.z() ,p1_plus_p2.x(), p1_plus_p2.y(), p1_plus_p2.z());
EXPECT_NEAR(0, (p1_plus_p2.getAsVectorVal()-p1_plus_p.getAsVectorVal()).array().abs().sum(), 1e-5);
// Repeat using same input/output variables:
{
double x = p.x();
double y = p.y();
double z = p.z();
p1.composePoint(x,y,z, x,y,z);
EXPECT_NEAR(0, std::abs(x-p1_plus_p.x())+std::abs(y-p1_plus_p.y())+std::abs(z-p1_plus_p.z()) , 1e-5);
}
// Inverse:
CPoint3D p_recov = p1_plus_p - p1;
CPoint3D p_recov2;
p1.inverseComposePoint(p1_plus_p.x(),p1_plus_p.y(),p1_plus_p.z(), p_recov2.x(),p_recov2.y(),p_recov2.z() );
EXPECT_NEAR(0, (p_recov2.getAsVectorVal()-p_recov.getAsVectorVal()).array().abs().sum(), 1e-5);
EXPECT_NEAR(0, (p.getAsVectorVal()-p_recov.getAsVectorVal()).array().abs().sum(), 1e-5);
} | false | false | false | false | false | 0 |
ConsState(CONSENT *pCE)
#else
ConsState(pCE)
CONSENT *pCE;
#endif
{
if (!pCE->fup)
return "down";
if (pCE->initfile != (CONSFILE *)0)
return "initializing";
switch (pCE->ioState) {
case ISNORMAL:
return "up";
case INCONNECT:
return "connecting";
case ISDISCONNECTED:
return "disconnected";
#if HAVE_OPENSSL
case INSSLACCEPT:
return "SSL_accept";
case INSSLSHUTDOWN:
return "SSL_shutdown";
#endif
case ISFLUSHING:
return "flushing";
}
return "in unknown state";
} | false | false | false | false | false | 0 |
new_update(int op, char * memtype, int filefmt, char * filename)
{
UPDATE * u;
u = (UPDATE *)malloc(sizeof(UPDATE));
if (u == NULL) {
fprintf(stderr, "%s: out of memory\n", progname);
exit(1);
}
u->memtype = strdup(memtype);
u->filename = strdup(filename);
u->op = op;
u->format = filefmt;
return u;
} | false | false | false | false | false | 0 |
brasero_file_monitor_start_monitoring_real (BraseroFileMonitor *self,
const gchar *uri)
{
BraseroFileMonitorPrivate *priv;
gchar *unescaped_uri;
gchar *path;
gint dev_fd;
uint32_t mask;
uint32_t wd;
priv = BRASERO_FILE_MONITOR_PRIVATE (self);
unescaped_uri = g_uri_unescape_string (uri, NULL);
path = g_filename_from_uri (unescaped_uri, NULL, NULL);
g_free (unescaped_uri);
dev_fd = g_io_channel_unix_get_fd (priv->notify);
mask = IN_MODIFY |
IN_ATTRIB |
IN_MOVED_FROM |
IN_MOVED_TO |
IN_CREATE |
IN_DELETE |
IN_DELETE_SELF |
IN_MOVE_SELF;
/* NOTE: always return the same wd when we ask for the same file */
wd = inotify_add_watch (dev_fd, path, mask);
if (wd == -1) {
BRASERO_BURN_LOG ("ERROR creating watch for local file %s : %s\n",
path,
g_strerror (errno));
g_free (path);
return 0;
}
g_free (path);
return wd;
} | false | false | false | false | false | 0 |
UpdatePartitionNamesInterface(void)
{
populatingPartitionNames = true;
partitionNameComboBox->clear();
int partitionsListWidgetRow = partitionsListWidget->currentRow();
if (partitionsListWidgetRow >= 0)
{
const FileInfo& partitionInfo = workingPackageData.GetFirmwareInfo().GetFileInfos()[partitionsListWidget->currentRow()];
for (int i = 0; i < unusedPartitionIds.length(); i++)
partitionNameComboBox->addItem(currentPitData.FindEntry(unusedPartitionIds[i])->GetPartitionName());
partitionNameComboBox->addItem(currentPitData.FindEntry(partitionInfo.GetPartitionId())->GetPartitionName());
partitionNameComboBox->setCurrentIndex(unusedPartitionIds.length());
}
populatingPartitionNames = false;
UpdateFlashInterfaceAvailability();
} | false | false | false | false | false | 0 |
mono_test_Winx64_structs_in2 (winx64_struct1 var1,
winx64_struct1 var2,
winx64_struct1 var3,
winx64_struct1 var4,
winx64_struct1 var5)
{
if (var1.a != 1)
return 1;
if (var2.a != 2)
return 2;
if (var3.a != 3)
return 3;
if (var4.a != 4)
return 4;
if (var5.a != 5)
return 5;
return 0;
} | false | false | false | false | false | 0 |
abraca_configurable_register (AbracaIConfigurable* obj) {
GKeyFile* file = NULL;
gboolean _tmp0_;
AbracaIConfigurable* _tmp5_;
AbracaIConfigurable* _tmp6_;
AbracaIConfigurable* _tmp7_;
GError * _inner_error_ = NULL;
g_return_if_fail (obj != NULL);
_tmp0_ = abraca_configurable_config_loaded;
if (_tmp0_) {
GKeyFile* _tmp1_ = NULL;
_tmp1_ = abraca_configurable_read_config ();
_g_key_file_free0 (file);
file = _tmp1_;
{
AbracaIConfigurable* _tmp2_;
GKeyFile* _tmp3_;
_tmp2_ = obj;
_tmp3_ = file;
abraca_iconfigurable_set_configuration (_tmp2_, _tmp3_, &_inner_error_);
if (_inner_error_ != NULL) {
if (_inner_error_->domain == G_KEY_FILE_ERROR) {
goto __catch13_g_key_file_error;
}
_g_key_file_free0 (file);
g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
}
goto __finally13;
__catch13_g_key_file_error:
{
GError* e = NULL;
const gchar* _tmp4_;
e = _inner_error_;
_inner_error_ = NULL;
_tmp4_ = e->message;
g_error ("configurable.vala:47: %s", _tmp4_);
_g_error_free0 (e);
}
__finally13:
if (_inner_error_ != NULL) {
_g_key_file_free0 (file);
g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
g_clear_error (&_inner_error_);
return;
}
}
_tmp5_ = obj;
abraca_configurable_configurables = g_slist_remove (abraca_configurable_configurables, _tmp5_);
_tmp6_ = obj;
_tmp7_ = _g_object_ref0 (_tmp6_);
abraca_configurable_configurables = g_slist_prepend (abraca_configurable_configurables, _tmp7_);
_g_key_file_free0 (file);
} | 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.