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 |
|---|---|---|---|---|---|---|
iwl_dbgfs_bt_tx_prio_write(struct iwl_mvm *mvm, char *buf,
size_t count, loff_t *ppos)
{
u32 bt_tx_prio;
if (sscanf(buf, "%u", &bt_tx_prio) != 1)
return -EINVAL;
if (bt_tx_prio > 4)
return -EINVAL;
mvm->bt_tx_prio = bt_tx_prio;
return count;
} | false | false | false | false | false | 0 |
read_pixel_shiftreg(offs_t offset)
{
if (state.config->to_shiftreg)
state.config->to_shiftreg(offset, &state.shiftreg[0]);
#if 0
else
logerror("To ShiftReg function not set. PC = %08X\n", PC);
#endif
return state.shiftreg[0];
} | false | false | false | false | false | 0 |
onDragEnabledChanged(WindowEventArgs& e)
{
fireEvent(EventDragEnabledChanged, e, EventNamespace);
// abort current drag operation if dragging gets disabled part way through
if (!d_draggingEnabled && d_dragging)
{
releaseInput();
}
} | false | false | false | false | false | 0 |
regcache_read(struct regmap *map,
unsigned int reg, unsigned int *value)
{
int ret;
if (map->cache_type == REGCACHE_NONE)
return -ENOSYS;
BUG_ON(!map->cache_ops);
if (!regmap_volatile(map, reg)) {
ret = map->cache_ops->read(map, reg, value);
if (ret == 0)
trace_regmap_reg_read_cache(map, reg, *value);
return ret;
}
return -EINVAL;
} | false | false | false | false | false | 0 |
_update_tags_string (FrogrPicture *self)
{
FrogrPicturePrivate *priv = FROGR_PICTURE_GET_PRIVATE (self);
/* Reset previous tags string */
g_free (priv->tags_string);
priv->tags_string = NULL;
/* Set the tags_string value, if needed */
if (priv->tags_list != NULL)
{
GSList *item = NULL;
gchar *new_str = NULL;
gchar *tmp_str = NULL;
/* Init new_string to first item */
new_str = g_strdup ((gchar *)priv->tags_list->data);
/* Continue with the remaining tags */
for (item = g_slist_next (priv->tags_list);
item != NULL;
item = g_slist_next (item))
{
tmp_str = g_strconcat (new_str, " ", (gchar *)item->data, NULL);
g_free (new_str);
/* Update pointer */
new_str = tmp_str;
}
/* Store final result */
priv->tags_string = new_str;
}
} | false | false | false | false | false | 0 |
ExtractChallenge(tChallenge *c, char *String)
{
char *s, *e, *Token, *Value;
int len;
memset(c, 0, sizeof(tChallenge));
Token = (char*) pal_malloc( pal_strlen(String)+1 );
Value = (char*) pal_malloc( pal_strlen(String)+1 );
*Token=*Value=0;
for(s=e=String; ; e++) {
if(*e== ',' || *e == '\r' || *e == '\n' || *e==0) {
if(s!=e) {
if(*Token && (*Value==0)) {
len = (int)((char *)e-(char *)s);
/* Chop the quotes */
if((*s == '"') && len) { s++; len--; }
if((s[len-1] == '"') && len) len--;
if(len) memcpy(Value, s, len);
Value[len] = 0;
}
if(*Token && *Value) {
InsertInChallegeStruct(c, Token,Value);
*Value = *Token = 0;
}
}
if(*e == 0) break;
s = ++e;
}
if((*e=='=' || *e== ',' || *e == '\r' || *e == '\n' || *e==0) && (*Token == 0) && (e != s)) {
len = (int)((char *)e-(char *)s);
memcpy(Token, s, len);
Token[len] = 0;
if(*e == 0) break;
s = ++e;
}
}
pal_free( Token );
pal_free( Value );
} | false | true | true | false | false | 1 |
raw_array(const redisReply *r, size_t *sz) {
unsigned int i;
char *ret, *p;
/* compute size */
*sz = 0;
*sz += 1 + integer_length(r->elements) + 2;
for(i = 0; i < r->elements; ++i) {
redisReply *e = r->element[i];
switch(e->type) {
case REDIS_REPLY_STRING:
*sz += 1 + integer_length(e->len) + 2
+ e->len + 2;
break;
case REDIS_REPLY_INTEGER:
*sz += 1 + integer_length(integer_length(e->integer)) + 2
+ integer_length(e->integer) + 2;
break;
}
}
/* allocate */
p = ret = malloc(1+*sz);
p += sprintf(p, "*%zd\r\n", r->elements);
/* copy */
for(i = 0; i < r->elements; ++i) {
redisReply *e = r->element[i];
switch(e->type) {
case REDIS_REPLY_STRING:
p += sprintf(p, "$%d\r\n", e->len);
memcpy(p, e->str, e->len);
p += e->len;
*p = '\r';
p++;
*p = '\n';
p++;
break;
case REDIS_REPLY_INTEGER:
p += sprintf(p, "$%d\r\n%lld\r\n",
integer_length(e->integer), e->integer);
break;
}
}
return ret;
} | false | false | false | false | false | 0 |
conf_ok(GHashTable *table)
{
if (!table){
if (gcomprisBoard)
pause_board(FALSE);
return;
}
g_hash_table_foreach(table, (GHFunc) save_table, NULL);
if (gcomprisBoard){
GHashTable *config;
if (profile_conf)
config = gc_db_get_board_conf();
else
config = table;
if (strcmp(gcomprisBoard->name, "imagename")==0){
gc_locale_set(g_hash_table_lookup( config, "locale"));
}
gchar *drag_mode_str = g_hash_table_lookup( config, "drag_mode");
if (drag_mode_str && (strcmp (drag_mode_str, "NULL") != 0))
drag_mode = (gint ) g_ascii_strtod(drag_mode_str, NULL);
else
drag_mode = 0;
if (profile_conf)
g_hash_table_destroy(config);
gc_drag_change_mode( drag_mode);
shapegame_next_level();
pause_board(FALSE);
}
board_conf = NULL;
profile_conf = NULL;
} | false | false | false | false | false | 0 |
mark_symbols_for_renaming (gimple stmt)
{
tree op;
ssa_op_iter iter;
update_stmt (stmt);
/* Mark all the operands for renaming. */
FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_ALL_OPERANDS)
if (DECL_P (op))
mark_sym_for_renaming (op);
} | false | false | false | false | false | 0 |
DumpMIDIMultiTrack ( MIDIMultiTrack *mlt )
{
MIDIMultiTrackIterator i ( mlt );
const MIDITimedBigMessage *msg;
i.GoToTime ( 0 );
do
{
int trk_num;
if ( i.GetCurEvent ( &trk_num, &msg ) )
{
fprintf ( stdout, "#%2d - ", trk_num );
DumpMIDITimedBigMessage ( msg );
}
}
while ( i.GoToNextEvent() );
} | false | false | false | false | false | 0 |
insertmacro(cmdstr, count)
char *cmdstr;
int count;
{
if (macro >= NMACROS)
error();
else if (*cmdstr != 0) {
macro++;
mcr[macro].mtext = cmdstr; /* point at the text */
mcr[macro].ip = cmdstr; /* starting index */
mcr[macro].m_iter = count; /* # times to do the macro */
}
} | false | false | false | false | false | 0 |
execmd_read_page_sector(struct mtd_info *mtd, int page_addr)
{
struct sh_flctl *flctl = mtd_to_flctl(mtd);
int sector, page_sectors;
enum flctl_ecc_res_t ecc_result;
page_sectors = flctl->page_size ? 4 : 1;
set_cmd_regs(mtd, NAND_CMD_READ0,
(NAND_CMD_READSTART << 8) | NAND_CMD_READ0);
writel(readl(FLCMNCR(flctl)) | ACM_SACCES_MODE | _4ECCCORRECT,
FLCMNCR(flctl));
writel(readl(FLCMDCR(flctl)) | page_sectors, FLCMDCR(flctl));
writel(page_addr << 2, FLADR(flctl));
empty_fifo(flctl);
start_translation(flctl);
for (sector = 0; sector < page_sectors; sector++) {
read_fiforeg(flctl, 512, 512 * sector);
ecc_result = read_ecfiforeg(flctl,
&flctl->done_buff[mtd->writesize + 16 * sector],
sector);
switch (ecc_result) {
case FL_REPAIRABLE:
dev_info(&flctl->pdev->dev,
"applied ecc on page 0x%x", page_addr);
flctl->mtd.ecc_stats.corrected++;
break;
case FL_ERROR:
dev_warn(&flctl->pdev->dev,
"page 0x%x contains corrupted data\n",
page_addr);
flctl->mtd.ecc_stats.failed++;
break;
default:
;
}
}
wait_completion(flctl);
writel(readl(FLCMNCR(flctl)) & ~(ACM_SACCES_MODE | _4ECCCORRECT),
FLCMNCR(flctl));
} | false | false | false | false | false | 0 |
SzReadArchiveProperties(CSzData *sd)
{
for (;;)
{
UInt64 type;
RINOK(SzReadID(sd, &type));
if (type == k7zIdEnd)
break;
SzSkeepData(sd);
}
return SZ_OK;
} | false | false | false | false | false | 0 |
histogram_tool_ok_clicked_cb (G_GNUC_UNUSED GtkWidget *button,
HistogramToolState *state)
{
data_analysis_output_t *dao;
analysis_tools_data_histogram_t *data;
GtkWidget *w;
data = g_new0 (analysis_tools_data_histogram_t, 1);
dao = parse_output ((GenericToolState *)state, NULL);
data->base.input = gnm_expr_entry_parse_as_list (
GNM_EXPR_ENTRY (state->base.input_entry), state->base.sheet);
data->base.group_by = gnm_gui_group_value (state->base.gui, grouped_by_group);
data->predetermined = gtk_toggle_button_get_active (
GTK_TOGGLE_BUTTON (state->predetermined_button));
if (data->predetermined) {
w = go_gtk_builder_get_widget (state->base.gui, "labels_2_button");
data->bin = gnm_expr_entry_parse_as_value
(GNM_EXPR_ENTRY (state->base.input_entry_2),
state->base.sheet);
} else {
entry_to_int(state->n_entry, &data->n,TRUE);
data->max_given = (0 == entry_to_float (state->max_entry,
&data->max , TRUE));
data->min_given = (0 == entry_to_float (state->min_entry,
&data->min , TRUE));
data->bin = NULL;
}
data->bin_type = gnm_gui_group_value (state->base.gui, bin_type_group);
data->chart = gnm_gui_group_value (state->base.gui, chart_group);
w = go_gtk_builder_get_widget (state->base.gui, "labels_button");
data->base.labels = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
w = go_gtk_builder_get_widget (state->base.gui, "percentage-button");
data->percentage = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
w = go_gtk_builder_get_widget (state->base.gui, "cum-button");
data->cumulative = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
w = go_gtk_builder_get_widget (state->base.gui, "only-num-button");
data->only_numbers = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w));
if (!cmd_analysis_tool (WORKBOOK_CONTROL (state->base.wbcg), state->base.sheet,
dao, data, analysis_tool_histogram_engine, TRUE))
gtk_widget_destroy (state->base.dialog);
return;
} | false | false | false | false | false | 0 |
g_vfs_http_input_stream_send (GInputStream *stream,
GCancellable *cancellable,
GError **error)
{
GVfsHttpInputStreamPrivate *priv;
g_return_val_if_fail (G_VFS_IS_HTTP_INPUT_STREAM (stream), FALSE);
priv = G_VFS_HTTP_INPUT_STREAM_GET_PRIVATE (stream);
if (priv->stream)
return TRUE;
if (!g_input_stream_set_pending (stream, error))
return FALSE;
g_vfs_http_input_stream_ensure_request (stream);
priv->stream = soup_request_send (priv->req, cancellable, error);
g_input_stream_clear_pending (stream);
return priv->stream != NULL;
} | false | false | false | false | false | 0 |
process (GeglOperation *operation,
GeglOperationContext *context,
const gchar *output_pad,
const GeglRectangle *result,
gint level)
{
GeglBuffer *buffer = ensure_buffer (operation);
if (buffer)
{
g_object_ref (buffer); /* Add an extra reference, since
* gegl_operation_set_data is
* stealing one.
*/
/* override core behaviour, by resetting the buffer in the operation_context */
gegl_operation_context_take_object (context, "output", G_OBJECT (buffer));
return TRUE;
}
return FALSE;
} | false | false | false | false | false | 0 |
ppd_file_callback(GtkWidget *widget, gpointer data)
{
const gchar *name = gtk_entry_get_text(GTK_ENTRY(widget));
if (name && pv && pv->v)
{
stp_parameter_t desc;
stp_vars_t *v = stp_vars_create_copy(pv->v);
stp_set_file_parameter(v, "PPDFile", name);
stp_describe_parameter(v, "ModelName", &desc);
if (desc.p_type == STP_PARAMETER_TYPE_STRING_LIST && desc.is_active)
gtk_label_set_text(GTK_LABEL(ppd_model), desc.deflt.str);
else
gtk_label_set_text(GTK_LABEL(ppd_model), "");
stp_parameter_description_destroy(&desc);
stp_vars_destroy(v);
}
else
gtk_label_set_text(GTK_LABEL(ppd_model), "");
} | false | false | false | false | false | 0 |
init_dirty_segmap(struct f2fs_sb_info *sbi)
{
struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
struct free_segmap_info *free_i = FREE_I(sbi);
unsigned int segno = 0, offset = 0;
unsigned short valid_blocks;
while (1) {
/* find dirty segment based on free segmap */
segno = find_next_inuse(free_i, MAIN_SEGS(sbi), offset);
if (segno >= MAIN_SEGS(sbi))
break;
offset = segno + 1;
valid_blocks = get_valid_blocks(sbi, segno, 0);
if (valid_blocks == sbi->blocks_per_seg || !valid_blocks)
continue;
if (valid_blocks > sbi->blocks_per_seg) {
f2fs_bug_on(sbi, 1);
continue;
}
mutex_lock(&dirty_i->seglist_lock);
__locate_dirty_segment(sbi, segno, DIRTY);
mutex_unlock(&dirty_i->seglist_lock);
}
} | false | false | false | false | false | 0 |
EndPrepare(GlobalTransaction gxact)
{
TransactionId xid = gxact->proc.xid;
TwoPhaseFileHeader *hdr;
char path[MAXPGPATH];
XLogRecData *record;
pg_crc32 statefile_crc;
pg_crc32 bogus_crc;
int fd;
/* Add the end sentinel to the list of 2PC records */
RegisterTwoPhaseRecord(TWOPHASE_RM_END_ID, 0,
NULL, 0);
/* Go back and fill in total_len in the file header record */
hdr = (TwoPhaseFileHeader *) records.head->data;
Assert(hdr->magic == TWOPHASE_MAGIC);
hdr->total_len = records.total_len + sizeof(pg_crc32);
/*
* If the file size exceeds MaxAllocSize, we won't be able to read it in
* ReadTwoPhaseFile. Check for that now, rather than fail at commit time.
*/
if (hdr->total_len > MaxAllocSize)
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("two-phase state file maximum length exceeded")));
/*
* Create the 2PC state file.
*
* Note: because we use BasicOpenFile(), we are responsible for ensuring
* the FD gets closed in any error exit path. Once we get into the
* critical section, though, it doesn't matter since any failure causes
* PANIC anyway.
*/
TwoPhaseFilePath(path, xid);
fd = BasicOpenFile(path,
O_CREAT | O_EXCL | O_WRONLY | PG_BINARY,
S_IRUSR | S_IWUSR);
if (fd < 0)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not create two-phase state file \"%s\": %m",
path)));
/* Write data to file, and calculate CRC as we pass over it */
INIT_CRC32(statefile_crc);
for (record = records.head; record != NULL; record = record->next)
{
COMP_CRC32(statefile_crc, record->data, record->len);
if ((write(fd, record->data, record->len)) != record->len)
{
close(fd);
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not write two-phase state file: %m")));
}
}
FIN_CRC32(statefile_crc);
/*
* Write a deliberately bogus CRC to the state file; this is just paranoia
* to catch the case where four more bytes will run us out of disk space.
*/
bogus_crc = ~statefile_crc;
if ((write(fd, &bogus_crc, sizeof(pg_crc32))) != sizeof(pg_crc32))
{
close(fd);
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not write two-phase state file: %m")));
}
/* Back up to prepare for rewriting the CRC */
if (lseek(fd, -((off_t) sizeof(pg_crc32)), SEEK_CUR) < 0)
{
close(fd);
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not seek in two-phase state file: %m")));
}
/*
* The state file isn't valid yet, because we haven't written the correct
* CRC yet. Before we do that, insert entry in WAL and flush it to disk.
*
* Between the time we have written the WAL entry and the time we write
* out the correct state file CRC, we have an inconsistency: the xact is
* prepared according to WAL but not according to our on-disk state. We
* use a critical section to force a PANIC if we are unable to complete
* the write --- then, WAL replay should repair the inconsistency. The
* odds of a PANIC actually occurring should be very tiny given that we
* were able to write the bogus CRC above.
*
* We have to lock out checkpoint start here, too; otherwise a checkpoint
* starting immediately after the WAL record is inserted could complete
* without fsync'ing our state file. (This is essentially the same kind
* of race condition as the COMMIT-to-clog-write case that
* RecordTransactionCommit uses CheckpointStartLock for; see notes there.)
*
* We save the PREPARE record's location in the gxact for later use by
* CheckPointTwoPhase.
*/
START_CRIT_SECTION();
LWLockAcquire(CheckpointStartLock, LW_SHARED);
gxact->prepare_lsn = XLogInsert(RM_XACT_ID, XLOG_XACT_PREPARE,
records.head);
XLogFlush(gxact->prepare_lsn);
/* If we crash now, we have prepared: WAL replay will fix things */
/* write correct CRC and close file */
if ((write(fd, &statefile_crc, sizeof(pg_crc32))) != sizeof(pg_crc32))
{
close(fd);
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not write two-phase state file: %m")));
}
if (close(fd) != 0)
ereport(ERROR,
(errcode_for_file_access(),
errmsg("could not close two-phase state file: %m")));
/*
* Mark the prepared transaction as valid. As soon as xact.c marks MyProc
* as not running our XID (which it will do immediately after this
* function returns), others can commit/rollback the xact.
*
* NB: a side effect of this is to make a dummy ProcArray entry for the
* prepared XID. This must happen before we clear the XID from MyProc,
* else there is a window where the XID is not running according to
* TransactionIdInProgress, and onlookers would be entitled to assume the
* xact crashed. Instead we have a window where the same XID appears
* twice in ProcArray, which is OK.
*/
MarkAsPrepared(gxact);
/*
* Now we can release the checkpoint start lock: a checkpoint starting
* after this will certainly see the gxact as a candidate for fsyncing.
*/
LWLockRelease(CheckpointStartLock);
END_CRIT_SECTION();
records.tail = records.head = NULL;
} | false | false | false | false | false | 0 |
remove_directory(string directory)
{
struct stat config_stat;
struct dirent *entry;
if(Utils::Io::check_directory(directory))
{
if(directory.substr(directory.length()-1,1) != "/")
directory += "/";
DIR *dir = opendir(directory.c_str());
if(!dir)
return 0;
else
{
while( (entry = readdir(dir)) )
{
string name = string(entry->d_name);
if(name != "." && name != "..")
{
if(Utils::Io::check_directory(directory + name))
{
if(!Utils::Io::remove_directory(directory + name))
{
closedir(dir);
return 0;
}
}
else if(!stat( (directory + name).c_str(), &config_stat))
{
if(!Utils::Io::remove_node(directory + name))
{
closedir(dir);
return 0;
}
}
}
}
}
closedir(dir);
if(!Utils::Io::remove_node(directory))
return 0;
return 1;
}
else
return 0;
} | false | false | false | false | false | 0 |
__connman_service_set_config(struct connman_service *service,
const char *file_id, const char *entry)
{
if (service == NULL)
return;
g_free(service->config_file);
service->config_file = g_strdup(file_id);
g_free(service->config_entry);
service->config_entry = g_strdup(entry);
} | false | false | false | false | false | 0 |
Read(void *buffer)
{
short int * img_buffer = (short int *)buffer;
IPLFileNameList::IteratorType it = m_FilenameList->begin();
IPLFileNameList::IteratorType itend = m_FilenameList->end();
for (; it != itend; it++ )
{
std::string curfilename = ( *it )->GetImageFileName();
std::ifstream f;
this->OpenFileForReading( f, curfilename );
f.seekg ( ( *it )->GetSliceOffset(), std::ios::beg );
if ( !this->ReadBufferAsBinary( f, img_buffer, m_FilenameList->GetXDim() * m_FilenameList->GetYDim()
* sizeof( short int ) ) )
{
f.close();
RAISE_EXCEPTION();
}
f.close();
// ByteSwapper::SwapRangeFromSystemToBigEndian is set up based on
// the FILE endian-ness, not as the name would lead you to believe.
// So, on LittleEndian systems, SwapFromSystemToBigEndian will swap.
// On BigEndian systems, SwapFromSystemToBigEndian will do nothing.
itk::ByteSwapper< short int >::SwapRangeFromSystemToBigEndian( img_buffer,
m_FilenameList->GetXDim() * m_FilenameList->GetYDim() );
img_buffer += m_FilenameList->GetXDim() * m_FilenameList->GetYDim();
}
} | false | false | false | false | false | 0 |
xchdir(int fd)
{
if (((fd == 0) ? chdir("/") : fchdir(fd)) == -1)
die1sys(1, "Could not change base directory");
} | false | false | false | false | false | 0 |
parse_pcr(int64_t *ppcr_high, int *ppcr_low,
const uint8_t *packet)
{
int afc, len, flags;
const uint8_t *p;
unsigned int v;
afc = (packet[3] >> 4) & 3;
if (afc <= 1)
return -1;
p = packet + 4;
len = p[0];
p++;
if (len == 0)
return -1;
flags = *p++;
len--;
if (!(flags & 0x10))
return -1;
if (len < 6)
return -1;
v = AV_RB32(p);
*ppcr_high = ((int64_t)v << 1) | (p[4] >> 7);
*ppcr_low = ((p[4] & 1) << 8) | p[5];
return 0;
} | false | false | false | false | false | 0 |
tag_image_read (VFSFile * handle, void * * data, int64_t * size)
{
tag_module_t * module = find_tag_module (handle, TAG_TYPE_NONE);
if (module == NULL || module->read_image == NULL)
return FALSE;
return module->read_image (handle, data, size);
} | false | false | false | false | false | 0 |
testOBRotorListFixedBonds()
{
// 1 2 3 4 5 6 7 8
// C-C-C-C-C-C-C-C
// 0 1 2 3 4 5 6
OBMolPtr mol = OBTestUtil::ReadFile("octane.cml");
// test with no bonds fixed
OBRotorList rlist1;
rlist1.Setup(*mol);
OB_ASSERT(rlist1.Size() == 5);
// test with bond 3 fixed
OBBitVec fixedBonds;
fixedBonds.SetBitOn(3);
rlist1.SetFixedBonds(fixedBonds);
rlist1.Setup(*mol);
OB_ASSERT(rlist1.Size() == 4);
// test with bond 1, 3, 5 fixed
fixedBonds.SetBitOn(1);
fixedBonds.SetBitOn(5);
rlist1.SetFixedBonds(fixedBonds);
rlist1.Setup(*mol);
OB_ASSERT(rlist1.Size() == 2);
// test with bond 1, 2, 3, 5 fixed
fixedBonds.SetBitOn(2);
rlist1.SetFixedBonds(fixedBonds);
rlist1.Setup(*mol);
OB_ASSERT(rlist1.Size() == 1);
} | false | false | false | false | false | 0 |
pmc551_read(struct mtd_info *mtd, loff_t from, size_t len,
size_t * retlen, u_char * buf)
{
struct mypriv *priv = mtd->priv;
u32 soff_hi, soff_lo; /* start address offset hi/lo */
u32 eoff_hi, eoff_lo; /* end address offset hi/lo */
unsigned long end;
u_char *ptr;
u_char *copyto = buf;
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_read(pos:%ld, len:%ld) asize: %ld\n",
(long)from, (long)len, (long)priv->asize);
#endif
end = from + len - 1;
soff_hi = from & ~(priv->asize - 1);
eoff_hi = end & ~(priv->asize - 1);
soff_lo = from & (priv->asize - 1);
eoff_lo = end & (priv->asize - 1);
pmc551_point(mtd, from, len, retlen, (void **)&ptr, NULL);
if (soff_hi == eoff_hi) {
/* The whole thing fits within one access, so just one shot
will do it. */
memcpy(copyto, ptr, len);
copyto += len;
} else {
/* We have to do multiple writes to get all the data
written. */
while (soff_hi != eoff_hi) {
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_read() soff_hi: %ld, "
"eoff_hi: %ld\n", (long)soff_hi, (long)eoff_hi);
#endif
memcpy(copyto, ptr, priv->asize);
copyto += priv->asize;
if (soff_hi + priv->asize >= mtd->size) {
goto out;
}
soff_hi += priv->asize;
pmc551_point(mtd, soff_hi, priv->asize, retlen,
(void **)&ptr, NULL);
}
memcpy(copyto, ptr, eoff_lo);
copyto += eoff_lo;
}
out:
#ifdef CONFIG_MTD_PMC551_DEBUG
printk(KERN_DEBUG "pmc551_read() done\n");
#endif
*retlen = copyto - buf;
return 0;
} | false | false | false | false | false | 0 |
AssignChannel(gboolean (*server_function)(GIOChannel *,GIOCondition,void *))
{
if(my_socket->getSocket() > 0) {
GIOChannel *channel = g_io_channel_unix_new(my_socket->getSocket());
GIOCondition condition = (GIOCondition)(G_IO_IN | G_IO_HUP | G_IO_ERR);
#if GLIB_MAJOR_VERSION >= 2
GError *err = NULL;
g_io_channel_set_encoding (channel, NULL, &err);
#if !defined _WIN32 || defined _DEBUG
g_io_channel_set_flags (channel, G_IO_FLAG_SET_MASK, &err);
#endif
#endif
g_io_add_watch(channel,
condition,
server_function,
(void*)this);
}
} | false | false | false | false | false | 0 |
start_caching(struct btrfs_root *root)
{
struct btrfs_free_space_ctl *ctl = root->free_ino_ctl;
struct task_struct *tsk;
int ret;
u64 objectid;
if (!btrfs_test_opt(root, INODE_MAP_CACHE))
return;
spin_lock(&root->ino_cache_lock);
if (root->ino_cache_state != BTRFS_CACHE_NO) {
spin_unlock(&root->ino_cache_lock);
return;
}
root->ino_cache_state = BTRFS_CACHE_STARTED;
spin_unlock(&root->ino_cache_lock);
ret = load_free_ino_cache(root->fs_info, root);
if (ret == 1) {
spin_lock(&root->ino_cache_lock);
root->ino_cache_state = BTRFS_CACHE_FINISHED;
spin_unlock(&root->ino_cache_lock);
return;
}
/*
* It can be quite time-consuming to fill the cache by searching
* through the extent tree, and this can keep ino allocation path
* waiting. Therefore at start we quickly find out the highest
* inode number and we know we can use inode numbers which fall in
* [highest_ino + 1, BTRFS_LAST_FREE_OBJECTID].
*/
ret = btrfs_find_free_objectid(root, &objectid);
if (!ret && objectid <= BTRFS_LAST_FREE_OBJECTID) {
__btrfs_add_free_space(ctl, objectid,
BTRFS_LAST_FREE_OBJECTID - objectid + 1);
}
tsk = kthread_run(caching_kthread, root, "btrfs-ino-cache-%llu",
root->root_key.objectid);
if (IS_ERR(tsk)) {
btrfs_warn(root->fs_info, "failed to start inode caching task");
btrfs_clear_pending_and_info(root->fs_info, INODE_MAP_CACHE,
"disabling inode map caching");
}
} | false | false | false | false | false | 0 |
get_cmd(char *prompt, char *allowed, char def) {
char result = 0;
char got_key;
uint32_t index;
set_canon(0);
while ( result == 0 ) {
printf("%s (%c)?", prompt, def);
got_key = read_key();
printf("\n");
if (got_key == ENTER_KEY) {
result = def;
} else {
for (index = 0; index < strlen(allowed); index++) {
if (allowed[index] == got_key) {
result = got_key;
break;
}
}
}
}
set_canon(1);
return result;
} | false | false | false | false | false | 0 |
RehashCatCache(CatCache *cp)
{
dlist_head *newbucket;
int newnbuckets;
int i;
elog(DEBUG1, "rehashing catalog cache id %d for %s; %d tups, %d buckets",
cp->id, cp->cc_relname, cp->cc_ntup, cp->cc_nbuckets);
/* Allocate a new, larger, hash table. */
newnbuckets = cp->cc_nbuckets * 2;
newbucket = (dlist_head *) MemoryContextAllocZero(CacheMemoryContext, newnbuckets * sizeof(dlist_head));
/* Move all entries from old hash table to new. */
for (i = 0; i < cp->cc_nbuckets; i++)
{
dlist_mutable_iter iter;
dlist_foreach_modify(iter, &cp->cc_bucket[i])
{
CatCTup *ct = dlist_container(CatCTup, cache_elem, iter.cur);
int hashIndex = HASH_INDEX(ct->hash_value, newnbuckets);
dlist_delete(iter.cur);
dlist_push_head(&newbucket[hashIndex], &ct->cache_elem);
}
}
/* Switch to the new array. */
pfree(cp->cc_bucket);
cp->cc_nbuckets = newnbuckets;
cp->cc_bucket = newbucket;
} | false | false | false | false | false | 0 |
p_create_or_replace_orig_and_opre_layer (GapStbAttrWidget *attw
, gint img_idx
, gint32 duration)
{
gint32 l_framenr_start;
gint32 l_framenr;
gint32 l_prefetch_framenr;
GapStorySection *section;
section = gap_story_find_section_by_stb_elem(attw->stb_refptr, attw->stb_elem_refptr);
/* calculate the absolute expanded frame number for the frame to access
* (we operate with expanded frame number, where the track overlapping
* is ignored. this allows access to frames that otherwise were skipped due to
* overlapping in the shadow track)
*/
l_framenr_start = gap_story_get_expanded_framenr_by_story_id(section
,attw->stb_elem_refptr->story_id
,attw->stb_elem_refptr->track
);
/* stb_elem_refptr refers to the transition attribute stb_elem
*/
l_framenr = l_framenr_start + MAX(0, (duration -1));
l_prefetch_framenr = -1;
if(attw->stb_elem_refptr->att_overlap > 0)
{
l_prefetch_framenr = l_framenr - attw->stb_elem_refptr->att_overlap;
}
p_calc_and_set_display_framenr(attw, img_idx, duration );
/* OPRE_LAYER (re)creation */
if(l_prefetch_framenr > 0)
{
p_orig_layer_frame_fetcher(attw
, l_prefetch_framenr
, attw->gfx_tab[img_idx].image_id
,&attw->gfx_tab[img_idx].opre_layer_id /* orig_layer_id_ptr */
,&attw->gfx_tab[img_idx].pref_layer_id /* derived_layer_id_ptr */
,&attw->gfx_tab[img_idx].opre_info /* linfo */
);
}
p_check_and_make_opre_default_layer(attw, img_idx);
/* ORIG_LAYER (re)creation */
p_orig_layer_frame_fetcher(attw
, l_framenr
, attw->gfx_tab[img_idx].image_id
,&attw->gfx_tab[img_idx].orig_layer_id /* orig_layer_id_ptr */
,&attw->gfx_tab[img_idx].curr_layer_id /* derived_layer_id_ptr */
,&attw->gfx_tab[img_idx].orig_info /* linfo */
);
/* check if we have a valid orig layer, create it if have not
* (includes setting invisible)
*/
p_check_and_make_orig_default_layer(attw, img_idx);
} | false | false | false | false | false | 0 |
putpwent (p, stream)
const struct passwd *p;
FILE *stream;
{
if (p == NULL || stream == NULL)
{
__set_errno (EINVAL);
return -1;
}
if (p->pw_name[0] == '+' || p->pw_name[0] == '-')
{
if (fprintf (stream, "%s:%s:::%s:%s:%s\n",
p->pw_name, _S (p->pw_passwd),
_S (p->pw_gecos), _S (p->pw_dir), _S (p->pw_shell)) < 0)
return -1;
}
else
{
if (fprintf (stream, "%s:%s:%lu:%lu:%s:%s:%s\n",
p->pw_name, _S (p->pw_passwd),
(unsigned long int) p->pw_uid,
(unsigned long int) p->pw_gid,
_S (p->pw_gecos), _S (p->pw_dir), _S (p->pw_shell)) < 0)
return -1;
}
return 0;
} | false | false | false | false | false | 0 |
ap_php_conv_10(register wide_int num, register bool_int is_unsigned,
register bool_int * is_negative, char *buf_end, register int *len)
{
register char *p = buf_end;
register u_wide_int magnitude;
if (is_unsigned) {
magnitude = (u_wide_int) num;
*is_negative = FALSE;
} else {
*is_negative = (num < 0);
/*
* On a 2's complement machine, negating the most negative integer
* results in a number that cannot be represented as a signed integer.
* Here is what we do to obtain the number's magnitude:
* a. add 1 to the number
* b. negate it (becomes positive)
* c. convert it to unsigned
* d. add 1
*/
if (*is_negative) {
wide_int t = num + 1;
magnitude = ((u_wide_int) - t) + 1;
} else {
magnitude = (u_wide_int) num;
}
}
/*
* We use a do-while loop so that we write at least 1 digit
*/
do {
register u_wide_int new_magnitude = magnitude / 10;
*--p = (char)(magnitude - new_magnitude * 10 + '0');
magnitude = new_magnitude;
}
while (magnitude);
*len = buf_end - p;
return (p);
} | false | false | false | false | false | 0 |
init(Processor *new_cpu)
{
_address = _opcode = _state = 0;
hll_mode = ASM_MODE;
// add the 'main' pma to the list pma context's. Processors may
// choose to add multiple pma's to the context list. The gui
// will build a source browser for each one of these. The purpose
// is to provide more than one way of debugging the code. (e.g.
// this is useful for debugging interrupt versus non-interrupt code).
if(cpu)
cpu->pma_context.push_back(this);
} | false | false | false | false | false | 0 |
CreateCircle(bool filled)
{
int circleRes = 16;
vtkIdType ptIds[17];
double x[3], theta;
// Allocate storage
vtkPolyData *poly = vtkPolyData::New();
VTK_CREATE(vtkPoints,pts);
VTK_CREATE(vtkCellArray, circle);
VTK_CREATE(vtkCellArray, outline);
// generate points around the circle
x[2] = 0.0;
theta = 2.0 * vtkMath::Pi() / circleRes;
for (int i=0; i<circleRes; i++)
{
x[0] = 0.5 * cos(i*theta);
x[1] = 0.5 * sin(i*theta);
ptIds[i] = pts->InsertNextPoint(x);
}
circle->InsertNextCell(circleRes,ptIds);
// Outline
ptIds[circleRes] = ptIds[0];
outline->InsertNextCell(circleRes+1,ptIds);
// Set up polydata
poly->SetPoints(pts);
if (filled)
{
poly->SetPolys(circle);
}
else
{
poly->SetLines(outline);
}
return poly;
} | false | false | false | false | false | 0 |
programmer_echo(int port, char ch) {
unsigned char command;
command = 2;
write(port,&command,1);
write(port,&ch,1);
read(port,&command,1);
if( command != ch ) {
printf("DEBUG: Bad echo: %c != %c\n", command, ch);
return -1;
}
return 0;
} | false | true | false | false | true | 1 |
GetArgs(Tcl_Interp *interp, int objc, Tcl_Obj **objv, CONST char *opts[],
int type, int create, int *optPtr, void **addrPtr)
{
int opt;
void *addr;
if (objc < 2) {
Tcl_WrongNumArgs(interp, 1, objv, "option ?arg ...?");
return 0;
}
if (Tcl_GetIndexFromObj(interp, objv[1], opts, "option", 0,
&opt) != TCL_OK) {
return 0;
}
if (opt == create) {
addr = ns_malloc(sizeof(void *));
SetAddrResult(interp, type, addr);
} else {
if (objc < 3) {
Tcl_WrongNumArgs(interp, 2, objv, "object");
return 0;
}
if (GetAddrFromObj(interp, objv[2], type, &addr) != TCL_OK) {
return 0;
}
}
*addrPtr = addr;
*optPtr = opt;
return 1;
} | false | false | false | false | false | 0 |
dot_pg_pass_warning(PGconn *conn)
{
/* If it was 'invalid authorization', add .pgpass mention */
if (conn->dot_pgpass_used && conn->password_needed && conn->result &&
/* only works with >= 9.0 servers */
strcmp(PQresultErrorField(conn->result, PG_DIAG_SQLSTATE),
ERRCODE_INVALID_PASSWORD) == 0)
{
char pgpassfile[MAXPGPATH];
if (!getPgPassFilename(pgpassfile))
return;
appendPQExpBuffer(&conn->errorMessage,
libpq_gettext("password retrieved from file \"%s\"\n"),
pgpassfile);
}
} | false | false | false | false | false | 0 |
_struct_new (PyObject *kw)
{
StructObject * const that = PyObject_New (StructObject,
(PyTypeObject *) &StructType);
g_assert (that != NULL && kw != NULL);
that->dict = kw;
that->repr = NULL;
return (PyObject *) that;
} | false | false | false | false | false | 0 |
resolveArrayLength(Expression *e)
{
if (e->op == TOKnull)
return 0;
if (e->op == TOKslice)
{ uinteger_t ilo = ((SliceExp *)e)->lwr->toInteger();
uinteger_t iup = ((SliceExp *)e)->upr->toInteger();
return iup - ilo;
}
if (e->op == TOKstring)
{ return ((StringExp *)e)->len;
}
if (e->op == TOKarrayliteral)
{ ArrayLiteralExp *ale = (ArrayLiteralExp *)e;
return ale->elements ? ale->elements->dim : 0;
}
if (e->op == TOKassocarrayliteral)
{ AssocArrayLiteralExp *ale = (AssocArrayLiteralExp *)e;
return ale->keys->dim;
}
assert(0);
return 0;
} | false | false | false | false | false | 0 |
auxgetinfo(lua_State*L,const char*what,lua_Debug*ar,
Closure*f,CallInfo*ci){
int status=1;
if(f==NULL){
info_tailcall(ar);
return status;
}
for(;*what;what++){
switch(*what){
case'S':{
funcinfo(ar,f);
break;
}
case'l':{
ar->currentline=(ci)?currentline(L,ci):-1;
break;
}
case'u':{
ar->nups=f->c.nupvalues;
break;
}
case'n':{
ar->namewhat=(ci)?NULL:NULL;
if(ar->namewhat==NULL){
ar->namewhat="";
ar->name=NULL;
}
break;
}
case'L':
case'f':
break;
default:status=0;
}
}
return status;
} | false | false | false | false | false | 0 |
radeon_atif_get_sbios_requests(acpi_handle handle,
struct atif_sbios_requests *req)
{
union acpi_object *info;
size_t size;
int count = 0;
info = radeon_atif_call(handle, ATIF_FUNCTION_GET_SYSTEM_BIOS_REQUESTS, NULL);
if (!info)
return -EIO;
size = *(u16 *)info->buffer.pointer;
if (size < 0xd) {
count = -EINVAL;
goto out;
}
memset(req, 0, sizeof(*req));
size = min(sizeof(*req), size);
memcpy(req, info->buffer.pointer, size);
DRM_DEBUG_DRIVER("SBIOS pending requests: %#x\n", req->pending);
count = hweight32(req->pending);
out:
kfree(info);
return count;
} | false | false | false | false | false | 0 |
sgmlExtensionHtmlElementBegin(SGML_PARSER *parser, void *userContext, const char *elementName)
{
SGML_EXTENSION_HTML *ext = (SGML_EXTENSION_HTML *)userContext;
DOM_ELEMENT *element = domElementNew(elementName);
int x = 0, match = 0;
if (ext->flags & SGML_EXTENSION_HTML_FLAG_STRIPELEMENT)
return;
if (ext->flags & SGML_EXTENSION_HTML_FLAG_ESCAPEUNKNOWNTAGS && ext->knownTags)
{
for (match = 0, x = 0; !match && ext->knownTags[x]; x++)
{
if (!strcasecmp(ext->knownTags[x], elementName))
match = 1;
}
if (!match)
element->escapeTags = 1;
}
if (ext->currElement)
domNodeAppendChild(ext->currElement, element);
else
domNodeAppendChild(ext->document, element);
for (match = 0, x = 0; !match && autocloseElements[x]; x++)
{
if (!strcasecmp(autocloseElements[x], elementName))
{
match = 1;
break;
}
}
if (match)
element->autoclose = 1;
ext->currElement = element;
} | false | false | false | false | false | 0 |
dessert_cli_get_cfg(int argc, char** argv) {
FILE* cfg;
const char* path_head = "/etc/";
const char* path_tail = ".conf";
char* str = alloca(strlen(argv[0])+1);
strcpy(str, argv[0]);
char* ptr = strtok(str, "/");
char* daemon = ptr;
while (ptr != NULL) {
daemon = ptr;
ptr = strtok(NULL, "/");
}
if (argc != 2) {
char
* path =
alloca(strlen(path_head)+1 +strlen(path_tail)+1 +strlen(daemon)+1);
strcat(path, path_head);
strcat(path, daemon);
strcat(path, path_tail);
cfg = fopen(path, "r");
if (cfg == NULL) {
dessert_err("specify configuration file\nusage: \"%s configfile\"\nusage: \"%s\" if /etc/%s.conf is present", daemon, daemon, daemon);
exit(1);
}
} else {
cfg = fopen(argv[1], "r");
if (cfg == NULL) {
dessert_err("failed to open configfile %s", argv[1]);
exit(2);
} else {
dessert_info("using file %s as configuration file", argv[1]);
}
}
return cfg;
} | false | true | false | false | true | 1 |
c_common_pch_pragma (cpp_reader *pfile, const char *name)
{
int fd;
if (!cpp_get_options (pfile)->preprocessed)
{
error ("pch_preprocess pragma should only be used with -fpreprocessed");
inform (input_location, "use #include instead");
return;
}
fd = open (name, O_RDONLY | O_BINARY, 0666);
if (fd == -1)
fatal_error ("%s: couldn%'t open PCH file: %m", name);
if (c_common_valid_pch (pfile, name, fd) != 1)
{
if (!cpp_get_options (pfile)->warn_invalid_pch)
inform (input_location, "use -Winvalid-pch for more information");
fatal_error ("%s: PCH file was invalid", name);
}
c_common_read_pch (pfile, name, fd, name);
close (fd);
} | false | false | false | false | false | 0 |
do_fw4_ack(struct cxgbi_device *cdev, struct sk_buff *skb)
{
struct cxgbi_sock *csk;
struct cpl_fw4_ack *rpl = (struct cpl_fw4_ack *)skb->data;
unsigned int tid = GET_TID(rpl);
struct cxgb4_lld_info *lldi = cxgbi_cdev_priv(cdev);
struct tid_info *t = lldi->tids;
csk = lookup_tid(t, tid);
if (unlikely(!csk))
pr_err("can't find connection for tid %u.\n", tid);
else {
log_debug(1 << CXGBI_DBG_TOE | 1 << CXGBI_DBG_SOCK,
"csk 0x%p,%u,0x%lx,%u.\n",
csk, csk->state, csk->flags, csk->tid);
cxgbi_sock_rcv_wr_ack(csk, rpl->credits, ntohl(rpl->snd_una),
rpl->seq_vld);
}
__kfree_skb(skb);
} | false | false | false | false | false | 0 |
calculate_xml_digest_v2(xmlNode * source, gboolean do_filter)
{
char *digest = NULL;
char *buffer = NULL;
int offset, max;
static struct qb_log_callsite *digest_cs = NULL;
crm_trace("Begin digest %s", do_filter?"filtered":"");
if (do_filter && BEST_EFFORT_STATUS) {
/* Exclude the status calculation from the digest
*
* This doesn't mean it wont be sync'd, we just wont be paranoid
* about it being an _exact_ copy
*
* We don't need it to be exact, since we throw it away and regenerate
* from our peers whenever a new DC is elected anyway
*
* Importantly, this reduces the amount of XML to copy+export as
* well as the amount of data for MD5 needs to operate on
*/
} else {
dump_xml(source, do_filter ? xml_log_option_filtered : 0, &buffer, &offset, &max, 0);
}
CRM_ASSERT(buffer != NULL);
digest = crm_md5sum(buffer);
if (digest_cs == NULL) {
digest_cs = qb_log_callsite_get(__func__, __FILE__, "cib-digest", LOG_TRACE, __LINE__,
crm_trace_nonlog);
}
if (digest_cs && digest_cs->targets) {
char *trace_file = crm_concat("/tmp/cib-digest", digest, '-');
crm_trace("Saving %s.%s.%s to %s",
crm_element_value(source, XML_ATTR_GENERATION_ADMIN),
crm_element_value(source, XML_ATTR_GENERATION),
crm_element_value(source, XML_ATTR_NUMUPDATES), trace_file);
save_xml_to_file(source, "digest input", trace_file);
free(trace_file);
}
free(buffer);
crm_trace("End digest");
return digest;
} | false | false | false | false | false | 0 |
configure(Vector<String> &conf, ErrorHandler *errh)
{
if (conf.size() != noutputs())
return errh->error("need %d arguments, one per output port", noutputs());
// leverage IPFilter's parsing
Vector<String> new_conf;
for (int i = 0; i < conf.size(); i++)
new_conf.push_back(String(i) + " " + conf[i]);
return IPFilter::configure(new_conf, errh);
} | false | false | false | false | false | 0 |
gt_region_mapping_get_sequence_length(GtRegionMapping *rm,
unsigned long *length, GtStr *seqid,
GtError *err)
{
int had_err;
unsigned long filenum, seqnum, GT_UNUSED offset;
gt_error_check(err);
GT_UNUSED GtRange range;
gt_assert(rm && seqid);
if (rm->userawseq) {
return rm->rawlength;
}
had_err = update_seq_col_if_necessary(rm, seqid, err);
if (!had_err) {
if (gt_md5_seqid_has_prefix(gt_str_get(seqid))) {
had_err = gt_seq_col_md5_to_sequence_length(rm->seq_col, length, seqid,
err);
}
return had_err;
}
if (!had_err) {
if (rm->usedesc) {
gt_assert(rm->seqid2seqnum_mapping);
had_err = gt_seqid2seqnum_mapping_map(rm->seqid2seqnum_mapping,
gt_str_get(seqid), &range, &seqnum,
&filenum,
&offset, err);
if (!had_err)
*length = gt_seq_col_get_sequence_length(rm->seq_col, filenum, seqnum);
}
else if (rm->matchdesc) {
had_err = gt_seq_col_grep_desc_sequence_length(rm->seq_col, length,
seqid, err);
}
else {
if (!had_err)
*length = gt_seq_col_get_sequence_length(rm->seq_col, 0, 0);
}
}
return had_err;
} | false | false | false | false | false | 0 |
_parse_accessible_playlists(JNIEnv* env, BITBUFFER* buf)
{
// skip length specifier
bb_seek(buf, 32, SEEK_CUR);
int count = bb_read(buf, 11);
jobjectArray playlists = bdj_make_array(env, "java/lang/String", count);
jboolean access_to_all_flag = bb_read(buf, 1);
jboolean autostart_first_playlist = bb_read(buf, 1);
// skip padding
bb_seek(buf, 19, SEEK_CUR);
for (int i = 0; i < count; i++) {
char playlist_name[6];
_get_string(buf, playlist_name, 5);
jstring jplaylist_name = (*env)->NewStringUTF(env, playlist_name);
JNICHK(jplaylist_name);
(*env)->SetObjectArrayElement(env, playlists, i, jplaylist_name);
// skip padding
bb_seek(buf, 8, SEEK_CUR);
}
return bdj_make_object(env, "org/videolan/bdjo/PlayListTable", "(ZZ[Ljava/lang/String;)V",
access_to_all_flag, autostart_first_playlist, playlists);
} | true | true | false | false | false | 1 |
WriteBytes(int nBytesToWrite, GByte *pabySrcBuf)
{
if (m_eAccess == TABWrite && m_poBlockManagerRef &&
(m_nBlockSize - m_nCurPos) < nBytesToWrite)
{
int nNewBlockOffset = m_poBlockManagerRef->AllocNewBlock();
SetNextToolBlock(nNewBlockOffset);
if (CommitToFile() != 0 ||
InitNewBlock(m_fp, 512, nNewBlockOffset) != 0)
{
// An error message should have already been reported.
return -1;
}
m_numBlocksInChain ++;
}
return TABRawBinBlock::WriteBytes(nBytesToWrite, pabySrcBuf);
} | false | false | false | false | false | 0 |
matcher(UText *input,
PatternIsUTextFlag /*flag*/,
UErrorCode &status) const {
RegexMatcher *retMatcher = matcher(status);
if (retMatcher != NULL) {
retMatcher->fDeferredStatus = status;
retMatcher->reset(input);
}
return retMatcher;
} | false | false | false | false | false | 0 |
selectAllWires(ViewGeometry::WireFlag flag)
{
int boardCount;
ItemBase * board = findSelectedBoard(boardCount);
if (boardCount == 0 && autorouteTypePCB()) {
QMessageBox::critical(this, tr("Fritzing"),
tr("Your sketch does not have a board yet! Please add a PCB in order to use this selection operation."));
return;
}
if (board == NULL) {
QMessageBox::critical(this, tr("Fritzing"),
tr("Please click on a PCB first--this selection operation only works for one board at a time."));
return;
}
QList<QGraphicsItem *> items = scene()->collidingItems(board);
selectAllWiresFrom(flag, items);
} | false | false | false | false | false | 0 |
DecodePredicateOperand(MCInst &Inst, unsigned Val,
uint64_t Address, const void *Decoder) {
if (Val == 0xF) return MCDisassembler::Fail;
// AL predicate is not allowed on Thumb1 branches.
if (Inst.getOpcode() == ARM::tBcc && Val == 0xE)
return MCDisassembler::Fail;
Inst.addOperand(MCOperand::createImm(Val));
if (Val == ARMCC::AL) {
Inst.addOperand(MCOperand::createReg(0));
} else
Inst.addOperand(MCOperand::createReg(ARM::CPSR));
return MCDisassembler::Success;
} | false | false | false | false | false | 0 |
xmalloc_freelist_grab(struct xfreelist *fl,
void *block, size_t length, bool split, size_t *allocated)
{
size_t blksize = fl->blocksize;
size_t len = length;
void *p = block;
g_assert(blksize >= len);
xfl_remove_selected(fl, block);
/*
* If the block is larger than the size we requested, the remainder
* is put back into the free list.
*/
if (len != blksize) {
void *sp; /* Split pointer */
size_t split_len;
split_len = blksize - len;
if (split && xmalloc_should_split(blksize, len)) {
xstats.freelist_split++;
if (xmalloc_grows_up) {
/* Split the end of the block */
sp = ptr_add_offset(p, len);
} else {
/* Split the head of the block */
sp = p;
p = ptr_add_offset(p, split_len);
}
if (xmalloc_debugging(3)) {
t_debug("XM splitting large %zu-byte block at %p"
" (need only %zu bytes: returning %zu bytes at %p)",
blksize, p, len, split_len, sp);
}
g_assert(split_len <= XMALLOC_MAXSIZE);
xmalloc_freelist_insert(sp, split_len, FALSE, XM_COALESCE_NONE);
} else {
if (xmalloc_debugging(3)) {
t_debug("XM NOT splitting %s %zu-byte block at %p"
" (need only %zu bytes, split of %zu bytes too small)",
split ? "large" : "(as requested)",
blksize, p, len, split_len);
}
xstats.freelist_nosplit++;
len = blksize; /* Wasting some trailing bytes */
}
}
*allocated = len;
return p;
} | false | false | false | false | false | 0 |
lsr_read_sync_tolerance(GF_LASeRCodec *lsr, GF_Node *n)
{
u32 flag;
GF_LSR_READ_INT(lsr, flag, 1, "syncTolerance");
if (flag) {
GF_FieldInfo info;
GF_LSR_READ_INT(lsr, flag, 1, "syncTolerance");
lsr->last_error = gf_node_get_attribute_by_tag(n, TAG_SVG_ATT_syncTolerance, 1, 0, &info);
if (flag) ((SMIL_SyncTolerance *)info.far_ptr)->type = SMIL_SYNCTOLERANCE_DEFAULT;
else {
u32 v = lsr_read_vluimsbf5(lsr, "value");
((SMIL_SyncTolerance *)info.far_ptr)->value = INT2FIX(v);
((SMIL_SyncTolerance *)info.far_ptr)->value /= lsr->time_resolution;
}
}
} | false | false | false | false | false | 0 |
mgslpc_put_char(struct tty_struct *tty, unsigned char ch)
{
MGSLPC_INFO *info = (MGSLPC_INFO *)tty->driver_data;
unsigned long flags;
if (debug_level >= DEBUG_LEVEL_INFO) {
printk("%s(%d):mgslpc_put_char(%d) on %s\n",
__FILE__, __LINE__, ch, info->device_name);
}
if (mgslpc_paranoia_check(info, tty->name, "mgslpc_put_char"))
return 0;
if (!info->tx_buf)
return 0;
spin_lock_irqsave(&info->lock, flags);
if (info->params.mode == MGSL_MODE_ASYNC || !info->tx_active) {
if (info->tx_count < TXBUFSIZE - 1) {
info->tx_buf[info->tx_put++] = ch;
info->tx_put &= TXBUFSIZE-1;
info->tx_count++;
}
}
spin_unlock_irqrestore(&info->lock, flags);
return 1;
} | false | false | false | false | false | 0 |
event_master_add_timer (struct event_master *em,
EventCallback func, void *arg, long sec)
{
struct timeval tv_now;
struct event *e, *f;
e = event_master_event_get (em, EVENT_TYPE_TIMER, func, arg);
if (e == NULL)
return NULL;
gettimeofday (&tv_now, NULL);
tv_now.tv_sec += sec;
e->u.sands = tv_now;
for (f = em->el_timer.head; f; f = f->next)
if (timeval_cmp (e->u.sands, f->u.sands) <= 0)
break;
if (f)
event_list_insert (&em->el_timer, f, e);
else
event_list_push_back (&em->el_timer, e);
return e;
} | false | false | false | false | false | 0 |
job_mark_check(const std::string &fname) {
struct stat st;
if(lstat(fname.c_str(),&st) != 0) return false;
if(!S_ISREG(st.st_mode)) return false;
return true;
} | false | false | false | false | false | 0 |
php_skip_variable(php_stream * stream TSRMLS_DC)
{
off_t length = ((unsigned int)php_read2(stream TSRMLS_CC));
if (length < 2) {
return 0;
}
length = length - 2;
php_stream_seek(stream, (long)length, SEEK_CUR);
return 1;
} | false | false | false | false | false | 0 |
PyFFFont_CreateUnicodeChar(PyObject *self, PyObject *args) {
int uni, enc;
char *name=NULL;
FontViewBase *fv = ((PyFF_Font *) self)->fv;
SplineChar *sc;
if ( !PyArg_ParseTuple(args,"i|s", &uni, &name ) )
return( NULL );
if ( uni<-1 || uni>=unicode4_size ) {
PyErr_Format(PyExc_ValueError, "Unicode codepoint, %d, out of range, must be either -1 or between 0 and 0x10ffff", uni );
return( NULL );
} else if ( uni==-1 && name==NULL ) {
PyErr_Format(PyExc_ValueError, "If you do not specify a code point, you must specify a name.");
return( NULL );
}
enc = SFFindSlot(fv->sf, fv->map, uni, name );
if ( enc!=-1 ) {
sc = SFMakeChar(fv->sf,fv->map,enc);
if ( name!=NULL ) {
free(sc->name);
sc->name = copy(name);
}
} else {
sc = SFGetOrMakeChar(fv->sf,uni,name);
/* does not add to current map. But since we didn't find a slot it's */
/* not in the encoding. We could add it in the unencoded area */
}
return( PySC_From_SC_I( sc ));
} | false | false | false | false | false | 0 |
globus_l_gram_tokenize(char * command, char ** args, int * n)
{
int i, x;
char * cp;
char * cp2;
char ** arg;
char * tmp_str = NULL;
arg = args;
i = *n - 1;
for (cp = strtok(command, " \t\n"); cp != 0; )
{
if ( cp[0] == '\'' && cp[strlen(cp) - 1] != '\'' )
{
cp2 = strtok(NULL, "'\n");
tmp_str = malloc(sizeof(char *) * (strlen(cp) + strlen(cp2) + 2));
sprintf(tmp_str, "%s %s", &cp[1], cp2);
}
else if ( cp[0] == '"' && cp[strlen(cp) - 1] != '"' )
{
cp2 = strtok(NULL, "\"\n");
tmp_str = malloc(sizeof(char *) * (strlen(cp) + strlen(cp2) + 2));
sprintf(tmp_str, "%s %s", &cp[1], cp2);
}
else
{
if (( cp[0] == '"' && cp[strlen(cp) - 1] == '"' ) ||
( cp[0] == '\'' && cp[strlen(cp) - 1] == '\'' ))
{
tmp_str = malloc(sizeof(char *) * strlen(cp));
x = strlen(cp)-2;
strncpy(tmp_str, &cp[1], x);
tmp_str[x] = '\0';
}
else
{
tmp_str = cp;
}
}
*arg = tmp_str;
i--;
if (i == 0)
return(-1); /* too many args */
arg++;
cp = strtok(NULL, " \t\n");
}
*arg = (char *) 0;
*n = *n - i - 1;
return(0);
} | false | true | false | false | false | 1 |
updateStatisticsMove(const moverecord * pmr, matchstate * pms, const listOLD * plGame, statcontext * psc)
{
FixMatchState(pms, pmr);
switch (pmr->mt) {
case MOVE_GAMEINFO:
IniStatcontext(psc);
updateStatcontext(psc, pmr, pms, plGame);
break;
case MOVE_NORMAL:
if (pmr->fPlayer != pms->fMove) {
SwapSides(pms->anBoard);
pms->fMove = pmr->fPlayer;
}
updateStatcontext(psc, pmr, pms, plGame);
break;
case MOVE_DOUBLE:
if (pmr->fPlayer != pms->fMove) {
SwapSides(pms->anBoard);
pms->fMove = pmr->fPlayer;
}
updateStatcontext(psc, pmr, pms, plGame);
break;
case MOVE_TAKE:
case MOVE_DROP:
updateStatcontext(psc, pmr, pms, plGame);
break;
default:
break;
}
ApplyMoveRecord(pms, plGame, pmr);
psc->fMoves = fAnalyseMove;
psc->fCube = fAnalyseCube;
psc->fDice = fAnalyseDice;
} | false | false | false | false | false | 0 |
gtk_tree_view_focus(GtkTreeView *view)
{
GtkTreeModel *model;
GtkTreePath *path;
GtkTreeIter iter;
if ((model = gtk_tree_view_get_model(view))
&& gtk_tree_model_get_iter_first(model, &iter)
&& (path = gtk_tree_model_get_path(model, &iter))) {
gtk_tree_view_set_cursor(view, path, NULL, FALSE);
gtk_tree_path_free(path);
gtk_widget_grab_focus(GTK_WIDGET(view));
}
} | false | false | false | false | false | 0 |
checkEnvironment(cchar *program)
{
#if BLD_UNIX_LIKE
char *home;
home = mprGetCurrentPath();
if (unixSecurityChecks(program, home) < 0) {
return -1;
}
app->pathVar = sjoin("PATH=", getenv("PATH"), ":", mprGetAppDir(), NULL);
putenv(app->pathVar);
#endif
return 0;
} | false | false | false | false | true | 1 |
find_png_eoi(unsigned char *buffer, const size_t len) {
unsigned char *end_data, *data, chunk_code[PNG_CODE_LEN + 1];
struct png_chunk chunk;
u_int32_t datalen;
/* Move past the PNG header */
data = (buffer + PNG_SIG_LEN);
end_data = (buffer + len - (sizeof(struct png_chunk) + PNG_CRC_LEN));
while (data <= end_data) {
memcpy(&chunk, data, sizeof chunk);
/* chunk = (struct png_chunk *)data; */ /* can't do that. */
memset(chunk_code, '\0', PNG_CODE_LEN + 1);
memcpy(chunk_code, chunk.code, PNG_CODE_LEN);
datalen = ntohl(chunk.datalen);
if (!strncasecmp((char*) chunk_code, "iend", PNG_CODE_LEN))
return (unsigned char *)(data + sizeof(struct png_chunk) + PNG_CRC_LEN);
/* Would this push us off the end of the buffer? */
if (datalen > (len - (data - buffer)))
return NULL;
data += (sizeof(struct png_chunk) + datalen + PNG_CRC_LEN);
}
return NULL;
} | false | false | false | false | false | 0 |
cb_func_document_action(guint key_id)
{
GeanyDocument *doc = document_get_current();
if (doc == NULL)
return TRUE;
switch (key_id)
{
case GEANY_KEYS_DOCUMENT_REPLACETABS:
on_replace_tabs_activate(NULL, NULL);
break;
case GEANY_KEYS_DOCUMENT_REPLACESPACES:
on_replace_spaces_activate(NULL, NULL);
break;
case GEANY_KEYS_DOCUMENT_LINEBREAK:
on_line_breaking1_activate(NULL, NULL);
ui_document_show_hide(doc);
break;
case GEANY_KEYS_DOCUMENT_LINEWRAP:
on_line_wrapping1_toggled(NULL, NULL);
ui_document_show_hide(doc);
break;
case GEANY_KEYS_DOCUMENT_CLONE:
document_clone(doc);
break;
case GEANY_KEYS_DOCUMENT_RELOADTAGLIST:
document_update_tags(doc);
break;
case GEANY_KEYS_DOCUMENT_FOLDALL:
editor_fold_all(doc->editor);
break;
case GEANY_KEYS_DOCUMENT_UNFOLDALL:
editor_unfold_all(doc->editor);
break;
case GEANY_KEYS_DOCUMENT_TOGGLEFOLD:
if (editor_prefs.folding)
{
gint line = sci_get_current_line(doc->editor->sci);
editor_toggle_fold(doc->editor, line, 0);
break;
}
case GEANY_KEYS_DOCUMENT_REMOVE_MARKERS:
on_remove_markers1_activate(NULL, NULL);
break;
case GEANY_KEYS_DOCUMENT_REMOVE_ERROR_INDICATORS:
on_menu_remove_indicators1_activate(NULL, NULL);
break;
case GEANY_KEYS_DOCUMENT_REMOVE_MARKERS_INDICATORS:
on_remove_markers1_activate(NULL, NULL);
on_menu_remove_indicators1_activate(NULL, NULL);
break;
}
return TRUE;
} | false | false | false | false | false | 0 |
log_time(uint32 process_utime) {
pticks++;
if (++psaveind >= PBUFLEN)
psaveind = 0;
process_utime_save[psaveind] = process_utime;
if (process_utime > process_max_utime)
process_max_utime = process_utime;
if (process_utime < process_min_utime)
process_min_utime = process_utime;
process_tot_mtime += process_utime/1000;
} | false | false | false | false | false | 0 |
initial_integrate(int vflag)
{
double dtfm;
// update v and x of atoms in group
double **x = atom->x;
double **v = atom->v;
double **f = atom->f;
double *rmass = atom->rmass;
double *mass = atom->mass;
int *type = atom->type;
int *mask = atom->mask;
int nlocal = atom->nlocal;
if (igroup == atom->firstgroup) nlocal = atom->nfirst;
if (rmass) {
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
dtfm = dtf / rmass[i];
v[i][0] += dtfm * f[i][0];
v[i][1] += dtfm * f[i][1];
v[i][2] += dtfm * f[i][2];
x[i][0] += dtv * v[i][0];
x[i][1] += dtv * v[i][1];
x[i][2] += dtv * v[i][2];
}
} else {
for (int i = 0; i < nlocal; i++)
if (mask[i] & groupbit) {
dtfm = dtf / mass[type[i]];
v[i][0] += dtfm * f[i][0];
v[i][1] += dtfm * f[i][1];
v[i][2] += dtfm * f[i][2];
x[i][0] += dtv * v[i][0];
x[i][1] += dtv * v[i][1];
x[i][2] += dtv * v[i][2];
}
}
} | false | false | false | false | false | 0 |
genie_exp_complex (NODE_T * p)
{
A68_REAL *re, *im;
double r;
im = (A68_REAL *) (STACK_OFFSET (-ALIGNED_SIZE_OF (A68_REAL)));
re = (A68_REAL *) (STACK_OFFSET (-2 * ALIGNED_SIZE_OF (A68_REAL)));
RESET_ERRNO;
r = exp (VALUE (re));
VALUE (re) = r * cos (VALUE (im));
VALUE (im) = r * sin (VALUE (im));
MATH_RTE (p, errno != 0, MODE (COMPLEX), NO_TEXT);
} | false | false | false | false | false | 0 |
_mesa_GetnMapivARB( GLenum target, GLenum query, GLsizei bufSize, GLint *v )
{
GET_CURRENT_CONTEXT(ctx);
struct gl_1d_map *map1d;
struct gl_2d_map *map2d;
GLuint i, n;
GLfloat *data;
GLuint comps;
GLsizei numBytes;
comps = _mesa_evaluator_components(target);
if (!comps) {
_mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(target)" );
return;
}
map1d = get_1d_map(ctx, target);
map2d = get_2d_map(ctx, target);
ASSERT(map1d || map2d);
switch (query) {
case GL_COEFF:
if (map1d) {
data = map1d->Points;
n = map1d->Order * comps;
}
else {
data = map2d->Points;
n = map2d->Uorder * map2d->Vorder * comps;
}
if (data) {
numBytes = n * sizeof *v;
if (bufSize < numBytes)
goto overflow;
for (i=0;i<n;i++) {
v[i] = IROUND(data[i]);
}
}
break;
case GL_ORDER:
if (map1d) {
numBytes = 1 * sizeof *v;
if (bufSize < numBytes)
goto overflow;
v[0] = map1d->Order;
}
else {
numBytes = 2 * sizeof *v;
if (bufSize < numBytes)
goto overflow;
v[0] = map2d->Uorder;
v[1] = map2d->Vorder;
}
break;
case GL_DOMAIN:
if (map1d) {
numBytes = 2 * sizeof *v;
if (bufSize < numBytes)
goto overflow;
v[0] = IROUND(map1d->u1);
v[1] = IROUND(map1d->u2);
}
else {
numBytes = 4 * sizeof *v;
if (bufSize < numBytes)
goto overflow;
v[0] = IROUND(map2d->u1);
v[1] = IROUND(map2d->u2);
v[2] = IROUND(map2d->v1);
v[3] = IROUND(map2d->v2);
}
break;
default:
_mesa_error( ctx, GL_INVALID_ENUM, "glGetMapiv(query)" );
}
return;
overflow:
_mesa_error( ctx, GL_INVALID_OPERATION,
"glGetnMapivARB(out of bounds: bufSize is %d,"
" but %d bytes are required)", bufSize, numBytes );
} | false | false | false | false | false | 0 |
OptimizeBlock(BasicBlock &BB) {
SunkAddrs.clear();
bool MadeChange = false;
CurInstIterator = BB.begin();
for (BasicBlock::iterator E = BB.end(); CurInstIterator != E; )
MadeChange |= OptimizeInst(CurInstIterator++);
return MadeChange;
} | false | false | false | false | false | 0 |
RenderTranslucentPolygonalGeometry(vtkViewport* viewport)
{
vtkDebugMacro(<< "vtkImageStack::RenderTranslucentPolygonalGeometry");
if (!this->IsIdentity)
{
this->PokeMatrices(this->GetMatrix());
}
int rendered = 0;
vtkImageSlice *image = 0;
vtkCollectionSimpleIterator pit;
vtkIdType n = 0;
this->Images->InitTraversal(pit);
while ( (image = this->Images->GetNextImage(pit)) != 0)
{
n += (image->GetVisibility() != 0);
}
double renderTime = this->AllocatedRenderTime/(n + (n == 0));
if (n == 1)
{
// no multi-pass if only one image
this->Images->InitTraversal(pit);
while ( (image = this->Images->GetNextImage(pit)) != 0)
{
if (image->GetVisibility())
{
image->SetAllocatedRenderTime(renderTime, viewport);
rendered = image->RenderTranslucentPolygonalGeometry(viewport);
}
}
}
else
{
for (int pass = 1; pass < 3; pass++)
{
this->Images->InitTraversal(pit);
while ( (image = this->Images->GetNextImage(pit)) != 0)
{
if (image->GetVisibility())
{
image->SetAllocatedRenderTime(renderTime, viewport);
image->SetStackedImagePass(pass);
rendered |= image->RenderTranslucentPolygonalGeometry(viewport);
image->SetStackedImagePass(-1);
}
}
}
}
if (!this->IsIdentity)
{
this->PokeMatrices(NULL);
}
return rendered;
} | false | false | false | false | false | 0 |
substituteRegister(unsigned FromReg,
unsigned ToReg,
unsigned SubIdx,
const TargetRegisterInfo &RegInfo) {
if (TargetRegisterInfo::isPhysicalRegister(ToReg)) {
if (SubIdx)
ToReg = RegInfo.getSubReg(ToReg, SubIdx);
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
MachineOperand &MO = getOperand(i);
if (!MO.isReg() || MO.getReg() != FromReg)
continue;
MO.substPhysReg(ToReg, RegInfo);
}
} else {
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
MachineOperand &MO = getOperand(i);
if (!MO.isReg() || MO.getReg() != FromReg)
continue;
MO.substVirtReg(ToReg, SubIdx, RegInfo);
}
}
} | false | false | false | false | false | 0 |
dce_v8_0_encoder_disable(struct drm_encoder *encoder)
{
struct amdgpu_encoder *amdgpu_encoder = to_amdgpu_encoder(encoder);
struct amdgpu_encoder_atom_dig *dig;
amdgpu_atombios_encoder_dpms(encoder, DRM_MODE_DPMS_OFF);
if (amdgpu_atombios_encoder_is_digital(encoder)) {
if (amdgpu_atombios_encoder_get_encoder_mode(encoder) == ATOM_ENCODER_MODE_HDMI)
dce_v8_0_afmt_enable(encoder, false);
dig = amdgpu_encoder->enc_priv;
dig->dig_encoder = -1;
}
amdgpu_encoder->active_device = 0;
} | false | false | false | false | false | 0 |
gst_raw_parse_convert (GstRawParse * rp,
GstFormat src_format, gint64 src_value,
GstFormat dest_format, gint64 * dest_value)
{
gboolean ret = FALSE;
GST_DEBUG ("converting value %" G_GINT64_FORMAT " from %s (%d) to %s (%d)",
src_value, gst_format_get_name (src_format), src_format,
gst_format_get_name (dest_format), dest_format);
if (src_format == dest_format) {
*dest_value = src_value;
ret = TRUE;
goto done;
}
if (src_value == -1) {
*dest_value = -1;
ret = TRUE;
goto done;
}
/* bytes to frames */
if (src_format == GST_FORMAT_BYTES && dest_format == GST_FORMAT_DEFAULT) {
if (rp->framesize != 0) {
*dest_value = gst_util_uint64_scale_int (src_value, 1, rp->framesize);
} else {
GST_ERROR ("framesize is 0");
*dest_value = 0;
}
ret = TRUE;
goto done;
}
/* frames to bytes */
if (src_format == GST_FORMAT_DEFAULT && dest_format == GST_FORMAT_BYTES) {
*dest_value = gst_util_uint64_scale_int (src_value, rp->framesize, 1);
ret = TRUE;
goto done;
}
/* time to frames */
if (src_format == GST_FORMAT_TIME && dest_format == GST_FORMAT_DEFAULT) {
if (rp->fps_d != 0) {
*dest_value = gst_util_uint64_scale (src_value,
rp->fps_n, GST_SECOND * rp->fps_d);
} else {
GST_ERROR ("framerate denominator is 0");
*dest_value = 0;
}
ret = TRUE;
goto done;
}
/* frames to time */
if (src_format == GST_FORMAT_DEFAULT && dest_format == GST_FORMAT_TIME) {
if (rp->fps_n != 0) {
*dest_value = gst_util_uint64_scale (src_value,
GST_SECOND * rp->fps_d, rp->fps_n);
} else {
GST_ERROR ("framerate numerator is 0");
*dest_value = 0;
}
ret = TRUE;
goto done;
}
/* time to bytes */
if (src_format == GST_FORMAT_TIME && dest_format == GST_FORMAT_BYTES) {
if (rp->fps_d != 0) {
*dest_value = gst_util_uint64_scale (src_value,
rp->fps_n * rp->framesize, GST_SECOND * rp->fps_d);
} else {
GST_ERROR ("framerate denominator is 0");
*dest_value = 0;
}
ret = TRUE;
goto done;
}
/* bytes to time */
if (src_format == GST_FORMAT_BYTES && dest_format == GST_FORMAT_TIME) {
if (rp->fps_n != 0 && rp->framesize != 0) {
*dest_value = gst_util_uint64_scale (src_value,
GST_SECOND * rp->fps_d, rp->fps_n * rp->framesize);
} else {
GST_ERROR ("framerate denominator and/or framesize is 0");
*dest_value = 0;
}
ret = TRUE;
}
done:
GST_DEBUG ("ret=%d result %" G_GINT64_FORMAT, ret, *dest_value);
return ret;
} | false | false | false | false | false | 0 |
set_smark_cb(AW_window *aw, AW_CL cd1, AW_CL cd2){
AED_window *aedw = (AED_window *)cd1;
GB_transaction dummy(GLOBAL_gb_main);
AED_area_entry *ae = aedw->selected_area_entry;
if (!ae) return;
GBDATA *gbd = ae->ad_species->get_GBDATA(); if (!gbd) return;
GB_write_flag( gbd, cd2 );
aedw->expose( aw );
} | false | false | false | false | false | 0 |
either_nan_p(ScmObj arg0, ScmObj arg1)
{
if (SCM_FLONUMP(arg0) && SCM_IS_NAN(SCM_FLONUM_VALUE(arg0))) return TRUE;
if (SCM_FLONUMP(arg1) && SCM_IS_NAN(SCM_FLONUM_VALUE(arg1))) return TRUE;
return FALSE;
} | false | false | false | false | false | 0 |
ConnectPlease(struct connectdata *conn,
struct Curl_dns_entry *hostaddr,
bool *connected)
{
CURLcode result;
Curl_addrinfo *addr;
struct SessionHandle *data = conn->data;
char *hostname = data->change.proxy?conn->proxy.name:conn->host.name;
infof(data, "About to connect() to %s port %d\n",
hostname, conn->port);
/*************************************************************
* Connect to server/proxy
*************************************************************/
result= Curl_connecthost(conn,
hostaddr,
&conn->sock[FIRSTSOCKET],
&addr,
connected);
if(CURLE_OK == result) {
/* All is cool, then we store the current information */
conn->dns_entry = hostaddr;
conn->ip_addr = addr;
Curl_store_ip_addr(conn);
if (conn->data->set.proxytype == CURLPROXY_SOCKS5) {
return handleSock5Proxy(conn->proxyuser,
conn->proxypasswd,
conn) ?
CURLE_COULDNT_CONNECT : CURLE_OK;
}
else if (conn->data->set.proxytype == CURLPROXY_HTTP) {
/* do nothing here. handled later. */
}
else {
failf(conn->data, "unknown proxytype option given");
return CURLE_COULDNT_CONNECT;
}
}
return result;
} | false | false | false | false | false | 0 |
search(AWT_species_set *set,long *best_co){
AWT_species_set *result = 0;
long i;
long best_cost = 0x7fffffff;
unsigned char *sbs = set->bitstring;
for (i=nsets-1;i>=0;i--){
long j;
long sum = 0;
unsigned char *rsb = sets[i]->bitstring;
for (j=nspecies/8 -1 + 1; j>=0;j--){
sum += diff_bits[ (sbs[j]) ^ (rsb[j]) ];
}
if (sum > nspecies/2) sum = nspecies - sum; // take always the minimum
if (sum < best_cost){
best_cost = sum;
result = sets[i];
}
}
*best_co = best_cost;
return result;
} | false | false | false | false | false | 0 |
enumDeclaration(Node *n) {
if (!ImportMode) {
emit_children(n);
}
return SWIG_OK;
} | false | false | false | false | false | 0 |
xml_sax_orientation (GsfXMLIn *xin, G_GNUC_UNUSED GsfXMLBlob *blob)
{
XMLSaxParseState *state = (XMLSaxParseState *)xin->user_state;
PrintInformation *pi;
GtkPageOrientation orient = GTK_PAGE_ORIENTATION_PORTRAIT;
xml_sax_must_have_sheet (state);
pi = state->sheet->print_info;
#warning TODO: we should also handle inversion
if (strcmp (xin->content->str, "portrait") == 0)
orient = GTK_PAGE_ORIENTATION_PORTRAIT;
else if (strcmp (xin->content->str, "landscape") == 0)
orient = GTK_PAGE_ORIENTATION_LANDSCAPE;
print_info_set_paper_orientation (pi, orient);
} | false | false | false | false | false | 0 |
kdb2_firstkey()
{
datum item;
if (__cur_db == NULL) {
no_open_db();
item.dptr = 0;
item.dsize = 0;
return (item);
}
return (kdb2_dbm_firstkey(__cur_db));
} | false | false | false | false | false | 0 |
PK11_GetAllSlotsForCert(CERTCertificate *cert, void *arg)
{
nssCryptokiObject **ip;
PK11SlotList *slotList;
NSSCertificate *c;
nssCryptokiObject **instances;
PRBool found = PR_FALSE;
if (!cert) {
PORT_SetError(SEC_ERROR_INVALID_ARGS);
return NULL;
}
c = STAN_GetNSSCertificate(cert);
if (!c) {
CERT_MapStanError();
return NULL;
}
/* add multiple instances to the cert list */
instances = nssPKIObject_GetInstances(&c->object);
if (!instances) {
PORT_SetError(SEC_ERROR_NO_TOKEN);
return NULL;
}
slotList = PK11_NewSlotList();
if (!slotList) {
nssCryptokiObjectArray_Destroy(instances);
return NULL;
}
for (ip = instances; *ip; ip++) {
nssCryptokiObject *instance = *ip;
PK11SlotInfo *slot = instance->token->pk11slot;
if (slot) {
PK11_AddSlotToList(slotList, slot, PR_TRUE);
found = PR_TRUE;
}
}
if (!found) {
PK11_FreeSlotList(slotList);
PORT_SetError(SEC_ERROR_NO_TOKEN);
slotList = NULL;
}
nssCryptokiObjectArray_Destroy(instances);
return slotList;
} | false | false | false | false | false | 0 |
o_isptr(void)
{
VALUE *vp;
long r;
vp = stack;
if (vp->v_type == V_ADDR)
vp = vp->v_addr;
r = 0;
switch(vp->v_type) {
case V_OPTR: r = 1; break;
case V_VPTR: r = 2; break;
case V_SPTR: r = 3; break;
case V_NPTR: r = 4; break;
}
freevalue(stack);
stack->v_num = itoq(r);
stack->v_type = V_NUM;
stack->v_subtype = V_NOSUBTYPE;
} | false | false | false | false | false | 0 |
folder_set_message_user_tag (CamelFolder *folder,
const gchar *uid,
const gchar *name,
const gchar *value)
{
CamelMessageInfo *info;
g_return_if_fail (folder->summary != NULL);
info = camel_folder_summary_get (folder->summary, uid);
if (info == NULL)
return;
camel_message_info_set_user_tag (info, name, value);
camel_message_info_free (info);
} | false | false | false | false | false | 0 |
profile_get_string(profile_t profile, const char *name, const char *subname,
const char *subsubname, const char *def_val,
char **ret_string)
{
const char *value;
long retval;
if (profile) {
retval = profile_get_value(profile, name, subname,
subsubname, &value);
if (retval == PROF_NO_SECTION || retval == PROF_NO_RELATION)
value = def_val;
else if (retval)
return retval;
} else
value = def_val;
if (value) {
*ret_string = malloc(strlen(value)+1);
if (*ret_string == 0)
return ENOMEM;
strcpy(*ret_string, value);
} else
*ret_string = 0;
return 0;
} | false | false | false | false | false | 0 |
showEvent(QShowEvent* event)
{
QFontMetrics metrics(m_symbol_preview_item->font());
float size = metrics.height() * 1.5f;
m_symbol_preview->fitInView(0, 0, size, size);
m_view->setFocus();
QDialog::showEvent(event);
} | false | false | false | false | false | 0 |
ConvertedString(w, encoding, format, length, string)
Widget w;
Atom *encoding;
int *format;
int *length;
XtPointer *string;
{
CannaObject obj = (CannaObject)w;
iBuf *ib = obj->canna.ibuf;
wchar *wbuf, *wp;
int len, wlen;
extern int convJWStoCT();
int offset = ib->offset;
if (ib == NULL) return -1;
if (ib->nseg == 0 || ib->offset == 0) return -1;
wlen = ib->len[offset - 1];
if (wlen == 0) return -1;
wbuf = ib->str[offset - 1];
/*
* Canna $B%*%V%8%'%/%H$O(B COMPOUND_TEXT $B%(%s%3!<%G%#%s%0$7$+%5%]!<%H$7$J$$(B
* COMPOUND_TEXT $B$KJQ49$9$k(B
*/
*encoding = XA_COMPOUND_TEXT(XtDisplayOfObject((Widget)obj));
*format = 8;
/* COMPOUND_TEXT $B$O(B \r $B$,Aw$l$J$$$N$G(B \n $B$KJQ49$7$F$*$/(B */
for (wp = wbuf; *wp != 0; wp++) {
if (*wp == '\r') *wp = '\n';
}
*length = len = convJWStoCT(wbuf, (unsigned char *)NULL, 0);
*string = XtMalloc(len + 1);
(void)convJWStoCT(wbuf, (unsigned char *)*string, 0);
shiftLeftAll(ib);
return 0;
} | false | false | false | false | false | 0 |
find(int symid) {
if (symid==-1)
return nil;
ALIterator i;
for (First(i); !Done(i); Next(i)) {
Attribute* attr = GetAttr(i);
if (attr->SymbolId() == symid) {
return attr->Value();
}
}
return nil;
} | false | false | false | false | false | 0 |
dibusb2_0_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
{
u8 b[3] = { 0 };
int ret;
if ((ret = dibusb_streaming_ctrl(adap,onoff)) < 0)
return ret;
if (onoff) {
b[0] = DIBUSB_REQ_SET_STREAMING_MODE;
b[1] = 0x00;
if ((ret = dvb_usb_generic_write(adap->dev,b,2)) < 0)
return ret;
}
b[0] = DIBUSB_REQ_SET_IOCTL;
b[1] = onoff ? DIBUSB_IOCTL_CMD_ENABLE_STREAM : DIBUSB_IOCTL_CMD_DISABLE_STREAM;
return dvb_usb_generic_write(adap->dev,b,3);
} | false | false | false | false | false | 0 |
print_node(const xmlNode * root, int depth)
{
xmlNode *node;
for (node = root; node; node = node->next) {
int i;
if (node->type != XML_ELEMENT_NODE)
continue;
for (i = 0; i < depth; i++)
printf(" ");
printf("%s\n", node->name);
print_node(node->children, depth + 1);
}
} | false | false | false | false | false | 0 |
dane_int_within_range(const char* arg, int max, const char* name)
{
char* endptr; /* utility var for strtol usage */
int val = strtol(arg, &endptr, 10);
if ((val < 0 || val > max)
|| (errno != 0 && val == 0) /* out of range */
|| endptr == arg /* no digits */
|| *endptr != '\0' /* more chars */
) {
fprintf(stderr, "<%s> should be in range [0-%d]\n", name, max);
exit(EXIT_FAILURE);
}
return val;
} | false | false | false | false | false | 0 |
IsTokenAcceptable(int token, int parent_token) {
if (token == TokenEnumerator::kNoSecurityToken
|| token == security_token_id_) return true;
if (token == TokenEnumerator::kInheritsSecurityToken) {
ASSERT(parent_token != TokenEnumerator::kInheritsSecurityToken);
return parent_token == TokenEnumerator::kNoSecurityToken
|| parent_token == security_token_id_;
}
return false;
} | false | false | false | false | false | 0 |
_xdg_mime_magic_matchlet_compare_level(XdgMimeMagicMatchlet *matchlet,
const void *data,
size_t len,
int indent)
{
while ((matchlet != NULL) && (matchlet->indent == indent))
{
if (_xdg_mime_magic_matchlet_compare_to_data(matchlet, data, len))
{
if ((matchlet->next == NULL) ||
(matchlet->next->indent <= indent))
return TRUE;
if (_xdg_mime_magic_matchlet_compare_level(matchlet->next,
data,
len,
indent + 1))
return TRUE;
}
do
{
matchlet = matchlet->next;
}
while (matchlet && matchlet->indent > indent);
}
return FALSE;
} | false | false | false | false | false | 0 |
is_primary_selection(ED4_terminal *object )
{
ED4_list_elem *tmp_elem;
ED4_selection_entry *tmp_entry;
tmp_elem = ( ED4_list_elem *) selected_objects.last();
if (!tmp_elem) return 0;
tmp_entry = ( ED4_selection_entry *) tmp_elem->elem();
return (tmp_entry != NULL) && (tmp_entry->object == object);
} | false | false | false | false | false | 0 |
escape_str (const gchar *str)
{
GString *s;
guint n;
s = g_string_new (NULL);
if (str == NULL)
goto out;
for (n = 0; str[n] != '\0'; n++)
{
guint c = str[n] & 0xff;
if (g_ascii_isalnum (c) || c=='_')
g_string_append_c (s, c);
else
g_string_append_printf (s, "\\%o", c);
}
out:
return g_string_free (s, FALSE);
} | false | false | false | false | false | 0 |
free_channel(aChannel *chptr)
{
Reg Link *tmp;
Link *obtmp;
int len = sizeof(aChannel) + strlen(chptr->chname), now = 0;
if (chptr->history == 0 || timeofday >= chptr->history)
/* no lock, nor expired lock, channel is no more, free it */
now = 1;
if (*chptr->chname != '!' || now)
{
while ((tmp = chptr->invites))
del_invite(tmp->value.cptr, chptr);
tmp = chptr->mlist;
while (tmp)
{
obtmp = tmp;
tmp = tmp->next;
istat.is_banmem -= BanLen(obtmp->value.alist);
istat.is_bans--;
free_bei(obtmp->value.alist);
free_link(obtmp);
}
chptr->mlist = NULL;
}
if (now)
{
istat.is_hchan--;
istat.is_hchanmem -= len;
if (chptr->prevch)
chptr->prevch->nextch = chptr->nextch;
else
channel = chptr->nextch;
if (chptr->nextch)
chptr->nextch->prevch = chptr->prevch;
del_from_channel_hash_table(chptr->chname, chptr);
if (*chptr->chname == '!' && close_chid(chptr->chname+1))
cache_chid(chptr);
else
MyFree(chptr);
}
} | false | false | false | false | false | 0 |
if_indextoname(unsigned int interface,char* blub) {
struct ifreq ifr;
int fd;
fd=socket(AF_INET6,SOCK_DGRAM,0);
if (fd<0) fd=socket(AF_INET,SOCK_DGRAM,0);
ifr.ifr_ifindex=interface;
if (ioctl(fd,SIOCGIFNAME,&ifr)==0) {
int i;
close(fd);
for (i=0; i<IFNAMSIZ-1; i++)
if (!(blub[i]=ifr.ifr_name[i]))
return blub;
blub[i]=0;
return blub;
}
close(fd);
return 0;
} | 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.