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 |
|---|---|---|---|---|---|---|
git_config_get_long(git_config *cfg, const char *name, long int *out)
{
const char *value, *num_end;
int ret;
long int num;
ret = git_config_get_string(cfg, name, &value);
if (ret < GIT_SUCCESS)
return ret;
ret = git__strtol32(&num, value, &num_end, 0);
if (ret < GIT_SUCCESS)
return ret;
switch (*num_end) {
case '\0':
break;
case 'k':
case 'K':
num *= 1024;
break;
case 'm':
case 'M':
num *= 1024 * 1024;
break;
case 'g':
case 'G':
num *= 1024 * 1024 * 1024;
break;
default:
return GIT_EINVALIDTYPE;
}
*out = num;
return GIT_SUCCESS;
} | false | false | false | false | false | 0 |
Launch(const LevelSet& levelset, wxUint16 levelnumber) const {
LevelSet tmplevelset(levelset);
if(ruleset)
tmplevelset.ruleset = ruleset;
wxString gamecmd;
if(program.empty())
gamecmd = arguments;
else
gamecmd = PlayTestProcess::GetArgumentQuoted(program) + wxT(" ") + arguments;
PlayTestProcess* proc = new PlayTestProcess;
if(!proc->Launch(gamecmd, tmplevelset, levelnumber, workingdir)) {
delete proc;
return NULL;
}
return proc;
} | false | false | false | false | false | 0 |
load_locate_elem(lList *load_list, lListElem *global_consumable,
lListElem *host_consumable, lListElem *queue_consumable,
const char *limit) {
lListElem *load_elem = NULL;
lListElem *load = NULL;
for_each(load, load_list) {
if ((lGetPosRef(load, LDR_global_pos) == global_consumable) &&
(lGetPosRef(load, LDR_host_pos) == host_consumable) &&
(lGetPosRef(load, LDR_queue_pos) == queue_consumable) &&
( strcmp(lGetPosString(load, LDR_limit_pos), limit) == 0)) {
load_elem = load;
break;
}
}
return load_elem;
} | false | false | false | false | false | 0 |
gf_w64_bytwo_p_nosse_multiply_region(gf_t *gf, void *src, void *dest, gf_val_64_t val, int bytes, int xor)
{
uint64_t *s64, *d64, ta, prod, amask, pmask, pp;
gf_region_data rd;
gf_internal_t *h;
if (val == 0) { gf_multby_zero(dest, bytes, xor); return; }
if (val == 1) { gf_multby_one(src, dest, bytes, xor); return; }
gf_set_region_data(&rd, gf, src, dest, bytes, val, xor, 8);
gf_do_initial_region_alignment(&rd);
h = (gf_internal_t *) gf->scratch;
s64 = (uint64_t *) rd.s_start;
d64 = (uint64_t *) rd.d_start;
pmask = 0x80000000;
pmask <<= 32;
pp = h->prim_poly;
if (xor) {
while (s64 < (uint64_t *) rd.s_top) {
prod = 0;
amask = pmask;
ta = *s64;
while (amask != 0) {
prod = (prod & pmask) ? ((prod << 1) ^ pp) : (prod << 1);
if (val & amask) prod ^= ta;
amask >>= 1;
}
*d64 ^= prod;
d64++;
s64++;
}
} else {
while (s64 < (uint64_t *) rd.s_top) {
prod = 0;
amask = pmask;
ta = *s64;
while (amask != 0) {
prod = (prod & pmask) ? ((prod << 1) ^ pp) : (prod << 1);
if (val & amask) prod ^= ta;
amask >>= 1;
}
*d64 = prod;
d64++;
s64++;
}
}
gf_do_final_region_alignment(&rd);
} | false | false | false | false | false | 0 |
cf_section_parse_free(CONF_SECTION *cs, void *base)
{
int i;
const CONF_PARSER *variables = cs->variables;
/*
* Don't automatically free the strings if we're being
* called from a module. This is also for clients.c,
* where client_free() expects to be able to free the
* client structure. If we moved everything to key off
* of the config files, we might solve some problems...
*/
if (!variables) return;
/*
* Free up dynamically allocated string pointers.
*/
for (i = 0; variables[i].name != NULL; i++) {
char **p;
if ((variables[i].type != PW_TYPE_STRING_PTR) &&
(variables[i].type != PW_TYPE_FILENAME)) {
continue;
}
/*
* No base struct offset, data must be the pointer.
* If data doesn't exist, ignore the entry, there
* must be something wrong.
*/
if (!base) {
if (!variables[i].data) {
continue;
}
p = (char **) variables[i].data;;
} else if (variables[i].data) {
p = (char **) variables[i].data;;
} else {
p = (char **) (((char *)base) + variables[i].offset);
}
free(*p);
*p = NULL;
}
} | true | true | false | false | false | 1 |
send_player_kick_packet(int player_index, int ban, int reason)
{
ubyte data[MAX_PACKET_SIZE];
int packet_size = 0;
BUILD_HEADER(KICK_PLAYER);
// add the address of the player to be kicked
ADD_SHORT(Net_players[player_index].player_id);
// indicate if he should be banned
ADD_INT(ban);
ADD_INT(reason);
// send the request to the server
multi_io_send_reliable(Net_player, data, packet_size);
} | false | false | false | false | false | 0 |
useredit(void)
{
char iwho[100];
int il;
printf("\n\n===== chntpw Edit User Info & Passwords ====\n\n");
if (H_SAM < 0) {
printf("ERROR: SAM registry file (which contains user data) is not loaded!\n\n");
return;
}
list_users(1);
while (1) {
printf("\nSelect: ! - quit, . - list users, 0x<RID> - User with RID (hex)\n");
printf("or simply enter the username to change: [%s] ",admuser);
il = fmyinput("",iwho,32);
if (il == 1 && *iwho == '.') { printf("\n"); list_users(1); continue; }
if (il == 1 && *iwho == '!') return;
if (il == 0) strcpy(iwho,admuser);
find_n_change(iwho);
}
} | true | true | false | false | false | 1 |
check_http (void)
{
GVfs *vfs;
gboolean error_out_on_http = FALSE;
if (g_strcmp0 (g_get_user_name (), "hadess") == 0 &&
http_supported == FALSE)
error_out_on_http = TRUE;
vfs = g_vfs_get_default ();
if (vfs == NULL) {
if (error_out_on_http)
g_error ("gvfs with http support is required (no gvfs)");
else
g_message ("gvfs with http support is required (no gvfs)");
return;
} else {
const char * const *schemes;
schemes = g_vfs_get_supported_uri_schemes (vfs);
if (schemes == NULL) {
if (error_out_on_http)
g_error ("gvfs with http support is required (no http)");
else
g_message ("gvfs with http support is required (no http)");
return;
} else {
guint i;
for (i = 0; schemes[i] != NULL; i++) {
if (g_str_equal (schemes[i], "http")) {
http_supported = TRUE;
break;
}
}
}
}
if (http_supported == FALSE) {
if (error_out_on_http)
g_error ("gvfs with http support is required (no http)");
else
g_message ("gvfs with http support is required (no http)");
}
} | false | false | false | false | false | 0 |
get_attribute(
const list<TagAttribute> *as,
const char *name, // Attribute name
const char *dflt1, // If attribute not specified
int dflt2, // If string value does not match s1, ...
const char *s1,
int v1,
...
)
{
if (as) {
list<TagAttribute>::const_iterator i;
for (i = as->begin(); i != as->end(); ++i) {
if (cmp_nocase((*i).first, name) == 0) {
dflt1 = (*i).second.c_str();
break;
}
}
}
if (!dflt1) return dflt2;
const char *s = s1;
int v = v1;
va_list va;
va_start(va, v1);
for (;;) {
if (cmp_nocase(s, dflt1) == 0) break;
s = va_arg(va, const char *);
if (!s) break;
v = va_arg(va, int);
}
va_end(va);
return s ? v : dflt2;
} | false | false | false | false | false | 0 |
collect_no_from_block_list(IntSet set, List *blklist)
{
List *li;
for (li = blklist; li != NULL; li = li->next) {
Block *bpt = li->data;
add1_IntSet(set, bpt->no);
}
} | false | false | false | false | false | 0 |
gst_video_test_src_smpte75 (GstVideoTestSrc * v, GstVideoFrame * frame)
{
int i;
int j;
paintinfo pi = PAINT_INFO_INIT;
paintinfo *p = π
int w = frame->info.width, h = frame->info.height;
videotestsrc_setup_paintinfo (v, p, w, h);
if (v->info.colorimetry.matrix == GST_VIDEO_COLOR_MATRIX_BT601) {
p->colors = vts_colors_bt601_ycbcr_75;
} else {
p->colors = vts_colors_bt709_ycbcr_75;
}
/* color bars */
for (j = 0; j < h; j++) {
for (i = 0; i < 7; i++) {
int x1 = i * w / 7;
int x2 = (i + 1) * w / 7;
p->color = p->colors + i;
p->paint_tmpline (p, x1, (x2 - x1));
}
videotestsrc_convert_tmpline (p, frame, j);
}
} | false | false | false | false | false | 0 |
removeItem(AbstractNode& node, void* item)
{
BoundableList& boundables = *(node.getChildBoundables());
BoundableList::iterator childToRemove = boundables.end();
for (BoundableList::iterator i=boundables.begin(),
e=boundables.end();
i!=e; i++)
{
Boundable* childBoundable = *i;
if (ItemBoundable *ib=dynamic_cast<ItemBoundable*>(childBoundable))
{
if ( ib->getItem() == item) childToRemove = i;
}
}
if (childToRemove != boundables.end()) {
boundables.erase(childToRemove);
return true;
}
return false;
} | false | false | false | false | false | 0 |
dump_basic_block_info (FILE *file, rtx insn, basic_block *start_to_bb,
basic_block *end_to_bb, int bb_map_size, int *bb_seqn)
{
basic_block bb;
if (!flag_debug_asm)
return;
if (INSN_UID (insn) < bb_map_size
&& (bb = start_to_bb[INSN_UID (insn)]) != NULL)
{
edge e;
edge_iterator ei;
fprintf (file, "%s BLOCK %d", ASM_COMMENT_START, bb->index);
if (bb->frequency)
fprintf (file, " freq:%d", bb->frequency);
if (bb->count)
fprintf (file, " count:" HOST_WIDEST_INT_PRINT_DEC,
bb->count);
fprintf (file, " seq:%d", (*bb_seqn)++);
fprintf (file, "\n%s PRED:", ASM_COMMENT_START);
FOR_EACH_EDGE (e, ei, bb->preds)
{
dump_edge_info (file, e, 0);
}
fprintf (file, "\n");
}
if (INSN_UID (insn) < bb_map_size
&& (bb = end_to_bb[INSN_UID (insn)]) != NULL)
{
edge e;
edge_iterator ei;
fprintf (asm_out_file, "%s SUCC:", ASM_COMMENT_START);
FOR_EACH_EDGE (e, ei, bb->succs)
{
dump_edge_info (asm_out_file, e, 1);
}
fprintf (file, "\n");
}
} | false | false | false | false | false | 0 |
propertyNodeToList(LoadState &state,
QString typeName, Node pnode)
{
Nodes sequence = sequenceStartingAt(pnode);
QVariantList list;
foreach (Node node, sequence) {
Nodes vnodes;
vnodes << node;
QVariant value = propertyNodeListToVariant(state, typeName, vnodes);
if (value.isValid()) {
DEBUG << "Found value: " << value << endl;
list.push_back(value);
} else {
DEBUG << "propertyNodeToList: Invalid value in list, skipping" << endl;
}
}
DEBUG << "propertyNodeToList: list has " << list.size() << " item(s)" << endl;
return list;
} | false | false | false | false | false | 0 |
restart(char *buf)
{
int n = 0;
double *list = (double *) buf;
int flag = static_cast<int> (list[n++]);
if (flag) {
int m = static_cast<int> (list[n++]);
if (tstat_flag && m == mtchain) {
for (int ich = 0; ich < mtchain; ich++)
eta[ich] = list[n++];
for (int ich = 0; ich < mtchain; ich++)
eta_dot[ich] = list[n++];
} else n += 2*m;
}
flag = static_cast<int> (list[n++]);
if (flag) {
omega[0] = list[n++];
omega[1] = list[n++];
omega[2] = list[n++];
omega[3] = list[n++];
omega[4] = list[n++];
omega[5] = list[n++];
omega_dot[0] = list[n++];
omega_dot[1] = list[n++];
omega_dot[2] = list[n++];
omega_dot[3] = list[n++];
omega_dot[4] = list[n++];
omega_dot[5] = list[n++];
vol0 = list[n++];
t0 = list[n++];
int m = static_cast<int> (list[n++]);
if (pstat_flag && m == mpchain) {
for (int ich = 0; ich < mpchain; ich++)
etap[ich] = list[n++];
for (int ich = 0; ich < mpchain; ich++)
etap_dot[ich] = list[n++];
} else n+=2*m;
flag = static_cast<int> (list[n++]);
if (flag) {
h0_inv[0] = list[n++];
h0_inv[1] = list[n++];
h0_inv[2] = list[n++];
h0_inv[3] = list[n++];
h0_inv[4] = list[n++];
h0_inv[5] = list[n++];
}
}
} | false | false | false | false | false | 0 |
gst_mem_index_free_id (gpointer key, gpointer value, gpointer user_data)
{
GstMemIndexId *id_index = (GstMemIndexId *) value;
if (id_index->format_index) {
g_hash_table_foreach (id_index->format_index, gst_mem_index_free_format,
NULL);
g_hash_table_destroy (id_index->format_index);
id_index->format_index = NULL;
}
g_slice_free (GstMemIndexId, id_index);
} | false | false | false | false | false | 0 |
rb_file_s_ctime(klass, fname)
VALUE klass, fname;
{
struct stat st;
if (rb_stat(fname, &st) < 0)
rb_sys_fail(RSTRING(fname)->ptr);
return rb_time_new(st.st_ctime, 0);
} | false | false | false | false | false | 0 |
FindLockTime(char *name)
{ CF_DB *dbp;
struct LockData entry;
Debug("FindLockTime(%s)\n",name);
if ((dbp = OpenLock()) == NULL)
{
return -1;
}
if (ReadDB(dbp,name,&entry,sizeof(entry)))
{
CloseLock(dbp);
return entry.time;
}
else
{
CloseLock(dbp);
return -1;
}
} | false | false | false | false | false | 0 |
recv_socket(void *data, size_t data_size, gearman_return_t& ret)
{
ssize_t read_size;
while (1)
{
read_size= ::recv(fd, data, data_size, MSG_NOSIGNAL);
if (read_size == 0)
{
ret= gearman_error(universal, GEARMAN_LOST_CONNECTION, "lost connection to server (EOF)");
close_socket();
return 0;
}
else if (read_size == -1)
{
if (errno == EAGAIN)
{
set_events(POLLIN);
if (gearman_universal_is_non_blocking(universal))
{
ret= gearman_gerror(universal, GEARMAN_IO_WAIT);
return 0;
}
ret= gearman_wait(universal);
if (gearman_failed(ret))
{
if (ret == GEARMAN_SHUTDOWN)
{
close_socket();
}
return 0;
}
continue;
}
else if (errno == EINTR)
{
continue;
}
else if (errno == EPIPE || errno == ECONNRESET || errno == EHOSTDOWN)
{
ret= gearman_perror(universal, "lost connection to server during read");
}
else
{
ret= gearman_perror(universal, "recv");
}
close_socket();
return 0;
}
break;
}
ret= GEARMAN_SUCCESS;
return size_t(read_size);
} | false | false | false | false | false | 0 |
slave_run(char *domain, int service_port, char *service_addr, int do_listen)
{
slave_instance_t *slave; // pointer to slave instance
uint32 *ns_test_list;
int udp_listen_port;
// allocate memory for slave instance
slave = (slave_instance_t *) malloc_or_die(sizeof(slave_instance_t));
slave->ticket = 0; // We don't have a ticket yet and therefore will use 0
slave->domain = domain;
slave->tcp_port = service_port;
// create buffer structure
slave->buffer = buffer_new(MAX_SEQ + 1,
BUFFER_FD_UNINITIALIZED,
BUFFER_FD_UNINITIALIZED);
// set the initial heartbeat timeout
slave->heartbeat_freq = HEARTBEAT_FREQ_SLOW;
// create sockets to write data in and out from or to the buffer
if (do_listen) {
#ifdef __WIN32__
CreateThread(0, 0, slave_wait_for_connection, slave, 0, 0);
#else
pthread_t new_thread;
pthread_create(&new_thread, NULL, slave_wait_for_connection, slave);
pthread_detach(new_thread);
#endif
} else {
slave->buffer->fd_r = net_socket(NET_SOCKET_TCP, 0, 0, 0);
if (slave->buffer->fd_r == NET_ERROR) {
error("Unable to create socket... exiting\n");
return 0;
}
slave->buffer->fd_w = slave->buffer->fd_r;
if (net_connect(slave->buffer->fd_r,
inet_addr(service_addr),
service_port) == NET_ERROR) {
error("Unable to connect to: %s:%i\n", service_addr, service_port);
return 0;
}
debug("Connected to %s:%i\n", service_addr, service_port);
}
// create the sending socket
slave->udp_send_sock = net_socket(NET_SOCKET_RAW,
NET_ADDR_ANY,
NET_PORT_NONE,
NET_DO_NOT_LISTEN);
if (slave->udp_send_sock == NET_ERROR) {
error("cannot create udp socket\n");
return 0;
}
// find a free port and bind the receiving socket to it
// for (udp_listen_port = 1024; udp_listen_port < 65535; udp_listen_port++) {
udp_listen_port = 3302;
slave->udp_recv_sock = net_socket(NET_SOCKET_UDP,
NET_ADDR_ANY,
udp_listen_port,
NET_DO_LISTEN);
// if (slave->udp_recv_sock != NET_ERROR) {
// break;
// }
// }
if (udp_listen_port != 65535) {
debug("slave sending and receiving DNS packets from %i/UDP\n", udp_listen_port);
slave->udp_listen_port = udp_listen_port;
} else {
error("could not bind slave to any port\n");
return 0;
}
// retrieve list of name servers
ns_test_list = slave_get_server_list();
// perform initial handshake with master to determine working name servers
// and the availability of encodings
slave->ns_list = slave_handshake(slave, domain, ns_test_list);
// create the sending thread
#ifdef __WIN32__
CreateThread(0, 0, slave_send, slave, 0, 0);
#else
pthread_t new_thread;
pthread_create(&new_thread, NULL, slave_send, slave);
pthread_detach(new_thread);
#endif
// start listening for responses from the master
slave_listen(slave);
return 1;
} | false | false | false | false | false | 0 |
qf_free()
{
struct qf_line *qfp;
while (qf_count)
{
qfp = qf_start->qf_next;
free(qf_start->qf_text);
free(qf_start);
qf_start = qfp;
--qf_count;
}
} | false | false | false | false | false | 0 |
fiji_upload_smu_firmware_image(struct pp_smumgr *smumgr)
{
const uint8_t *src;
uint32_t byte_count;
uint32_t *data;
struct cgs_firmware_info info = {0};
cgs_get_firmware_info(smumgr->device,
fiji_convert_fw_type_to_cgs(UCODE_ID_SMU), &info);
if (info.image_size & 3) {
printk(KERN_ERR "SMC ucode is not 4 bytes aligned\n");
return -EINVAL;
}
if (info.image_size > FIJI_SMC_SIZE) {
printk(KERN_ERR "SMC address is beyond the SMC RAM area\n");
return -EINVAL;
}
cgs_write_register(smumgr->device, mmSMC_IND_INDEX_0, 0x20000);
SMUM_WRITE_FIELD(smumgr->device, SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, 1);
byte_count = info.image_size;
src = (const uint8_t *)info.kptr;
data = (uint32_t *)src;
for (; byte_count >= 4; data++, byte_count -= 4)
cgs_write_register(smumgr->device, mmSMC_IND_DATA_0, data[0]);
SMUM_WRITE_FIELD(smumgr->device, SMC_IND_ACCESS_CNTL, AUTO_INCREMENT_IND_0, 0);
return 0;
} | false | false | false | false | false | 0 |
plpgsql_validator(PG_FUNCTION_ARGS)
{
Oid funcoid = PG_GETARG_OID(0);
HeapTuple tuple;
Form_pg_proc proc;
char functyptype;
int numargs;
Oid *argtypes;
char **argnames;
char *argmodes;
bool istrigger = false;
int i;
/* Get the new function's pg_proc entry */
tuple = SearchSysCache(PROCOID,
ObjectIdGetDatum(funcoid),
0, 0, 0);
if (!HeapTupleIsValid(tuple))
elog(ERROR, "cache lookup failed for function %u", funcoid);
proc = (Form_pg_proc) GETSTRUCT(tuple);
functyptype = get_typtype(proc->prorettype);
/* Disallow pseudotype result */
/* except for TRIGGER, RECORD, VOID, or polymorphic */
if (functyptype == TYPTYPE_PSEUDO)
{
/* we assume OPAQUE with no arguments means a trigger */
if (proc->prorettype == TRIGGEROID ||
(proc->prorettype == OPAQUEOID && proc->pronargs == 0))
istrigger = true;
else if (proc->prorettype != RECORDOID &&
proc->prorettype != VOIDOID &&
!IsPolymorphicType(proc->prorettype))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plpgsql functions cannot return type %s",
format_type_be(proc->prorettype))));
}
/* Disallow pseudotypes in arguments (either IN or OUT) */
/* except for polymorphic */
numargs = get_func_arg_info(tuple,
&argtypes, &argnames, &argmodes);
for (i = 0; i < numargs; i++)
{
if (get_typtype(argtypes[i]) == TYPTYPE_PSEUDO)
{
if (!IsPolymorphicType(argtypes[i]))
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("plpgsql functions cannot take type %s",
format_type_be(argtypes[i]))));
}
}
/* Postpone body checks if !check_function_bodies */
if (check_function_bodies)
{
FunctionCallInfoData fake_fcinfo;
FmgrInfo flinfo;
TriggerData trigdata;
int rc;
/*
* Connect to SPI manager (is this needed for compilation?)
*/
if ((rc = SPI_connect()) != SPI_OK_CONNECT)
elog(ERROR, "SPI_connect failed: %s", SPI_result_code_string(rc));
/*
* Set up a fake fcinfo with just enough info to satisfy
* plpgsql_compile().
*/
MemSet(&fake_fcinfo, 0, sizeof(fake_fcinfo));
MemSet(&flinfo, 0, sizeof(flinfo));
fake_fcinfo.flinfo = &flinfo;
flinfo.fn_oid = funcoid;
flinfo.fn_mcxt = CurrentMemoryContext;
if (istrigger)
{
MemSet(&trigdata, 0, sizeof(trigdata));
trigdata.type = T_TriggerData;
fake_fcinfo.context = (Node *) &trigdata;
}
/* Test-compile the function */
plpgsql_compile(&fake_fcinfo, true);
/*
* Disconnect from SPI manager
*/
if ((rc = SPI_finish()) != SPI_OK_FINISH)
elog(ERROR, "SPI_finish failed: %s", SPI_result_code_string(rc));
}
ReleaseSysCache(tuple);
PG_RETURN_VOID();
} | false | false | false | true | false | 1 |
IsWritable(SignalingProtocol protocol,
const ContentDescription* content) {
const MediaContentDescription* media =
static_cast<const MediaContentDescription*>(content);
if (protocol == PROTOCOL_GINGLE &&
media->type() == MEDIA_TYPE_DATA) {
return false;
}
return true;
} | false | false | false | false | false | 0 |
test_lookup_no_match (Test *test,
gconstpointer used)
{
GError *error = NULL;
GHashTable *attributes;
SecretValue *value;
attributes = secret_attributes_build (&MOCK_SCHEMA,
"even", TRUE,
"string", "one",
NULL);
/* Won't match anything */
value = secret_service_lookup_sync (test->service, &MOCK_SCHEMA, attributes, NULL, &error);
g_assert_no_error (error);
g_assert (value == NULL);
g_hash_table_unref (attributes);
} | false | false | false | false | false | 0 |
mxf_metadata_file_descriptor_to_structure (MXFMetadataBase * m)
{
GstStructure *ret =
MXF_METADATA_BASE_CLASS
(mxf_metadata_file_descriptor_parent_class)->to_structure (m);
MXFMetadataFileDescriptor *self = MXF_METADATA_FILE_DESCRIPTOR (m);
gchar str[48];
if (self->linked_track_id)
gst_structure_id_set (ret, MXF_QUARK (LINKED_TRACK_ID), G_TYPE_UINT,
self->linked_track_id, NULL);
if (self->sample_rate.n && self->sample_rate.d)
gst_structure_id_set (ret, MXF_QUARK (SAMPLE_RATE), GST_TYPE_FRACTION,
self->sample_rate.n, self->sample_rate.d, NULL);
if (self->container_duration)
gst_structure_id_set (ret, MXF_QUARK (CONTAINER_DURATION), G_TYPE_INT64,
self->container_duration, NULL);
mxf_ul_to_string (&self->essence_container, str);
gst_structure_id_set (ret, MXF_QUARK (ESSENCE_CONTAINER), G_TYPE_STRING, str,
NULL);
if (!mxf_ul_is_zero (&self->codec)) {
mxf_ul_to_string (&self->codec, str);
gst_structure_id_set (ret, MXF_QUARK (CODEC), G_TYPE_STRING, str, NULL);
}
return ret;
} | false | false | false | false | false | 0 |
dp(A a)
{
I k,d=0;
if(QF(a))R -1;
if(a->t<Et)R 0;
DO(a->n,if((k=1+dp((A)a->p[i]))>d)d=k);
R d;
} | false | false | false | false | true | 1 |
sci_request_build_sgl(struct isci_request *ireq)
{
struct isci_host *ihost = ireq->isci_host;
struct sas_task *task = isci_request_access_task(ireq);
struct scatterlist *sg = NULL;
dma_addr_t dma_addr;
u32 sg_idx = 0;
struct scu_sgl_element_pair *scu_sg = NULL;
struct scu_sgl_element_pair *prev_sg = NULL;
if (task->num_scatter > 0) {
sg = task->scatter;
while (sg) {
scu_sg = to_sgl_element_pair(ireq, sg_idx);
init_sgl_element(&scu_sg->A, sg);
sg = sg_next(sg);
if (sg) {
init_sgl_element(&scu_sg->B, sg);
sg = sg_next(sg);
} else
memset(&scu_sg->B, 0, sizeof(scu_sg->B));
if (prev_sg) {
dma_addr = to_sgl_element_pair_dma(ihost,
ireq,
sg_idx);
prev_sg->next_pair_upper =
upper_32_bits(dma_addr);
prev_sg->next_pair_lower =
lower_32_bits(dma_addr);
}
prev_sg = scu_sg;
sg_idx++;
}
} else { /* handle when no sg */
scu_sg = to_sgl_element_pair(ireq, sg_idx);
dma_addr = dma_map_single(&ihost->pdev->dev,
task->scatter,
task->total_xfer_len,
task->data_dir);
ireq->zero_scatter_daddr = dma_addr;
scu_sg->A.length = task->total_xfer_len;
scu_sg->A.address_upper = upper_32_bits(dma_addr);
scu_sg->A.address_lower = lower_32_bits(dma_addr);
}
if (scu_sg) {
scu_sg->next_pair_upper = 0;
scu_sg->next_pair_lower = 0;
}
} | false | false | false | false | false | 0 |
pdf_mark_font_descriptor_used(gx_device_pdf *pdev, pdf_font_descriptor_t *pfd)
{
if (pfd != NULL && pfd->common.object->id == -1)
pdf_reserve_object_id(pdev, (pdf_resource_t *)&pfd->common, 0);
return 0;
} | false | false | false | false | false | 0 |
set_FloatPrecision (GelETree * a)
{
long bits;
if G_UNLIKELY ( ! check_argument_integer (&a, 0, "set_FloatPrecision"))
return NULL;
bits = mpw_get_long(a->val.value);
if G_UNLIKELY (gel_error_num) {
gel_error_num = 0;
return NULL;
}
if G_UNLIKELY (bits < 60 || bits > 16384) {
gel_errorout (_("%s: argument should be between %d and %d"),
"set_FloatPrecision", 60, 16384);
return NULL;
}
if(gel_calcstate.float_prec != bits) {
gel_calcstate.float_prec = bits;
mpw_set_default_prec (gel_calcstate.float_prec);
gel_break_fp_caches ();
gel_set_state (gel_calcstate);
}
return gel_makenum_ui(gel_calcstate.float_prec);
} | false | false | false | false | false | 0 |
n_pure_div_eq(struct isl_basic_map *bmap)
{
int i, j;
unsigned total;
total = isl_space_dim(bmap->dim, isl_dim_all);
for (i = 0, j = bmap->n_div-1; i < bmap->n_eq; ++i) {
while (j >= 0 && isl_int_is_zero(bmap->eq[i][1 + total + j]))
--j;
if (j < 0)
break;
if (isl_seq_first_non_zero(bmap->eq[i] + 1 + total, j) != -1)
return 0;
}
return i;
} | false | false | false | false | false | 0 |
UpdatePageVars(void)
{
float temp; /* Swapping variable */
switch (Orientation & 3)
{
case 0 : /* Portait */
break;
case 1 : /* Landscape */
temp = PageLeft;
PageLeft = PageBottom;
PageBottom = temp;
temp = PageRight;
PageRight = PageTop;
PageTop = temp;
temp = PageWidth;
PageWidth = PageLength;
PageLength = temp;
break;
case 2 : /* Reverse Portrait */
temp = PageWidth - PageLeft;
PageLeft = PageWidth - PageRight;
PageRight = temp;
temp = PageLength - PageBottom;
PageBottom = PageLength - PageTop;
PageTop = temp;
break;
case 3 : /* Reverse Landscape */
temp = PageWidth - PageLeft;
PageLeft = PageWidth - PageRight;
PageRight = temp;
temp = PageLength - PageBottom;
PageBottom = PageLength - PageTop;
PageTop = temp;
temp = PageLeft;
PageLeft = PageBottom;
PageBottom = temp;
temp = PageRight;
PageRight = PageTop;
PageTop = temp;
temp = PageWidth;
PageWidth = PageLength;
PageLength = temp;
break;
}
} | false | false | false | false | false | 0 |
get_mm_enabled_done (DBusGProxy *proxy, DBusGProxyCall *call_id, gpointer user_data)
{
NMModem *self = NM_MODEM (user_data);
GError *error = NULL;
GValue value = { 0, };
if (!dbus_g_proxy_end_call (proxy, call_id, &error,
G_TYPE_VALUE, &value,
G_TYPE_INVALID)) {
nm_log_warn (LOGD_MB, "failed get modem enabled state: (%d) %s",
error ? error->code : -1,
error && error->message ? error->message : "(unknown)");
return;
}
if (G_VALUE_HOLDS_BOOLEAN (&value)) {
update_mm_enabled (self, g_value_get_boolean (&value));
} else
nm_log_warn (LOGD_MB, "failed get modem enabled state: unexpected reply type");
g_value_unset (&value);
} | false | false | false | false | false | 0 |
parse_include(std::ostream* os)
{
Object params;
if (getparamlist(params))
return;
Object::ArrayType& pl = params.array();
if (pl.size() != 1)
{
recorderror("Error: @include takes exactly 1 parameter");
return;
}
Object& obj = *pl[0].get();
if (obj.gettype() != Object::type_scalar)
{
recorderror("Error: @include excpects string");
return;
}
// Create another Impl which inherits symbols table
// to process include
if (!inclist.empty())
{
IncludeList::iterator it(inclist.begin()), end(inclist.end());
for (; it != end; ++it)
{
std::string path(*it);
path+= '/';
path+= obj.scalar().c_str();
Buffer buf(path.c_str());
if (buf)
{
Parser_Impl incl(buf, symbols, macros, funcs, inclist);
if (incl.pass1(os))
{
// copy incl's error list, if any
ErrorList::iterator it(incl.errlist.begin()), end(incl.errlist.end());
for (; it != end; ++it)
errlist.push_back(*it);
}
return;
}
}
}
Buffer buf(obj.scalar().c_str());
if (!buf)
{
recorderror("File Error: Could not read " + obj.scalar());
return;
}
Parser_Impl incl(buf, symbols, macros, funcs, inclist);
if (incl.pass1(os))
{
// copy incl's error list, if any
ErrorList::iterator it(incl.errlist.begin()), end(incl.errlist.end());
for (; it != end; ++it)
errlist.push_back(*it);
}
} | false | false | false | false | false | 0 |
byt_pte_encode(dma_addr_t addr,
enum i915_cache_level level,
bool valid, u32 flags)
{
gen6_pte_t pte = valid ? GEN6_PTE_VALID : 0;
pte |= GEN6_PTE_ADDR_ENCODE(addr);
if (!(flags & PTE_READ_ONLY))
pte |= BYT_PTE_WRITEABLE;
if (level != I915_CACHE_NONE)
pte |= BYT_PTE_SNOOPED_BY_CPU_CACHES;
return pte;
} | false | false | false | false | false | 0 |
makePlanarTextureMapping(scene::IMeshBuffer* buffer, f32 resolutionS, f32 resolutionT, u8 axis, const core::vector3df& offset) const
{
u32 idxcnt = buffer->getIndexCount();
u16* idx = buffer->getIndices();
for (u32 i=0; i<idxcnt; i+=3)
{
// calculate planar mapping worldspace coordinates
if (axis==0)
{
for (u32 o=0; o!=3; ++o)
{
buffer->getTCoords(idx[i+o]).X = 0.5f+(buffer->getPosition(idx[i+o]).Z + offset.Z) * resolutionS;
buffer->getTCoords(idx[i+o]).Y = 0.5f-(buffer->getPosition(idx[i+o]).Y + offset.Y) * resolutionT;
}
}
else if (axis==1)
{
for (u32 o=0; o!=3; ++o)
{
buffer->getTCoords(idx[i+o]).X = 0.5f+(buffer->getPosition(idx[i+o]).X + offset.X) * resolutionS;
buffer->getTCoords(idx[i+o]).Y = 1.f-(buffer->getPosition(idx[i+o]).Z + offset.Z) * resolutionT;
}
}
else if (axis==2)
{
for (u32 o=0; o!=3; ++o)
{
buffer->getTCoords(idx[i+o]).X = 0.5f+(buffer->getPosition(idx[i+o]).X + offset.X) * resolutionS;
buffer->getTCoords(idx[i+o]).Y = 0.5f-(buffer->getPosition(idx[i+o]).Y + offset.Y) * resolutionT;
}
}
}
} | false | false | false | false | false | 0 |
mpt_detach(struct pci_dev *pdev)
{
MPT_ADAPTER *ioc = pci_get_drvdata(pdev);
char pname[32];
u8 cb_idx;
unsigned long flags;
struct workqueue_struct *wq;
/*
* Stop polling ioc for fault condition
*/
spin_lock_irqsave(&ioc->taskmgmt_lock, flags);
wq = ioc->reset_work_q;
ioc->reset_work_q = NULL;
spin_unlock_irqrestore(&ioc->taskmgmt_lock, flags);
cancel_delayed_work(&ioc->fault_reset_work);
destroy_workqueue(wq);
spin_lock_irqsave(&ioc->fw_event_lock, flags);
wq = ioc->fw_event_q;
ioc->fw_event_q = NULL;
spin_unlock_irqrestore(&ioc->fw_event_lock, flags);
destroy_workqueue(wq);
sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/summary", ioc->name);
remove_proc_entry(pname, NULL);
sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s/info", ioc->name);
remove_proc_entry(pname, NULL);
sprintf(pname, MPT_PROCFS_MPTBASEDIR "/%s", ioc->name);
remove_proc_entry(pname, NULL);
/* call per device driver remove entry point */
for(cb_idx = 0; cb_idx < MPT_MAX_PROTOCOL_DRIVERS; cb_idx++) {
if(MptDeviceDriverHandlers[cb_idx] &&
MptDeviceDriverHandlers[cb_idx]->remove) {
MptDeviceDriverHandlers[cb_idx]->remove(pdev);
}
}
/* Disable interrupts! */
CHIPREG_WRITE32(&ioc->chip->IntMask, 0xFFFFFFFF);
ioc->active = 0;
synchronize_irq(pdev->irq);
/* Clear any lingering interrupt */
CHIPREG_WRITE32(&ioc->chip->IntStatus, 0);
CHIPREG_READ32(&ioc->chip->IntStatus);
mpt_adapter_dispose(ioc);
} | false | false | false | false | false | 0 |
playlists_menuitem_update_individual_playlist (PlaylistsMenuitem* self, PlaylistDetails* new_detail) {
DbusmenuMenuitem* _tmp19_ = NULL;
const gchar* _tmp20_ = NULL;
PlaylistDetails _tmp21_ = {0};
const char* _tmp22_ = NULL;
g_return_if_fail (self != NULL);
g_return_if_fail (new_detail != NULL);
{
GeeIterator* _item_it = NULL;
GeeHashMap* _tmp0_ = NULL;
GeeCollection* _tmp1_ = NULL;
GeeCollection* _tmp2_ = NULL;
GeeCollection* _tmp3_ = NULL;
GeeIterator* _tmp4_ = NULL;
GeeIterator* _tmp5_ = NULL;
_tmp0_ = self->priv->current_playlists;
_tmp1_ = gee_abstract_map_get_values ((GeeMap*) _tmp0_);
_tmp2_ = _tmp1_;
_tmp3_ = _tmp2_;
_tmp4_ = gee_iterable_iterator ((GeeIterable*) _tmp3_);
_tmp5_ = _tmp4_;
_g_object_unref0 (_tmp3_);
_item_it = _tmp5_;
while (TRUE) {
GeeIterator* _tmp6_ = NULL;
gboolean _tmp7_ = FALSE;
DbusmenuMenuitem* item = NULL;
GeeIterator* _tmp8_ = NULL;
gpointer _tmp9_ = NULL;
PlaylistDetails _tmp10_ = {0};
const char* _tmp11_ = NULL;
DbusmenuMenuitem* _tmp12_ = NULL;
const gchar* _tmp13_ = NULL;
_tmp6_ = _item_it;
_tmp7_ = gee_iterator_next (_tmp6_);
if (!_tmp7_) {
break;
}
_tmp8_ = _item_it;
_tmp9_ = gee_iterator_get (_tmp8_);
item = (DbusmenuMenuitem*) _tmp9_;
_tmp10_ = *new_detail;
_tmp11_ = _tmp10_.path;
_tmp12_ = item;
_tmp13_ = dbusmenu_menuitem_property_get (_tmp12_, DBUSMENU_PLAYLIST_MENUITEM_PATH);
if (g_strcmp0 (_tmp11_, _tmp13_) == 0) {
DbusmenuMenuitem* _tmp14_ = NULL;
PlaylistDetails _tmp15_ = {0};
const gchar* _tmp16_ = NULL;
gchar* _tmp17_ = NULL;
gchar* _tmp18_ = NULL;
_tmp14_ = item;
_tmp15_ = *new_detail;
_tmp16_ = _tmp15_.name;
_tmp17_ = playlists_menuitem_truncate_item_label_if_needs_be (self, _tmp16_);
_tmp18_ = _tmp17_;
dbusmenu_menuitem_property_set (_tmp14_, DBUSMENU_MENUITEM_PROP_LABEL, _tmp18_);
_g_free0 (_tmp18_);
}
_g_object_unref0 (item);
}
_g_object_unref0 (_item_it);
}
_tmp19_ = self->root_item;
_tmp20_ = dbusmenu_menuitem_property_get (_tmp19_, DBUSMENU_PLAYLIST_MENUITEM_PATH);
_tmp21_ = *new_detail;
_tmp22_ = _tmp21_.path;
if (g_strcmp0 (_tmp20_, _tmp22_) == 0) {
DbusmenuMenuitem* _tmp23_ = NULL;
PlaylistDetails _tmp24_ = {0};
const gchar* _tmp25_ = NULL;
gchar* _tmp26_ = NULL;
gchar* _tmp27_ = NULL;
_tmp23_ = self->root_item;
_tmp24_ = *new_detail;
_tmp25_ = _tmp24_.name;
_tmp26_ = playlists_menuitem_truncate_item_label_if_needs_be (self, _tmp25_);
_tmp27_ = _tmp26_;
dbusmenu_menuitem_property_set (_tmp23_, DBUSMENU_MENUITEM_PROP_LABEL, _tmp27_);
_g_free0 (_tmp27_);
}
} | false | false | false | false | false | 0 |
xen_hyper_dump_xen_hyper_sched_table(int verbose)
{
struct xen_hyper_sched_context *schc;
char buf[XEN_HYPER_CMD_BUFSIZE];
int len, flag, i;
len = 21;
flag = XEN_HYPER_PRI_R;
XEN_HYPER_PRI(fp, len, "name: ", buf, flag,
(buf, "%s\n", xhscht->name));
XEN_HYPER_PRI(fp, len, "opt_sched: ", buf, flag,
(buf, "%s\n", xhscht->opt_sched));
XEN_HYPER_PRI(fp, len, "sched_id: ", buf, flag,
(buf, "%d\n", xhscht->sched_id));
XEN_HYPER_PRI(fp, len, "scheduler: ", buf, flag,
(buf, "%lx\n", xhscht->scheduler));
XEN_HYPER_PRI(fp, len, "scheduler_struct: ", buf, flag,
(buf, "%p\n", xhscht->scheduler_struct));
XEN_HYPER_PRI(fp, len, "sched_context_array: ", buf, flag,
(buf, "%p\n", xhscht->sched_context_array));
if (verbose) {
for (i = 0, schc = xhscht->sched_context_array;
i < xht->pcpus; i++, schc++) {
XEN_HYPER_PRI(fp, len, "sched_context_array[", buf,
flag, (buf, "%d]\n", i));
XEN_HYPER_PRI(fp, len, "schedule_data: ", buf, flag,
(buf, "%lx\n", schc->schedule_data));
XEN_HYPER_PRI(fp, len, "curr: ", buf, flag,
(buf, "%lx\n", schc->curr));
XEN_HYPER_PRI(fp, len, "idle: ", buf, flag,
(buf, "%lx\n", schc->idle));
XEN_HYPER_PRI(fp, len, "sched_priv: ", buf, flag,
(buf, "%lx\n", schc->sched_priv));
XEN_HYPER_PRI(fp, len, "tick: ", buf, flag,
(buf, "%lx\n", schc->tick));
}
}
} | true | true | false | false | false | 1 |
bindUniformParameters(Program* pCpuProgram, const GpuProgramParametersSharedPtr& passParams)
{
const UniformParameterList& progParams = pCpuProgram->getParameters();
UniformParameterConstIterator itParams = progParams.begin();
UniformParameterConstIterator itParamsEnd = progParams.end();
// Bind each uniform parameter to its GPU parameter.
for (; itParams != itParamsEnd; ++itParams)
{
(*itParams)->bind(passParams);
}
} | false | false | false | false | false | 0 |
gtpfunc_list_commands(const std::string &/*str*/, size_t /*i*/,
bool has_id, unsigned id)
{
std::string output;
for (int k = 0 ; gtp_commands[k].command; ++k) {
if (k != 0)
output += '\n';
output += gtp_commands[k].command;
}
output_response(output, has_id, id);
} | false | false | false | false | false | 0 |
checkLastBoundaryTag(bool being_deleted)
{
// Nothing to do
if ( boundaryTag == NO_INDEX )
return;
// If the last element is being deleted
if (being_deleted) {
if (last_boundaryTag == boundaryTag) {
last_boundaryTag--;
}
}
// If this element has larger id than what
// corresponds to the current lastId
else {
if (last_boundaryTag < boundaryTag) {
last_boundaryTag = boundaryTag;
}
}
} | false | false | false | false | false | 0 |
changelog5_dup_config(changelog5Config *config)
{
changelog5Config *dup = (changelog5Config *) slapi_ch_calloc(1, sizeof(changelog5Config));
if (config->dir)
dup->dir = slapi_ch_strdup(config->dir);
if (config->maxAge)
dup->maxAge = slapi_ch_strdup(config->maxAge);
dup->maxEntries = config->maxEntries;
dup->compactInterval = config->compactInterval;
dup->trimInterval = config->trimInterval;
dup->dbconfig.pageSize = config->dbconfig.pageSize;
dup->dbconfig.fileMode = config->dbconfig.fileMode;
dup->dbconfig.maxConcurrentWrites = config->dbconfig.maxConcurrentWrites;
return dup;
} | false | false | false | false | false | 0 |
hdp_get_mdep(struct hdp_device *device, struct hdp_application *app,
hdp_continue_mdep_f func, gpointer data,
GDestroyNotify destroy, GError **err)
{
struct get_mdep_data *mdep_data;
bdaddr_t dst, src;
uuid_t uuid;
device_get_address(device->dev, &dst, NULL);
adapter_get_address(device_get_adapter(device->dev), &src);
mdep_data = g_new0(struct get_mdep_data, 1);
mdep_data->app = hdp_application_ref(app);
mdep_data->func = func;
mdep_data->data = data;
mdep_data->destroy = destroy;
bt_string2uuid(&uuid, HDP_UUID);
if (bt_search_service(&src, &dst, &uuid, get_mdep_cb, mdep_data,
free_mdep_data) < 0) {
g_set_error(err, HDP_ERROR, HDP_CONNECTION_ERROR,
"Can't get remote SDP record");
g_free(mdep_data);
return FALSE;
}
return TRUE;
} | false | false | false | false | false | 0 |
putString(const char *stringVal)
{
/* determine length of the string value */
const Uint32 stringLen = (stringVal != NULL) ? strlen(stringVal) : 0;
/* call the real function */
return putString(stringVal, stringLen);
} | false | false | false | false | false | 0 |
loader_BASIC_load(const char *filename,
unsigned char *data,
long size,
fileio_prop_t **prop)
{
int b;
long xsize, len;
unsigned char *sptr, *dptr;
*prop = (fileio_prop_t *)malloc(sizeof(fileio_prop_t));
if (*prop == NULL)
return -1;
memset(*prop, 0, sizeof(fileio_prop_t));
switch (*data)
{
case 0xd3: (*prop)->type = FILEIO_TYPE_BAS; break;
case 0xd7: (*prop)->type = FILEIO_TYPE_PROT_BAS; break;
default: return -1;
}
xsize = size + (size + 127) / 128;
(*prop)->valid = FILEIO_V_NONE;
(*prop)->load_addr = 0;
(*prop)->start_addr = 0;
(*prop)->autostart = 0;
(*prop)->size = xsize;
memcpy((*prop)->name, data + 3, 8);
(*prop)->name[8] = '\0';
(*prop)->data = (unsigned char *)malloc(xsize);
if ((*prop)->data == 0)
return -1;
sptr = data;
dptr = (*prop)->data;
b = 1;
while (size > 0)
{
*dptr++ = b++;
len = (size > 128) ? 128 : size;
memcpy(dptr, sptr, len);
dptr += 128;
sptr += 128;
size -= 128;
}
return 0;
} | false | true | false | false | false | 1 |
frogr_add_tags_dialog_show (GtkWindow *parent, const GSList *pictures, const GSList *tags)
{
FrogrConfig *config = NULL;
GObject *new = NULL;
new = g_object_new (FROGR_TYPE_ADD_TAGS_DIALOG,
"title", _("Add Tags"),
"modal", TRUE,
"pictures", pictures,
"transient-for", parent,
"resizable", FALSE,
NULL);
/* Enable autocompletion if needed */
config = frogr_config_get_instance ();
if (config && frogr_config_get_tags_autocompletion (config))
{
FrogrAddTagsDialogPrivate *priv = NULL;
priv = FROGR_ADD_TAGS_DIALOG_GET_PRIVATE (new);
frogr_live_entry_set_auto_completion (FROGR_LIVE_ENTRY (priv->entry), tags);
}
gtk_widget_show_all (GTK_WIDGET (new));
} | false | false | false | false | false | 0 |
PrintFpt(const vector<int>& f, int hash)
{
unsigned int i;
for(i=0;i<f.size();++i)
_ss << f[i] << " ";
_ss << "<" << hash << ">" << endl;
} | false | false | false | false | false | 0 |
xmlXPathCompEqualityExpr(xmlXPathParserContextPtr ctxt) {
xmlXPathCompRelationalExpr(ctxt);
CHECK_ERROR;
SKIP_BLANKS;
while ((CUR == '=') || ((CUR == '!') && (NXT(1) == '='))) {
int eq;
int op1 = ctxt->comp->last;
if (CUR == '=') eq = 1;
else eq = 0;
NEXT;
if (!eq) NEXT;
SKIP_BLANKS;
xmlXPathCompRelationalExpr(ctxt);
CHECK_ERROR;
PUSH_BINARY_EXPR(XPATH_OP_EQUAL, op1, ctxt->comp->last, eq, 0);
SKIP_BLANKS;
}
} | false | false | false | false | false | 0 |
SpillRegToStackSlot(MachineBasicBlock::iterator &MII,
int Idx, unsigned PhysReg, int StackSlot,
const TargetRegisterClass *RC,
bool isAvailable, MachineInstr *&LastStore,
AvailableSpills &Spills,
SmallSet<MachineInstr*, 4> &ReMatDefs,
BitVector &RegKills,
std::vector<MachineOperand*> &KillOps) {
MachineBasicBlock::iterator oldNextMII = llvm::next(MII);
TII->storeRegToStackSlot(*MBB, llvm::next(MII), PhysReg, true, StackSlot, RC,
TRI);
MachineInstr *StoreMI = prior(oldNextMII);
VRM->addSpillSlotUse(StackSlot, StoreMI);
DEBUG(dbgs() << "Store:\t" << *StoreMI);
// If there is a dead store to this stack slot, nuke it now.
if (LastStore) {
DEBUG(dbgs() << "Removed dead store:\t" << *LastStore);
++NumDSE;
SmallVector<unsigned, 2> KillRegs;
InvalidateKills(*LastStore, TRI, RegKills, KillOps, &KillRegs);
MachineBasicBlock::iterator PrevMII = LastStore;
bool CheckDef = PrevMII != MBB->begin();
if (CheckDef)
--PrevMII;
VRM->RemoveMachineInstrFromMaps(LastStore);
MBB->erase(LastStore);
if (CheckDef) {
// Look at defs of killed registers on the store. Mark the defs
// as dead since the store has been deleted and they aren't
// being reused.
for (unsigned j = 0, ee = KillRegs.size(); j != ee; ++j) {
bool HasOtherDef = false;
if (InvalidateRegDef(PrevMII, *MII, KillRegs[j], HasOtherDef, TRI)) {
MachineInstr *DeadDef = PrevMII;
if (ReMatDefs.count(DeadDef) && !HasOtherDef) {
// FIXME: This assumes a remat def does not have side effects.
VRM->RemoveMachineInstrFromMaps(DeadDef);
MBB->erase(DeadDef);
++NumDRM;
}
}
}
}
}
// Allow for multi-instruction spill sequences, as on PPC Altivec. Presume
// the last of multiple instructions is the actual store.
LastStore = prior(oldNextMII);
// If the stack slot value was previously available in some other
// register, change it now. Otherwise, make the register available,
// in PhysReg.
Spills.ModifyStackSlotOrReMat(StackSlot);
Spills.ClobberPhysReg(PhysReg);
Spills.addAvailable(StackSlot, PhysReg, isAvailable);
++NumStores;
} | false | false | false | false | false | 0 |
check_effect_access(struct ff_device *ff, int effect_id,
struct file *file)
{
if (effect_id < 0 || effect_id >= ff->max_effects ||
!ff->effect_owners[effect_id])
return -EINVAL;
if (file && ff->effect_owners[effect_id] != file)
return -EACCES;
return 0;
} | false | false | false | false | false | 0 |
do_frame(float frametime)
{
//Figure out how much alpha
if(time_displayed < fade_time)
{
text_color.alpha = (ubyte)fl2i(255.0f*(time_displayed/fade_time));
}
else if(time_displayed > time_displayed_end)
{
//We're finished
return;
}
else if((time_displayed - fade_time) > display_time)
{
text_color.alpha = (ubyte)fl2i(255.0f*(1-(time_displayed - fade_time - display_time)/fade_time));
}
else
{
text_color.alpha = 255;
}
gr_set_color_fast(&text_color);
// save old font and set new font
int old_fontnum;
if (text_fontnum >= 0)
{
old_fontnum = gr_get_current_fontnum();
gr_set_font(text_fontnum);
}
else
{
old_fontnum = -1;
}
int font_height = gr_get_font_height();
int x = text_pos.x;
int y = text_pos.y;
for(SCP_vector<SCP_string>::iterator line = text_lines.begin(); line != text_lines.end(); ++line)
{
gr_string(x, y, (char*)line->c_str(), false);
y += font_height;
}
// restore old font
if (old_fontnum >= 0)
{
gr_set_font(old_fontnum);
}
if(image_id >= 0)
{
gr_set_bitmap(image_id, GR_ALPHABLEND_FILTER, GR_BITBLT_MODE_NORMAL, text_color.alpha/255.0f);
// scaling?
if (image_pos.w > 0 || image_pos.h > 0)
{
int orig_w, orig_h;
vec3d scale;
bm_get_info(image_id, &orig_w, &orig_h);
scale.xyz.x = image_pos.w / (float) orig_w;
scale.xyz.y = image_pos.h / (float) orig_h;
scale.xyz.z = 1.0f;
gr_push_scale_matrix(&scale);
gr_bitmap(image_pos.x, image_pos.y, false);
gr_pop_scale_matrix();
}
// no scaling
else
{
gr_bitmap(image_pos.x, image_pos.y, false);
}
}
time_displayed += frametime;
} | false | false | false | false | false | 0 |
graphicsToDeviceCoordinates(const JsGraphics *gfx, short *x, short *y) {
if (gfx->data.flags & JSGRAPHICSFLAGS_SWAP_XY) {
short t = *x;
*x = *y;
*y = t;
}
if (gfx->data.flags & JSGRAPHICSFLAGS_INVERT_X) *x = (short)(gfx->data.width - (*x+1));
if (gfx->data.flags & JSGRAPHICSFLAGS_INVERT_Y) *y = (short)(gfx->data.height - (*y+1));
} | false | false | false | false | false | 0 |
list_read(SparseElementList *l, FILE *fp, int n_elts) {
SparseNode n, pn;
int i;
size_t unused;
if (!l || !fp || n_elts < 0) {
if (MATR_DEBUG_MODE) {
fprintf(stderr, "list_write: null arguments.\n");
}
return 0;
}
if (!list_is_empty(l)) {
list_clear(l);
}
l->last_addr = NULL;
unused = fread(l, sizeof(SparseElementList), 1, fp);
if (n_elts <= 0) {
return 0;
}
l->head = node_read(l->compact, fp);
pn = l->head;
for (i = 1; i < n_elts; i++) {
if (null_node(pn)) {
break;
}
n = node_read(l->compact, fp);
if (null_node(n)) {
break;
}
if (l->compact) {
pn.compact->next = n.compact;
n.compact->prev = pn.compact;
} else {
pn.precise->next = n.precise;
n.precise->prev = pn.precise;
}
pn = n;
}
if (i != n_elts) {
if (!null_node(pn)) {
if (l->compact) {
pn.compact->next = NULL;
} else {
pn.precise->next = NULL;
}
}
if (MATR_DEBUG_MODE) {
fprintf(stderr, "list_read: Couldn't read in enough elements.\n");
}
}
l->tail = pn;
return i;
} | false | false | false | false | false | 0 |
linkDestination( const QString &name )
{
GooString * namedDest = QStringToGooString( name );
LinkDestinationData ldd(NULL, namedDest, m_doc, false);
LinkDestination *ld = new LinkDestination(ldd);
delete namedDest;
return ld;
} | false | false | false | false | false | 0 |
mag_g_pop_open(mag_t *g, int min_elen)
{
int64_t i;
for (i = 0; i < g->v.n; ++i)
mag_v_pop_open(g, &g->v.a[i], min_elen);
mag_g_merge(g, 0);
} | false | false | false | false | false | 0 |
xgene_enet_clear(struct xgene_enet_pdata *pdata,
struct xgene_enet_desc_ring *ring)
{
u32 addr, val, data;
val = xgene_enet_ring_bufnum(ring->id);
if (xgene_enet_is_bufpool(ring->id)) {
addr = ENET_CFGSSQMIFPRESET_ADDR;
data = BIT(val - 0x20);
} else {
addr = ENET_CFGSSQMIWQRESET_ADDR;
data = BIT(val);
}
xgene_enet_wr_ring_if(pdata, addr, data);
} | false | false | false | false | false | 0 |
updateFreqBandTable(HANDLE_SBR_CONFIG_DATA sbrConfigData,
HANDLE_SBR_HEADER_DATA sbrHeaderData,
INT noQmfChannels)
{
INT k0, k2;
if(FDKsbrEnc_FindStartAndStopBand(sbrConfigData->sampleFreq,
noQmfChannels,
sbrHeaderData->sbr_start_frequency,
sbrHeaderData->sbr_stop_frequency,
sbrHeaderData->sampleRateMode,
&k0, &k2))
return(1);
if(FDKsbrEnc_UpdateFreqScale(sbrConfigData->v_k_master, &sbrConfigData->num_Master,
k0, k2, sbrHeaderData->freqScale,
sbrHeaderData->alterScale))
return(1);
sbrHeaderData->sbr_xover_band=0;
if(FDKsbrEnc_UpdateHiRes(sbrConfigData->freqBandTable[HI],
&sbrConfigData->nSfb[HI],
sbrConfigData->v_k_master,
sbrConfigData->num_Master ,
&sbrHeaderData->sbr_xover_band,
sbrHeaderData->sampleRateMode,
noQmfChannels))
return(1);
FDKsbrEnc_UpdateLoRes(sbrConfigData->freqBandTable[LO],
&sbrConfigData->nSfb[LO],
sbrConfigData->freqBandTable[HI],
sbrConfigData->nSfb[HI]);
sbrConfigData->xOverFreq = (sbrConfigData->freqBandTable[LOW_RES][0] * sbrConfigData->sampleFreq / noQmfChannels+1)>>1;
return (0);
} | false | false | false | false | false | 0 |
ttusb_dec_exit_dvb(struct ttusb_dec *dec)
{
dprintk("%s\n", __func__);
dvb_net_release(&dec->dvb_net);
dec->demux.dmx.close(&dec->demux.dmx);
dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend);
dvb_dmxdev_release(&dec->dmxdev);
dvb_dmx_release(&dec->demux);
if (dec->fe) {
dvb_unregister_frontend(dec->fe);
if (dec->fe->ops.release)
dec->fe->ops.release(dec->fe);
}
dvb_unregister_adapter(&dec->adapter);
} | false | false | false | false | false | 0 |
gst_app_sink_render_common (GstBaseSink * psink, GstMiniObject * data,
gboolean is_list)
{
GstFlowReturn ret;
GstAppSink *appsink = GST_APP_SINK_CAST (psink);
GstAppSinkPrivate *priv = appsink->priv;
gboolean emit;
restart:
g_mutex_lock (priv->mutex);
if (priv->flushing)
goto flushing;
GST_DEBUG_OBJECT (appsink, "pushing render buffer%s %p on queue (%d)",
is_list ? " list" : "", data, priv->queue->length);
while (priv->max_buffers > 0 && priv->queue->length >= priv->max_buffers) {
if (priv->drop) {
GstMiniObject *obj;
/* we need to drop the oldest buffer/list and try again */
obj = g_queue_pop_head (priv->queue);
GST_DEBUG_OBJECT (appsink, "dropping old buffer/list %p", obj);
gst_mini_object_unref (obj);
} else {
GST_DEBUG_OBJECT (appsink, "waiting for free space, length %d >= %d",
priv->queue->length, priv->max_buffers);
if (priv->unlock) {
/* we are asked to unlock, call the wait_preroll method */
g_mutex_unlock (priv->mutex);
if ((ret = gst_base_sink_wait_preroll (psink)) != GST_FLOW_OK)
goto stopping;
/* we are allowed to continue now */
goto restart;
}
/* wait for a buffer to be removed or flush */
g_cond_wait (priv->cond, priv->mutex);
if (priv->flushing)
goto flushing;
}
}
/* we need to ref the buffer when pushing it in the queue */
g_queue_push_tail (priv->queue, gst_mini_object_ref (data));
g_cond_signal (priv->cond);
emit = priv->emit_signals;
g_mutex_unlock (priv->mutex);
if (is_list) {
if (priv->callbacks.new_buffer_list)
priv->callbacks.new_buffer_list (appsink, priv->user_data);
else if (emit)
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_BUFFER_LIST], 0);
} else {
if (priv->callbacks.new_buffer)
priv->callbacks.new_buffer (appsink, priv->user_data);
else if (emit)
g_signal_emit (appsink, gst_app_sink_signals[SIGNAL_NEW_BUFFER], 0);
}
return GST_FLOW_OK;
flushing:
{
GST_DEBUG_OBJECT (appsink, "we are flushing");
g_mutex_unlock (priv->mutex);
return GST_FLOW_WRONG_STATE;
}
stopping:
{
GST_DEBUG_OBJECT (appsink, "we are stopping");
return ret;
}
} | false | false | false | false | false | 0 |
feed_mailstorage_init(struct mailstorage * storage,
const char * feed_url,
int feed_cached, const char * feed_cache_directory,
const char * feed_flags_directory)
{
struct feed_mailstorage * feed_storage;
int res;
feed_storage = malloc(sizeof(* feed_storage));
if (feed_storage == NULL) {
res = MAIL_ERROR_MEMORY;
goto err;
}
feed_storage->feed_url = strdup(feed_url);
if (feed_storage->feed_url == NULL) {
res = MAIL_ERROR_MEMORY;
goto free;
}
feed_storage->feed_cached = feed_cached;
if (feed_cached && (feed_cache_directory != NULL) &&
(feed_flags_directory != NULL)) {
feed_storage->feed_cache_directory = strdup(feed_cache_directory);
if (feed_storage->feed_cache_directory == NULL) {
res = MAIL_ERROR_MEMORY;
goto free_url;
}
feed_storage->feed_flags_directory = strdup(feed_flags_directory);
if (feed_storage->feed_flags_directory == NULL) {
res = MAIL_ERROR_MEMORY;
goto free_cache_directory;
}
}
else {
feed_storage->feed_cached = FALSE;
feed_storage->feed_cache_directory = NULL;
feed_storage->feed_flags_directory = NULL;
}
storage->sto_data = feed_storage;
storage->sto_driver = &feed_mailstorage_driver;
return MAIL_NO_ERROR;
free_cache_directory:
free(feed_storage->feed_cache_directory);
free_url:
free(feed_storage->feed_url);
free:
free(feed_storage);
err:
return res;
} | false | false | false | false | false | 0 |
ensBasealignfeatureNewIniP(
EnsPProteinalignfeatureadaptor pafa,
ajuint identifier,
EnsPFeaturepair fp,
AjPStr cigar)
{
EnsPBasealignfeature baf = NULL;
if (!fp)
return NULL;
if (!cigar)
return NULL;
AJNEW0(baf);
baf->Use = 1U;
baf->Identifier = identifier;
baf->Proteinalignfeatureadaptor = pafa;
baf->Featurepair = ensFeaturepairNewRef(fp);
baf->FobjectGetFeaturepair = (EnsPFeaturepair (*) (const void*))
&ensBasealignfeatureGetFeaturepair;
if (cigar)
baf->Cigar = ajStrNewRef(cigar);
baf->Type = ensEBasealignfeatureTypeProtein;
baf->Pairdnaalignfeatureidentifier = 0;
return baf;
} | false | false | false | false | false | 0 |
dax_load_hole(struct address_space *mapping, struct page *page,
struct vm_fault *vmf)
{
unsigned long size;
struct inode *inode = mapping->host;
if (!page)
page = find_or_create_page(mapping, vmf->pgoff,
GFP_KERNEL | __GFP_ZERO);
if (!page)
return VM_FAULT_OOM;
/* Recheck i_size under page lock to avoid truncate race */
size = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT;
if (vmf->pgoff >= size) {
unlock_page(page);
page_cache_release(page);
return VM_FAULT_SIGBUS;
}
vmf->page = page;
return VM_FAULT_LOCKED;
} | false | false | false | false | false | 0 |
visornic_cleanup(void)
{
visorbus_unregister_visor_driver(&visornic_driver);
if (visornic_timeout_reset_workqueue) {
flush_workqueue(visornic_timeout_reset_workqueue);
destroy_workqueue(visornic_timeout_reset_workqueue);
}
debugfs_remove_recursive(visornic_debugfs_dir);
} | false | false | false | false | false | 0 |
vc1_put_block(VC1Context *v, DCTELEM block[6][64])
{
uint8_t *Y;
int ys, us, vs;
DSPContext *dsp = &v->s.dsp;
if(v->rangeredfrm) {
int i, j, k;
for(k = 0; k < 6; k++)
for(j = 0; j < 8; j++)
for(i = 0; i < 8; i++)
block[k][i + j*8] = ((block[k][i + j*8] - 128) << 1) + 128;
}
ys = v->s.current_picture.linesize[0];
us = v->s.current_picture.linesize[1];
vs = v->s.current_picture.linesize[2];
Y = v->s.dest[0];
dsp->put_pixels_clamped(block[0], Y, ys);
dsp->put_pixels_clamped(block[1], Y + 8, ys);
Y += ys * 8;
dsp->put_pixels_clamped(block[2], Y, ys);
dsp->put_pixels_clamped(block[3], Y + 8, ys);
if(!(v->s.flags & CODEC_FLAG_GRAY)) {
dsp->put_pixels_clamped(block[4], v->s.dest[1], us);
dsp->put_pixels_clamped(block[5], v->s.dest[2], vs);
}
} | false | false | false | false | false | 0 |
ircprot_freectcp(struct ctcpmessage *cmsg) {
int i;
for (i = 0; i < cmsg->numparams; i++)
free(cmsg->params[i]);
free(cmsg->cmd);
free(cmsg->params);
free(cmsg->paramstarts);
free(cmsg->orig);
} | false | false | false | false | false | 0 |
draw ()
{
int i;
if (active && visible)
{
for (i = 0; i < numcomponents; i ++)
{
components [i]->draw ();
}
}
} | false | false | false | false | false | 0 |
ValidateDayOfTheYear(const char* &start) //Jn,n,Mm.n.d
{
string str="";
switch(*start)
{
case 'J':
str='J'+ValidateJulianDay((++start));
break;
case 'M':
str='M'+ValidateDayOfTheWeek(++start);
break;
default:
str=ValidateZeroJulianDay((start));
break;
}
if (!Valid) return "";
return str;
} | false | false | false | false | false | 0 |
hwloc_bitmap_compare_first(const struct hwloc_bitmap_s * set1, const struct hwloc_bitmap_s * set2)
{
unsigned i;
HWLOC__BITMAP_CHECK(set1);
HWLOC__BITMAP_CHECK(set2);
for(i=0; i<set1->ulongs_count || i<set2->ulongs_count; i++) {
unsigned long w1 = HWLOC_SUBBITMAP_READULONG(set1, i);
unsigned long w2 = HWLOC_SUBBITMAP_READULONG(set2, i);
if (w1 || w2) {
int _ffs1 = hwloc_ffsl(w1);
int _ffs2 = hwloc_ffsl(w2);
/* if both have a bit set, compare for real */
if (_ffs1 && _ffs2)
return _ffs1-_ffs2;
/* one is empty, and it is considered higher, so reverse-compare them */
return _ffs2-_ffs1;
}
}
if ((!set1->infinite) != (!set2->infinite))
return !!set1->infinite - !!set2->infinite;
return 0;
} | false | false | false | false | false | 0 |
markQueryForLocking(Query *qry, Node *jtnode,
bool forUpdate, bool noWait, bool pushedDown)
{
if (jtnode == NULL)
return;
if (IsA(jtnode, RangeTblRef))
{
int rti = ((RangeTblRef *) jtnode)->rtindex;
RangeTblEntry *rte = rt_fetch(rti, qry->rtable);
if (rte->rtekind == RTE_RELATION)
{
applyLockingClause(qry, rti, forUpdate, noWait, pushedDown);
rte->requiredPerms |= ACL_SELECT_FOR_UPDATE;
}
else if (rte->rtekind == RTE_SUBQUERY)
{
applyLockingClause(qry, rti, forUpdate, noWait, pushedDown);
/* FOR UPDATE/SHARE of subquery is propagated to subquery's rels */
markQueryForLocking(rte->subquery, (Node *) rte->subquery->jointree,
forUpdate, noWait, true);
}
/* other RTE types are unaffected by FOR UPDATE */
}
else if (IsA(jtnode, FromExpr))
{
FromExpr *f = (FromExpr *) jtnode;
ListCell *l;
foreach(l, f->fromlist)
markQueryForLocking(qry, lfirst(l), forUpdate, noWait, pushedDown);
}
else if (IsA(jtnode, JoinExpr))
{
JoinExpr *j = (JoinExpr *) jtnode;
markQueryForLocking(qry, j->larg, forUpdate, noWait, pushedDown);
markQueryForLocking(qry, j->rarg, forUpdate, noWait, pushedDown);
}
else
elog(ERROR, "unrecognized node type: %d",
(int) nodeTag(jtnode));
} | false | false | false | false | false | 0 |
set_script(cmd_parms *cmd, void *m_v,
const char *method, const char *script)
{
action_dir_config *m = (action_dir_config *)m_v;
int methnum;
if (cmd->pool == cmd->temp_pool) {
/* In .htaccess, we can't globally register new methods. */
methnum = ap_method_number_of(method);
}
else {
/* ap_method_register recognizes already registered methods,
* so don't bother to check its previous existence explicitely.
*/
methnum = ap_method_register(cmd->pool, method);
}
if (methnum == M_TRACE) {
return "TRACE not allowed for Script";
}
else if (methnum == M_INVALID) {
return apr_pstrcat(cmd->pool, "Could not register method '", method,
"' for Script", NULL);
}
m->scripted[methnum] = script;
m->configured = 1;
return NULL;
} | false | false | false | false | false | 0 |
vs_remove_connection(void)
{
unsigned int i, j;
VSession *session;
VSSubscriptionList *list;
session = VSConnectionStorage.connection[VSConnectionStorage.current_session].session;
for(i = 0; i < VSConnectionStorage.list_length; i++)
{
list = VSConnectionStorage.list[i];
for(j = 0; j < list->session_count && list->session[j] != session; j++);
if(j < list->session_count)
list->session[j] = list->session[--list->session_count];
}
j = --VSConnectionStorage.connection_length;
if(VSConnectionStorage.current_session < j)
{
VSConnectionStorage.connection[VSConnectionStorage.current_session].session = VSConnectionStorage.connection[j].session;
VSConnectionStorage.connection[VSConnectionStorage.current_session].node_id = VSConnectionStorage.connection[j].node_id;
}
else
VSConnectionStorage.current_session = 0;
} | false | false | false | false | false | 0 |
write(hsStream* S) {
S->writeByte(3);
S->writeSafeStr(fName);
S->writeShort(fDisplay.len());
S->writeStr(fDisplay);
S->writeInt(fCount);
S->writeByte(fType);
S->writeSafeStr(fDefault);
S->writeInt(fFlags);
if (fType == kStateDescriptor) {
S->writeSafeStr(fStateDescType);
S->writeShort(fStateDescVer);
} else {
S->writeShort(fCount);
S->writeByte(fType);
}
} | false | false | false | false | false | 0 |
ApplyFunction(uint64_t iLODLevel,
bool (*brickFunc)(void* pData,
const UINT64VECTOR3& vBrickSize,
const UINT64VECTOR3& vBrickOffset,
void* pUserContext),
void *pUserContext,
uint64_t iOverlap) const {
if (m_bToCBlock) {
bool okay = true;
for(std::vector<Timestep*>::const_iterator ts = m_timesteps.begin();
ts != m_timesteps.end(); ++ts) {
const TOCTimestep* toc_ts = static_cast<TOCTimestep*>(*ts);
okay &= toc_ts->GetDB()->ApplyFunction(
iLODLevel,
brickFunc, pUserContext,
uint32_t(iOverlap), &Controller::Debug::Out()
);
}
return okay;
} else {
std::vector<uint64_t> vLOD; vLOD.push_back(iLODLevel);
bool okay = true;
for(std::vector<Timestep*>::const_iterator ts = m_timesteps.begin();
ts != m_timesteps.end(); ++ts) {
const RDTimestep* rd_ts = static_cast<RDTimestep*>(*ts);
okay &= rd_ts->GetDB()->ApplyFunction(
vLOD, brickFunc, pUserContext,
iOverlap, &Controller::Debug::Out()
);
}
return okay;
}
} | false | false | false | false | false | 0 |
iraf2str (irafstring, nchar)
char *irafstring; /* IRAF 2-byte/character string */
int nchar; /* Number of characters in string */
{
char *string;
int i, j;
/* Set swap flag according to position of nulls in 2-byte characters */
if (headswap < 0) {
if (irafstring[0] != 0 && irafstring[1] == 0)
headswap = 1;
else if (irafstring[0] == 0 && irafstring[1] != 0)
headswap = 0;
else
return (NULL);
}
string = (char *) calloc (nchar+1, 1);
if (string == NULL) {
(void)fprintf(stderr, "IRAF2STR Cannot allocate %d-byte variable\n",
nchar+1);
return (NULL);
}
/* Swap bytes, if requested */
if (headswap)
j = 0;
else
j = 1;
/* Convert appropriate byte of input to output character */
for (i = 0; i < nchar; i++) {
string[i] = irafstring[j];
j = j + 2;
}
return (string);
} | false | false | false | false | false | 0 |
PrepareTrailer (HPDF_Doc pdf)
{
HPDF_PTRACE ((" PrepareTrailer\n"));
if (HPDF_Dict_Add (pdf->trailer, "Root", pdf->catalog) != HPDF_OK)
return pdf->error.error_no;
if (HPDF_Dict_Add (pdf->trailer, "Info", pdf->info) != HPDF_OK)
return pdf->error.error_no;
return HPDF_OK;
} | false | false | false | false | false | 0 |
write_regscript( const statement_list_t *stmts )
{
const type_t *ps_factory;
if (!do_regscript) return;
if (do_everything && !need_proxy_file( stmts )) return;
init_output_buffer();
put_str( indent, "HKCR\n" );
put_str( indent++, "{\n" );
put_str( indent, "NoRemove Interface\n" );
put_str( indent++, "{\n" );
ps_factory = find_ps_factory( stmts );
if (ps_factory) write_interfaces( stmts, ps_factory );
put_str( --indent, "}\n" );
put_str( indent, "NoRemove CLSID\n" );
put_str( indent++, "{\n" );
write_coclasses( stmts, NULL );
put_str( --indent, "}\n" );
write_progids( stmts );
put_str( --indent, "}\n" );
if (strendswith( regscript_name, ".res" )) /* create a binary resource file */
{
add_output_to_resources( "WINE_REGISTRY", regscript_token );
flush_output_resources( regscript_name );
}
else
{
FILE *f = fopen( regscript_name, "w" );
if (!f) error( "Could not open %s for output\n", regscript_name );
if (fwrite( output_buffer, output_buffer_pos, 1, f ) != output_buffer_pos)
error( "Failed to write to %s\n", regscript_name );
if (fclose( f ))
error( "Failed to write to %s\n", regscript_name );
}
} | false | false | false | false | true | 1 |
populateColors()
{
const QStringList colorNames = QStringList()
// Basic 16 HTML colors (minus greys):
<< "black"
<< "white"
<< "maroon"
<< "red"
<< "purple"
<< "fuchsia"
<< "green"
<< "lime"
<< "olive"
<< "yellow"
<< "navy"
<< "blue"
<< "teal"
<< "aqua"
// Greys
<< "gainsboro"
<< "lightgrey"
<< "silver"
<< "darkgrey"
<< "grey"
<< "dimgrey"
// Reds
<< "tomato"
<< "orangered"
<< "orange"
<< "crimson"
<< "darkred"
// Greens
<< "greenyellow"
<< "lightgreen"
<< "darkgreen"
<< "lightseagreen"
// Blues
<< "lightcyan"
<< "darkturquoise"
<< "steelblue"
<< "lightblue"
<< "royalblue"
<< "darkblue"
<< "midnightblue"
// Browns
<< "bisque"
<< "tan"
<< "sandybrown"
<< "chocolate";
for ( QStringList::const_iterator i = colorNames.constBegin();
i != colorNames.constEnd(); ++i ) {
QPixmap solidPixmap( 20, 10 );
solidPixmap.fill( QColor( *i ) );
QIcon* solidIcon = new QIcon( solidPixmap );
foreColorBox->addItem( *solidIcon, *i );
backColorBox->addItem( *solidIcon, *i );
}
} | false | false | false | false | false | 0 |
panel_act_CMPDIR(this, other, quick)
panel_t *this;
panel_t *other;
int quick;
{
int i, j;
il_message(PANEL_COMPARE_DIR_MSG);
tty_update();
if (strcmp(this->path, other->path) == 0)
{
panel_1s_message("No point in comparing a directory with itself. ",
(char *)NULL, IL_BEEP | IL_SAVE | IL_ERROR);
panel_unselect_all(this);
panel_unselect_all(other);
panel_update(this);
panel_update(other);
return;
}
panel_select_all(this);
panel_select_all(other);
for (i = 1; i < this->entries; i++)
if (this->dir_entry[i].type == FILE_ENTRY)
for (j = 1; j < other->entries; j++)
{
service_pending_signals();
if (other->dir_entry[j].type == FILE_ENTRY &&
strcmp(this->dir_entry[i].name,
other->dir_entry[j].name) == 0)
{
if (this->dir_entry[i].size == other->dir_entry[j].size)
{
if (quick)
{
if (this->dir_entry[i].mtime !=
other->dir_entry[j].mtime)
goto hilight_the_newer_one;
else
goto unhilight_both;
}
else
{
off64_t this_size, other_size;
off64_t result = panel_compare(this, i, &this_size,
other, j, &other_size);
if (result == CF_ABORT)
goto done;
if ((result == this_size) &&
(result == other_size))
goto unhilight_both;
}
}
hilight_the_newer_one:
/* We don't use difftime(), to avoid floating
point (Thix doesn't have fp :-(). Not good. */
if (this->dir_entry[i].mtime >= other->dir_entry[j].mtime)
{
other->dir_entry[j].selected = 0;
other->selected_entries--;
}
else
{
this->dir_entry[i].selected = 0;
this->selected_entries--;
}
break;
unhilight_both:
this->dir_entry[i].selected = 0;
this->selected_entries--;
other->dir_entry[j].selected = 0;
other->selected_entries--;
break;
}
}
done:
status_default();
panel_update(this);
panel_update(other);
tty_update();
/* Beep if there are differences. */
if (this->selected_entries || other->selected_entries)
tty_beep();
} | false | false | false | false | false | 0 |
gdkgc_gdk_gc_new_with_values(ScmObj *SCM_FP, int SCM_ARGCNT, void *data_)
{
ScmObj drawable_scm;
GdkDrawable* drawable;
ScmObj values_scm;
GdkGCValues* values;
ScmObj mask_scm;
int mask;
ScmObj SCM_SUBRARGS[3];
int SCM_i;
SCM_ENTER_SUBR("gdk-gc-new-with-values");
for (SCM_i=0; SCM_i<3; SCM_i++) {
SCM_SUBRARGS[SCM_i] = SCM_ARGREF(SCM_i);
}
drawable_scm = SCM_SUBRARGS[0];
if (!SCM_GDK_DRAWABLE_P(drawable_scm)) Scm_Error("<gdk-drawable> required, but got %S", drawable_scm);
drawable = SCM_GDK_DRAWABLE(drawable_scm);
values_scm = SCM_SUBRARGS[1];
if (!SCM_GDK_GC_VALUES_P(values_scm)) Scm_Error("<gdk-gc-values> required, but got %S", values_scm);
values = SCM_GDK_GC_VALUES(values_scm);
mask_scm = SCM_SUBRARGS[2];
if (!SCM_INTEGERP(mask_scm)) Scm_Error("C integer required, but got %S", mask_scm);
mask = Scm_GetInteger(mask_scm);
{
SCM_RETURN(SCM_MAKE_GDK_GC(gdk_gc_new_with_values(drawable, values, mask)));
}
} | false | false | false | false | false | 0 |
receiveStatusMessage(std::string& message)
{
message.clear();
int status = receiveStatusLine(message);
if (status < 0)
{
while (status <= 0)
{
message += '\n';
status = receiveStatusLine(message);
}
}
return status;
} | false | false | false | false | false | 0 |
print()
{
OsiRowCut * cut;
if (way_ < 0) {
cut = &down_;
printf("CbcCut would branch down");
} else {
cut = &up_;
printf("CbcCut would branch up");
}
double lb = cut->lb();
double ub = cut->ub();
int n = cut->row().getNumElements();
const int * column = cut->row().getIndices();
const double * element = cut->row().getElements();
if (n > 5) {
printf(" - %d elements, lo=%g, up=%g\n", n, lb, ub);
} else {
printf(" - %g <=", lb);
for (int i = 0; i < n; i++) {
int iColumn = column[i];
double value = element[i];
printf(" (%d,%g)", iColumn, value);
}
printf(" <= %g\n", ub);
}
} | false | false | false | false | false | 0 |
cvt_32(union VALUETYPE *p, const struct magic *m)
{
DO_CVT(l, (uint32_t));
} | false | false | false | false | false | 0 |
ResetTheory(GtkWidget * UNUSED(pw), theorywidget * ptw)
{
float aarRates[2][2];
evalcontext ec = { FALSE, 0, FALSE, TRUE, 0.0 };
float arOutput[NUM_OUTPUTS];
int i, j;
/* get current gammon rates */
GetMatchStateCubeInfo(&ptw->ci, &ms);
getCurrentGammonRates(aarRates, arOutput, msBoard(), &ptw->ci, &ec);
/* cube */
j = 1;
for (i = 0; i < 7; i++) {
if (j == ptw->ci.nCube) {
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ptw->apwCube[i]), TRUE);
break;
}
j *= 2;
}
/* set match play/money play radio button */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ptw->apwRadio[ptw->ci.nMatchTo == 0]), TRUE);
/* crawford, jacoby, beavers */
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ptw->pwCrawford), ptw->ci.fCrawford);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ptw->pwJacoby), ptw->ci.fJacoby);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ptw->pwBeavers), ptw->ci.fBeavers);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(ptw->apwPly[ec.nPlies]), TRUE);
for (i = 0; i < 2; i++) {
/* set score for player i */
gtk_adjustment_set_value(GTK_ADJUSTMENT(ptw->apwScoreAway[i]),
(ptw->ci.nMatchTo) ? (ptw->ci.nMatchTo - ptw->ci.anScore[i]) : 1);
for (j = 0; j < 2; j++)
/* gammon/backgammon rates */
gtk_adjustment_set_value(GTK_ADJUSTMENT(ptw->aapwRates[i][j]), aarRates[i][j] * 100.0f);
}
} | false | false | false | false | false | 0 |
FindDuplicateQuestion(const mDNS *const m, const DNSQuestion *const question)
{
DNSQuestion *q;
// Note: A question can only be marked as a duplicate of one that occurs *earlier* in the list.
// This prevents circular references, where two questions are each marked as a duplicate of the other.
// Accordingly, we break out of the loop when we get to 'question', because there's no point searching
// further in the list.
for (q = m->Questions; q && q != question; q=q->next) // Scan our list of questions
if (q->InterfaceID == question->InterfaceID && // for another question with the same InterfaceID,
q->qtype == question->qtype && // type,
q->qclass == question->qclass && // class,
q->qnamehash == question->qnamehash &&
SameDomainName(&q->qname, &question->qname)) // and name
return(q);
return(mDNSNULL);
} | false | false | false | false | false | 0 |
shouldSkip(MachineBasicBlock *From,
MachineBasicBlock *To) {
unsigned NumInstr = 0;
for (MachineBasicBlock *MBB = From; MBB != To && !MBB->succ_empty();
MBB = *MBB->succ_begin()) {
for (MachineBasicBlock::iterator I = MBB->begin(), E = MBB->end();
NumInstr < SkipThreshold && I != E; ++I) {
if (I->isBundle() || !I->isBundled())
if (++NumInstr >= SkipThreshold)
return true;
}
}
return false;
} | false | false | false | false | false | 0 |
split_virtual_grfs()
{
int num_vars = this->virtual_grf_count;
int new_virtual_grf[num_vars];
bool split_grf[num_vars];
memset(new_virtual_grf, 0, sizeof(new_virtual_grf));
/* Try to split anything > 0 sized. */
for (int i = 0; i < num_vars; i++) {
split_grf[i] = this->virtual_grf_sizes[i] != 1;
}
/* Check that the instructions are compatible with the registers we're trying
* to split.
*/
foreach_list(node, &this->instructions) {
vec4_instruction *inst = (vec4_instruction *)node;
/* If there's a SEND message loading from a GRF on gen7+, it needs to be
* contiguous.
*/
if (inst->is_send_from_grf()) {
for (int i = 0; i < 3; i++) {
if (inst->src[i].file == GRF) {
split_grf[inst->src[i].reg] = false;
}
}
}
}
/* Allocate new space for split regs. Note that the virtual
* numbers will be contiguous.
*/
for (int i = 0; i < num_vars; i++) {
if (!split_grf[i])
continue;
new_virtual_grf[i] = virtual_grf_alloc(1);
for (int j = 2; j < this->virtual_grf_sizes[i]; j++) {
int reg = virtual_grf_alloc(1);
assert(reg == new_virtual_grf[i] + j - 1);
(void) reg;
}
this->virtual_grf_sizes[i] = 1;
}
foreach_list(node, &this->instructions) {
vec4_instruction *inst = (vec4_instruction *)node;
if (inst->dst.file == GRF && split_grf[inst->dst.reg] &&
inst->dst.reg_offset != 0) {
inst->dst.reg = (new_virtual_grf[inst->dst.reg] +
inst->dst.reg_offset - 1);
inst->dst.reg_offset = 0;
}
for (int i = 0; i < 3; i++) {
if (inst->src[i].file == GRF && split_grf[inst->src[i].reg] &&
inst->src[i].reg_offset != 0) {
inst->src[i].reg = (new_virtual_grf[inst->src[i].reg] +
inst->src[i].reg_offset - 1);
inst->src[i].reg_offset = 0;
}
}
}
invalidate_live_intervals();
} | false | false | false | false | false | 0 |
ldm_validate_vmdb(struct parsed_partitions *state,
unsigned long base, struct ldmdb *ldb)
{
Sector sect;
u8 *data;
bool result = false;
struct vmdb *vm;
struct tocblock *toc;
BUG_ON (!state || !ldb);
vm = &ldb->vm;
toc = &ldb->toc;
data = read_part_sector(state, base + OFF_VMDB, §);
if (!data) {
ldm_crit ("Disk read failed.");
return false;
}
if (!ldm_parse_vmdb (data, vm))
goto out; /* Already logged */
/* Are there uncommitted transactions? */
if (get_unaligned_be16(data + 0x10) != 0x01) {
ldm_crit ("Database is not in a consistent state. Aborting.");
goto out;
}
if (vm->vblk_offset != 512)
ldm_info ("VBLKs start at offset 0x%04x.", vm->vblk_offset);
/*
* The last_vblkd_seq can be before the end of the vmdb, just make sure
* it is not out of bounds.
*/
if ((vm->vblk_size * vm->last_vblk_seq) > (toc->bitmap1_size << 9)) {
ldm_crit ("VMDB exceeds allowed size specified by TOCBLOCK. "
"Database is corrupt. Aborting.");
goto out;
}
result = true;
out:
put_dev_sector (sect);
return result;
} | false | false | false | false | false | 0 |
TLan_SetMac(struct nic *nic __unused, int areg, unsigned char *mac)
{
int i;
areg *= 6;
if (mac != NULL) {
for (i = 0; i < 6; i++)
TLan_DioWrite8(BASE, TLAN_AREG_0 + areg + i,
mac[i]);
} else {
for (i = 0; i < 6; i++)
TLan_DioWrite8(BASE, TLAN_AREG_0 + areg + i, 0);
}
} | false | false | false | false | false | 0 |
irq_create_mapping(struct irq_domain *domain,
irq_hw_number_t hwirq)
{
struct device_node *of_node;
int virq;
pr_debug("irq_create_mapping(0x%p, 0x%lx)\n", domain, hwirq);
/* Look for default domain if nececssary */
if (domain == NULL)
domain = irq_default_domain;
if (domain == NULL) {
WARN(1, "%s(, %lx) called with NULL domain\n", __func__, hwirq);
return 0;
}
pr_debug("-> using domain @%p\n", domain);
of_node = irq_domain_get_of_node(domain);
/* Check if mapping already exists */
virq = irq_find_mapping(domain, hwirq);
if (virq) {
pr_debug("-> existing mapping on virq %d\n", virq);
return virq;
}
/* Allocate a virtual interrupt number */
virq = irq_domain_alloc_descs(-1, 1, hwirq, of_node_to_nid(of_node));
if (virq <= 0) {
pr_debug("-> virq allocation failed\n");
return 0;
}
if (irq_domain_associate(domain, virq, hwirq)) {
irq_free_desc(virq);
return 0;
}
pr_debug("irq %lu on domain %s mapped to virtual irq %u\n",
hwirq, of_node_full_name(of_node), virq);
return virq;
} | false | false | false | false | false | 0 |
queue_info_cleanup(void *data_)
{
fd_queue_info_t *qi = data_;
apr_thread_cond_destroy(qi->wait_for_idler);
apr_thread_mutex_destroy(qi->idlers_mutex);
/* Clean up any pools in the recycled list */
for (;;) {
struct recycled_pool *first_pool = qi->recycled_pools;
if (first_pool == NULL) {
break;
}
if (apr_atomic_casptr
((void*) &(qi->recycled_pools), first_pool->next,
first_pool) == first_pool) {
apr_pool_destroy(first_pool->pool);
}
}
return APR_SUCCESS;
} | false | false | false | false | false | 0 |
hup(sig)
int sig;
{
syslog(LOG_INFO, "Hangup (SIGHUP)");
kill_link = 1;
if (conn_running)
/* Send the signal to the [dis]connector process(es) also */
kill_my_pg(sig);
if (waiting)
longjmp(sigjmp, 1);
} | false | false | false | false | false | 0 |
pattern_walk_forward(int fd, pattern_op_t op, void **state_p, float *percent_p)
{
long storage[TESTBLOCK];
off64_t *state = *state_p;
pattern_result_t result = pr_continue;
switch( op) {
case op_init:
*state_p = calloc(1, sizeof(off64_t));
break;
case op_access:
*percent_p = 100.0*(unsigned long)*state/(unsigned long)file_size;
if( !is_offset_in_file(*state)) {
result = pr_finished;
break;
}
read_and_assert(fd, storage, sizeof(storage), *state);
*state += sizeof(storage) + (rand()%512-1) * sizeof(long);
break;
case op_fini:
free( state);
break;
}
return result;
} | false | false | false | false | false | 0 |
nssPKIX509_GetIssuerAndSerialFromDER(NSSDER *der, NSSArena *arena,
NSSDER *issuer, NSSDER *serial)
{
SECStatus secrv;
SECItem derCert;
SECItem derIssuer = { 0 };
SECItem derSerial = { 0 };
SECITEM_FROM_NSSITEM(&derCert, der);
secrv = CERT_SerialNumberFromDERCert(&derCert, &derSerial);
if (secrv != SECSuccess) {
return PR_FAILURE;
}
(void)nssItem_Create(arena, serial, derSerial.len, derSerial.data);
secrv = CERT_IssuerNameFromDERCert(&derCert, &derIssuer);
if (secrv != SECSuccess) {
PORT_Free(derSerial.data);
return PR_FAILURE;
}
(void)nssItem_Create(arena, issuer, derIssuer.len, derIssuer.data);
PORT_Free(derSerial.data);
PORT_Free(derIssuer.data);
return PR_SUCCESS;
} | false | false | false | false | false | 0 |
set_b_bus_req(struct device *dev, struct device_attribute *attr,
const char *buf, size_t count)
{
struct ci_hdrc *ci = dev_get_drvdata(dev);
if (count > 2)
return -1;
mutex_lock(&ci->fsm.lock);
if (buf[0] == '0')
ci->fsm.b_bus_req = 0;
else if (buf[0] == '1')
ci->fsm.b_bus_req = 1;
ci_otg_queue_work(ci);
mutex_unlock(&ci->fsm.lock);
return count;
} | false | false | false | false | false | 0 |
getClientRects()
{
if (isRenderInline() && isInlineFlow()) {
QList<QRectF> list;
InlineFlowBox *child = firstLineBox();
if (child) {
int x = 0, y = 0;
absolutePosition(x,y);
do {
QRectF rect(x + child->xPos(), y + child->yPos(), child->width(), child->height());
list.append(clientRectToViewport(rect));
child = child->nextFlowBox();
} while (child);
}
// In case our flow is splitted by blocks
for (RenderObject *cont = continuation(); cont; cont = cont->continuation()) {
list.append(cont->getClientRects());
}
// Empty Flow, return the Flow itself
if (list.isEmpty()) {
return RenderObject::getClientRects();
}
return list;
} else {
return RenderObject::getClientRects();
}
} | false | false | false | false | false | 0 |
gst_sbc_enc_fill_sbc_params(GstSbcEnc *enc, GstCaps *caps)
{
if (!gst_caps_is_fixed(caps)) {
GST_DEBUG_OBJECT(enc, "didn't receive fixed caps, "
"returning false");
return FALSE;
}
if (!gst_sbc_util_fill_sbc_params(&enc->sbc, caps))
return FALSE;
if (enc->rate != 0 && gst_sbc_parse_rate_from_sbc(enc->sbc.frequency)
!= enc->rate)
goto fail;
if (enc->channels != 0 && gst_sbc_get_channel_number(enc->sbc.mode)
!= enc->channels)
goto fail;
if (enc->blocks != 0 && gst_sbc_parse_blocks_from_sbc(enc->sbc.blocks)
!= enc->blocks)
goto fail;
if (enc->subbands != 0 && gst_sbc_parse_subbands_from_sbc(
enc->sbc.subbands) != enc->subbands)
goto fail;
if (enc->mode != SBC_ENC_DEFAULT_MODE && enc->sbc.mode != enc->mode)
goto fail;
if (enc->allocation != SBC_AM_AUTO &&
enc->sbc.allocation != enc->allocation)
goto fail;
if (enc->bitpool != SBC_ENC_BITPOOL_AUTO &&
enc->sbc.bitpool != enc->bitpool)
goto fail;
enc->codesize = sbc_get_codesize(&enc->sbc);
enc->frame_length = sbc_get_frame_length(&enc->sbc);
enc->frame_duration = sbc_get_frame_duration(&enc->sbc);
GST_DEBUG_OBJECT(enc, "codesize: %d, frame_length: %d, frame_duration:"
" %d", enc->codesize, enc->frame_length,
enc->frame_duration);
return TRUE;
fail:
memset(&enc->sbc, 0, sizeof(sbc_t));
return FALSE;
} | false | false | false | false | false | 0 |
__kvm_write_guest_page(struct kvm_memory_slot *memslot, gfn_t gfn,
const void *data, int offset, int len)
{
int r;
unsigned long addr;
addr = gfn_to_hva_memslot(memslot, gfn);
if (kvm_is_error_hva(addr))
return -EFAULT;
r = __copy_to_user((void __user *)addr + offset, data, len);
if (r)
return -EFAULT;
mark_page_dirty_in_slot(memslot, gfn);
return 0;
} | false | false | false | false | false | 0 |
FunctionCall4Coll(FmgrInfo *flinfo, Oid collation, Datum arg1, Datum arg2,
Datum arg3, Datum arg4)
{
FunctionCallInfoData fcinfo;
Datum result;
InitFunctionCallInfoData(fcinfo, flinfo, 4, collation, NULL, NULL);
fcinfo.arg[0] = arg1;
fcinfo.arg[1] = arg2;
fcinfo.arg[2] = arg3;
fcinfo.arg[3] = arg4;
fcinfo.argnull[0] = false;
fcinfo.argnull[1] = false;
fcinfo.argnull[2] = false;
fcinfo.argnull[3] = false;
result = FunctionCallInvoke(&fcinfo);
/* Check for null result, since caller is clearly not expecting one */
if (fcinfo.isnull)
elog(ERROR, "function %u returned NULL", fcinfo.flinfo->fn_oid);
return result;
} | false | false | false | false | false | 0 |
_dxfCategorize( Object o, char **comp_list )
{
catinfo c;
Object retval = o;
if ( !o ) {
DXSetError( ERROR_BAD_PARAMETER, "#10000", "input" );
return ERROR;
}
memset( ( char * ) & c, '\0', sizeof( c ) );
c.maxparallel = DXProcessors( 0 );
if ( c.maxparallel > 1 )
c.maxparallel = ( c.maxparallel - 1 ) * PFACTOR;
c.comp_list = comp_list;
c.o = ( Object ) o;
retval = Object_Categorize( &c );
return retval;
} | 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.