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
|
---|---|---|---|---|---|---|
fst_init(void)
{
int i;
for (i = 0; i < FST_MAX_CARDS; i++)
fst_card_array[i] = NULL;
spin_lock_init(&fst_work_q_lock);
return pci_register_driver(&fst_driver);
}
| false | false | false | false | false | 0 |
page_to_file(int page_num) const
{
GCriticalSectionLock lock((GCriticalSection *) &class_lock);
return (page_num<page2file.size())?page2file[page_num]:(GP<DjVmDir::File>(0));
}
| false | false | false | false | false | 0 |
caml_fl_add_blocks (char *bp)
{
Assert (fl_last != NULL);
Assert (Next (fl_last) == NULL);
caml_fl_cur_size += Whsize_bp (bp);
if (bp > fl_last){
Next (fl_last) = bp;
if (fl_last == caml_fl_merge && bp < caml_gc_sweep_hp){
caml_fl_merge = (char *) Field (bp, 1);
}
if (policy == Policy_first_fit && flp_size < FLP_MAX){
flp [flp_size++] = fl_last;
}
}else{
char *cur, *prev;
prev = Fl_head;
cur = Next (prev);
while (cur != NULL && cur < bp){ Assert (prev < bp || prev == Fl_head);
/* XXX TODO: extend flp on the fly */
prev = cur;
cur = Next (prev);
} Assert (prev < bp || prev == Fl_head);
Assert (cur > bp || cur == NULL);
Next (Field (bp, 1)) = cur;
Next (prev) = bp;
/* When inserting blocks between [caml_fl_merge] and [caml_gc_sweep_hp],
we must advance [caml_fl_merge] to the new block, so that [caml_fl_merge]
is always the last free-list block before [caml_gc_sweep_hp]. */
if (prev == caml_fl_merge && bp < caml_gc_sweep_hp){
caml_fl_merge = (char *) Field (bp, 1);
}
if (policy == Policy_first_fit) truncate_flp (bp);
}
}
| false | false | false | false | false | 0 |
convert_to_gcda(char *buffer, struct gcov_info *info)
{
struct gcov_fn_info *fi_ptr;
struct gcov_ctr_info *ci_ptr;
unsigned int fi_idx;
unsigned int ct_idx;
unsigned int cv_idx;
size_t pos = 0;
/* File header. */
pos += store_gcov_u32(buffer, pos, GCOV_DATA_MAGIC);
pos += store_gcov_u32(buffer, pos, info->version);
pos += store_gcov_u32(buffer, pos, info->stamp);
for (fi_idx = 0; fi_idx < info->n_functions; fi_idx++) {
fi_ptr = info->functions[fi_idx];
/* Function record. */
pos += store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION);
pos += store_gcov_u32(buffer, pos, GCOV_TAG_FUNCTION_LENGTH);
pos += store_gcov_u32(buffer, pos, fi_ptr->ident);
pos += store_gcov_u32(buffer, pos, fi_ptr->lineno_checksum);
pos += store_gcov_u32(buffer, pos, fi_ptr->cfg_checksum);
ci_ptr = fi_ptr->ctrs;
for (ct_idx = 0; ct_idx < GCOV_COUNTERS; ct_idx++) {
if (!counter_active(info, ct_idx))
continue;
/* Counter record. */
pos += store_gcov_u32(buffer, pos,
GCOV_TAG_FOR_COUNTER(ct_idx));
pos += store_gcov_u32(buffer, pos, ci_ptr->num * 2);
for (cv_idx = 0; cv_idx < ci_ptr->num; cv_idx++) {
pos += store_gcov_u64(buffer, pos,
ci_ptr->values[cv_idx]);
}
ci_ptr++;
}
}
return pos;
}
| false | false | false | false | false | 0 |
inputNewFragment(giopStream* g) {
if (g->pd_currentInputBuffer) {
g->releaseInputBuffer(g->pd_currentInputBuffer);
g->pd_currentInputBuffer = 0;
}
again:
if (!g->pd_input) {
giopStream_Buffer* p = g->inputMessage();
inputQueueMessage(g,p);
goto again;
}
else {
g->pd_currentInputBuffer = g->pd_input;
g->pd_input = g->pd_currentInputBuffer->next;
g->pd_currentInputBuffer->next = 0;
}
char* hdr = (char*)g->pd_currentInputBuffer +
g->pd_currentInputBuffer->start;
if (hdr[7] == GIOP::CancelRequest) {
if (g->pd_strand->biDir || !g->pd_strand->isClient()) {
throw GIOP_S::terminateProcessing();
}
else {
inputTerminalProtocolError(g, __FILE__, __LINE__,
"Client received a CancelRequest message");
// never reach here.
}
}
CORBA::Boolean bswap = (((hdr[6] & 0x1) == _OMNIORB_HOST_BYTE_ORDER_)
? 0 : 1 );
if (bswap != g->pd_unmarshal_byte_swap) {
inputTerminalProtocolError(g, __FILE__, __LINE__,
"Fragment has different byte ordering to "
"initial message");
// never reach here
}
g->pd_inb_mkr = (void*)(hdr + 16);
g->pd_inb_end = (void*)((omni::ptr_arith_t)g->pd_currentInputBuffer +
g->pd_currentInputBuffer->last);
g->inputExpectAnotherFragment(((hdr[6] & 0x2) ? 1 : 0));
g->inputMessageSize(g->inputMessageSize() +
g->pd_currentInputBuffer->size - 16);
g->inputFragmentToCome(g->pd_currentInputBuffer->size -
(g->pd_currentInputBuffer->last -
g->pd_currentInputBuffer->start));
}
| false | false | false | false | false | 0 |
libbfio_memory_range_io_handle_clone(
libbfio_memory_range_io_handle_t **destination_memory_range_io_handle,
libbfio_memory_range_io_handle_t *source_memory_range_io_handle,
libcerror_error_t **error )
{
static char *function = "libbfio_memory_range_io_handle_clone";
if( destination_memory_range_io_handle == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_ARGUMENTS,
LIBCERROR_ARGUMENT_ERROR_INVALID_VALUE,
"%s: invalid destination memory range IO handle.",
function );
return( -1 );
}
if( *destination_memory_range_io_handle != NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_VALUE_ALREADY_SET,
"%s: destination memory range IO handle already set.",
function );
return( -1 );
}
if( source_memory_range_io_handle == NULL )
{
*destination_memory_range_io_handle = NULL;
return( 1 );
}
if( libbfio_memory_range_io_handle_initialize(
destination_memory_range_io_handle,
error ) != 1 )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_INITIALIZE_FAILED,
"%s: unable to create memory range handle.",
function );
return( -1 );
}
if( *destination_memory_range_io_handle == NULL )
{
libcerror_error_set(
error,
LIBCERROR_ERROR_DOMAIN_RUNTIME,
LIBCERROR_RUNTIME_ERROR_VALUE_MISSING,
"%s: missing destination memory range IO handle.",
function );
return( -1 );
}
( *destination_memory_range_io_handle )->range_start = source_memory_range_io_handle->range_start;
( *destination_memory_range_io_handle )->range_size = source_memory_range_io_handle->range_size;
( *destination_memory_range_io_handle )->range_offset = source_memory_range_io_handle->range_offset;
( *destination_memory_range_io_handle )->access_flags = source_memory_range_io_handle->access_flags;
return( 1 );
}
| false | false | false | false | false | 0 |
parse_controllers(cont_name_t cont_names[CG_CONTROLLER_MAX],
const char *program_name)
{
int ret = 0;
void *handle;
char path[FILENAME_MAX];
struct cgroup_mount_point controller;
char controllers[CG_CONTROLLER_MAX][FILENAME_MAX];
int max = 0;
path[0] = '\0';
ret = cgroup_get_controller_begin(&handle, &controller);
/* go through the list of controllers/mount point pairs */
while (ret == 0) {
if (strcmp(path, controller.path) == 0) {
/* if it is still the same mount point */
if (max < CG_CONTROLLER_MAX) {
strncpy(controllers[max],
controller.name, FILENAME_MAX);
(controllers[max])[FILENAME_MAX-1] = '\0';
max++;
}
} else {
/* we got new mount point, print it if needed */
if ((!(flags & FL_LIST) ||
(is_ctlr_on_list(controllers, cont_names)))
&& (max != 0)) {
(controllers[max])[0] = '\0';
ret = display_controller_data(
controllers, program_name);
}
strncpy(controllers[0], controller.name, FILENAME_MAX);
(controllers[0])[FILENAME_MAX-1] = '\0';
strncpy(path, controller.path, FILENAME_MAX);
path[FILENAME_MAX-1] = '\0';
max = 1;
}
/* the actual controller should not be printed */
ret = cgroup_get_controller_next(&handle, &controller);
}
if (max != 0) {
(controllers[max])[0] = '\0';
ret = display_controller_data(
controllers, program_name);
}
cgroup_get_controller_end(&handle);
if (ret != ECGEOF)
return ret;
return 0;
}
| false | false | false | false | false | 0 |
print_set(int *a) {
int i;
for (i = 0; i < N && a[i]; i++) {
printf("%d ", a[i]);
}
printf("\n");
}
| false | false | false | false | false | 0 |
write_properties_between(uchar *p, int mark, int from, int to)
{ int j, k, prop_number, prop_length;
/* Note that p is properties_table. */
for (prop_number=to; prop_number>=from; prop_number--)
{ for (j=0; j<full_object.l; j++)
{ if ((full_object.pp[j].num == prop_number)
&& (full_object.pp[j].l != 100))
{ prop_length = 2*full_object.pp[j].l;
if (mark+2+prop_length >= MAX_PROP_TABLE_SIZE)
memoryerror("MAX_PROP_TABLE_SIZE",MAX_PROP_TABLE_SIZE);
if (version_number == 3)
p[mark++] = prop_number + (prop_length - 1)*32;
else
{ switch(prop_length)
{ case 1:
p[mark++] = prop_number; break;
case 2:
p[mark++] = prop_number + 0x40; break;
default:
p[mark++] = prop_number + 0x80;
p[mark++] = prop_length + 0x80; break;
}
}
for (k=0; k<full_object.pp[j].l; k++)
{ if (full_object.pp[j].ao[k].marker != 0)
backpatch_zmachine(full_object.pp[j].ao[k].marker,
PROP_ZA, mark);
p[mark++] = full_object.pp[j].ao[k].value/256;
p[mark++] = full_object.pp[j].ao[k].value%256;
}
}
}
}
p[mark++]=0;
return(mark);
}
| false | false | false | false | false | 0 |
compareAttEntries(GinState *ginstate, OffsetNumber attnum_a, Datum a,
OffsetNumber attnum_b, Datum b)
{
if (attnum_a == attnum_b)
return compareEntries(ginstate, attnum_a, a, b);
return (attnum_a < attnum_b) ? -1 : 1;
}
| false | false | false | false | false | 0 |
dcompare(double a, enum match_type mtype, double b)
{
DBGP2("comparing doubles '%.lf' and '%.lf'", a, b);
COMPARE((a - b), mtype);
}
| false | false | false | false | false | 0 |
count(MCInst &Inst,
const MCSubtargetInfo &STI) {
if (InShadow) {
SmallString<256> Code;
SmallVector<MCFixup, 4> Fixups;
raw_svector_ostream VecOS(Code);
CodeEmitter->encodeInstruction(Inst, VecOS, Fixups, STI);
CurrentShadowSize += Code.size();
if (CurrentShadowSize >= RequiredShadowSize)
InShadow = false; // The shadow is big enough. Stop counting.
}
}
| false | false | false | false | false | 0 |
modules_load(gchar ** module_list)
{
GDir *dir;
GSList *modules = NULL;
ShellModule *module;
gchar *filename;
filename = g_build_filename(params.path_lib, "modules", NULL);
dir = g_dir_open(filename, 0, NULL);
g_free(filename);
if (dir) {
while ((filename = (gchar *) g_dir_read_name(dir))) {
if (g_strrstr(filename, "." G_MODULE_SUFFIX) &&
module_in_module_list(filename, module_list) &&
((module = module_load(filename)))) {
modules = g_slist_prepend(modules, module);
}
}
g_dir_close(dir);
}
modules = modules_check_deps(modules);
if (g_slist_length(modules) == 0) {
if (params.use_modules == NULL) {
g_error
("No module could be loaded. Check permissions on \"%s\" and try again.",
params.path_lib);
} else {
g_error
("No module could be loaded. Please use hardinfo -l to list all avai"
"lable modules and try again with a valid module list.");
}
}
return g_slist_sort(modules, module_cmp);
}
| false | false | false | false | false | 0 |
printing_to_standard_stream (PRN *prn)
{
int ret = 0;
if (prn != NULL && (prn->fp == stdout || prn->fp == stderr)) {
ret = 1;
}
return ret;
}
| false | false | false | false | false | 0 |
SolveLeastSquares(float *solution, int rows, int cols,
const FloatMatrix& jacobian,
float *errvec, FloatMatrix& sqarray)
{
int r, c, i;
float sum;
assert(rows >= cols);
/* Multiply Jacobian transpose by Jacobian, and put result in sqarray. */
for (r = 0; r < cols; r++)
for (c = 0; c < cols; c++) {
sum = 0.0;
for (i = 0; i < rows; i++)
sum += jacobian[i][r] * jacobian[i][c];
sqarray[r][c] = sum;
}
/* Multiply transpose of Jacobian by errvec, and put result in solution. */
for (c = 0; c < cols; c++) {
sum = 0.0;
for (i = 0; i < rows; i++)
sum += jacobian[i][c] * errvec[i];
solution[c] = sum;
}
/* Now, solve square system of equations. */
SolveLinearSystem(solution, sqarray, cols);
}
| false | false | false | false | false | 0 |
ecryptfs_process_key_cipher(struct crypto_blkcipher **key_tfm,
char *cipher_name, size_t *key_size)
{
char dummy_key[ECRYPTFS_MAX_KEY_BYTES];
char *full_alg_name = NULL;
int rc;
*key_tfm = NULL;
if (*key_size > ECRYPTFS_MAX_KEY_BYTES) {
rc = -EINVAL;
printk(KERN_ERR "Requested key size is [%zd] bytes; maximum "
"allowable is [%d]\n", *key_size, ECRYPTFS_MAX_KEY_BYTES);
goto out;
}
rc = ecryptfs_crypto_api_algify_cipher_name(&full_alg_name, cipher_name,
"ecb");
if (rc)
goto out;
*key_tfm = crypto_alloc_blkcipher(full_alg_name, 0, CRYPTO_ALG_ASYNC);
if (IS_ERR(*key_tfm)) {
rc = PTR_ERR(*key_tfm);
printk(KERN_ERR "Unable to allocate crypto cipher with name "
"[%s]; rc = [%d]\n", full_alg_name, rc);
goto out;
}
crypto_blkcipher_set_flags(*key_tfm, CRYPTO_TFM_REQ_WEAK_KEY);
if (*key_size == 0) {
struct blkcipher_alg *alg = crypto_blkcipher_alg(*key_tfm);
*key_size = alg->max_keysize;
}
get_random_bytes(dummy_key, *key_size);
rc = crypto_blkcipher_setkey(*key_tfm, dummy_key, *key_size);
if (rc) {
printk(KERN_ERR "Error attempting to set key of size [%zd] for "
"cipher [%s]; rc = [%d]\n", *key_size, full_alg_name,
rc);
rc = -EINVAL;
goto out;
}
out:
kfree(full_alg_name);
return rc;
}
| true | true | false | false | false | 1 |
shdma_chan_probe(struct shdma_dev *sdev,
struct shdma_chan *schan, int id)
{
schan->pm_state = SHDMA_PM_ESTABLISHED;
/* reference struct dma_device */
schan->dma_chan.device = &sdev->dma_dev;
dma_cookie_init(&schan->dma_chan);
schan->dev = sdev->dma_dev.dev;
schan->id = id;
if (!schan->max_xfer_len)
schan->max_xfer_len = PAGE_SIZE;
spin_lock_init(&schan->chan_lock);
/* Init descripter manage list */
INIT_LIST_HEAD(&schan->ld_queue);
INIT_LIST_HEAD(&schan->ld_free);
/* Add the channel to DMA device channel list */
list_add_tail(&schan->dma_chan.device_node,
&sdev->dma_dev.channels);
sdev->schan[id] = schan;
}
| false | false | false | false | false | 0 |
_dump_node_state (struct node_record *dump_node_ptr, Buf buffer)
{
packstr (dump_node_ptr->comm_name, buffer);
packstr (dump_node_ptr->name, buffer);
packstr (dump_node_ptr->node_hostname, buffer);
packstr (dump_node_ptr->reason, buffer);
packstr (dump_node_ptr->features, buffer);
packstr (dump_node_ptr->gres, buffer);
pack16 (dump_node_ptr->node_state, buffer);
pack16 (dump_node_ptr->cpus, buffer);
pack16 (dump_node_ptr->boards, buffer);
pack16 (dump_node_ptr->sockets, buffer);
pack16 (dump_node_ptr->cores, buffer);
pack16 (dump_node_ptr->threads, buffer);
pack32 (dump_node_ptr->real_memory, buffer);
pack32 (dump_node_ptr->tmp_disk, buffer);
pack32 (dump_node_ptr->reason_uid, buffer);
pack_time(dump_node_ptr->reason_time, buffer);
(void) gres_plugin_node_state_pack(dump_node_ptr->gres_list, buffer,
dump_node_ptr->name);
}
| false | false | false | false | false | 0 |
VP8LEncodeImage(const WebPConfig* const config,
const WebPPicture* const picture) {
int width, height;
int has_alpha;
size_t coded_size;
int percent = 0;
WebPEncodingError err = VP8_ENC_OK;
VP8LBitWriter bw;
if (picture == NULL) return 0;
if (config == NULL || picture->argb == NULL) {
err = VP8_ENC_ERROR_NULL_PARAMETER;
WebPEncodingSetError(picture, err);
return 0;
}
width = picture->width;
height = picture->height;
if (!VP8LBitWriterInit(&bw, (width * height) >> 1)) {
err = VP8_ENC_ERROR_OUT_OF_MEMORY;
goto Error;
}
if (!WebPReportProgress(picture, 1, &percent)) {
UserAbort:
err = VP8_ENC_ERROR_USER_ABORT;
goto Error;
}
// Reset stats (for pure lossless coding)
if (picture->stats != NULL) {
WebPAuxStats* const stats = picture->stats;
memset(stats, 0, sizeof(*stats));
stats->PSNR[0] = 99.f;
stats->PSNR[1] = 99.f;
stats->PSNR[2] = 99.f;
stats->PSNR[3] = 99.f;
stats->PSNR[4] = 99.f;
}
// Write image size.
if (!WriteImageSize(picture, &bw)) {
err = VP8_ENC_ERROR_OUT_OF_MEMORY;
goto Error;
}
has_alpha = WebPPictureHasTransparency(picture);
// Write the non-trivial Alpha flag and lossless version.
if (!WriteRealAlphaAndVersion(&bw, has_alpha)) {
err = VP8_ENC_ERROR_OUT_OF_MEMORY;
goto Error;
}
if (!WebPReportProgress(picture, 5, &percent)) goto UserAbort;
// Encode main image stream.
err = VP8LEncodeStream(config, picture, &bw);
if (err != VP8_ENC_OK) goto Error;
// TODO(skal): have a fine-grained progress report in VP8LEncodeStream().
if (!WebPReportProgress(picture, 90, &percent)) goto UserAbort;
// Finish the RIFF chunk.
err = WriteImage(picture, &bw, &coded_size);
if (err != VP8_ENC_OK) goto Error;
if (!WebPReportProgress(picture, 100, &percent)) goto UserAbort;
// Save size.
if (picture->stats != NULL) {
picture->stats->coded_size += (int)coded_size;
picture->stats->lossless_size = (int)coded_size;
}
if (picture->extra_info != NULL) {
const int mb_w = (width + 15) >> 4;
const int mb_h = (height + 15) >> 4;
memset(picture->extra_info, 0, mb_w * mb_h * sizeof(*picture->extra_info));
}
Error:
if (bw.error_) err = VP8_ENC_ERROR_OUT_OF_MEMORY;
VP8LBitWriterDestroy(&bw);
if (err != VP8_ENC_OK) {
WebPEncodingSetError(picture, err);
return 0;
}
return 1;
}
| false | false | false | false | false | 0 |
event_whois_away(IRC_SERVER_REC *server, const char *data)
{
char *params, *nick, *awaymsg, *recoded;
g_return_if_fail(data != NULL);
params = event_get_params(data, 3, NULL, &nick, &awaymsg);
recoded = recode_in(SERVER(server), awaymsg, nick);
printformat(server, nick, MSGLEVEL_CRAP,
IRCTXT_WHOIS_AWAY, nick, recoded);
g_free(params);
g_free(recoded);
}
| false | false | false | false | false | 0 |
gdm_display_store_find (GdmDisplayStore *store,
GdmDisplayStoreFunc predicate,
gpointer user_data)
{
StoredDisplay *stored_display;
FindClosure closure;
g_return_val_if_fail (store != NULL, NULL);
g_return_val_if_fail (predicate != NULL, NULL);
closure.predicate = predicate;
closure.user_data = user_data;
stored_display = g_hash_table_find (store->priv->displays,
(GHRFunc) find_func,
&closure);
if (stored_display == NULL) {
return NULL;
}
return stored_display->display;
}
| false | false | false | false | false | 0 |
zend_fcall_info_argp(zend_fcall_info *fci TSRMLS_DC, int argc, zval ***argv) /* {{{ */
{
int i;
if (argc < 0) {
return FAILURE;
}
zend_fcall_info_args_clear(fci, !argc);
if (argc) {
fci->param_count = argc;
fci->params = (zval ***) erealloc(fci->params, fci->param_count * sizeof(zval **));
for (i = 0; i < argc; ++i) {
fci->params[i] = argv[i];
}
}
return SUCCESS;
}
| false | false | false | false | false | 0 |
change_definition(const sharedptr<const Field>& fieldOld, const sharedptr<const Field>& field)
{
BusyCursor busy_cursor(get_app_window());
//DB field definition:
sharedptr<Field> result;
if(!fieldOld || !field)
return result;
type_vec_const_fields old_fields;
type_vec_fields new_fields;
if(fieldOld->get_primary_key() != field->get_primary_key())
{
//Note: We have already checked whether this change of primary key is likely to succeed.
if(field->get_primary_key())
{
//Unset the current primary key:
//(There should be one.)
sharedptr<Field> existing_primary_key = get_field_primary_key_for_table(m_table_name);
if(existing_primary_key)
{
sharedptr<Field> existing_primary_key_unset = glom_sharedptr_clone(existing_primary_key);
existing_primary_key_unset->set_primary_key(false);
old_fields.push_back(existing_primary_key);
new_fields.push_back(existing_primary_key_unset);
}
}
//Forget the remembered currently-viewed primary key value,
//because it will be useless with a different field as the primary key, or with no field as primary key:
Document* document = get_document();
document->forget_layout_record_viewed(m_table_name);
}
old_fields.push_back(fieldOld);
new_fields.push_back(glom_sharedptr_clone(field));
//TODO: Warn about a delay, and possible loss of precision, before actually
//changing types or when the backend needs to recreate the whole column or
//table.
// TODO: Don't call change_columns if only the field title has changed,
// since the title is only stored in the document anyway.
if(change_columns(m_table_name, old_fields, new_fields, get_app_window()))
{
result = new_fields.back();
}
else
{
//Give up. Don't update the document. Hope that we can read the current field properties from the database.
fill_fields();
//fill_from_database(); //We should not change the database definition in a cell renderer signal handler.
//Select the same field again:
m_AddDel.select_item(field->get_name(), m_colName, false);
return glom_sharedptr_clone(old_fields.back());
}
//Extra Glom field definitions:
Document* pDoc = static_cast<Document*>(get_document());
if(pDoc)
{
//Get Table's fields:
Document::type_vec_fields vecFields = pDoc->get_table_fields(m_table_name);
for(unsigned int i = 0; i < old_fields.size(); ++ i)
{
//Find old field:
const Glib::ustring field_name_old = old_fields[i]->get_name();
Document::type_vec_fields::iterator iterFind = std::find_if( vecFields.begin(), vecFields.end(), predicate_FieldHasName<Field>(field_name_old) );
if(iterFind != vecFields.end()) //If it was found:
{
//Change it to the new Fields's value:
*iterFind = glom_sharedptr_clone(new_fields[i]);
}
else
{
//Add it, because it's not there already:
vecFields.push_back( glom_sharedptr_clone(new_fields[i]) );
}
// TODO_Performance: Can we do this at the end, after the loop? Or do
// the following operations depend on this?
pDoc->set_table_fields(m_table_name, vecFields);
//Update field names where they are used in relationships or on layouts:
if(field_name_old != new_fields[i]->get_name())
{
pDoc->change_field_name(m_table_name, field_name_old, new_fields[i]->get_name());
}
// TODO_Performance: Do we even need to do this if only the primary key
// flag changed, such as for the first entry in the new_fields vector?
//Recalculate if necessary:
if(new_fields[i]->get_has_calculation())
{
const Glib::ustring calculation = new_fields[i]->get_calculation();
if(calculation != old_fields[i]->get_calculation())
calculate_field_in_all_records(m_table_name, new_fields[i]);
}
}
}
//Update UI:
fill_fields();
//fill_from_database(); //We should not change the database definition in a cell renderer signal handler.
//Select the same field again:
m_AddDel.select_item(field->get_name(), m_colName, false);
return result;
}
| false | false | false | false | false | 0 |
TS_CONF_load_certs(const char *file)
{
BIO *certs = NULL;
STACK_OF(X509) *othercerts = NULL;
STACK_OF(X509_INFO) *allcerts = NULL;
int i;
if (!(certs = BIO_new_file(file, "r"))) goto end;
if (!(othercerts = sk_X509_new_null())) goto end;
allcerts = PEM_X509_INFO_read_bio(certs, NULL, NULL, NULL);
for(i = 0; i < sk_X509_INFO_num(allcerts); i++)
{
X509_INFO *xi = sk_X509_INFO_value(allcerts, i);
if (xi->x509)
{
sk_X509_push(othercerts, xi->x509);
xi->x509 = NULL;
}
}
end:
if (othercerts == NULL)
fprintf(stderr, "unable to load certificates: %s\n", file);
sk_X509_INFO_pop_free(allcerts, X509_INFO_free);
BIO_free(certs);
return othercerts;
}
| false | false | false | false | false | 0 |
PrintObj (
Obj obj )
{
Int i; /* loop variable */
UInt lastPV; /* save LastPV */
UInt fromview; /* non-zero when we were called
from viewObj of the SAME object */
/* check for interrupts */
if ( SyIsIntr() ) {
i = PrintObjDepth;
Pr( "%c%c", (Int)'\03', (Int)'\04' );
ErrorReturnVoid(
"user interrupt while printing",
0L, 0L,
"you can 'return;'" );
PrintObjDepth = i;
}
/* First check if <obj> is actually the current object being Viewed
Since ViewObj(<obj>) may result in a call to PrintObj(<obj>) */
lastPV = LastPV;
LastPV = 1;
fromview = (lastPV == 2) && (obj == PrintObjThis);
/* if <obj> is a subobject, then mark and remember the superobject
unless ViewObj has done that job already */
if ( !fromview && 0 < PrintObjDepth ) {
if ( IS_MARKABLE(PrintObjThis) ) MARK( PrintObjThis );
PrintObjThiss[PrintObjDepth-1] = PrintObjThis;
PrintObjIndices[PrintObjDepth-1] = PrintObjIndex;
}
/* handle the <obj> */
if (!fromview)
{
PrintObjDepth += 1;
PrintObjThis = obj;
PrintObjIndex = 0;
}
/* dispatch to the appropriate printing function */
if ( (! IS_MARKED( PrintObjThis )) ) {
if (PrintObjDepth < MAXPRINTDEPTH) {
(*PrintObjFuncs[ TNUM_OBJ(PrintObjThis) ])( PrintObjThis );
}
else {
/* don't recurse if depth too high */
Pr("\nprinting stopped, too many recursion levels!\n", 0L, 0L);
}
}
/* or print the path */
else {
Pr( "~", 0L, 0L );
for ( i = 0; PrintObjThis != PrintObjThiss[i]; i++ ) {
(*PrintPathFuncs[ TNUM_OBJ(PrintObjThiss[i])])
( PrintObjThiss[i], PrintObjIndices[i] );
}
}
/* done with <obj> */
if (!fromview)
{
PrintObjDepth -= 1;
/* if <obj> is a subobject, then restore and unmark the superobject */
if ( 0 < PrintObjDepth ) {
PrintObjThis = PrintObjThiss[PrintObjDepth-1];
PrintObjIndex = PrintObjIndices[PrintObjDepth-1];
if ( IS_MARKED(PrintObjThis) ) UNMARK( PrintObjThis );
}
}
LastPV = lastPV;
}
| false | false | false | false | false | 0 |
marker_priv_cleanup (xlator_t *this)
{
marker_conf_t *priv = NULL;
GF_VALIDATE_OR_GOTO ("marker", this, out);
priv = (marker_conf_t *) this->private;
GF_VALIDATE_OR_GOTO (this->name, priv, out);
marker_xtime_priv_cleanup (this);
LOCK_DESTROY (&priv->lock);
GF_FREE (priv);
out:
return;
}
| false | false | false | false | false | 0 |
Shortread_print_quality (FILE *fp, T this, int hardclip_low, int hardclip_high,
int shift, bool show_chopped_p) {
int i;
int c;
if (this->quality == NULL) {
fprintf(fp,"*");
} else {
for (i = hardclip_low; i < this->fulllength - hardclip_high; i++) {
if ((c = this->quality[i] + shift) <= 32) {
fprintf(stderr,"Warning: With a quality-print-shift of %d, QC score %c becomes non-printable. May need to specify --quality-protocol or --quality-print-shift\n",
shift,this->quality[i]);
abort();
} else {
fprintf(fp,"%c",c);
}
}
if (show_chopped_p == true) {
assert(hardclip_high == 0);
for (i = 0; i < this->choplength; i++) {
if ((c = this->chop_quality[i] + shift) <= 32) {
fprintf(stderr,"Warning: With a quality-print-shift of %d, QC score %c becomes non-printable. May need to specify --quality-protocol or --quality-print-shift\n",
shift,this->chop_quality[i]);
abort();
} else {
fprintf(fp,"%c",c);
}
}
}
}
return;
}
| false | false | false | false | false | 0 |
statObjects(void *data)
{
StatObjectsState *state = data;
StoreEntry *e;
hash_link *link_ptr = NULL;
hash_link *link_next = NULL;
if (state->bucket >= store_hash_buckets) {
storeComplete(state->sentry);
storeUnlockObject(state->sentry);
cbdataFree(state);
return;
} else if (EBIT_TEST(state->sentry->flags, ENTRY_ABORTED)) {
storeUnlockObject(state->sentry);
cbdataFree(state);
return;
} else if (fwdCheckDeferRead(-1, state->sentry)) {
eventAdd("statObjects", statObjects, state, 0.1, 1);
return;
}
debug(49, 3) ("statObjects: Bucket #%d\n", state->bucket);
link_next = hash_get_bucket(store_table, state->bucket);
if (link_next) {
MemBuf mb;
memBufDefInit(&mb);
while (NULL != (link_ptr = link_next)) {
link_next = link_ptr->next;
e = (StoreEntry *) link_ptr;
if (state->filter && 0 == state->filter(e))
continue;
statStoreEntry(&mb, e);
}
storeAppend(state->sentry, mb.buf, mb.size);
memBufClean(&mb);
}
state->bucket++;
eventAdd("statObjects", statObjects, state, 0.0, 1);
}
| false | false | false | false | false | 0 |
score_moves()
{
if (type == ROOT)
return;
for (unsigned int i=current_move_no+1; i<movelist.size(); i++) {
int score = 0;
Move mov = movelist[i];
if (mov == hashmv) {
/* The hash move is treated specially. It won't be
* returned by pick(), thus we do not need to assign
* any score to it. */
continue;
} else if (mov.is_capture()
#ifdef HOICHESS
|| mov.is_promotion()
|| mov.is_enpassant()
#endif
) {
/* TODO This could be improved I think */
score += 10000
+ mat_values[mov.cap_ptype()]
- mat_values[mov.ptype()];
#ifdef HOICHESS
if (mov.is_promotion()) {
score += mat_values[mov.promote_to()];
}
#endif
} else {
#ifdef USE_KILLER
/* TODO This could be improved I think */
if (mov == killer1 || mov == killer2) {
score += 5000;
}
#endif
#ifdef USE_HISTORY
/* TODO This could be improved I think */
if (historytable) {
score += historytable->get(mov);
}
#endif
}
movelist.set_score(i, score);
}
}
| false | false | false | false | false | 0 |
FloodAreaConnections (void)
{
int i;
carea_t *area;
int floodnum;
// all current floods are now invalid
floodvalid++;
floodnum = 0;
// area 0 is not used
for (i=1 ; i<numareas ; i++)
{
area = &map_areas[i];
if (area->floodvalid == floodvalid)
continue; // already flooded into
floodnum++;
FloodArea_r (area, floodnum);
}
}
| false | false | false | false | false | 0 |
lock_tree_promotably (int argc, char **argv, int local, int which, int aflag)
{
TRACE (TRACE_FUNCTION, "lock_tree_promotably (%d, argv, %d, %d, %d)",
argc, local, which, aflag);
/*
* Run the recursion processor to find all the dirs to lock and lock all
* the dirs
*/
lock_tree_list = getlist ();
start_recursion
(NULL, lock_filesdoneproc,
NULL, NULL, NULL, argc,
argv, local, which, aflag, CVS_LOCK_NONE,
NULL, 0, NULL );
sortlist (lock_tree_list, fsortcmp);
if (lock_list_promotably (lock_tree_list) != 0)
error (1, 0, "lock failed - giving up");
}
| false | false | false | false | false | 0 |
get_bw_filesize(request_rec * r, apr_array_header_t * a,
apr_uint32_t filesize, const char *filename)
{
bw_sizel *e = (bw_sizel *) a->elts;
int i;
apr_uint32_t tmpsize = 0, tmprate = 0;
if (!filesize)
return (0);
filesize /= 1024;
for (i = 0; i < a->nelts; i++) {
if ((e[i].size <= filesize) && match_ext(filename, e[i].file))
if (tmpsize <= e[i].size) {
tmpsize = e[i].size;
tmprate = e[i].rate;
}
}
return (tmprate);
}
| false | false | false | false | false | 0 |
gf_isom_streamer_del(GF_ISOMRTPStreamer *streamer)
{
GF_RTPTrack *track = streamer->stream;
while (track) {
GF_RTPTrack *tmp = track;
if (track->au) gf_isom_sample_del(&track->au);
if (track->rtp) gf_rtp_streamer_del(track->rtp);
track = track->next;
gf_free(tmp);
}
if (streamer->isom) gf_isom_close(streamer->isom);
gf_free(streamer->dest_ip);
gf_free(streamer);
}
| false | false | false | false | false | 0 |
storeOrigin(IRBuilder<> &IRB, Value *Addr, Value *Shadow, Value *Origin,
unsigned Alignment, bool AsCall) {
const DataLayout &DL = F.getParent()->getDataLayout();
unsigned OriginAlignment = std::max(kMinOriginAlignment, Alignment);
unsigned StoreSize = DL.getTypeStoreSize(Shadow->getType());
if (isa<StructType>(Shadow->getType())) {
paintOrigin(IRB, updateOrigin(Origin, IRB),
getOriginPtr(Addr, IRB, Alignment), StoreSize,
OriginAlignment);
} else {
Value *ConvertedShadow = convertToShadowTyNoVec(Shadow, IRB);
Constant *ConstantShadow = dyn_cast_or_null<Constant>(ConvertedShadow);
if (ConstantShadow) {
if (ClCheckConstantShadow && !ConstantShadow->isZeroValue())
paintOrigin(IRB, updateOrigin(Origin, IRB),
getOriginPtr(Addr, IRB, Alignment), StoreSize,
OriginAlignment);
return;
}
unsigned TypeSizeInBits =
DL.getTypeSizeInBits(ConvertedShadow->getType());
unsigned SizeIndex = TypeSizeToSizeIndex(TypeSizeInBits);
if (AsCall && SizeIndex < kNumberOfAccessSizes) {
Value *Fn = MS.MaybeStoreOriginFn[SizeIndex];
Value *ConvertedShadow2 = IRB.CreateZExt(
ConvertedShadow, IRB.getIntNTy(8 * (1 << SizeIndex)));
IRB.CreateCall(Fn, {ConvertedShadow2,
IRB.CreatePointerCast(Addr, IRB.getInt8PtrTy()),
Origin});
} else {
Value *Cmp = IRB.CreateICmpNE(
ConvertedShadow, getCleanShadow(ConvertedShadow), "_mscmp");
Instruction *CheckTerm = SplitBlockAndInsertIfThen(
Cmp, &*IRB.GetInsertPoint(), false, MS.OriginStoreWeights);
IRBuilder<> IRBNew(CheckTerm);
paintOrigin(IRBNew, updateOrigin(Origin, IRBNew),
getOriginPtr(Addr, IRBNew, Alignment), StoreSize,
OriginAlignment);
}
}
}
| false | false | false | false | false | 0 |
_show_hide(Evas_Object *obj)
{
ELM_FLIP_DATA_GET(obj, sd);
Evas_Coord x, y, w, h;
if (!sd) return;
evas_object_geometry_get(obj, &x, &y, &w, &h);
if (sd->front.content)
{
if ((sd->pageflip) && (sd->state))
{
evas_object_move(sd->front.content, 4999, 4999);
}
else
{
if (!sd->animator)
evas_object_move(sd->front.content, x, y);
}
evas_object_resize(sd->front.content, w, h);
}
if (sd->back.content)
{
if ((sd->pageflip) && (!sd->state))
{
evas_object_move(sd->back.content, 4999, 4999);
}
else
{
if (!sd->animator)
evas_object_move(sd->back.content, x, y);
}
evas_object_resize(sd->back.content, w, h);
}
}
| false | false | false | false | false | 0 |
cec_set_menu_state(cec_menu_state state, int bSendUpdate) {
if (cec_parser)
return cec_parser->SetMenuState(state, bSendUpdate == 1) ? 1 : 0;
return -1;
}
| false | false | false | false | false | 0 |
ixgbe_acquire_swfw_sync_X550em(struct ixgbe_hw *hw, u32 mask)
{
s32 status;
status = ixgbe_acquire_swfw_sync_X540(hw, mask);
if (status)
return status;
if (mask & IXGBE_GSSR_I2C_MASK)
ixgbe_set_mux(hw, 1);
return 0;
}
| false | false | false | false | false | 0 |
gst_date_time_get_time_zone_offset (const GstDateTime * datetime)
{
g_return_val_if_fail (datetime != NULL, 0.0);
g_return_val_if_fail (gst_date_time_has_time (datetime), 0.0);
return (g_date_time_get_utc_offset (datetime->datetime) /
G_USEC_PER_SEC) / 3600.0;
}
| false | false | false | false | false | 0 |
xmalloc_chunk_find(struct xchunkhead *ch, unsigned stid)
{
link_t *lk;
struct xchunk *xck;
for (lk = elist_first(&ch->list); lk != NULL; lk = elist_next(lk)) {
xck = elist_data(&ch->list, lk);
xchunk_check(xck);
if (0 != xck->xc_count)
goto found;
}
/*
* No free chunk, allocate a new one and move it to the head of the list.
*
* If the thread-pool is shared, it is not worth continuing to expand
* the thread-specific pool for sizes where we lose more from the memory
* alignment constraints in the chunk than the typical overhead we stuff
* at the front of each block: prefer regular allocations.
*/
if G_UNLIKELY(ch->shared) {
unsigned capacity, overhead;
/*
* If we no longer have any chunks, redirect to the main freelist.
* Regardless of the possible per-block overhead saving that this
* thread-specific pool could provide, we can nonetheless fragment
* the space with some sub-optimal allocation patterns. Avoid it.
*/
if (0 == elist_count(&ch->list))
return NULL;
/*
* The overhead of each chunk is the largest between the size of
* the chunk overhead structure and the block size, due to alignment
* of the first available block.
*/
capacity = (xmalloc_pagesize - sizeof *xck) / ch->blocksize;
overhead = MAX(sizeof *xck, ch->blocksize);
if (overhead / capacity >= XHEADER_SIZE) {
if (xmalloc_debugging(1)) {
t_debug("XM not creating new %zu-byte blocks for thread #%u: "
"shared blocks have %F bytes overhead (%u per page), "
"currently has %zu chunk%s",
ch->blocksize, stid, (double) overhead / capacity,
capacity, elist_count(&ch->list),
1 == elist_count(&ch->list) ? "" : "s");
}
return NULL;
}
if (xmalloc_debugging(1)) {
t_debug("XM still creating new %zu-byte blocks for thread #%u: "
"shared blocks have only %F bytes overhead (%u per page)",
ch->blocksize, stid, (double) overhead / capacity,
capacity);
}
}
xck = xmalloc_chunk_allocate(ch, stid);
elist_prepend(&ch->list, xck);
if (xmalloc_debugging(1)) {
t_debug("XM new chunk #%zu of %zu-byte blocks for thread #%u at %p",
elist_count(&ch->list) - 1, ch->blocksize, stid, xck);
}
return xck;
found:
/*
* Move the selected chunk to the head of the list.
*/
if (lk != elist_first(&ch->list)) {
elist_link_remove(&ch->list, lk);
elist_link_prepend(&ch->list, lk);
}
return xck;
}
| false | false | false | false | false | 0 |
nvme_trans_report_luns(struct nvme_ns *ns, struct sg_io_hdr *hdr,
u8 *cmd)
{
int res;
int nvme_sc;
u32 alloc_len, xfer_len, resp_size;
u8 *response;
struct nvme_id_ctrl *id_ctrl;
u32 ll_length, lun_id;
u8 lun_id_offset = REPORT_LUNS_FIRST_LUN_OFFSET;
__be32 tmp_len;
switch (cmd[2]) {
default:
return nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION,
ILLEGAL_REQUEST, SCSI_ASC_INVALID_CDB,
SCSI_ASCQ_CAUSE_NOT_REPORTABLE);
case ALL_LUNS_RETURNED:
case ALL_WELL_KNOWN_LUNS_RETURNED:
case RESTRICTED_LUNS_RETURNED:
nvme_sc = nvme_identify_ctrl(ns->ctrl, &id_ctrl);
res = nvme_trans_status_code(hdr, nvme_sc);
if (res)
return res;
ll_length = le32_to_cpu(id_ctrl->nn) * LUN_ENTRY_SIZE;
resp_size = ll_length + LUN_DATA_HEADER_SIZE;
alloc_len = get_unaligned_be32(&cmd[6]);
if (alloc_len < resp_size) {
res = nvme_trans_completion(hdr,
SAM_STAT_CHECK_CONDITION,
ILLEGAL_REQUEST, SCSI_ASC_INVALID_CDB,
SCSI_ASCQ_CAUSE_NOT_REPORTABLE);
goto out_free_id;
}
response = kzalloc(resp_size, GFP_KERNEL);
if (response == NULL) {
res = -ENOMEM;
goto out_free_id;
}
/* The first LUN ID will always be 0 per the SAM spec */
for (lun_id = 0; lun_id < le32_to_cpu(id_ctrl->nn); lun_id++) {
/*
* Set the LUN Id and then increment to the next LUN
* location in the parameter data.
*/
__be64 tmp_id = cpu_to_be64(lun_id);
memcpy(&response[lun_id_offset], &tmp_id, sizeof(u64));
lun_id_offset += LUN_ENTRY_SIZE;
}
tmp_len = cpu_to_be32(ll_length);
memcpy(response, &tmp_len, sizeof(u32));
}
xfer_len = min(alloc_len, resp_size);
res = nvme_trans_copy_to_user(hdr, response, xfer_len);
kfree(response);
out_free_id:
kfree(id_ctrl);
return res;
}
| false | false | false | false | false | 0 |
keyMapPrim()
{
if (!trans.setPrimary(prim_lang))
trans.enablePrimary();
keymapon = true;
keymap = PRIMARY;
}
| false | false | false | false | false | 0 |
gt_clustered_set_union_find_merge_clusters(GtClusteredSet *cs,
unsigned long e1,
unsigned long e2,
GtError *err)
{
gt_assert(cs);
int had_err = 0;
GtClusteredSetUFClusterInfo *cluster_info_c1 = NULL;
GtClusteredSetUFClusterInfo *cluster_info_c2 = NULL;
unsigned long target = 0, source = 0, c1 = 0, c2 = 0;
GtClusteredSetUF *cs_uf = (GtClusteredSetUF*) cs;
if (e1 == e2) {
gt_error_set(err, "expected %lu to be unequal %lu", e1, e2 );
had_err = -1;
}
if (e1 >= cs_uf->num_of_elems || e2 >= cs_uf->num_of_elems) {
gt_error_set(err, "%lu and %lu must not be larger than %lu",
e1, e2, cs_uf->num_of_elems);
had_err = -1;
}
if (!had_err) {
if (SINGLETON(e1)) {
/* printf("%lu is singleton\n", e1); */
if (SINGLETON(e2)) {
/* printf("%lu is singleton\n", e2);*/
gt_clustered_set_union_find_make_new_cluster(cs_uf, e1, e2, err);
gt_bittab_set_bit(cs_uf->in_cluster, e2);
}
else {
c2 = cs_uf->cluster_elems[e2].cluster_num;
CHECKCLUSTER(c2);
gt_clustered_set_union_find_append_elem(cs_uf, c2, e1, err);
}
gt_bittab_set_bit(cs_uf->in_cluster, e1);
}
else {
c1 = cs_uf->cluster_elems[e1].cluster_num;
CHECKCLUSTER(c1);
if (SINGLETON(e2)) {
gt_clustered_set_union_find_append_elem(cs_uf, c1, e2, err);
gt_bittab_set_bit(cs_uf->in_cluster, e2);
}
else {
c2 = cs_uf->cluster_elems[e2].cluster_num;
CHECKCLUSTER(c2);
cluster_info_c1 = CINFO(c1);
cluster_info_c2 = CINFO(c2);
if (cluster_info_c1->cluster_size > cluster_info_c2->cluster_size) {
target = c1;
source = c2;
}
else {
target = c1;
source = c2;
}
if (target != source)
gt_clustered_set_union_find_join_clusters(cs_uf, target, source, err);
}
}
}
return had_err;
}
| false | false | false | false | false | 0 |
ic_compar(const void *ap, const void *bp)
{
int st;
char *a_name, *b_name;
Ic_entry *a, *b;
a = *(Ic_entry **) ap;
b = *(Ic_entry **) bp;
if (a->sic != NULL)
a_name = auth_identity_mine(a->sic->username);
else
a_name = a->mic->identity;
if (b->sic != NULL)
b_name = auth_identity_mine(b->sic->username);
else
b_name = b->mic->identity;
if ((st = strcmp(a_name, b_name)) != 0)
return(st);
if (a->mic != NULL)
return(-1);
return(1);
}
| false | false | false | false | false | 0 |
bna_enet_sm_pause_init_wait(struct bna_enet *enet,
enum bna_enet_event event)
{
switch (event) {
case ENET_E_STOP:
enet->flags &= ~BNA_ENET_F_PAUSE_CHANGED;
bfa_fsm_set_state(enet, bna_enet_sm_last_resp_wait);
break;
case ENET_E_FAIL:
enet->flags &= ~BNA_ENET_F_PAUSE_CHANGED;
bfa_fsm_set_state(enet, bna_enet_sm_stopped);
break;
case ENET_E_PAUSE_CFG:
enet->flags |= BNA_ENET_F_PAUSE_CHANGED;
break;
case ENET_E_MTU_CFG:
/* No-op */
break;
case ENET_E_FWRESP_PAUSE:
if (enet->flags & BNA_ENET_F_PAUSE_CHANGED) {
enet->flags &= ~BNA_ENET_F_PAUSE_CHANGED;
bna_bfi_pause_set(enet);
} else {
bfa_fsm_set_state(enet, bna_enet_sm_started);
bna_enet_chld_start(enet);
}
break;
default:
bfa_sm_fault(event);
}
}
| false | false | false | false | false | 0 |
PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os,indent);
os << indent << "AreaThreshold: " << this->AreaThreshold;
if (this->SquareNeighborhood)
{
os << indent << "Neighborhood: Square";
}
else
{
os << indent << "Neighborhood: Cross";
}
os << indent << "IslandValue: " << this->IslandValue;
os << indent << "ReplaceValue: " << this->ReplaceValue;
}
| false | false | false | false | false | 0 |
as_double() const
{
if (nbits_ == 0) return 0.0;
double val = 0.0;
/* Do we have/want a signed value? */
if (has_sign_ && bits_[nbits_-1] == V1) {
V carry = V1;
for (unsigned idx = 0; idx < nbits_; idx += 1) {
V sum = add_with_carry(~bits_[idx], V0, carry);
if (sum == V1)
val += pow(2.0, (double)idx);
}
val *= -1.0;
} else {
for (unsigned idx = 0; idx < nbits_; idx += 1) {
if (bits_[idx] == V1)
val += pow(2.0, (double)idx);
}
}
return val;
}
| false | false | false | false | false | 0 |
dmaengine_get(void)
{
struct dma_device *device, *_d;
struct dma_chan *chan;
int err;
mutex_lock(&dma_list_mutex);
dmaengine_ref_count++;
/* try to grab channels */
list_for_each_entry_safe(device, _d, &dma_device_list, global_node) {
if (dma_has_cap(DMA_PRIVATE, device->cap_mask))
continue;
list_for_each_entry(chan, &device->channels, device_node) {
err = dma_chan_get(chan);
if (err == -ENODEV) {
/* module removed before we could use it */
list_del_rcu(&device->global_node);
break;
} else if (err)
pr_debug("%s: failed to get %s: (%d)\n",
__func__, dma_chan_name(chan), err);
}
}
/* if this is the first reference and there were channels
* waiting we need to rebalance to get those channels
* incorporated into the channel table
*/
if (dmaengine_ref_count == 1)
dma_channel_rebalance();
mutex_unlock(&dma_list_mutex);
}
| false | false | false | false | false | 0 |
prefs_template_delete_cb(gpointer action, gpointer data)
{
Template *tmpl;
gint row;
GtkTreeIter iter;
GtkTreeModel *model;
row = gtkut_list_view_get_selected_row(templates.list_view);
if (row <= 0)
return;
model = gtk_tree_view_get_model(GTK_TREE_VIEW(templates.list_view));
if (!gtk_tree_model_iter_nth_child(model, &iter, NULL, row))
return;
gtk_tree_model_get(model, &iter, TEMPL_DATA, &tmpl, -1);
if (!tmpl)
return;
if (alertpanel(_("Delete template"),
_("Do you really want to delete this template?"),
GTK_STOCK_CANCEL, GTK_STOCK_DELETE,
NULL) != G_ALERTALTERNATE)
return;
gtk_list_store_remove(GTK_LIST_STORE(model), &iter);
prefs_template_reset_dialog();
modified_list = TRUE;
}
| false | false | false | false | false | 0 |
removeMessages(const std::vector<size_t> &messages,
callback &cb)
{
installTask(new ExpungeTask(*this, cb, true, &messages));
}
| false | false | false | false | false | 0 |
bench()
{
int i;
double d, a=1.1,b=123.0,c=0.12334;
double t0;
t0 = second();
for (i = 0; i<100000*multiplier; i++)
d = a*a*i - 4*b*c*i + b*i*b - c*i*i*c;
return (u_short)(second() - t0);
}
| false | false | false | false | false | 0 |
match_gai_table(struct sockaddr *sa, const struct gai_table *tbl)
{
struct sockaddr_in *sin = (void *)sa;
struct sockaddr_in6 *sin6 = (void *)sa;
void *addr;
if (sa->sa_family == AF_INET) {
addr = v4mapped;
memcpy(v4mapped+12, &sin->sin_addr, NS_INADDRSZ);
} else
addr = &sin6->sin6_addr;
while (1) {
if (mask_compare(addr, tbl->addr, tbl->mask))
return tbl->value;
tbl++;
}
}
| false | false | false | false | false | 0 |
nc_API(caller)
const char *caller;
{
char *nc_api=NULL;
nc_api = strstr(caller, "nc");
if (nc_api == caller)
return TRUE;
}
| false | false | false | false | false | 0 |
get_encoding (const gchar * text, guint * start_text, gboolean * is_multibyte)
{
LocalIconvCode encoding;
guint8 firstbyte;
*is_multibyte = FALSE;
*start_text = 0;
firstbyte = (guint8) text[0];
/* A wrong value */
g_return_val_if_fail (firstbyte != 0x00, _ICONV_UNKNOWN);
if (firstbyte <= 0x0B) {
/* 0x01 => iso 8859-5 */
encoding = firstbyte + _ICONV_ISO8859_4;
*start_text = 1;
goto beach;
}
/* ETSI EN 300 468, "Selection of character table" */
switch (firstbyte) {
case 0x0C:
case 0x0D:
case 0x0E:
case 0x0F:
/* RESERVED */
encoding = _ICONV_UNKNOWN;
break;
case 0x10:
{
guint16 table;
table = GST_READ_UINT16_BE (text + 1);
if (table < 17)
encoding = _ICONV_UNKNOWN + table;
else
encoding = _ICONV_UNKNOWN;;
*start_text = 3;
break;
}
case 0x11:
encoding = _ICONV_ISO10646_UC2;
*start_text = 1;
*is_multibyte = TRUE;
break;
case 0x12:
/* EUC-KR implements KSX1001 */
encoding = _ICONV_EUC_KR;
*start_text = 1;
*is_multibyte = TRUE;
break;
case 0x13:
encoding = _ICONV_GB2312;
*start_text = 1;
break;
case 0x14:
encoding = _ICONV_UTF_16BE;
*start_text = 1;
*is_multibyte = TRUE;
break;
case 0x15:
/* TODO : Where does this come from ?? */
encoding = _ICONV_ISO10646_UTF8;
*start_text = 1;
break;
case 0x16:
case 0x17:
case 0x18:
case 0x19:
case 0x1A:
case 0x1B:
case 0x1C:
case 0x1D:
case 0x1E:
case 0x1F:
/* RESERVED */
encoding = _ICONV_UNKNOWN;
break;
default:
encoding = _ICONV_ISO6937;
break;
}
beach:
GST_DEBUG
("Found encoding %d, first byte is 0x%02x, start_text: %u, is_multibyte: %d",
encoding, firstbyte, *start_text, *is_multibyte);
return encoding;
}
| false | false | false | false | false | 0 |
stp_parameter_has_category_value(const stp_vars_t *v,
const stp_parameter_t *desc,
const char *category, const char *value)
{
char *cptr;
int answer = 0;
if (!v || !desc || !category)
return -1;
cptr = stp_parameter_get_category(v, desc, category);
if (cptr == NULL)
return 0;
if (value == NULL || strcmp(value, cptr) == 0)
answer = 1;
stp_free(cptr);
return answer;
}
| false | false | false | false | false | 0 |
pmcraid_send_hcam_cmd(struct pmcraid_cmd *cmd)
{
if (cmd->ioa_cb->ioarcb.cdb[1] == PMCRAID_HCAM_CODE_CONFIG_CHANGE)
atomic_set(&(cmd->drv_inst->ccn.ignore), 0);
else
atomic_set(&(cmd->drv_inst->ldn.ignore), 0);
pmcraid_send_cmd(cmd, cmd->cmd_done, 0, NULL);
}
| false | false | false | false | false | 0 |
seahorse_object_lookup_property (SeahorseObject *self, const gchar *field, GValue *value)
{
GParamSpec *spec;
g_return_val_if_fail (SEAHORSE_IS_OBJECT (self), FALSE);
g_return_val_if_fail (field, FALSE);
g_return_val_if_fail (value, FALSE);
spec = g_object_class_find_property (G_OBJECT_GET_CLASS (self), field);
if (!spec) {
/* Some name mapping to new style names */
if (g_str_equal (field, "simple-name"))
field = "nickname";
else if (g_str_equal (field, "key-id"))
field = "identifier";
else if (g_str_equal (field, "display-name"))
field = "label";
else if (g_str_equal (field, "key-desc"))
field = "description";
else if (g_str_equal (field, "ktype"))
field = "tag";
else if (g_str_equal (field, "etype"))
field = "usage";
else if (g_str_equal (field, "display-id"))
field = "identifier";
else if (g_str_equal (field, "stock-id"))
field = "icon";
else if (g_str_equal (field, "raw-id"))
field = "identifier";
else
return FALSE;
/* Try again */
spec = g_object_class_find_property (G_OBJECT_GET_CLASS (self), field);
if (!spec)
return FALSE;
}
g_value_init (value, spec->value_type);
g_object_get_property (G_OBJECT (self), field, value);
return TRUE;
}
| false | false | false | false | false | 0 |
message_view_on_column_click(GtkTreeViewColumn * column, gpointer user_data)
{
gint column_id = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(column), "column id"));
message_view_t *view = (message_view_t *) user_data;
int dir = 0;
seaudit_sort_t *sort;
GtkTreeViewColumn *prev_column;
if (column_id == view->store->sort_field) {
dir = view->store->sort_dir * -1;
} else {
dir = 1;
}
if ((sort = column_data[(preference_field_e) column_id].sort(dir)) == NULL) {
toplevel_ERR(view->top, "%s", strerror(errno));
return TRUE;
}
seaudit_model_clear_sorts(view->model);
if (seaudit_model_append_sort(view->model, sort) < 0) {
seaudit_sort_destroy(&sort);
toplevel_ERR(view->top, "%s", strerror(errno));
}
prev_column = gtk_tree_view_get_column(view->view, view->store->sort_field);
if (prev_column != NULL) {
gtk_tree_view_column_set_sort_indicator(prev_column, FALSE);
}
gtk_tree_view_column_set_sort_indicator(column, TRUE);
if (dir > 0) {
gtk_tree_view_column_set_sort_order(column, GTK_SORT_ASCENDING);
} else {
gtk_tree_view_column_set_sort_order(column, GTK_SORT_DESCENDING);
}
view->store->sort_field = column_id;
view->store->sort_dir = dir;
message_view_update_rows(view);
return TRUE;
}
| false | false | false | false | false | 0 |
cgroup_config_unload_controller(const struct cgroup_mount_point *mount_info)
{
int ret, error;
struct cgroup *cgroup = NULL;
struct cgroup_controller *cgc = NULL;
char path[FILENAME_MAX];
void *handle;
cgroup = cgroup_new_cgroup(".");
if (cgroup == NULL)
return ECGFAIL;
cgc = cgroup_add_controller(cgroup, mount_info->name);
if (cgc == NULL) {
ret = ECGFAIL;
goto out_error;
}
ret = cgroup_delete_cgroup_ext(cgroup, CGFLAG_DELETE_RECURSIVE);
if (ret != 0)
goto out_error;
/* unmount everything */
ret = cgroup_get_subsys_mount_point_begin(mount_info->name, &handle,
path);
while (ret == 0) {
error = umount(path);
if (error) {
last_errno = errno;
ret = ECGOTHER;
goto out_error;
}
ret = cgroup_get_subsys_mount_point_next(&handle, path);
}
cgroup_get_subsys_mount_point_end(&handle);
if (ret == ECGEOF)
ret = 0;
out_error:
if (cgroup)
cgroup_free(&cgroup);
return ret;
}
| false | false | false | false | false | 0 |
ar9003_get_training_power_2g(struct ath_hw *ah)
{
struct ath9k_channel *chan = ah->curchan;
unsigned int power, scale, delta;
scale = ar9003_get_paprd_scale_factor(ah, chan);
if (AR_SREV_9330(ah) || AR_SREV_9340(ah) ||
AR_SREV_9462(ah) || AR_SREV_9565(ah)) {
power = ah->paprd_target_power + 2;
} else if (AR_SREV_9485(ah)) {
power = 25;
} else {
power = REG_READ_FIELD(ah, AR_PHY_POWERTX_RATE5,
AR_PHY_POWERTX_RATE5_POWERTXHT20_0);
delta = abs((int) ah->paprd_target_power - (int) power);
if (delta > scale)
return -1;
if (delta < 4)
power -= 4 - delta;
}
return power;
}
| false | false | false | false | false | 0 |
expand_number_all(char *s, int add_prefix)
{
int all_allowed = 0;
char *Ptr;
int Index = 0;
char Help[NUMBER_SIZE+1];
static char Num[NUMBER_SIZE+1];
Help[0] = '\0';
Ptr = s;
if (Ptr == NULL || Ptr[0] == '\0')
return "";
while(isblank(*Ptr))
Ptr++;
if (*Ptr == '+')
{
Strncpy(Help,countryprefix,NUMBER_SIZE);
Ptr++;
}
Index = strlen(Help);
while(*Ptr != '\0')
{
if (*Ptr == ',' || Index >= NUMBER_SIZE)
break;
if (isdigit(*Ptr) || *Ptr == '?' || *Ptr == '*'||
*Ptr == '[' || *Ptr == ']' || all_allowed )
{
if (*Ptr == '[')
all_allowed = 1;
if (*Ptr == ']')
all_allowed = 0;
Help[Index++] = *Ptr;
}
Ptr++;
}
Help[Index] = '\0';
if (Help[0] == '\0')
return s;
if (Help[0] == '*' || !strncmp(Help,countryprefix,strlen(countryprefix)) || !add_prefix)
{
strcpy(Num,Help);
}
else
if (!strncmp(Help,areaprefix,strlen(areaprefix)))
{
strcpy(Num,mycountry);
strcat(Num,Help+strlen(areaprefix));
}
else
{
strcpy(Num,mycountry);
strcat(Num,myarea/*+strlen(areaprefix)*/);
strcat(Num,Help);
}
return Num;
}
| false | false | false | false | false | 0 |
ldapu_get_values( LDAP *ld, LDAPMessage *entry, const char *desc )
{
if (ldapu_VTable.ldapuV_get_values) {
return ldapu_VTable.ldapuV_get_values (ld, entry, desc);
} else if (!ldapu_VTable.ldapuV_value_free
&& ldapu_VTable.ldapuV_get_values_len) {
auto struct berval** bvals =
ldapu_VTable.ldapuV_get_values_len (ld, entry, desc);
if (bvals) {
auto char** vals = (char**)
ldapu_malloc ((ldap_count_values_len (bvals) + 1)
* sizeof(char*));
if (vals) {
auto char** val;
auto struct berval** bval;
for (val = vals, bval = bvals; *bval; ++val, ++bval) {
auto const size_t len = (*bval)->bv_len;
*val = (char*) ldapu_malloc (len + 1);
memcpy (*val, (*bval)->bv_val, len);
(*val)[len] = '\0';
}
*val = NULL;
ldapu_value_free_len(ld, bvals);
return vals;
}
}
ldapu_value_free_len(ld, bvals);
}
return NULL;
}
| false | false | false | false | false | 0 |
PK11_WriteRawAttribute(PK11ObjectType objType, void *objSpec,
CK_ATTRIBUTE_TYPE attrType, SECItem *item)
{
PK11SlotInfo *slot = NULL;
CK_OBJECT_HANDLE handle;
CK_ATTRIBUTE setTemplate;
CK_RV crv;
CK_SESSION_HANDLE rwsession;
switch (objType) {
case PK11_TypeGeneric:
slot = ((PK11GenericObject *)objSpec)->slot;
handle = ((PK11GenericObject *)objSpec)->objectID;
break;
case PK11_TypePrivKey:
slot = ((SECKEYPrivateKey *)objSpec)->pkcs11Slot;
handle = ((SECKEYPrivateKey *)objSpec)->pkcs11ID;
break;
case PK11_TypePubKey:
slot = ((SECKEYPublicKey *)objSpec)->pkcs11Slot;
handle = ((SECKEYPublicKey *)objSpec)->pkcs11ID;
break;
case PK11_TypeSymKey:
slot = ((PK11SymKey *)objSpec)->slot;
handle = ((PK11SymKey *)objSpec)->objectID;
break;
case PK11_TypeCert: /* don't handle cert case for now */
default:
break;
}
if (slot == NULL) {
PORT_SetError(SEC_ERROR_UNKNOWN_OBJECT_TYPE);
return SECFailure;
}
PK11_SETATTRS(&setTemplate, attrType, (CK_CHAR *) item->data, item->len);
rwsession = PK11_GetRWSession(slot);
if (rwsession == CK_INVALID_SESSION) {
PORT_SetError(SEC_ERROR_BAD_DATA);
return SECFailure;
}
crv = PK11_GETTAB(slot)->C_SetAttributeValue(rwsession, handle,
&setTemplate, 1);
PK11_RestoreROSession(slot, rwsession);
if (crv != CKR_OK) {
PORT_SetError(PK11_MapError(crv));
return SECFailure;
}
return SECSuccess;
}
| false | false | false | false | false | 0 |
help_command(const char *command_name,
int major_version, int minor_version,
const struct option *long_options)
{
std::cout << command_name << " " << major_version << "." << minor_version << std::endl;
std::cout << "Current options. A '=' means the option takes a value." << std::endl << std::endl;
for (uint32_t x= 0; long_options[x].name; x++)
{
std::cout << "\t --" << long_options[x].name << char(long_options[x].has_arg ? '=' : ' ') << std::endl;
}
std::cout << std::endl;
}
| false | false | false | false | false | 0 |
oc_enc_sb_transform_quantize_intra_chroma(oc_enc_ctx *_enc,
oc_enc_pipeline_state *_pipe,int _pli,int _sbi_start,int _sbi_end){
const oc_sb_map *sb_maps;
oc_sb_flags *sb_flags;
ptrdiff_t *coded_fragis;
ptrdiff_t ncoded_fragis;
int sbi;
sb_maps=(const oc_sb_map *)_enc->state.sb_maps;
sb_flags=_enc->state.sb_flags;
coded_fragis=_pipe->coded_fragis[_pli];
ncoded_fragis=_pipe->ncoded_fragis[_pli];
for(sbi=_sbi_start;sbi<_sbi_end;sbi++){
/*Worst case token stack usage for 1 fragment.*/
oc_token_checkpoint stack[64];
int quadi;
int bi;
for(quadi=0;quadi<4;quadi++)for(bi=0;bi<4;bi++){
ptrdiff_t fragi;
fragi=sb_maps[sbi][quadi][bi];
if(fragi>=0){
oc_token_checkpoint *stackptr;
oc_analyze_intra_chroma_block(_enc,_pipe->qs+_pli,_pli,fragi);
stackptr=stack;
oc_enc_block_transform_quantize(_enc,
_pipe,_pli,fragi,0,NULL,&stackptr);
coded_fragis[ncoded_fragis++]=fragi;
}
}
}
_pipe->ncoded_fragis[_pli]=ncoded_fragis;
}
| false | false | false | false | false | 0 |
update_arrival_stats (RTPSession * sess, RTPArrivalStats * arrival,
gboolean rtp, GstBuffer * buffer, GstClockTime current_time,
GstClockTime running_time, guint64 ntpnstime)
{
/* get time of arrival */
arrival->current_time = current_time;
arrival->running_time = running_time;
arrival->ntpnstime = ntpnstime;
/* get packet size including header overhead */
arrival->bytes = GST_BUFFER_SIZE (buffer) + sess->header_len;
if (rtp) {
arrival->payload_len = gst_rtp_buffer_get_payload_len (buffer);
} else {
arrival->payload_len = 0;
}
/* for netbuffer we can store the IP address to check for collisions */
arrival->have_address = GST_IS_NETBUFFER (buffer);
if (arrival->have_address) {
GstNetBuffer *netbuf = (GstNetBuffer *) buffer;
memcpy (&arrival->address, &netbuf->from, sizeof (GstNetAddress));
}
}
| false | true | false | false | false | 1 |
initialize_savefile_support()
{
CYG_REPORT_FUNCNAME("CdlConfiguration::initialize_savefile_support");
CYG_REPORT_FUNCARG1XV(this);
CYG_PRECONDITION_THISC();
// Start with the generic stuff such as cdl_savefile_version and
// cdl_command.
this->CdlToplevelBody::initialize_savefile_support();
// Now add in the cdl_configuration command and its subcommands.
this->add_savefile_command("cdl_configuration", 0, &savefile_configuration_command);
this->add_savefile_subcommand("cdl_configuration", "description", 0, &savefile_description_command);
this->add_savefile_subcommand("cdl_configuration", "hardware", 0, &savefile_hardware_command);
this->add_savefile_subcommand("cdl_configuration", "template", 0, &savefile_template_command);
this->add_savefile_subcommand("cdl_configuration", "package", 0, &savefile_package_command);
CdlPackageBody::initialize_savefile_support(this);
CdlComponentBody::initialize_savefile_support(this);
CdlOptionBody::initialize_savefile_support(this);
CdlInterfaceBody::initialize_savefile_support(this);
}
//}}}
| false | false | false | false | false | 0 |
WriteErrorsToFile(std::string staFileName,
std::string staGdlFile, std::string staInputFontFile,
std::string staOutputFile, std::string staOutputFamily, std::string staVersion,
bool fSepCtrlFile)
{
std::ofstream strmOut;
strmOut.open(staFileName.c_str());
if (strmOut.fail())
{
g_errorList.AddError(106, NULL,
"Error in writing to file ",
std::string(staFileName));
return;
}
WriteErrorsToStream(strmOut, staGdlFile, staInputFontFile, staOutputFile, staOutputFamily,
staVersion, fSepCtrlFile);
strmOut.close();
}
| false | false | false | false | false | 0 |
gf_w4_log_divide (gf_t *gf, gf_val_32_t a, gf_val_32_t b)
{
int log_sum = 0;
struct gf_logtable_data *ltd;
if (a == 0 || b == 0) return 0;
ltd = (struct gf_logtable_data *) ((gf_internal_t *) (gf->scratch))->private;
log_sum = ltd->log_tbl[a] - ltd->log_tbl[b];
return (ltd->antilog_tbl_div[log_sum]);
}
| false | false | false | false | false | 0 |
file_closer(ScmPort *p)
{
int fd = (int)(intptr_t)p->src.buf.data;
SCM_ASSERT(fd >= 0);
close(fd);
}
| false | false | false | false | false | 0 |
systemId() const
{
if (!impl)
return DOMString(); // ### enable throw DOMException(DOMException::NOT_FOUND_ERR);
return ((NotationImpl*)impl)->systemId();
}
| false | false | false | false | false | 0 |
file_skip(struct archive *a, void *client_data, off_t request)
#endif
{
struct read_FILE_data *mine = (struct read_FILE_data *)client_data;
(void)a; /* UNUSED */
/*
* If we can't skip, return 0 as the amount we did step and
* the caller will work around by reading and discarding.
*/
if (!mine->can_skip)
return (0);
if (request == 0)
return (0);
#if HAVE_FSEEKO
if (fseeko(mine->f, request, SEEK_CUR) != 0)
#else
if (fseek(mine->f, request, SEEK_CUR) != 0)
#endif
{
mine->can_skip = 0;
return (0);
}
return (request);
}
| false | false | false | false | false | 0 |
getTracedRays(CSetOfLinesPtr &res) const {
if (!meshUpToDate) updateMesh();
size_t count=0;
for (size_t i=0;i<validityMatrix.getRowCount();i++) for (size_t j=0;j<validityMatrix.getColCount();j++) if (validityMatrix(i,j)) count++;
res->reserve(count);
for (size_t i=0;i<actualMesh.getRowCount();i++) for (size_t j=0;j<actualMesh.getColCount();j++) if (validityMatrix(i,j)) res->appendLine(TPose3D(scanSet[i].sensorPose),actualMesh(i,j));
}
| false | false | false | false | false | 0 |
entered_from_non_parent_p (ira_loop_tree_node_t loop_node)
{
ira_loop_tree_node_t bb_node, src_loop_node, parent;
edge e;
edge_iterator ei;
for (bb_node = loop_node->children; bb_node != NULL; bb_node = bb_node->next)
if (bb_node->bb != NULL)
{
FOR_EACH_EDGE (e, ei, bb_node->bb->preds)
if (e->src != ENTRY_BLOCK_PTR
&& (src_loop_node = IRA_BB_NODE (e->src)->parent) != loop_node)
{
for (parent = src_loop_node->parent;
parent != NULL;
parent = parent->parent)
if (parent == loop_node)
break;
if (parent != NULL)
/* That is an exit from a nested loop -- skip it. */
continue;
for (parent = loop_node->parent;
parent != NULL;
parent = parent->parent)
if (src_loop_node == parent)
break;
if (parent == NULL)
return true;
}
}
return false;
}
| false | false | false | false | false | 0 |
connection_cb (GObject *object,
GAsyncResult *res,
gpointer user_data)
{
MyData *md = user_data;
GError *error = NULL;
md->connection = tracker_sparql_connection_get_finish (res, &error);
g_print ("Async connection took: %.6f\n", g_timer_elapsed (md->timer, NULL));
g_timer_start (md->timer);
if (!error) {
tracker_sparql_connection_query_async (md->connection,
"SELECT ?r { ?r a rdfs:Resource }",
md->cancellable,
query_cb,
md);
} else {
g_critical ("Could not connect: %s", error->message);
g_error_free (error);
g_main_loop_quit (md->loop);
}
}
| false | false | false | false | false | 0 |
dfb_surface_set_alpha_ramp( CoreSurface *surface,
u8 a0,
u8 a1,
u8 a2,
u8 a3 )
{
D_MAGIC_ASSERT( surface, CoreSurface );
if (fusion_skirmish_prevail( &surface->lock ))
return DFB_FUSION;
surface->alpha_ramp[0] = a0;
surface->alpha_ramp[1] = a1;
surface->alpha_ramp[2] = a2;
surface->alpha_ramp[3] = a3;
dfb_surface_notify( surface, CSNF_ALPHA_RAMP );
fusion_skirmish_dismiss( &surface->lock );
return DFB_OK;
}
| false | false | false | false | false | 0 |
CORD_iter_fn_rpos(char c, CORD_pos_info* info) {
if(info->pos < info->left){
info->pos=STRING_NOT_FOUND;
return 1;
}
if(strchr(info->chars, c))
return 1;
--(info->pos);
return 0;
}
| false | false | false | false | false | 0 |
sparse_file_len(struct sparse_file *s, bool sparse, bool crc)
{
int ret;
int chunks = sparse_count_chunks(s);
int64_t count = 0;
struct output_file *out;
out = output_file_open_callback(out_counter_write, &count,
s->block_size, s->len, false, sparse, chunks, crc);
if (!out) {
return -1;
}
ret = write_all_blocks(s, out);
output_file_close(out);
if (ret < 0) {
return -1;
}
return count;
}
| false | false | false | false | false | 0 |
acct_policy_start( Slapi_PBlock *pb ) {
acctPluginCfg *cfg;
void *plugin_id = get_identity();
/* Load plugin configuration */
if( acct_policy_load_config_startup( pb, plugin_id ) ) {
slapi_log_error( SLAPI_LOG_FATAL, PLUGIN_NAME,
"acct_policy_start failed to load configuration\n" );
return( CALLBACK_ERR );
}
/* Show the configuration */
cfg = get_config();
slapi_log_error( SLAPI_LOG_PLUGIN, PLUGIN_NAME, "acct_policy_start config: "
"stateAttrName=%s altStateAttrName=%s specAttrName=%s limitAttrName=%s "
"alwaysRecordLogin=%d\n",
cfg->state_attr_name, cfg->alt_state_attr_name?cfg->alt_state_attr_name:"not configured", cfg->spec_attr_name,
cfg->limit_attr_name, cfg->always_record_login);
return( CALLBACK_OK );
}
| false | false | false | false | false | 0 |
enet_protocol_handle_send_unsequenced (ENetHost * host, ENetPeer * peer, const ENetProtocol * command, enet_uint8 ** currentData)
{
ENetPacket * packet;
enet_uint32 unsequencedGroup, index;
size_t dataLength;
if (command -> header.channelID >= peer -> channelCount ||
(peer -> state != ENET_PEER_STATE_CONNECTED && peer -> state != ENET_PEER_STATE_DISCONNECT_LATER))
return -1;
dataLength = ENET_NET_TO_HOST_16 (command -> sendUnsequenced.dataLength);
* currentData += dataLength;
if (* currentData > & host -> receivedData [host -> receivedDataLength])
return -1;
unsequencedGroup = ENET_NET_TO_HOST_16 (command -> sendUnsequenced.unsequencedGroup);
index = unsequencedGroup % ENET_PEER_UNSEQUENCED_WINDOW_SIZE;
if (unsequencedGroup < peer -> incomingUnsequencedGroup)
unsequencedGroup += 0x10000;
if (unsequencedGroup >= (enet_uint32) peer -> incomingUnsequencedGroup + ENET_PEER_FREE_UNSEQUENCED_WINDOWS * ENET_PEER_UNSEQUENCED_WINDOW_SIZE)
return 0;
unsequencedGroup &= 0xFFFF;
if (unsequencedGroup - index != peer -> incomingUnsequencedGroup)
{
peer -> incomingUnsequencedGroup = unsequencedGroup - index;
memset (peer -> unsequencedWindow, 0, sizeof (peer -> unsequencedWindow));
}
else
if (peer -> unsequencedWindow [index / 32] & (1 << (index % 32)))
return 0;
packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendUnsequenced),
dataLength,
ENET_PACKET_FLAG_UNSEQUENCED);
if (packet == NULL ||
enet_peer_queue_incoming_command (peer, command, packet, 0) == NULL)
return -1;
peer -> unsequencedWindow [index / 32] |= 1 << (index % 32);
return 0;
}
| false | false | false | false | false | 0 |
verify_absent_1(struct cache_entry *ce,
enum unpack_trees_error_types error_type,
struct unpack_trees_options *o)
{
int len;
struct stat st;
if (o->index_only || o->reset || !o->update)
return 0;
len = check_leading_path(ce->name, ce_namelen(ce));
if (!len)
return 0;
else if (len > 0) {
char path[PATH_MAX + 1];
memcpy(path, ce->name, len);
path[len] = 0;
if (lstat(path, &st))
return error("cannot stat '%s': %s", path,
strerror(errno));
return check_ok_to_remove(path, len, DT_UNKNOWN, NULL, &st,
error_type, o);
} else if (lstat(ce->name, &st)) {
if (errno != ENOENT)
return error("cannot stat '%s': %s", ce->name,
strerror(errno));
return 0;
} else {
return check_ok_to_remove(ce->name, ce_namelen(ce),
ce_to_dtype(ce), ce, &st,
error_type, o);
}
}
| true | true | false | false | false | 1 |
cancelcb(void *cv, globus_io_handle_t *handlep, globus_result_t r)
{
globus_result_t s = GLOBUS_FAILURE;
char errmsg[MAXERRMSG];
CONNECTION *c = (CONNECTION *) cv;
if (loglevel > 3)
logit(LOG_DEBUG, "cancelcb: connection %X", c);
/*
* If we're quitting, we don't call into globus_io since the
* module might be deactivated
*/
if (!quitting && *handlep) {
if ((s = globus_io_register_close(handlep, closecb, c)) !=
GLOBUS_SUCCESS)
logit(LOG_WARNING, "cancelcb: %s", globuserr(s, errmsg));
}
if ((quitting || s != GLOBUS_SUCCESS) && c) {
if (c->dn)
globus_libc_free(c->dn);
globus_libc_free(c);
}
}
| false | false | false | false | false | 0 |
json_print_pwr_wghfreq_stats(struct activity *a, int curr, int tab,
unsigned long long itv)
{
int i, k;
struct stats_pwr_wghfreq *spc, *spp, *spc_k, *spp_k;
unsigned long long tis, tisfreq;
int sep = FALSE;
char cpuno[8];
if (!IS_SELECTED(a->options) || (a->nr <= 0))
goto close_json_markup;
json_markup_power_management(tab, OPEN_JSON_MARKUP);
tab++;
xprintf(tab++, "\"cpu-weighted-frequency\": [");
for (i = 0; (i < a->nr) && (i < a->bitmap->b_size + 1); i++) {
spc = (struct stats_pwr_wghfreq *) ((char *) a->buf[curr] + i * a->msize * a->nr2);
spp = (struct stats_pwr_wghfreq *) ((char *) a->buf[!curr] + i * a->msize * a->nr2);
/* Should current CPU (including CPU "all") be displayed? */
if (a->bitmap->b_array[i >> 3] & (1 << (i & 0x07))) {
/* Yes... */
tisfreq = 0;
tis = 0;
for (k = 0; k < a->nr2; k++) {
spc_k = (struct stats_pwr_wghfreq *) ((char *) spc + k * a->msize);
if (!spc_k->freq)
break;
spp_k = (struct stats_pwr_wghfreq *) ((char *) spp + k * a->msize);
tisfreq += (spc_k->freq / 1000) *
(spc_k->time_in_state - spp_k->time_in_state);
tis += (spc_k->time_in_state - spp_k->time_in_state);
}
if (!i) {
/* This is CPU "all" */
strcpy(cpuno, "all");
}
else {
sprintf(cpuno, "%d", i - 1);
}
if (sep) {
printf(",\n");
}
sep = TRUE;
xprintf0(tab, "{\"number\": \"%s\", "
"\"weighted-frequency\": %.2f}",
cpuno,
tis ? ((double) tisfreq) / tis : 0.0);
}
}
printf("\n");
xprintf0(--tab, "]");
tab--;
close_json_markup:
if (CLOSE_MARKUP(a->options)) {
json_markup_power_management(tab, CLOSE_JSON_MARKUP);
}
}
| true | true | false | false | false | 1 |
run ( const Context& context )
{
if ( !receivers.size() )
return;
while ( mouseparams.taste )
releasetimeslice();
mousevisible ( true );
do {
tdialogbox :: run ( );
int old = markedplayer;
if ( taste == ct_up && markedplayer > 0 )
markedplayer --;
if ( taste == ct_down && markedplayer < receivers.size()-1 )
markedplayer ++;
if ( mouseparams.taste == 1 )
for ( int i = 0; i < receivers.size(); i++ )
if ( mouseinrect ( x1 + 20, y1 + starty + xs + i * 40, x1 + xsize - 20, y1 + starty + 60 + i * 40 ) )
markedplayer = i;
if ( old != markedplayer ) {
paintplayer ( markedplayer );
paintplayer ( old );
}
} while ( status < 10 ); /* enddo */
if ( status == 12 ) {
auto_ptr<TransferControlCommand> tcc ( new TransferControlCommand( fld->getContainer() ));
tcc->setReceiver( receivers[markedplayer] );
ActionResult res = tcc->execute( context );
if ( res.successful() )
tcc.release();
else {
displayActionError(res );
}
}
}
| false | false | false | false | false | 0 |
ixgbe_set_vmdq_82598(struct ixgbe_hw *hw, u32 rar, u32 vmdq)
{
u32 rar_high;
u32 rar_entries = hw->mac.num_rar_entries;
/* Make sure we are using a valid rar index range */
if (rar >= rar_entries) {
hw_dbg(hw, "RAR index %d is out of range.\n", rar);
return IXGBE_ERR_INVALID_ARGUMENT;
}
rar_high = IXGBE_READ_REG(hw, IXGBE_RAH(rar));
rar_high &= ~IXGBE_RAH_VIND_MASK;
rar_high |= ((vmdq << IXGBE_RAH_VIND_SHIFT) & IXGBE_RAH_VIND_MASK);
IXGBE_WRITE_REG(hw, IXGBE_RAH(rar), rar_high);
return 0;
}
| false | false | false | false | false | 0 |
cma_remove_id_dev(struct rdma_id_private *id_priv)
{
struct rdma_cm_event event;
enum rdma_cm_state state;
int ret = 0;
/* Record that we want to remove the device */
state = cma_exch(id_priv, RDMA_CM_DEVICE_REMOVAL);
if (state == RDMA_CM_DESTROYING)
return 0;
cma_cancel_operation(id_priv, state);
mutex_lock(&id_priv->handler_mutex);
/* Check for destruction from another callback. */
if (!cma_comp(id_priv, RDMA_CM_DEVICE_REMOVAL))
goto out;
memset(&event, 0, sizeof event);
event.event = RDMA_CM_EVENT_DEVICE_REMOVAL;
ret = id_priv->id.event_handler(&id_priv->id, &event);
out:
mutex_unlock(&id_priv->handler_mutex);
return ret;
}
| false | false | false | false | false | 0 |
canMoveUp() const
{
if (!m_CurrentView)
return false;
const QModelIndex idx = m_CurrentView->prescriptionListView()->currentIndex();
if (!idx.isValid())
return false;
if (idx.row() >= 1)
return true;
return false;
}
| false | false | false | false | false | 0 |
clear_gc_stats(void)
{
int i;
for(i = 0; i < MAX_GEN_COUNT; i++)
memset(&gc_stats[i],0,sizeof(F_GC_STATS));
cards_scanned = 0;
decks_scanned = 0;
code_heap_scans = 0;
}
| false | false | false | false | false | 0 |
composeDerivatives(const vector<expr_t> &dargs)
{
vector<expr_t> dNodes;
for (int i = 0; i < (int) dargs.size(); i++)
if (dargs.at(i) != 0)
dNodes.push_back(datatree.AddTimes(dargs.at(i),
datatree.AddFirstDerivExternalFunctionNode(symb_id, arguments, i+1)));
expr_t theDeriv = datatree.Zero;
for (vector<expr_t>::const_iterator it = dNodes.begin(); it != dNodes.end(); it++)
theDeriv = datatree.AddPlus(theDeriv, *it);
return theDeriv;
}
| false | false | false | false | false | 0 |
test_partial_ipv4_tcp_msg(void)
{
int sk, received = 0;
sk = connect_tcp_socket("127.0.0.1");
g_assert_cmpint(sk, >=, 0);
change_msg(msg, 2, 20, '1');
send_msg(sk, msg, sizeof(msg), 1);
received = receive_message(sk, 10, sizeof(msg), NULL);
close(sk);
g_assert_cmpint(received, >=, sizeof(msg));
}
| false | false | false | false | false | 0 |
handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{
struct cache_file_mtime *cfmtime;
char *prev = "", *completion_value = NULL;
int wordlen, which = 0;
switch (cmd) {
case CLI_INIT:
e->command = "config reload";
e->usage =
"Usage: config reload <filename.conf>\n"
" Reloads all modules that reference <filename.conf>\n";
return NULL;
case CLI_GENERATE:
if (a->pos > 2) {
return NULL;
}
wordlen = strlen(a->word);
AST_LIST_LOCK(&cfmtime_head);
AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
/* Skip duplicates - this only works because the list is sorted by filename */
if (strcmp(cfmtime->filename, prev) == 0) {
continue;
}
/* Core configs cannot be reloaded */
if (ast_strlen_zero(cfmtime->who_asked)) {
continue;
}
if (++which > a->n && strncmp(cfmtime->filename, a->word, wordlen) == 0) {
completion_value = ast_strdup(cfmtime->filename);
break;
}
/* Otherwise save that we've seen this filename */
prev = cfmtime->filename;
}
AST_LIST_UNLOCK(&cfmtime_head);
return completion_value;
}
if (a->argc != 3) {
return CLI_SHOWUSAGE;
}
AST_LIST_LOCK(&cfmtime_head);
AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
if (!strcmp(cfmtime->filename, a->argv[2])) {
char *buf = ast_alloca(strlen("module reload ") + strlen(cfmtime->who_asked) + 1);
sprintf(buf, "module reload %s", cfmtime->who_asked);
ast_cli_command(a->fd, buf);
}
}
AST_LIST_UNLOCK(&cfmtime_head);
return CLI_SUCCESS;
}
| false | false | false | false | false | 0 |
vector_op_clog2(
vector* tgt, /*!< Pointer to vector to store results in */
const vector* src /*! Pointer to value to perform operation on */
) { PROFILE(VECTOR_OP_CLOG2);
bool retval;
ulong vall = 0;
ulong valh = 0;
if( vector_is_unknown( src ) ) {
retval = vector_set_to_x( tgt );
} else {
switch( src->suppl.part.data_type ) {
case VDATA_UL :
{
unsigned int size = UL_SIZE(src->width);
unsigned int num_ones = 0;
while( size > 0 ) {
ulong i = src->value.ul[--size][VTYPE_INDEX_VAL_VALL];
while( i != 0 ) {
vall++;
num_ones += (i & 0x1);
i >>= 1;
}
if( vall != 0 ) {
vall += (size * UL_BITS);
if( num_ones == 1 ) {
while( (size > 0) && (src->value.ul[--size][VTYPE_INDEX_VAL_VALL] == 0) );
if( size == 0 ) {
vall--;
}
}
break;
}
}
}
break;
case VDATA_R64 :
case VDATA_R32 :
{
uint64 i = vector_to_uint64( src ) - 1;
unsigned int num_ones = 0;
while( i != 0 ) {
vall++;
num_ones += (i & 0x1);
i >>= 1;
}
if( num_ones == 1 ) {
vall--;
}
}
break;
default : assert( 0 ); break;
}
retval = vector_set_coverage_and_assign_ulong( tgt, &vall, &valh, 0, (tgt->width - 1) );
}
PROFILE_END;
return( retval );
}
| false | false | false | false | false | 0 |
mob_unlocktarget(struct mob_data *md,unsigned int tick)
{
nullpo_retr(0, md);
md->target_id = 0;
md->ud.attacktarget_lv = 0;
md->state.skillstate = MSS_IDLE;
md->next_walktime = tick + atn_rand()%3000 + 3000;
return 0;
}
| false | false | false | false | false | 0 |
snd_cs4281_proc_init(struct cs4281 *chip)
{
struct snd_info_entry *entry;
if (! snd_card_proc_new(chip->card, "cs4281", &entry))
snd_info_set_text_ops(entry, chip, snd_cs4281_proc_read);
if (! snd_card_proc_new(chip->card, "cs4281_BA0", &entry)) {
entry->content = SNDRV_INFO_CONTENT_DATA;
entry->private_data = chip;
entry->c.ops = &snd_cs4281_proc_ops_BA0;
entry->size = CS4281_BA0_SIZE;
}
if (! snd_card_proc_new(chip->card, "cs4281_BA1", &entry)) {
entry->content = SNDRV_INFO_CONTENT_DATA;
entry->private_data = chip;
entry->c.ops = &snd_cs4281_proc_ops_BA1;
entry->size = CS4281_BA1_SIZE;
}
}
| false | false | false | false | false | 0 |
bf_set_task_local(Var arglist, Byte next, void *vdata, Objid progr)
{ /* (ANY value) */
if (!is_wizard(progr)) {
free_var(arglist);
return make_error_pack(E_PERM);
}
Var v = var_ref(arglist.v.list[1]);
free_var(current_local);
current_local = v;
free_var(arglist);
return no_var_pack();
}
| false | false | false | false | false | 0 |
getNumPreds(const BasicBlock *BB) {
unsigned &NP = BBNumPreds[BB];
if (NP == 0)
NP = std::distance(pred_begin(BB), pred_end(BB))+1;
return NP-1;
}
| false | false | false | false | false | 0 |
gameFinished() {
QSettings settings;
int count = settings.value("Current/Count").toInt();
int length = settings.value("Current/Length").toInt();
int msecs = settings.value("Current/Time").toInt();
m_clock->stop();
m_clock->setDisabled(true);
m_pause_action->setDisabled(true);
m_success->show();
m_scores->addScore(qRound(msecs / 1000.0), count, length);
}
| false | false | false | false | false | 0 |
complete_connection (NMDevice *device,
NMConnection *connection,
const char *specific_object,
const GSList *existing_connections,
GError **error)
{
NMSettingBridge *s_bridge, *tmp;
guint32 i = 0;
char *name;
const GSList *iter;
gboolean found;
nm_utils_complete_generic (connection,
NM_SETTING_BRIDGE_SETTING_NAME,
existing_connections,
_("Bridge connection %d"),
NULL,
TRUE);
s_bridge = nm_connection_get_setting_bridge (connection);
if (!s_bridge) {
s_bridge = (NMSettingBridge *) nm_setting_bridge_new ();
nm_connection_add_setting (connection, NM_SETTING (s_bridge));
}
/* Grab the first name that doesn't exist in either our connections
* or a device on the system.
*/
while (i < 500 && !nm_setting_bridge_get_interface_name (s_bridge)) {
name = g_strdup_printf ("br%u", i);
/* check interface names */
if (nm_netlink_iface_to_index (name) < 0) {
/* check existing bridge connections */
for (iter = existing_connections, found = FALSE; iter; iter = g_slist_next (iter)) {
NMConnection *candidate = iter->data;
tmp = nm_connection_get_setting_bridge (candidate);
if (tmp && nm_connection_is_type (candidate, NM_SETTING_BRIDGE_SETTING_NAME)) {
if (g_strcmp0 (nm_setting_bridge_get_interface_name (tmp), name) == 0) {
found = TRUE;
break;
}
}
}
if (!found)
g_object_set (G_OBJECT (s_bridge), NM_SETTING_BRIDGE_INTERFACE_NAME, name, NULL);
}
g_free (name);
i++;
}
return TRUE;
}
| false | false | false | false | false | 0 |
getBoundingRect(const Window& wnd) const
{
Rect compRect;
Rect bounds(0, 0, 0, 0);
// measure all frame components
for(FrameList::const_iterator frame = d_frames.begin(); frame != d_frames.end(); ++frame)
{
compRect = (*frame).getComponentArea().getPixelRect(wnd);
bounds.d_left = ceguimin(bounds.d_left, compRect.d_left);
bounds.d_top = ceguimin(bounds.d_top, compRect.d_top);
bounds.d_right = ceguimax(bounds.d_right, compRect.d_right);
bounds.d_bottom = ceguimax(bounds.d_bottom, compRect.d_bottom);
}
// measure all imagery components
for(ImageryList::const_iterator image = d_images.begin(); image != d_images.end(); ++image)
{
compRect = (*image).getComponentArea().getPixelRect(wnd);
bounds.d_left = ceguimin(bounds.d_left, compRect.d_left);
bounds.d_top = ceguimin(bounds.d_top, compRect.d_top);
bounds.d_right = ceguimax(bounds.d_right, compRect.d_right);
bounds.d_bottom = ceguimax(bounds.d_bottom, compRect.d_bottom);
}
// measure all text components
for(TextList::const_iterator text = d_texts.begin(); text != d_texts.end(); ++text)
{
compRect = (*text).getComponentArea().getPixelRect(wnd);
bounds.d_left = ceguimin(bounds.d_left, compRect.d_left);
bounds.d_top = ceguimin(bounds.d_top, compRect.d_top);
bounds.d_right = ceguimax(bounds.d_right, compRect.d_right);
bounds.d_bottom = ceguimax(bounds.d_bottom, compRect.d_bottom);
}
return bounds;
}
| false | false | false | false | false | 0 |
m6800_get_reg(int regnum)
{
switch( regnum )
{
case REG_PC: return PC;
case M6800_PC: return m6800.pc.w.l;
case REG_SP: return S;
case M6800_S: return m6800.s.w.l;
case M6800_CC: return m6800.cc;
case M6800_A: return m6800.d.b.h;
case M6800_B: return m6800.d.b.l;
case M6800_X: return m6800.x.w.l;
case M6800_NMI_STATE: return m6800.nmi_state;
case M6800_IRQ_STATE: return m6800.irq_state[M6800_IRQ_LINE];
case REG_PREVIOUSPC: return m6800.ppc.w.l;
default:
if( regnum <= REG_SP_CONTENTS )
{
unsigned offset = S + 2 * (REG_SP_CONTENTS - regnum);
if( offset < 0xffff )
return ( RM( offset ) << 8 ) | RM( offset+1 );
}
}
return 0;
}
| false | false | false | false | false | 0 |
compareFunction(ExecState* exec, JSValue* a, JSValue* b)
{
return (a == b || (b != 0 && a == 0) || (a && b && sameValue(exec, a, b)));
}
| 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.