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 |
|---|---|---|---|---|---|---|
bFmtResults( void )
{
bool bRtn;
wxString os1;
m_osErrMsg.Empty( );
// Check that the results file exists
if( ! roGetResultsFile( ).FileExists( ) )
{
os1.Empty( );
os1 << wxT("Results file doesn't exist : \n\n")
<< roGetResultsFile( ).GetFullPath( );
SetErrMsg( os1 );
return( FALSE );
}
// Attempt to open the results file
if( ! m_oFileResults.Open( roGetResultsFile( ).GetFullPath( ) ) )
{
os1.Empty( );
os1 << wxT("Results file couldn't be opened : \n\n")
<< roGetResultsFile( ).GetFullPath( );
SetErrMsg( os1 );
return( FALSE );
}
// Format the simulation results
if( roGetResultsFile( ).GetFullName( ).Right( 3 ) == wxT(".fo") )
bRtn = bFmtResultsFO( );
else bRtn = bFmtCommon( );
// Need last line to end with a '\n' or text controls will not load it
if( m_oFileResults.GetLastLine( ).Last( ) != wxT('\n') )
m_oFileResults.GetLastLine( ) << wxT('\n');
m_oFileResults.Write( ); // Save the changes to disk
m_oFileResults.Close( ); // Close the file
return( bRtn );
} | false | false | false | false | false | 0 |
fl_winshow( Window win )
{
XMapRaised( flx->display, win );
/* Wait until the newly mapped window shows up */
if ( st_xwmh.initial_state == NormalState )
wait_mapwin( win );
setup_catch_destroy( win );
fl_winset( win );
/* Re-initialize window defaults */
fli_default_xswa( );
return win;
} | false | false | false | false | false | 0 |
kmo_free_fits_desc(main_fits_desc *desc)
{
KMO_TRY
{
KMO_TRY_ASSURE(desc != NULL,
CPL_ERROR_NULL_INPUT,
"No input data is provided!");
if (desc->sub_desc != NULL) {
/* free main_fits_desc */
cpl_free(desc->sub_desc); desc->sub_desc = NULL;
/* reset main_fits_desc */
kmo_init_fits_desc(desc);
}
}
KMO_CATCH
{
KMO_CATCH_MSG();
}
} | false | false | false | false | false | 0 |
qib_setup_sdma(struct qib_pportdata *ppd)
{
struct qib_devdata *dd = ppd->dd;
unsigned long flags;
int ret = 0;
ret = alloc_sdma(ppd);
if (ret)
goto bail;
/* set consistent sdma state */
ppd->dd->f_sdma_init_early(ppd);
spin_lock_irqsave(&ppd->sdma_lock, flags);
sdma_set_state(ppd, qib_sdma_state_s00_hw_down);
spin_unlock_irqrestore(&ppd->sdma_lock, flags);
/* set up reference counting */
kref_init(&ppd->sdma_state.kref);
init_completion(&ppd->sdma_state.comp);
ppd->sdma_generation = 0;
ppd->sdma_descq_head = 0;
ppd->sdma_descq_removed = 0;
ppd->sdma_descq_added = 0;
ppd->sdma_intrequest = 0;
INIT_LIST_HEAD(&ppd->sdma_userpending);
INIT_LIST_HEAD(&ppd->sdma_activelist);
tasklet_init(&ppd->sdma_sw_clean_up_task, sdma_sw_clean_up_task,
(unsigned long)ppd);
ret = dd->f_init_sdma_regs(ppd);
if (ret)
goto bail_alloc;
qib_sdma_process_event(ppd, qib_sdma_event_e10_go_hw_start);
return 0;
bail_alloc:
qib_teardown_sdma(ppd);
bail:
return ret;
} | false | false | false | false | false | 0 |
tdb1_recovery_area(struct tdb_context *tdb,
const struct tdb1_methods *methods,
tdb1_off_t *recovery_offset,
struct tdb1_record *rec)
{
if (tdb1_ofs_read(tdb, TDB1_RECOVERY_HEAD, recovery_offset) == -1) {
return -1;
}
if (*recovery_offset == 0) {
rec->rec_len = 0;
return 0;
}
if (methods->tdb1_read(tdb, *recovery_offset, rec, sizeof(*rec),
TDB1_DOCONV()) == -1) {
return -1;
}
/* ignore invalid recovery regions: can happen in crash */
if (rec->magic != TDB1_RECOVERY_MAGIC &&
rec->magic != TDB1_RECOVERY_INVALID_MAGIC) {
*recovery_offset = 0;
rec->rec_len = 0;
}
return 0;
} | false | false | false | false | false | 0 |
disposeImpl(
void* firstElement, size_t elementSize, size_t elementCount, size_t capacity,
void (*destroyElement)(void*)) const {
// Note that capacity is ignored since operator delete() doesn't care about it.
AutoDeleter deleter(firstElement);
if (destroyElement != nullptr) {
ExceptionSafeArrayUtil guard(firstElement, elementSize, elementCount, destroyElement);
guard.destroyAll();
}
} | false | false | false | false | false | 0 |
__ecereMethod_Debugger_StepUntil(struct __ecereNameSpace__ecere__com__Instance * this, struct __ecereNameSpace__ecere__com__Instance * compiler, struct ProjectConfig * config, int bitDepth, unsigned int useValgrind, unsigned int ignoreBreakpoints)
{
struct Debugger * __ecerePointer_Debugger = (struct Debugger *)(this ? (((char *)this) + __ecereClass_Debugger->offset) : 0);
;
__ecerePointer_Debugger->userAction = 10;
switch(__ecereMethod_Debugger_StartSession(this, compiler, config, bitDepth, useValgrind, 0x0, ignoreBreakpoints))
{
case 2:
__ecereMethod_Debugger_GdbExecRun(this);
break;
case 4:
__ecereMethod_Debugger_GdbExecUntil(this, (((void *)0)), 0);
break;
}
} | false | false | false | true | false | 1 |
wl1251_irq(int irq, void *cookie)
{
struct wl1251 *wl;
wl1251_debug(DEBUG_IRQ, "IRQ");
wl = cookie;
ieee80211_queue_work(wl->hw, &wl->irq_work);
return IRQ_HANDLED;
} | false | false | false | false | false | 0 |
can_handle(int parent, int child)
{
return (parent == 0 && child == ELM_multistatus) ||
(parent == ELM_multistatus && child == ELM_response) ||
(parent == ELM_response &&
(child == ELM_href || child == ELM_status ||
child == ELM_propstat || child == ELM_responsedescription)) ||
(parent == ELM_propstat &&
(child == ELM_prop || child == ELM_status ||
child == ELM_responsedescription));
} | false | false | false | false | false | 0 |
objectIsInShadow(Point hit, Light *light)
{
if (!shadows)
return false;
float tmax = (light->position - hit).length();
Ray shadowray(hit, (light->position - hit).normalized());
for (std::vector<Object*>::iterator jt=objects.begin(); jt!=objects.end(); ++jt) {
if ((*jt)->intersect(shadowray).t <= tmax) {
return true;
}
}
return false;
} | false | false | false | false | false | 0 |
takeBitmap() {
SplashBitmap *ret;
ret = bitmap;
bitmap = new SplashBitmap(1, 1, bitmapRowPad, colorMode,
colorMode != splashModeMono1, bitmapTopDown);
return ret;
} | false | false | false | false | false | 0 |
wi_mutable_string_delete_characters_from_index(wi_mutable_string_t *string, wi_uinteger_t index) {
WI_RUNTIME_ASSERT_MUTABLE(string);
wi_mutable_string_delete_characters_in_range(string, wi_make_range(index, string->length - index));
} | false | false | false | false | false | 0 |
encode_OCSPBasicOCSPResponse(unsigned char *p HEIMDAL_UNUSED_ATTRIBUTE, size_t len HEIMDAL_UNUSED_ATTRIBUTE, const OCSPBasicOCSPResponse *data, size_t *size)
{
size_t ret HEIMDAL_UNUSED_ATTRIBUTE = 0;
size_t l HEIMDAL_UNUSED_ATTRIBUTE;
int i HEIMDAL_UNUSED_ATTRIBUTE, e HEIMDAL_UNUSED_ATTRIBUTE;
/* certs */
if((data)->certs) {
size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
ret = 0;
for(i = (int)((data)->certs)->len - 1; i >= 0; --i) {
size_t certs_tag_tag_for_oldret = ret;
ret = 0;
e = encode_Certificate(p, len, &((data)->certs)->val[i], &l);
if (e) return e;
p -= l; len -= l; ret += l;
ret += certs_tag_tag_for_oldret;
}
e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
if (e) return e;
p -= l; len -= l; ret += l;
e = der_put_length_and_tag (p, len, ret, ASN1_C_CONTEXT, CONS, 0, &l);
if (e) return e;
p -= l; len -= l; ret += l;
ret += Top_tag_oldret;
}
/* signature */
{
size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
ret = 0;
e = der_put_bit_string(p, len, &(data)->signature, &l);
if (e) return e;
p -= l; len -= l; ret += l;
e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, PRIM, UT_BitString, &l);
if (e) return e;
p -= l; len -= l; ret += l;
ret += Top_tag_oldret;
}
/* signatureAlgorithm */
{
size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
ret = 0;
e = encode_AlgorithmIdentifier(p, len, &(data)->signatureAlgorithm, &l);
if (e) return e;
p -= l; len -= l; ret += l;
ret += Top_tag_oldret;
}
/* tbsResponseData */
{
size_t Top_tag_oldret HEIMDAL_UNUSED_ATTRIBUTE = ret;
ret = 0;
e = encode_OCSPResponseData(p, len, &(data)->tbsResponseData, &l);
if (e) return e;
p -= l; len -= l; ret += l;
ret += Top_tag_oldret;
}
e = der_put_length_and_tag (p, len, ret, ASN1_C_UNIV, CONS, UT_Sequence, &l);
if (e) return e;
p -= l; len -= l; ret += l;
*size = ret;
return 0;
} | false | false | false | false | false | 0 |
gd_header_bar_map (GtkWidget *widget)
{
GdHeaderBar *bar = GD_HEADER_BAR (widget);
GdHeaderBarPrivate *priv = bar->priv;
GTK_WIDGET_CLASS (gd_header_bar_parent_class)->map (widget);
if (priv->event_window)
gdk_window_show_unraised (priv->event_window);
} | false | false | false | false | false | 0 |
print_actions(stateno)
int stateno;
{
register action *p;
register shifts *sp;
register int as;
if (stateno == final_state)
fprintf(verbose_file, "\t$end accept\n");
p = parser[stateno];
if (p)
{
print_shifts(p);
print_reductions(p, defred[stateno]);
}
sp = shift_table[stateno];
if (sp && sp->nshifts > 0)
{
as = accessing_symbol[sp->shift[sp->nshifts - 1]];
if (ISVAR(as))
print_gotos(stateno);
}
} | false | false | false | false | false | 0 |
mantis_i2c_init(struct mantis_pci *mantis)
{
u32 intstat;
struct i2c_adapter *i2c_adapter = &mantis->adapter;
struct pci_dev *pdev = mantis->pdev;
init_waitqueue_head(&mantis->i2c_wq);
mutex_init(&mantis->i2c_lock);
strncpy(i2c_adapter->name, "Mantis I2C", sizeof(i2c_adapter->name));
i2c_set_adapdata(i2c_adapter, mantis);
i2c_adapter->owner = THIS_MODULE;
i2c_adapter->algo = &mantis_algo;
i2c_adapter->algo_data = NULL;
i2c_adapter->timeout = 500;
i2c_adapter->retries = 3;
i2c_adapter->dev.parent = &pdev->dev;
mantis->i2c_rc = i2c_add_adapter(i2c_adapter);
if (mantis->i2c_rc < 0)
return mantis->i2c_rc;
dprintk(MANTIS_DEBUG, 1, "Initializing I2C ..");
intstat = mmread(MANTIS_INT_STAT);
mmread(MANTIS_INT_MASK);
mmwrite(intstat, MANTIS_INT_STAT);
dprintk(MANTIS_DEBUG, 1, "Disabling I2C interrupt");
mantis_mask_ints(mantis, MANTIS_INT_I2CDONE);
return 0;
} | false | false | false | false | false | 0 |
read_radio_id(struct brcms_phy *pi)
{
u32 id;
if (D11REV_GE(pi->sh->corerev, 24)) {
u32 b0, b1, b2;
bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), 0);
b0 = (u32) bcma_read16(pi->d11core, D11REGOFFS(radioregdata));
bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), 1);
b1 = (u32) bcma_read16(pi->d11core, D11REGOFFS(radioregdata));
bcma_wflush16(pi->d11core, D11REGOFFS(radioregaddr), 2);
b2 = (u32) bcma_read16(pi->d11core, D11REGOFFS(radioregdata));
id = ((b0 & 0xf) << 28) | (((b2 << 8) | b1) << 12) | ((b0 >> 4)
& 0xf);
} else {
bcma_wflush16(pi->d11core, D11REGOFFS(phy4waddr), RADIO_IDCODE);
id = (u32) bcma_read16(pi->d11core, D11REGOFFS(phy4wdatalo));
id |= (u32) bcma_read16(pi->d11core,
D11REGOFFS(phy4wdatahi)) << 16;
}
pi->phy_wreg = 0;
return id;
} | false | false | false | false | false | 0 |
fm10k_mbx_validate_msg_size(struct fm10k_mbx_info *mbx, u16 len)
{
struct fm10k_mbx_fifo *fifo = &mbx->rx;
u16 total_len = 0, msg_len;
u32 *msg;
/* length should include previous amounts pushed */
len += mbx->pushed;
/* offset in message is based off of current message size */
do {
msg = fifo->buffer + fm10k_fifo_tail_offset(fifo, total_len);
msg_len = FM10K_TLV_DWORD_LEN(*msg);
total_len += msg_len;
} while (total_len < len);
/* message extends out of pushed section, but fits in FIFO */
if ((len < total_len) && (msg_len <= mbx->max_size))
return 0;
/* return length of invalid section */
return (len < total_len) ? len : (len - total_len);
} | false | false | false | false | false | 0 |
runOnMachineFunction(MachineFunction &MF) {
TII = MF.getTarget().getInstrInfo();
bool Changed = false;
// Process any unreachable blocks in arbitrary order now.
for (MachineFunction::iterator BB = MF.begin(), E = MF.end(); BB != E; ++BB)
Changed |= processBasicBlock(MF, *BB);
return Changed;
} | false | false | false | false | false | 0 |
client_handle_get_interfaces(struct lldpd *cfg, enum hmsg_type *type,
void *input, int input_len, void **output, int *subscribed)
{
struct lldpd_interface *iff, *iff_next;
struct lldpd_hardware *hardware;
ssize_t output_len;
/* Build the list of interfaces */
struct lldpd_interface_list ifs;
log_debug("rpc", "client request the list of interfaces");
TAILQ_INIT(&ifs);
TAILQ_FOREACH(hardware, &cfg->g_hardware, h_entries) {
if ((iff = (struct lldpd_interface*)malloc(sizeof(
struct lldpd_interface))) == NULL)
fatal("rpc", NULL);
iff->name = hardware->h_ifname;
TAILQ_INSERT_TAIL(&ifs, iff, next);
}
output_len = lldpd_interface_list_serialize(&ifs, output);
if (output_len <= 0) {
output_len = 0;
*type = NONE;
}
/* Free the temporary list */
for (iff = TAILQ_FIRST(&ifs);
iff != NULL;
iff = iff_next) {
iff_next = TAILQ_NEXT(iff, next);
TAILQ_REMOVE(&ifs, iff, next);
free(iff);
}
return output_len;
} | false | false | false | false | false | 0 |
msg_join(IRC_SERVER_REC *server, const char *channel,
const char *nick, const char *address)
{
NETSPLIT_REC *split;
NETJOIN_REC *netjoin;
GSList *channels;
int rejoin = 1;
if (!IS_IRC_SERVER(server))
return;
if (ignore_check(SERVER(server), nick, address,
channel, NULL, MSGLEVEL_JOINS))
return;
split = netsplit_find(server, nick, address);
netjoin = netjoin_find(server, nick);
if (split == NULL && netjoin == NULL)
return;
/* if this was not a channel they split from, treat it normally */
if (netjoin != NULL) {
if (!gslist_find_icase_string(netjoin->old_channels, channel))
return;
} else {
channels = split->channels;
while (channels != NULL) {
NETSPLIT_CHAN_REC *schannel = channels->data;
if (!strcasecmp(schannel->name, channel))
break;
channels = channels->next;
}
/* we still need to create a NETJOIN_REC now as the
* NETSPLIT_REC will be destroyed */
if (channels == NULL)
rejoin = 0;
}
if (join_tag == -1) {
join_tag = g_timeout_add(1000, (GSourceFunc)
sig_check_netjoins, NULL);
signal_add("print starting", (SIGNAL_FUNC) sig_print_starting);
}
if (netjoin == NULL)
netjoin = netjoin_add(server, nick, split->channels);
if (rejoin)
{
netjoin->now_channels = g_slist_append(netjoin->now_channels,
g_strconcat(" ", channel, NULL));
signal_stop();
}
} | false | false | false | false | false | 0 |
DoRefreshSize()
{
int w, h,tw,th;
gr_get_string_size(&w, &h, (char *)Label.c_str());
tw = w;
th = h;
gr_get_string_size(&w, &h, "X");
tw += w;
th += h + CB_TEXTCHECKDIST; //Spacing b/t 'em
CheckCoords[0] = Coords[0];
CheckCoords[1] = Coords[1];
CheckCoords[2] = Coords[0] + w;
CheckCoords[3] = Coords[1] + h;
if (!(Style & GS_NOAUTORESIZEX)) {
Coords[2] = Coords[0] + tw;
}
if (!(Style & GS_NOAUTORESIZEY)) {
Coords[3] = Coords[1] + th;
}
return OF_TRUE;
} | false | false | false | false | false | 0 |
indexingFinished( bool success )
{
LOG(logDEBUG) << "Entering LogData::indexingFinished.";
// We use the newly created file data or restore the old ones.
// (Qt implicit copy makes this fast!)
{
QMutexLocker locker( &dataMutex_ );
workerThread_.getIndexingData( &fileSize_, &maxLength_, &linePosition_ );
nbLines_ = linePosition_.size();
}
LOG(logDEBUG) << "indexingFinished: " << success <<
", found " << nbLines_ << " lines.";
if ( success ) {
// Use the new filename if needed
if ( !currentOperation_->getFilename().isNull() ) {
QString newFileName = currentOperation_->getFilename();
if ( file_ ) {
QMutexLocker locker( &fileMutex_ );
file_->setFileName( newFileName );
}
else {
QMutexLocker locker( &fileMutex_ );
file_ = new QFile( newFileName );
}
}
// Update the modified date/time if the file exists
lastModifiedDate_ = QDateTime();
QFileInfo fileInfo( *file_ );
if ( fileInfo.exists() )
lastModifiedDate_ = fileInfo.lastModified();
}
if ( file_ ) {
// And we watch the file for updates
fileChangedOnDisk_ = Unchanged;
fileWatcher_.addFile( file_->fileName() );
}
emit loadingFinished( success );
// So now the operation is done, let's see if there is something
// else to do, in which case, do it!
if ( currentOperation_ ) {
delete currentOperation_;
currentOperation_ = nextOperation_;
nextOperation_ = NULL;
}
else {
LOG(logERROR) << "currentOperation_ is NULL in indexingFinished()";
}
if ( currentOperation_ ) {
LOG(logDEBUG) << "indexingFinished is performing the next operation";
startOperation();
}
} | false | false | false | false | false | 0 |
numerical_score_matrix (double *b, int T, int k,
BFGS_LLT_FUNC lltfun,
void *data, int *err)
{
double h = 1e-8;
#if ALT_OPG
double d = 1.0e-4;
#endif
gretl_matrix *G;
const double *x;
double bi0, x0;
int i, t;
G = gretl_zero_matrix_new(T, k);
if (G == NULL) {
*err = E_ALLOC;
return NULL;
}
for (i=0; i<k; i++) {
bi0 = b[i];
#if ALT_OPG
h = d * bi0 + d * (b[i] == 0.0);
#endif
b[i] = bi0 - h;
x = lltfun(b, i, data);
if (x == NULL) {
*err = E_NAN;
goto bailout;
}
for (t=0; t<T; t++) {
gretl_matrix_set(G, t, i, x[t]);
}
b[i] = bi0 + h;
x = lltfun(b, i, data);
if (x == NULL) {
*err = E_NAN;
goto bailout;
}
for (t=0; t<T; t++) {
x0 = gretl_matrix_get(G, t, i);
gretl_matrix_set(G, t, i, (x[t] - x0) / (2.0 * h));
}
b[i] = bi0;
#if NLS_DEBUG
fprintf(stderr, "b[%d]: using %#.12g and %#.12g\n", i, bi0 - h, bi0 + h);
#endif
}
#if NLS_DEBUG
gretl_matrix_print(G, "Numerically estimated score");
#endif
bailout:
if (*err) {
gretl_matrix_free(G);
G = NULL;
}
return G;
} | false | false | false | false | false | 0 |
messageReferencesCallback(size_t messageNumber,
const vector<string> &references)
{
if (folder.isDestroyed())
return;
if (messageNumber >= folder->serverIndex.size())
return;
Index &i=folder->serverIndex[messageNumber];
i.references.clear();
i.references.reserve(references.size());
i.watchLevel=0;
i.expires=0;
if (references.size() > 0)
{
vector<string>::const_iterator rb=references.begin(),
re=references.end();
while (rb != re)
{
string s=*rb;
if (s.size() > 0 && s[0] == '<')
s=s.substr(1);
if (s.size() > 0 && s[s.size()-1] == '>')
s=s.substr(0, s.size()-1);
messageId mid(folder->msgIds, s);
i.references.push_back(mid);
if (!folder->watchList.watching(messageId(folder
->msgIds,
*rb),
i.expires,
i.watchLevel))
if (i.watchLevel)
{
if (--i.watchLevel == 0)
i.expires=0;
}
++rb;
}
}
if (((string)i.messageid).size() > 0) // Already seen env
{
if (i.watchLevel)
{
--i.watchLevel;
folder->watchList(i.messageid, i.expires,
i.watchLevel);
}
i.checkwatch(*folder);
}
} | false | false | false | false | false | 0 |
clause_cmp (const void* x, const void* y) {
return clause_size((clause*)x) > 2
&& (clause_size((clause*)y) == 2
|| clause_activity((clause*)x)
< clause_activity((clause*)y)) ? -1 : 1; } | false | false | false | false | false | 0 |
gst_caps_structure_subtract_field (GQuark field_id, const GValue * value,
gpointer user_data)
{
SubtractionEntry *e = user_data;
GValue subtraction = { 0, };
const GValue *other;
GstStructure *structure;
other = gst_structure_id_get_value (e->subtract_from, field_id);
if (!other) {
return FALSE;
}
if (!gst_value_subtract (&subtraction, other, value))
return TRUE;
if (gst_value_compare (&subtraction, other) == GST_VALUE_EQUAL) {
g_value_unset (&subtraction);
return FALSE;
} else {
structure = gst_structure_copy (e->subtract_from);
gst_structure_id_set_value (structure, field_id, &subtraction);
g_value_unset (&subtraction);
e->put_into = g_slist_prepend (e->put_into, structure);
return TRUE;
}
} | false | false | false | false | false | 0 |
get_handler_index(struct handler_data *table, void *handler, offs_t start)
{
int i;
/* all static handlers are hardcoded */
if (HANDLER_IS_STATIC(handler))
return (FPTR)handler;
/* otherwise, we have to search */
for (i = STATIC_COUNT; i < SUBTABLE_BASE; i++)
{
if (table[i].handler == NULL)
{
table[i].handler = handler;
table[i].offset = start;
}
if (table[i].handler == handler && table[i].offset == start)
return i;
}
return 0;
} | false | false | false | false | false | 0 |
gt_bsStoreUInt8(BitString str, BitOffset offset,
unsigned numBits, uint8_t val)
{
unsigned bitsLeft = numBits,
bitTop = offset%bitElemBits;
size_t elemStart = offset/bitElemBits;
BitElem *p = str + elemStart;
gt_assert(str);
gt_assert(numBits <= sizeof (val)*CHAR_BIT);
/* set bits of first element, accounting for bits to be preserved */
if (bitTop)
{
unsigned long mask = ~(unsigned long)0;
if (bitElemBits < (sizeof (unsigned long)*CHAR_BIT))
{
mask <<= bitElemBits;
}
else
{
mask = 0;
}
mask = (~mask) >> bitTop;
if (numBits < bitElemBits - bitTop)
{
unsigned backShift = bitElemBits - numBits - bitTop;
mask &= ~(unsigned long)0 << backShift;
*p = (*p & ~mask) | ((val << backShift) & mask);
/* TODO: try wether r = a ^ ((a ^ b) & mask) is faster, see below */
return;
}
else
{
bitsLeft -= bitElemBits - bitTop;
*p = (*p & ~mask) | ((val >> bitsLeft) & mask);
++p;
}
}
/* set bits for intervening elems */
while (bitsLeft >= bitElemBits)
{
bitsLeft -= bitElemBits;
*p++ = val >> bitsLeft;
}
/* set bits for last elem */
if (bitsLeft)
{
unsigned long mask =
((~(unsigned long)0)<<(bitElemBits - bitsLeft));
if (bitElemBits < (sizeof (unsigned long)*CHAR_BIT))
mask &= (~(~(unsigned long)0<<bitElemBits));
*p = (*p & ~mask) | ((val << (bitElemBits - bitsLeft)) & mask);
}
} | false | false | false | false | false | 0 |
CalcScore(const Phrase &phrase, float &fullScore, float &ngramScore, size_t &oovCount) const {
fullScore = 0;
ngramScore = 0;
oovCount = 0;
size_t phraseSize = phrase.GetSize();
if (!phraseSize) return;
vector<const Word*> contextFactor;
contextFactor.reserve(GetNGramOrder());
std::auto_ptr<FFState> state(NewState((phrase.GetWord(0) == GetSentenceStartArray()) ?
GetBeginSentenceState() : GetNullContextState()));
size_t currPos = 0;
while (currPos < phraseSize) {
const Word &word = phrase.GetWord(currPos);
if (word.IsNonTerminal()) {
// do nothing. reset ngram. needed to score target phrases during pt loading in chart decoding
if (!contextFactor.empty()) {
// TODO: state operator= ?
state.reset(NewState(GetNullContextState()));
contextFactor.clear();
}
} else {
ShiftOrPush(contextFactor, word);
CHECK(contextFactor.size() <= GetNGramOrder());
if (word == GetSentenceStartArray()) {
// do nothing, don't include prob for <s> unigram
if (currPos != 0) {
std::cerr << "Either your data contains <s> in a position other than the first word or your language model is missing <s>. Did you build your ARPA using IRSTLM and forget to run add-start-end.sh?" << std::endl;
abort();
}
} else {
LMResult result = GetValueGivenState(contextFactor, *state);
fullScore += result.score;
if (contextFactor.size() == GetNGramOrder())
ngramScore += result.score;
if (result.unknown) ++oovCount;
}
}
currPos++;
}
} | false | false | false | false | false | 0 |
draw_outlines(const PathVec& path_vec,
const std::vector<LineStyle>& line_styles,
const SWFCxForm& cx,
const SWFMatrix& mat)
{
for (PathVec::const_iterator it = path_vec.begin(), end = path_vec.end();
it != end; ++it) {
const Path& cur_path = *it;
if (!cur_path.m_line) {
continue;
}
apply_line_style(line_styles[cur_path.m_line-1], cx, mat);
add_path(_cr, cur_path);
cairo_stroke(_cr);
}
} | false | false | false | false | false | 0 |
N_alloc_les_param(int cols, int rows, int type, int parts)
{
N_les *les;
int i;
if (type == N_SPARSE_LES)
G_debug(2,
"Allocate memory for a sparse linear equation system with %i rows\n",
rows);
else
G_debug(2,
"Allocate memory for a regular linear equation system with %i rows\n",
rows);
les = (N_les *) G_calloc(1, sizeof(N_les));
if (parts > 0) {
les->x = (double *)G_calloc(cols, sizeof(double));
for (i = 0; i < cols; i++)
les->x[i] = 0.0;
}
if (parts > 1) {
les->b = (double *)G_calloc(cols, sizeof(double));
for (i = 0; i < cols; i++)
les->b[i] = 0.0;
}
les->A = NULL;
les->Asp = NULL;
les->rows = rows;
les->cols = cols;
if (rows == cols)
les->quad = 1;
else
les->quad = 0;
if (type == N_SPARSE_LES) {
les->Asp = (N_spvector **) G_calloc(rows, sizeof(N_spvector *));
les->type = N_SPARSE_LES;
}
else {
les->A = (double **)G_calloc(rows, sizeof(double *));
for (i = 0; i < rows; i++) {
les->A[i] = (double *)G_calloc(cols, sizeof(double));
}
les->type = N_NORMAL_LES;
}
return les;
} | false | false | false | false | false | 0 |
SplitProgramFromArgs(const std::string& path,
std::string& program, std::string& args)
{
// see if this is a full path to a program
// if so then set program to path and args to nothing
if (SystemTools::FileExists(path)) {
program = path;
args = "";
return;
}
// Try to find the program in the path, note the program
// may have spaces in its name so we have to look for it
std::vector<std::string> e;
std::string findProg = SystemTools::FindProgram(path, e);
if (!findProg.empty()) {
program = findProg;
args = "";
return;
}
// Now try and peel off space separated chunks from the end of the string
// so the largest path possible is found allowing for spaces in the path
std::string dir = path;
std::string::size_type spacePos = dir.rfind(' ');
while (spacePos != std::string::npos) {
std::string tryProg = dir.substr(0, spacePos);
// See if the file exists
if (SystemTools::FileExists(tryProg)) {
program = tryProg;
// remove trailing spaces from program
std::string::size_type pos = program.size() - 1;
while (program[pos] == ' ') {
program.erase(pos);
pos--;
}
args = dir.substr(spacePos, dir.size() - spacePos);
return;
}
// Now try and find the program in the path
findProg = SystemTools::FindProgram(tryProg, e);
if (!findProg.empty()) {
program = findProg;
// remove trailing spaces from program
std::string::size_type pos = program.size() - 1;
while (program[pos] == ' ') {
program.erase(pos);
pos--;
}
args = dir.substr(spacePos, dir.size() - spacePos);
return;
}
// move past the space for the next search
spacePos--;
spacePos = dir.rfind(' ', spacePos);
}
program = "";
args = "";
} | false | false | false | false | false | 0 |
scope_format_text (NODE_T * p, SCOPE_T ** s)
{
for (; p != NO_NODE; FORWARD (p)) {
if (IS (p, FORMAT_PATTERN)) {
scope_enclosed_clause (SUB (NEXT_SUB (p)), s);
} else if (IS (p, FORMAT_ITEM_G) && NEXT (p) != NO_NODE) {
scope_enclosed_clause (SUB_NEXT (p), s);
} else if (IS (p, DYNAMIC_REPLICATOR)) {
scope_enclosed_clause (SUB (NEXT_SUB (p)), s);
} else {
scope_format_text (SUB (p), s);
}
}
} | false | false | false | false | false | 0 |
updateFilteredView( int nbMatches, int progress )
{
LOG(logDEBUG) << "updateFilteredView received.";
if ( progress == 100 ) {
// Searching done
printSearchInfoMessage( nbMatches );
searchInfoLine->hideGauge();
// De-activate the stop button
stopButton->setEnabled( false );
}
else {
// Search in progress
// We ignore 0% and 100% to avoid a flash when the search is very short
if ( progress > 0 ) {
searchInfoLine->setText(
tr("Search in progress (%1 %)... %2 match%3 found so far.")
.arg( progress )
.arg( nbMatches )
.arg( nbMatches > 1 ? "es" : "" ) );
searchInfoLine->displayGauge( progress );
}
}
// Recompute the content of the filtered window.
filteredView->updateData();
// Update the match overview
overview_->updateData( logData_->getNbLine() );
// Also update the top window for the coloured bullets.
update();
} | false | false | false | false | false | 0 |
ldns_pkt_new(void)
{
ldns_pkt *packet;
packet = LDNS_MALLOC(ldns_pkt);
if (!packet) {
return NULL;
}
packet->_header = LDNS_MALLOC(ldns_hdr);
if (!packet->_header) {
LDNS_FREE(packet);
return NULL;
}
packet->_question = ldns_rr_list_new();
packet->_answer = ldns_rr_list_new();
packet->_authority = ldns_rr_list_new();
packet->_additional = ldns_rr_list_new();
/* default everything to false */
ldns_pkt_set_qr(packet, false);
ldns_pkt_set_aa(packet, false);
ldns_pkt_set_tc(packet, false);
ldns_pkt_set_rd(packet, false);
ldns_pkt_set_ra(packet, false);
ldns_pkt_set_ad(packet, false);
ldns_pkt_set_cd(packet, false);
ldns_pkt_set_opcode(packet, LDNS_PACKET_QUERY);
ldns_pkt_set_rcode(packet, 0);
ldns_pkt_set_id(packet, 0);
ldns_pkt_set_size(packet, 0);
ldns_pkt_set_querytime(packet, 0);
memset(&packet->timestamp, 0, sizeof(packet->timestamp));
ldns_pkt_set_answerfrom(packet, NULL);
ldns_pkt_set_section_count(packet, LDNS_SECTION_QUESTION, 0);
ldns_pkt_set_section_count(packet, LDNS_SECTION_ANSWER, 0);
ldns_pkt_set_section_count(packet, LDNS_SECTION_AUTHORITY, 0);
ldns_pkt_set_section_count(packet, LDNS_SECTION_ADDITIONAL, 0);
ldns_pkt_set_edns_udp_size(packet, 0);
ldns_pkt_set_edns_extended_rcode(packet, 0);
ldns_pkt_set_edns_version(packet, 0);
ldns_pkt_set_edns_z(packet, 0);
ldns_pkt_set_edns_data(packet, NULL);
ldns_pkt_set_tsig(packet, NULL);
return packet;
} | false | false | false | false | false | 0 |
Pair_check_list (List_T pairs) {
T this;
List_T p;
int prev_querypos, prev_genomepos;
if (pairs == NULL) {
return;
} else {
this = List_head(pairs);
prev_querypos = this->querypos;
prev_genomepos = this->genomepos;
for (p = List_next(pairs); p != NULL; p = List_next(p)) {
this = List_head(p);
if (this->gapp == false) {
if (this->querypos > prev_querypos) {
printf("Problem at querypos %d\n",this->querypos);
}
#if 0
/* No longer a valid check after genomepos converted to chrpos */
if (this->genomepos > prev_genomepos) {
printf("Problem at genomepos %d\n",this->genomepos);
}
#endif
prev_querypos = this->querypos;
prev_genomepos = this->genomepos;
}
}
}
return;
} | false | false | false | false | false | 0 |
hann(int N)
{
float *x = (float *) MALLOC(N * sizeof(float) );
for (int i = 0; i < N+2; i++) {
if (i > 0 && i < N + 1) { // matlab has no zeroes at the beginning/end for hanning, only for hann (?!)
float temp = ((float)i) / (N+1);
x[i-1] = 0.5 * (1. - cos(2 * M_PI * temp));
}
}
return x;
} | false | false | false | false | false | 0 |
update_inline_extent_backref(struct btrfs_root *root,
struct btrfs_path *path,
struct btrfs_extent_inline_ref *iref,
int refs_to_mod,
struct btrfs_delayed_extent_op *extent_op,
int *last_ref)
{
struct extent_buffer *leaf;
struct btrfs_extent_item *ei;
struct btrfs_extent_data_ref *dref = NULL;
struct btrfs_shared_data_ref *sref = NULL;
unsigned long ptr;
unsigned long end;
u32 item_size;
int size;
int type;
u64 refs;
leaf = path->nodes[0];
ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_extent_item);
refs = btrfs_extent_refs(leaf, ei);
WARN_ON(refs_to_mod < 0 && refs + refs_to_mod <= 0);
refs += refs_to_mod;
btrfs_set_extent_refs(leaf, ei, refs);
if (extent_op)
__run_delayed_extent_op(extent_op, leaf, ei);
type = btrfs_extent_inline_ref_type(leaf, iref);
if (type == BTRFS_EXTENT_DATA_REF_KEY) {
dref = (struct btrfs_extent_data_ref *)(&iref->offset);
refs = btrfs_extent_data_ref_count(leaf, dref);
} else if (type == BTRFS_SHARED_DATA_REF_KEY) {
sref = (struct btrfs_shared_data_ref *)(iref + 1);
refs = btrfs_shared_data_ref_count(leaf, sref);
} else {
refs = 1;
BUG_ON(refs_to_mod != -1);
}
BUG_ON(refs_to_mod < 0 && refs < -refs_to_mod);
refs += refs_to_mod;
if (refs > 0) {
if (type == BTRFS_EXTENT_DATA_REF_KEY)
btrfs_set_extent_data_ref_count(leaf, dref, refs);
else
btrfs_set_shared_data_ref_count(leaf, sref, refs);
} else {
*last_ref = 1;
size = btrfs_extent_inline_ref_size(type);
item_size = btrfs_item_size_nr(leaf, path->slots[0]);
ptr = (unsigned long)iref;
end = (unsigned long)ei + item_size;
if (ptr + size < end)
memmove_extent_buffer(leaf, ptr, ptr + size,
end - ptr - size);
item_size -= size;
btrfs_truncate_item(root, path, item_size, 1);
}
btrfs_mark_buffer_dirty(leaf);
} | false | false | false | false | false | 0 |
moveDone()
{
// Called after non-animated move, animated move, end of game or hint action.
m_view->setNormalCursor();
emit statusMessage (QString(""), false); // Clear the status bar.
m_activity = Idle;
setAction (HINT, true);
m_fullSpeed = Prefs::animationNone();
m_view->hidePopup();
if (m_interrupting) {
m_interrupting = false;
m_waitingState = ComputerToMove;
}
} | false | false | false | false | false | 0 |
lp3972_dcdc_set_voltage_sel(struct regulator_dev *dev,
unsigned int selector)
{
struct lp3972 *lp3972 = rdev_get_drvdata(dev);
int buck = rdev_get_id(dev) - LP3972_DCDC1;
int ret;
ret = lp3972_set_bits(lp3972, LP3972_BUCK_VOL1_REG(buck),
LP3972_BUCK_VOL_MASK, selector);
if (ret)
return ret;
if (buck != 0)
return ret;
ret = lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG,
LP3972_VOL_CHANGE_FLAG_MASK, LP3972_VOL_CHANGE_FLAG_GO);
if (ret)
return ret;
return lp3972_set_bits(lp3972, LP3972_VOL_CHANGE_REG,
LP3972_VOL_CHANGE_FLAG_MASK, 0);
} | false | false | false | false | false | 0 |
dpm_insert_spcmd_entry(dbfd, dpm_spcmd)
struct dpm_dbfd *dbfd;
struct dpm_space_reserv *dpm_spcmd;
{
char escaped_name[255*2+1];
char func[23];
char g_space_str[21];
static char insert_stmt[] =
"INSERT INTO dpm_space_reserv \
(S_TOKEN, CLIENT_DN, S_UID, S_GID, RET_POLICY, \
AC_LATENCY, S_TYPE, U_TOKEN, T_SPACE, G_SPACE, \
U_SPACE, POOLNAME, ASSIGN_TIME, EXPIRE_TIME, GROUPS) \
VALUES \
('%s', '%s', %d, %d, '%c', '%c', '%c', '%s', %s, %s, %s, '%s', %d, %d, '%s')";
PGresult *res;
char sql_stmt[1416];
char t_space_str[21];
char u_space_str[21];
strcpy (func, "dpm_insert_spcmd_entry");
PQescapeStringConn (dbfd->Pconn, escaped_name, dpm_spcmd->client_dn,
strlen (dpm_spcmd->client_dn), NULL);
sprintf (sql_stmt, insert_stmt,
dpm_spcmd->s_token, escaped_name,
dpm_spcmd->s_uid, dpm_spcmd->s_gid, dpm_spcmd->ret_policy,
dpm_spcmd->ac_latency, dpm_spcmd->s_type, dpm_spcmd->u_token,
u64tostr (dpm_spcmd->t_space, t_space_str, -1),
u64tostr (dpm_spcmd->g_space, g_space_str, -1),
i64tostr (dpm_spcmd->u_space, u_space_str, -1),
dpm_spcmd->poolname, dpm_spcmd->assign_time, dpm_spcmd->expire_time,
dpm_spcmd->groups);
res = PQexec (dbfd->Pconn, sql_stmt);
if (PQresultStatus (res) != PGRES_COMMAND_OK) {
if (strstr (PQresultErrorMessage (res), "duplicate")) {
serrno = EEXIST;
PQclear (res);
} else
dpm_libpq_error (func, "INSERT", res, dbfd);
return (-1);
}
PQclear (res);
return (0);
} | false | false | false | false | false | 0 |
MeshEvert(Mesh *m)
{
int i;
Point3 *n;
if (m)
{
if (m->geomflags & MESH_EVERT)
m->geomflags &= ~MESH_EVERT;
else
m->geomflags |= MESH_EVERT;
if (m->geomflags & MESH_N) {
for (i = 0, n = m->n; i < m->nu*m->nv; i++,n++){
n->x = -n->x;
n->y = -n->y;
n->z = -n->z;
}
}
if (m->geomflags & MESH_NQ) {
for (i = 0, n = m->nq; i < m->nu*m->nv; i++,n++){
n->x = -n->x;
n->y = -n->y;
n->z = -n->z;
}
}
MeshComputeNormals(m, MESH_N|MESH_NQ);
}
return m;
} | false | false | false | false | false | 0 |
autohelperjoseki1618(int trans, int move, int color, int action)
{
int A;
UNUSED(color);
UNUSED(action);
A = AFFINE_TRANSFORM(430, trans, move);
return !DEFEND_MACRO(A);
} | false | false | false | false | false | 0 |
ajUtilGetUid(AjPStr* Puid)
{
#ifndef WIN32
ajint uid;
struct passwd* pwd;
ajDebug("ajUtilUid\n");
uid = getuid();
if(!uid)
{
ajStrAssignClear(Puid);
return ajFalse;
}
ajDebug(" uid: %d\n", uid);
pwd = getpwuid(uid);
if(!pwd)
{
ajStrAssignClear(Puid);
return ajFalse;
}
ajDebug(" pwd: '%s'\n", pwd->pw_name);
ajStrAssignC(Puid, pwd->pw_name);
return ajTrue;
#else /* WIN32 */
char nameBuf[UNLEN+1];
DWORD nameLen = UNLEN+1;
ajDebug("ajUtilUid\n");
if (GetUserName(nameBuf, &nameLen))
{
ajDebug(" pwd: '%s'\n", nameBuf);
ajStrAssignC(Puid, nameBuf);
return ajTrue;
}
ajStrAssignC(Puid, "");
return ajFalse;
#endif /* !WIN32 */
} | false | false | false | false | false | 0 |
validate(const char *pString_,unsigned row_)
{
if (MSView::model()!=0)
{
MSFloat aFloat;
if (aFloat.set(pString_)==MSError::MSSuccess)
{
vector().set(row_,aFloat);
return MSTrue;
}
}
return MSFalse;
} | false | false | false | false | false | 0 |
gsmld_config(struct tty_struct *tty, struct gsm_mux *gsm,
struct gsm_config *c)
{
int need_close = 0;
int need_restart = 0;
/* Stuff we don't support yet - UI or I frame transport, windowing */
if ((c->adaption != 1 && c->adaption != 2) || c->k)
return -EOPNOTSUPP;
/* Check the MRU/MTU range looks sane */
if (c->mru > MAX_MRU || c->mtu > MAX_MTU || c->mru < 8 || c->mtu < 8)
return -EINVAL;
if (c->n2 < 3)
return -EINVAL;
if (c->encapsulation > 1) /* Basic, advanced, no I */
return -EINVAL;
if (c->initiator > 1)
return -EINVAL;
if (c->i == 0 || c->i > 2) /* UIH and UI only */
return -EINVAL;
/*
* See what is needed for reconfiguration
*/
/* Timing fields */
if (c->t1 != 0 && c->t1 != gsm->t1)
need_restart = 1;
if (c->t2 != 0 && c->t2 != gsm->t2)
need_restart = 1;
if (c->encapsulation != gsm->encoding)
need_restart = 1;
if (c->adaption != gsm->adaption)
need_restart = 1;
/* Requires care */
if (c->initiator != gsm->initiator)
need_close = 1;
if (c->mru != gsm->mru)
need_restart = 1;
if (c->mtu != gsm->mtu)
need_restart = 1;
/*
* Close down what is needed, restart and initiate the new
* configuration
*/
if (need_close || need_restart) {
gsm_dlci_begin_close(gsm->dlci[0]);
/* This will timeout if the link is down due to N2 expiring */
wait_event_interruptible(gsm->event,
gsm->dlci[0]->state == DLCI_CLOSED);
if (signal_pending(current))
return -EINTR;
}
if (need_restart)
gsm_cleanup_mux(gsm);
gsm->initiator = c->initiator;
gsm->mru = c->mru;
gsm->mtu = c->mtu;
gsm->encoding = c->encapsulation;
gsm->adaption = c->adaption;
gsm->n2 = c->n2;
if (c->i == 1)
gsm->ftype = UIH;
else if (c->i == 2)
gsm->ftype = UI;
if (c->t1)
gsm->t1 = c->t1;
if (c->t2)
gsm->t2 = c->t2;
/* FIXME: We need to separate activation/deactivation from adding
and removing from the mux array */
if (need_restart)
gsm_activate_mux(gsm);
if (gsm->initiator && need_close)
gsm_dlci_begin_open(gsm->dlci[0]);
return 0;
} | false | false | false | false | false | 0 |
test_rebase_merge__copy_notes_disabled_in_config(void)
{
git_config *config;
cl_git_pass(git_repository_config(&config, repo));
cl_git_pass(git_config_set_bool(config, "notes.rewrite.rebase", 0));
cl_git_pass(git_config_set_string(config,
"notes.rewriteRef", "refs/notes/test"));
test_copy_note(NULL, 0);
} | false | false | false | false | false | 0 |
addToMyParts(ModelPart * modelPart)
{
if (modelPart != NULL) m_binManager->addToMyParts(modelPart);
} | false | false | false | false | false | 0 |
long_richcompare(PyObject *self, PyObject *other, int op)
{
int result;
PyObject *v;
CHECK_BINOP(self, other);
if (self == other)
result = 0;
else
result = long_compare((PyLongObject*)self, (PyLongObject*)other);
/* Convert the return value to a Boolean */
switch (op) {
case Py_EQ:
v = TEST_COND(result == 0);
break;
case Py_NE:
v = TEST_COND(result != 0);
break;
case Py_LE:
v = TEST_COND(result <= 0);
break;
case Py_GE:
v = TEST_COND(result >= 0);
break;
case Py_LT:
v = TEST_COND(result == -1);
break;
case Py_GT:
v = TEST_COND(result == 1);
break;
default:
PyErr_BadArgument();
return NULL;
}
Py_INCREF(v);
return v;
} | false | false | false | false | false | 0 |
find_components(struct master *master)
{
struct component_match *match = master->match;
size_t i;
int ret = 0;
if (!match) {
/*
* Search the list of components, looking for components that
* belong to this master, and attach them to the master.
*/
return master->ops->add_components(master->dev, master);
}
/*
* Scan the array of match functions and attach
* any components which are found to this master.
*/
for (i = 0; i < match->num; i++) {
ret = component_master_add_child(master,
match->compare[i].fn,
match->compare[i].data);
if (ret)
break;
}
return ret;
} | false | false | false | false | false | 0 |
qcow_create(const char *filename, int64_t total_size,
const char *backing_file, int flags)
{
int fd, header_size, backing_filename_len, l1_size, i, shift;
QCowHeader header;
uint64_t tmp;
fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0644);
if (fd < 0)
return -1;
memset(&header, 0, sizeof(header));
header.magic = cpu_to_be32(QCOW_MAGIC);
header.version = cpu_to_be32(QCOW_VERSION);
header.size = cpu_to_be64(total_size * 512);
header_size = sizeof(header);
backing_filename_len = 0;
if (backing_file) {
header.backing_file_offset = cpu_to_be64(header_size);
backing_filename_len = strlen(backing_file);
header.backing_file_size = cpu_to_be32(backing_filename_len);
header_size += backing_filename_len;
header.mtime = cpu_to_be32(0);
header.cluster_bits = 9; /* 512 byte cluster to avoid copying
unmodifyed sectors */
header.l2_bits = 12; /* 32 KB L2 tables */
} else {
header.cluster_bits = 12; /* 4 KB clusters */
header.l2_bits = 9; /* 4 KB L2 tables */
}
header_size = (header_size + 7) & ~7;
shift = header.cluster_bits + header.l2_bits;
l1_size = ((total_size * 512) + (1LL << shift) - 1) >> shift;
header.l1_table_offset = cpu_to_be64(header_size);
if (flags & BLOCK_FLAG_ENCRYPT) {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_AES);
} else {
header.crypt_method = cpu_to_be32(QCOW_CRYPT_NONE);
}
/* write all the data */
if(write(fd, &header, sizeof(header))!=sizeof(header)) return -1;
if (backing_file) {
if(write(fd, backing_file, backing_filename_len)!=backing_filename_len) return -1;
}
lseek(fd, header_size, SEEK_SET);
tmp = 0;
for(i = 0;i < l1_size; i++) {
if(write(fd, &tmp, sizeof(tmp))!=sizeof(tmp)) return -1;
}
close(fd);
return 0;
} | false | false | false | false | true | 1 |
socket_new_ipcmsg(IPC_Channel* ch, const void* data, int len, void* private)
{
IPC_Message* hdr;
if (ch == NULL || len < 0) {
cl_log(LOG_ERR, "socket_new_ipcmsg:"
" invalid parameter");
return NULL;
}
if (ch->msgpad > MAX_MSGPAD) {
cl_log(LOG_ERR, "socket_new_ipcmsg: too many pads "
"something is wrong");
return NULL;
}
hdr = ipcmsg_new(ch, data, len, private, socket_del_ipcmsg);
if (hdr) ipcmsg_count_allocated ++;
return hdr;
} | false | true | false | false | false | 1 |
cache_load(unsigned char *id, unsigned int *size){
unsigned char *data;
unsigned long fsize;
/* Build cache filename. */
snprintf(cache_filename, PATH_MAX, "%s/%s", cache_directory, id);
/* Try to open file for reading. */
FILE *file = fopen(cache_filename, "r");
if(!file){
DSFYDEBUG("Error opening file in read-mode.\n");
return NULL;
}
/* Determine file size. */
fseek(file, 0, SEEK_END);
fsize = ftell(file);
fseek(file, 0L, SEEK_SET);
/* Allocate memory. */
data = (unsigned char *)malloc(fsize);
if(!data){
DSFYDEBUG("Error allocating memory for cache data.\n");
return NULL;
}
/* Read data into memory. */
if(fread(data, 1, fsize, file) != fsize){
free(data);
DSFYDEBUG("Error reading cache data.\n");
return NULL;
}
fclose(file);
if(size){
*size = fsize;
}
return data;
} | false | false | false | false | true | 1 |
fosfat_symlink (fosfat_t *fosfat, const char *location)
{
fosfat_bd_t *entry;
char *link = NULL;
if (!fosfat || !location)
return NULL;
entry = fosfat_search_insys (fosfat, location, S_BD);
if (entry)
{
link = fosfat_get_link (fosfat, entry);
free (entry);
}
if (!link)
foslog (FOSLOG_ERROR, "target of symlink \"%s\" not found", location);
return link;
} | false | false | false | false | false | 0 |
time_range() {
ANTLR_USE_NAMESPACE(antlr)RefToken tr_name = ANTLR_USE_NAMESPACE(antlr)nullToken;
try { // for error handling
match(TIME_RANGE);
tr_name = LT(1);
match(WORD);
if ( inputState->guessing==0 ) {
#line 1376 "pix.g"
importer->time_range_name = tr_name->getText();
*dbg << "time_range " << tr_name->getText() << " ";
#line 4699 "PIXCfgParser.cpp"
}
}
catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
if( inputState->guessing == 0 ) {
reportError(ex);
recover(ex,_tokenSet_22);
} else {
throw;
}
}
} | false | false | false | false | false | 0 |
browseRootPath()
{
QString dir = QFileDialog::getExistingDirectory(this,
tr("Select Directory"));
if (!dir.isEmpty())
rootPathEdit_->setText(dir);
} | false | false | false | false | false | 0 |
derpol(int n, int k, real_t x, real_t a[])
{
void norderpol(int, int, real_t, real_t []);
int j;
real_t fac;
fac=1.0;
norderpol(n,k,x,a);
for (j=2; j<=k; j++) {
fac *= j;
a[j] *=fac;
}
} | false | false | false | false | false | 0 |
conn_counter_init( Operation *op, void *ctx )
{
slap_counters_t *sc;
void *vsc = NULL;
if ( ldap_pvt_thread_pool_getkey(
ctx, (void *)conn_counter_init, &vsc, NULL ) || !vsc ) {
vsc = ch_malloc( sizeof( slap_counters_t ));
sc = vsc;
slap_counters_init( sc );
ldap_pvt_thread_pool_setkey( ctx, (void*)conn_counter_init, vsc,
conn_counter_destroy, NULL, NULL );
ldap_pvt_thread_mutex_lock( &slap_counters.sc_mutex );
sc->sc_next = slap_counters.sc_next;
slap_counters.sc_next = sc;
ldap_pvt_thread_mutex_unlock( &slap_counters.sc_mutex );
}
op->o_counters = vsc;
} | false | false | false | false | false | 0 |
getMeanChildLogOdds() const{
double mean = 0;
char c = 0;
for (unsigned int i=0; i<8; i++) {
if (childExists(i)) {
mean += getChild(i)->getOccupancy();
c++;
}
}
if (c) mean /= (double) c;
return log(mean/(1-mean));
} | false | false | false | false | false | 0 |
is_comment(const char *buf)
{
return ((strspn(buf, " #") > 0) &&
(strchr(buf, '#') != NULL) &&
strncmp(buf, "# ignore ", strlen("# ignore")));
} | false | false | false | false | false | 0 |
getDefaultMonthInYear(int32_t eyear)
{
int32_t era = internalGetEra();
// TODO do we assume we can trust 'era'? What if it is denormalized?
int32_t month = 0;
// Find out if we are at the edge of an era
if(eyear == kEraInfo[era].year) {
// Yes, we're in the first year of this era.
return kEraInfo[era].month-1;
}
return month;
} | false | false | false | false | false | 0 |
reload_logger(int rotate, const char *altconf)
{
int queue_rotate = rotate;
struct logchannel *f;
int res = 0;
AST_RWLIST_WRLOCK(&logchannels);
if (qlog) {
if (rotate < 0) {
/* Check filesize - this one typically doesn't need an auto-rotate */
if (ftello(qlog) > 0x40000000) { /* Arbitrarily, 1 GB */
fclose(qlog);
qlog = NULL;
} else {
queue_rotate = 0;
}
} else {
fclose(qlog);
qlog = NULL;
}
} else {
queue_rotate = 0;
}
ast_mkdir(ast_config_AST_LOG_DIR, 0777);
AST_RWLIST_TRAVERSE(&logchannels, f, list) {
if (f->disabled) {
f->disabled = 0; /* Re-enable logging at reload */
/*** DOCUMENTATION
<managerEventInstance>
<synopsis>Raised when a logging channel is re-enabled after a reload operation.</synopsis>
<syntax>
<parameter name="Channel">
<para>The name of the logging channel.</para>
</parameter>
</syntax>
</managerEventInstance>
***/
manager_event(EVENT_FLAG_SYSTEM, "LogChannel", "Channel: %s\r\nEnabled: Yes\r\n", f->filename);
}
if (f->fileptr && (f->fileptr != stdout) && (f->fileptr != stderr)) {
int rotate_this = 0;
if (ftello(f->fileptr) > 0x40000000) { /* Arbitrarily, 1 GB */
/* Be more proactive about rotating massive log files */
rotate_this = 1;
}
fclose(f->fileptr); /* Close file */
f->fileptr = NULL;
if (rotate || rotate_this) {
rotate_file(f->filename);
}
}
}
filesize_reload_needed = 0;
init_logger_chain(1 /* locked */, altconf);
ast_unload_realtime("queue_log");
if (logfiles.queue_log) {
res = logger_queue_restart(queue_rotate);
AST_RWLIST_UNLOCK(&logchannels);
ast_queue_log("NONE", "NONE", "NONE", "CONFIGRELOAD", "%s", "");
ast_verb(1, "Asterisk Queue Logger restarted\n");
} else {
AST_RWLIST_UNLOCK(&logchannels);
}
return res;
} | false | false | false | false | true | 1 |
IntrUnbRecName (
UInt rnam )
{
Obj record; /* record, left operand */
/* ignore or code */
if ( IntrReturning > 0 ) { return; }
if ( IntrIgnoring > 0 ) { return; }
if ( IntrCoding > 0 ) { CodeUnbRecName( rnam ); return; }
/* get the record (checking is done by 'UNB_REC') */
record = PopObj();
/* assign the right hand side to the element of the record */
UNB_REC( record, rnam );
/* push void */
PushVoidObj();
} | false | false | false | false | false | 0 |
zswap_frontswap_load(unsigned type, pgoff_t offset,
struct page *page)
{
struct zswap_tree *tree = zswap_trees[type];
struct zswap_entry *entry;
struct crypto_comp *tfm;
u8 *src, *dst;
unsigned int dlen;
int ret;
/* find */
spin_lock(&tree->lock);
entry = zswap_entry_find_get(&tree->rbroot, offset);
if (!entry) {
/* entry was written back */
spin_unlock(&tree->lock);
return -1;
}
spin_unlock(&tree->lock);
/* decompress */
dlen = PAGE_SIZE;
src = (u8 *)zpool_map_handle(entry->pool->zpool, entry->handle,
ZPOOL_MM_RO) + sizeof(struct zswap_header);
dst = kmap_atomic(page);
tfm = *get_cpu_ptr(entry->pool->tfm);
ret = crypto_comp_decompress(tfm, src, entry->length, dst, &dlen);
put_cpu_ptr(entry->pool->tfm);
kunmap_atomic(dst);
zpool_unmap_handle(entry->pool->zpool, entry->handle);
BUG_ON(ret);
spin_lock(&tree->lock);
zswap_entry_put(tree, entry);
spin_unlock(&tree->lock);
return 0;
} | false | false | false | false | false | 0 |
failover_message_dereference (failover_message_t **mp,
const char *file, int line)
{
failover_message_t *m;
m = (*mp);
m -> refcnt--;
if (m -> refcnt == 0) {
if (m -> next)
failover_message_dereference (&m -> next,
file, line);
if (m -> chaddr.data)
dfree (m -> chaddr.data, file, line);
if (m -> client_identifier.data)
dfree (m -> client_identifier.data, file, line);
if (m -> hba.data)
dfree (m -> hba.data, file, line);
if (m -> message.data)
dfree (m -> message.data, file, line);
if (m -> reply_options.data)
dfree (m -> reply_options.data, file, line);
if (m -> request_options.data)
dfree (m -> request_options.data, file, line);
if (m -> vendor_class.data)
dfree (m -> vendor_class.data, file, line);
if (m -> vendor_options.data)
dfree (m -> vendor_options.data, file, line);
if (m -> ddns.data)
dfree (m -> ddns.data, file, line);
dfree (*mp, file, line);
}
*mp = 0;
return ISC_R_SUCCESS;
} | false | false | false | false | false | 0 |
Compile(v8::Handle<String> source,
v8::ScriptOrigin* origin,
v8::ScriptData* pre_data,
v8::Handle<String> script_data) {
ON_BAILOUT("v8::Script::Compile()", return Local<Script>());
LOG_API("Script::Compile");
ENTER_V8;
Local<Script> generic = New(source, origin, pre_data, script_data);
if (generic.IsEmpty())
return generic;
i::Handle<i::Object> obj = Utils::OpenHandle(*generic);
i::Handle<i::SharedFunctionInfo> function =
i::Handle<i::SharedFunctionInfo>(i::SharedFunctionInfo::cast(*obj));
i::Handle<i::JSFunction> result =
i::Factory::NewFunctionFromSharedFunctionInfo(function,
i::Top::global_context());
return Local<Script>(ToApi<Script>(result));
} | false | false | false | false | false | 0 |
vecvalue( list, index )
register sptr list;
int index;
{
register int offset, i;
register nptr *n;
for( ; list != NULL; list = list->next )
{
offset = list->vsize * (index % list->nvalues);
n = (list->which == 0) ? &list->ptr.n : list->ptr.b->nodes;
for( i = 0; i < list->vsize; i++ )
(void) setin( *n++, &list->values[ offset++ ] );
}
} | false | false | false | false | true | 1 |
stop()
{
// Not running
if (!started) {
return;
}
//---Stop process timer
end_process_time = getProcessTime();
//---Stop wall clock timer
end_wall_time = getWallClockTime();
stopped = 1;
} | false | false | false | false | false | 0 |
ListDraw(List *list)
{
List *l;
GeomMakePath(list, 'L', path, pathlen);
list->geomflags &= ~GEOM_ALPHA;
for (l = list; l != NULL; l = l->cdr) {
int lpathlen = pathlen+1;
char *lpath = alloca(lpathlen+1);
memcpy(lpath, path, pathlen);
lpath[lpathlen-1] = 'l';
lpath[lpathlen] = '\0';
if (l->car) {
l->car->ppath = lpath;
l->car->ppathlen = lpathlen;
GeomDraw(l->car);
if (l->car->geomflags & GEOM_ALPHA) {
list->geomflags |= GEOM_ALPHA;
}
}
path = lpath;
pathlen = lpathlen;
}
return list;
} | false | false | false | false | false | 0 |
setDateTimeFromCalendar(const Locale& locale, UErrorCode& status) {
const UChar *resStr;
int32_t resStrLen = 0;
Calendar* fCalendar = Calendar::createInstance(locale, status);
CalendarData calData(locale, fCalendar?fCalendar->getType():NULL, status);
UResourceBundle *dateTimePatterns = calData.getByKey(DT_DateTimePatternsTag, status);
if (U_FAILURE(status)) return;
if (ures_getSize(dateTimePatterns) <= DateFormat::kDateTime)
{
status = U_INVALID_FORMAT_ERROR;
return;
}
resStr = ures_getStringByIndex(dateTimePatterns, (int32_t)DateFormat::kDateTime, &resStrLen, &status);
setDateTimeFormat(UnicodeString(TRUE, resStr, resStrLen));
delete fCalendar;
} | false | false | false | false | false | 0 |
mark_exclude_vector(int loc, int len, int *vmark, int vlen)
{
int i;
#ifdef DEBUG
printf("delmark: %d-%d\n",loc, loc+len-1);
#endif
for (i=0;i<len;i++) {
#ifdef DEBUG
if (loc + i >= vlen) {
printf("delmark buffer exceeded!!\n");
exit(0);
}
#endif
vmark[loc+i] = 1;
}
#ifdef DEBUG
printf("now :");
for (i=0;i<vlen;i++) {
if (vmark[i] == 1) {
printf("-");
} else {
printf("O");
}
}
printf("\n");
#endif
} | false | false | false | false | false | 0 |
filebrowser_add_files (GtkFileChooser * browser, GSList * files,
bool_t play)
{
Index * list = index_new ();
for (GSList * node = files; node; node = node->next)
index_append (list, str_get (node->data));
if (play)
aud_drct_pl_open_list (list);
else
aud_drct_pl_add_list (list, -1);
char * path = gtk_file_chooser_get_current_folder (browser);
if (path)
{
aud_set_string ("audgui", "filesel_path", path);
g_free (path);
}
} | false | false | false | false | false | 0 |
HPDF_FreeCCITTFax3(struct _HPDF_CCITT_Data *pData)
{
if(pData->tif_data!=NULL) {
HPDF_Fax3CodecState* esp=pData->tif_data;
if(esp->refline!=NULL) {
free(esp->refline);
esp->refline=NULL;
}
if(esp->runs!=NULL) {
free(esp->runs);
esp->runs=NULL;
}
free(pData->tif_data);
pData->tif_data=NULL;
}
if(pData->tif_rawdata!=NULL) {
free(pData->tif_rawdata);
pData->tif_rawdata=NULL;
}
return HPDF_OK;
} | false | false | false | false | false | 0 |
stbl_AppendDegradation(GF_SampleTableBox *stbl, u16 DegradationPriority)
{
if (!stbl->DegradationPriority) stbl->DegradationPriority = (GF_DegradationPriorityBox *) gf_isom_box_new(GF_ISOM_BOX_TYPE_STDP);
stbl->DegradationPriority->priorities = (u16 *)gf_realloc(stbl->DegradationPriority->priorities, sizeof(u16) * stbl->SampleSize->sampleCount);
stbl->DegradationPriority->priorities[stbl->SampleSize->sampleCount-1] = DegradationPriority;
stbl->DegradationPriority->nb_entries = stbl->SampleSize->sampleCount;
} | false | false | false | false | false | 0 |
cpl_gaussian_eval_2d(const cpl_array * self, double x, double y)
{
cpl_errorstate prestate = cpl_errorstate_get();
const double B = cpl_array_get_double(self, 0, NULL);
const double A = cpl_array_get_double(self, 1, NULL);
const double R = cpl_array_get_double(self, 2, NULL);
const double M_x = cpl_array_get_double(self, 3, NULL);
const double M_y = cpl_array_get_double(self, 4, NULL);
const double S_x = cpl_array_get_double(self, 5, NULL);
const double S_y = cpl_array_get_double(self, 6, NULL);
double value = 0.0;
if (!cpl_errorstate_is_equal(prestate)) {
(void)cpl_error_set_where_();
} else if (cpl_array_get_size(self) != 7) {
(void)cpl_error_set_(CPL_ERROR_ILLEGAL_INPUT);
} else if (fabs(R) < 1.0 && S_x != 0.0 && S_y != 0.0) {
const double x_n = (x - M_x) / S_x;
const double y_n = (y - M_y) / S_y;
value = B + A / (CPL_MATH_2PI * S_x * S_y * sqrt(1 - R * R)) *
exp(-0.5 / (1 - R * R) * ( x_n * x_n + y_n * y_n
- 2.0 * R * x_n * y_n));
} else if (fabs(R) > 1.0) {
(void)cpl_error_set_message_(CPL_ERROR_ILLEGAL_OUTPUT,
"fabs(R=%g) > 1", R);
} else {
(void)cpl_error_set_message_(CPL_ERROR_DIVISION_BY_ZERO,
"R=%g. Sigma=(%g, %g)", R, S_x, S_y);
}
return value;
} | false | false | false | false | false | 0 |
snd_sonicvibes_out(struct sonicvibes * sonic,
unsigned char reg,
unsigned char value)
{
unsigned long flags;
spin_lock_irqsave(&sonic->reg_lock, flags);
outb(reg, SV_REG(sonic, INDEX));
udelay(10);
outb(value, SV_REG(sonic, DATA));
udelay(10);
spin_unlock_irqrestore(&sonic->reg_lock, flags);
} | false | false | false | false | false | 0 |
j2k_add_tlmarker( int tileno, opj_codestream_info_t *cstr_info, unsigned short int type, int pos, int len) {
opj_marker_info_t *marker;
if (!cstr_info)
return;
/* expand the list? */
if ((cstr_info->tile[tileno].marknum + 1) > cstr_info->tile[tileno].maxmarknum) {
cstr_info->tile[tileno].maxmarknum = 100 + (int) ((float) cstr_info->tile[tileno].maxmarknum * 1.0F);
cstr_info->tile[tileno].marker = (opj_marker_info_t*)opj_realloc(cstr_info->tile[tileno].marker, cstr_info->maxmarknum);
}
marker = &(cstr_info->tile[tileno].marker[cstr_info->tile[tileno].marknum]);
/* add the marker */
marker->type = type;
marker->pos = pos;
marker->len = len;
cstr_info->tile[tileno].marknum++;
} | false | false | false | false | false | 0 |
AcpiExOpcode_1A_1T_0R (
ACPI_WALK_STATE *WalkState)
{
ACPI_STATUS Status = AE_OK;
ACPI_OPERAND_OBJECT **Operand = &WalkState->Operands[0];
ACPI_FUNCTION_TRACE_STR (ExOpcode_1A_1T_0R,
AcpiPsGetOpcodeName (WalkState->Opcode));
/* Examine the AML opcode */
switch (WalkState->Opcode)
{
case AML_LOAD_OP:
Status = AcpiExLoadOp (Operand[0], Operand[1], WalkState);
break;
default: /* Unknown opcode */
ACPI_ERROR ((AE_INFO, "Unknown AML opcode 0x%X",
WalkState->Opcode));
Status = AE_AML_BAD_OPCODE;
goto Cleanup;
}
Cleanup:
return_ACPI_STATUS (Status);
} | false | false | false | false | false | 0 |
TigerDigest(unsigned char *digest_str, unsigned int digest_len, PHP_TIGER_CTX *context)
{
unsigned int i;
for (i = 0; i < digest_len; ++i) {
digest_str[i] = (unsigned char) ((context->state[i/8] >> (8 * (i%8))) & 0xff);
}
} | false | false | false | false | false | 0 |
_backup_audio_convert_orc_pack_double_s16_swap (OrcExecutor * ORC_RESTRICT ex)
{
int i;
int n = ex->n;
orc_union16 * ORC_RESTRICT ptr0;
const orc_union64 * ORC_RESTRICT ptr4;
orc_union64 var34;
orc_union16 var35;
orc_union32 var36;
orc_union32 var37;
orc_union16 var38;
ptr0 = (orc_union16 *)ex->arrays[0];
ptr4 = (orc_union64 *)ex->arrays[4];
for (i = 0; i < n; i++) {
/* 0: loadq */
var34 = ptr4[i];
/* 1: convdl */
{
int tmp;
tmp = var34.f;
if (tmp == 0x80000000 && !(var34.i & ORC_UINT64_C(0x8000000000000000))) tmp = 0x7fffffff;
var36.i = tmp;
}
/* 2: shrsl */
var37.i = var36.i >> ex->params[24];
/* 3: convlw */
var38.i = var37.i;
/* 4: swapw */
var35.i = ORC_SWAP_W(var38.i);
/* 5: storew */
ptr0[i] = var35;
}
} | false | false | false | false | false | 0 |
do_dump(int op)
{
char buf[DLMC_DUMP_SIZE];
memset(buf, 0, sizeof(buf));
if (op == OP_DUMP)
dlmc_dump_debug(buf);
else if (op == OP_DUMP_CONFIG)
dlmc_dump_config(buf);
buf[DLMC_DUMP_SIZE-1] = '\0';
do_write(STDOUT_FILENO, buf, strlen(buf));
printf("\n");
} | false | false | false | false | false | 0 |
free_substream(struct snd_usb_substream *subs)
{
struct audioformat *fp, *n;
if (!subs->num_formats)
return; /* not initialized */
list_for_each_entry_safe(fp, n, &subs->fmt_list, list) {
kfree(fp->rate_table);
kfree(fp->chmap);
kfree(fp);
}
kfree(subs->rate_list.list);
} | false | false | false | false | false | 0 |
_dxfFloatDataBoundingBoxDiagonal(float *data, int n_data, int data_dim)
{
float diagonal = 0.0;
float
*cur_data = data,
*bbox = NULL;
register int i,j;
bbox = (float *) DXAllocateZero (2 * data_dim * sizeof (float));
if (!bbox) goto error;
/* initialize the bounding box to the first array values */
/* the bbox is organized as follows
bbox[0] MININUM
bbox[1] DATA
VALUES
FOR
EACH
bbox[data_dim-1] COMPONENT
bbox[data_dim] MAXIMUM
bbox[data_dim+1] DATA
VALUES
FOR
EACH
bbox[2*data_dim-1] COMPONENT
*/
for(j=0;j<data_dim;j++)
{
bbox[j] = bbox[j+data_dim] = data[j];
}
/* update the bounding box if data values are smaller than the minimum or larger than the maximum */
cur_data = data + data_dim;
for (i=1;i<n_data;i++,cur_data+=data_dim)
for(j=0;j<data_dim;j++)
{
if (cur_data[j] < bbox[j]) bbox[j] = cur_data[j];
else if (cur_data[j] > bbox[j+data_dim]) bbox[j+data_dim] = cur_data[j];
}
/* once the bounding box is complete, compute its diameter. If the dimension of the data is
one, we just compute max-min and thus avoid the computation of squares and of a square root */
if (data_dim == 1) diagonal = bbox[1] - bbox[0];
else
{
double
one_coordinate,
double_diagonal = 0.0;
for (j=0;j<data_dim;j++)
{
one_coordinate = bbox[j+data_dim] - bbox[j];
double_diagonal += one_coordinate * one_coordinate;
}
if (double_diagonal>0.0) double_diagonal = sqrt(double_diagonal);
diagonal = (float) double_diagonal;
}
DXFree((Pointer)bbox);
return diagonal;
error:
DXFree((Pointer)bbox);
return 0.0;
} | false | false | false | false | false | 0 |
CopyAndAdvance(char **destPtr, char **srcPtr, int n)
{
char *dest = *destPtr;
char *src = *srcPtr;
int i;
for (i = 0; i < n; i++)
*dest++ = *src++;
*destPtr = dest;
*srcPtr = src;
} | false | false | false | false | false | 0 |
marshal_VOID__MINIOBJECT (GClosure * closure, GValue * return_value,
guint n_param_values, const GValue * param_values, gpointer invocation_hint,
gpointer marshal_data)
{
typedef void (*marshalfunc_VOID__MINIOBJECT) (gpointer obj, gpointer arg1,
gpointer data2);
register marshalfunc_VOID__MINIOBJECT callback;
register GCClosure *cc = (GCClosure *) closure;
register gpointer data1, data2;
g_return_if_fail (n_param_values == 2);
if (G_CCLOSURE_SWAP_DATA (closure)) {
data1 = closure->data;
data2 = g_value_peek_pointer (param_values + 0);
} else {
data1 = g_value_peek_pointer (param_values + 0);
data2 = closure->data;
}
callback =
(marshalfunc_VOID__MINIOBJECT) (marshal_data ? marshal_data :
cc->callback);
callback (data1, gst_value_get_mini_object (param_values + 1), data2);
} | false | false | false | false | false | 0 |
suspend(bool force) const
{
if(!mSystemSession->suspend(force))
throwError("SuspendError", tr("Suspend failed"));
return thisObject();
} | false | false | false | false | false | 0 |
getClones(UT_GenericVector<XAP_Frame*> *pvClonesCopy, XAP_Frame * pFrame)
{
UT_ASSERT(pvClonesCopy);
UT_return_val_if_fail(pFrame,false);
UT_ASSERT(pFrame->getViewNumber() > 0);
// locate vector of this frame's clones
CloneMap::const_iterator iter = m_hashClones.find(pFrame->getViewKey());
UT_GenericVector<XAP_Frame*> * pvClones = NULL;
if (iter != m_hashClones.end()) {
pvClones = iter->second;
}
UT_ASSERT(pvClones);
return pvClonesCopy->copy(pvClones);
} | false | false | false | false | false | 0 |
ParseEditorChunk()
{
ASSIMP_3DS_BEGIN_CHUNK();
// get chunk type
switch (chunk.Flag)
{
case Discreet3DS::CHUNK_OBJMESH:
ParseObjectChunk();
break;
// NOTE: In several documentations in the internet this
// chunk appears at different locations
case Discreet3DS::CHUNK_KEYFRAMER:
ParseKeyframeChunk();
break;
case Discreet3DS::CHUNK_VERSION:
{
// print the version number
char buff[10];
ASSIMP_itoa10(buff,stream->GetI2());
DefaultLogger::get()->info(std::string("3DS file format version: ") + buff);
}
break;
};
ASSIMP_3DS_END_CHUNK();
} | false | false | false | false | false | 0 |
detach_conf(aClient *cptr, aConfItem *aconf)
{
Reg Link **lp, *tmp;
aConfItem **aconf2,*aconf3;
lp = &(cptr->confs);
while (*lp)
{
if ((*lp)->value.aconf == aconf)
{
if ((aconf) && (Class(aconf)))
{
if (aconf->status & CONF_CLIENT_MASK)
{
if (ConfLinks(aconf) > 0)
--ConfLinks(aconf);
#ifdef ENABLE_CIDR_LIMITS
if ((aconf->status & CONF_CLIENT))
remove_cidr_limit(cptr, aconf);
#endif
}
if (ConfMaxLinks(aconf) == -1 &&
ConfLinks(aconf) == 0)
{
free_class(Class(aconf));
Class(aconf) = NULL;
}
}
if (aconf && --aconf->clients <= 0 && IsIllegal(aconf))
{
/* Remove the conf entry from the Conf linked list */
for (aconf2 = &conf; (aconf3 = *aconf2); )
{
if (aconf3 == aconf)
{
*aconf2 = aconf3->next;
aconf3->next = NULL;
free_conf(aconf);
}
else
{
aconf2 = &aconf3->next;
}
}
}
tmp = *lp;
*lp = tmp->next;
free_link(tmp);
istat.is_conflink--;
return 0;
}
else
lp = &((*lp)->next);
}
return -1;
} | false | false | false | false | false | 0 |
calc_attenuation_trad(int att_cB)
{
att_cB = (int)(att_cB / awe_option.atten_sense);
if (att_cB < 0) return 0;
else if (att_cB > 956) return 255;
return (unsigned char)(att_cB * 8 / 30);
} | false | false | false | false | false | 0 |
isl_upoly_pow(__isl_take struct isl_upoly *up,
unsigned power)
{
struct isl_upoly *res;
if (!up)
return NULL;
if (power == 1)
return up;
if (power % 2)
res = isl_upoly_copy(up);
else
res = isl_upoly_one(up->ctx);
while (power >>= 1) {
up = isl_upoly_mul(up, isl_upoly_copy(up));
if (power % 2)
res = isl_upoly_mul(res, isl_upoly_copy(up));
}
isl_upoly_free(up);
return res;
} | false | false | false | false | false | 0 |
gst_static_caps_get (GstStaticCaps * static_caps)
{
GstCaps *caps;
g_return_val_if_fail (static_caps != NULL, NULL);
caps = (GstCaps *) static_caps;
/* refcount is 0 when we need to convert */
if (G_UNLIKELY (g_atomic_int_get (&caps->refcount) == 0)) {
const char *string;
GstCaps temp;
G_LOCK (static_caps_lock);
/* check if other thread already updated */
if (G_UNLIKELY (g_atomic_int_get (&caps->refcount) > 0))
goto done;
string = static_caps->string;
if (G_UNLIKELY (string == NULL))
goto no_string;
GST_CAT_TRACE (GST_CAT_CAPS, "creating %p", static_caps);
/* we construct the caps on the stack, then copy over the struct into our
* real caps, refcount last. We do this because we must leave the refcount
* of the result caps to 0 so that other threads don't run away with the
* caps while we are constructing it. */
temp.type = GST_TYPE_CAPS;
temp.flags = GST_CAPS_FLAGS_NONE;
temp.structs = g_ptr_array_new ();
/* initialize the caps to a refcount of 1 so the caps can be writable for
* the next statement */
temp.refcount = 1;
/* convert to string */
if (G_UNLIKELY (!gst_caps_from_string_inplace (&temp, string)))
g_critical ("Could not convert static caps \"%s\"", string);
/* now copy stuff over to the real caps. */
caps->type = temp.type;
caps->flags = temp.flags;
caps->structs = temp.structs;
/* and bump the refcount so other threads can now read */
g_atomic_int_set (&caps->refcount, 1);
GST_CAT_TRACE (GST_CAT_CAPS, "created %p", static_caps);
done:
G_UNLOCK (static_caps_lock);
}
/* ref the caps, makes it not writable */
gst_caps_ref (caps);
return caps;
/* ERRORS */
no_string:
{
G_UNLOCK (static_caps_lock);
g_warning ("static caps %p string is NULL", static_caps);
return NULL;
}
} | false | false | false | false | false | 0 |
krb5_create_checksum(krb5_context context,
krb5_crypto crypto,
krb5_key_usage usage,
int type,
void *data,
size_t len,
Checksum *result)
{
struct _krb5_checksum_type *ct = NULL;
unsigned keyusage;
/* type 0 -> pick from crypto */
if (type) {
ct = _krb5_find_checksum(type);
} else if (crypto) {
ct = crypto->et->keyed_checksum;
if (ct == NULL)
ct = crypto->et->checksum;
}
if(ct == NULL) {
krb5_set_error_message (context, KRB5_PROG_SUMTYPE_NOSUPP,
N_("checksum type %d not supported", ""),
type);
return KRB5_PROG_SUMTYPE_NOSUPP;
}
if (arcfour_checksum_p(ct, crypto)) {
keyusage = usage;
_krb5_usage2arcfour(context, &keyusage);
} else
keyusage = CHECKSUM_USAGE(usage);
return create_checksum(context, ct, crypto, keyusage,
data, len, result);
} | false | false | false | false | false | 0 |
createTextElement(const QString &ns, const QString &tagName, const QString &text)
{
QDomElement e = d->s->doc().createElementNS(ns, tagName);
e.appendChild(d->s->doc().createTextNode(text));
return e;
} | false | false | false | false | false | 0 |
tm_model_track_changed(GtkTreeModel *model, GtkTreePath *path, GtkTreeIter *iter, gpointer data) {
Track *track;
gtk_tree_model_get(model, iter, READOUT_COL, &track, -1);
if (track == (Track *) data) {
gtk_tree_model_row_changed(model, path, iter);
return TRUE;
}
return FALSE;
} | false | false | false | false | false | 0 |
_e_wid_focus_hook(Evas_Object *obj)
{
E_Widget_Data *wd = NULL;
wd = e_widget_data_get(obj);
if (e_widget_focus_get(obj))
{
edje_object_signal_emit(e_scrollframe_edje_object_get(wd->o_scroll),
"e,state,focused", "e");
evas_object_focus_set(wd->o_fm, 1);
}
else
{
edje_object_signal_emit(e_scrollframe_edje_object_get(wd->o_scroll),
"e,state,unfocused", "e");
evas_object_focus_set(wd->o_fm, 0);
}
} | false | false | false | false | false | 0 |
clean_supernodes(S)
struct linsys *S;
{ struct supernode *s;
int i,j,k,m;
int n;
for ( n = superstart ; n >= 0 ; n = s->next )
{ s = slist + n;
for ( i=0,j=0 ; i < s->rcount ; i++ )
{ int rnum = INT(s->rlist)[i];
while ( REG(rnum)->merged != rnum ) rnum = REG(rnum)->merged;
if ( REG(rnum)->timestamp > old_rtimestamp )
s->rtimestamp = REG(rnum)->timestamp; /* mark as affected */
for ( k = 0 ; k < j ; k++ )
{ if ( INT(s->rlist)[k] == rnum ) break; /* duplicate */
if ( INT(s->rlist)[k] > rnum ) /* insert */
{ for ( m = j ; m > k ; m-- ) INT(s->rlist)[m] = INT(s->rlist)[m-1];
INT(s->rlist)[k] = rnum;
j++;
break;
}
}
if ( k == j ) { INT(s->rlist)[j++] = rnum; }
}
s->rcount = j;
}
} | false | false | false | false | false | 0 |
tun_newlink(unsigned flags, unsigned change, void *user_data)
{
int index = GPOINTER_TO_INT(user_data);
if ((newlink_flags & IFF_UP) == (flags & IFF_UP)) {
newlink_flags = flags;
return;
}
if (flags & IFF_UP) {
/*
* We try to verify that connectivity through tunnel works ok.
*/
if (newlink_timeout_id > 0) {
g_source_remove(newlink_timeout_id);
newlink_timeout_id = 0;
}
web = g_web_new(index);
if (web == NULL) {
tunnel_destroy();
return;
}
g_web_set_accept(web, NULL);
g_web_set_user_agent(web, "ConnMan/%s", VERSION);
g_web_set_close_connection(web, TRUE);
if (getenv("CONNMAN_WEB_DEBUG"))
g_web_set_debug(web, web_debug, "6to4");
web_request_id = g_web_request_get(web, STATUS_URL,
web_result, NULL, NULL);
newlink_timeout(NULL);
}
newlink_flags = flags;
} | false | false | false | false | true | 1 |
encodeBlock(const int16_t *decoded, uint8_t *encoded)
{
choosePredictorForBlock(decoded);
int channelCount = m_track->f.channelCount;
// Encode predictor.
for (int c=0; c<channelCount; c++)
*encoded++ = m_state[c].predictorIndex;
// Encode delta.
for (int c=0; c<channelCount; c++)
{
*encoded++ = m_state[c].delta & 0xff;
*encoded++ = m_state[c].delta >> 8;
}
// Enccode first two samples.
for (int c=0; c<channelCount; c++)
m_state[c].sample2 = *decoded++;
for (int c=0; c<channelCount; c++)
m_state[c].sample1 = *decoded++;
for (int c=0; c<channelCount; c++)
{
*encoded++ = m_state[c].sample1 & 0xff;
*encoded++ = m_state[c].sample1 >> 8;
}
for (int c=0; c<channelCount; c++)
{
*encoded++ = m_state[c].sample2 & 0xff;
*encoded++ = m_state[c].sample2 >> 8;
}
ms_adpcm_state *state[2] = { &m_state[0], &m_state[channelCount - 1] };
const int16_t *coefficient[2] =
{
m_coefficients[state[0]->predictorIndex],
m_coefficients[state[1]->predictorIndex]
};
int samplesRemaining = (m_framesPerPacket - 2) * m_track->f.channelCount;
while (samplesRemaining > 0)
{
uint8_t code1 = encodeSample(*state[0], *decoded++, coefficient[0]);
uint8_t code2 = encodeSample(*state[1], *decoded++, coefficient[1]);
*encoded++ = (code1 << 4) | code2;
samplesRemaining -= 2;
}
return m_bytesPerPacket;
} | 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.