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 |
|---|---|---|---|---|---|---|
nfs_auth_info_add(struct nfs_auth_info *auth_info,
rpc_authflavor_t flavor)
{
unsigned int i;
unsigned int max_flavor_len = ARRAY_SIZE(auth_info->flavors);
/* make sure this flavor isn't already in the list */
for (i = 0; i < auth_info->flavor_len; i++) {
if (flavor == auth_info->flavors[i])
return true;
}
if (auth_info->flavor_len + 1 >= max_flavor_len) {
dfprintk(MOUNT, "NFS: too many sec= flavors\n");
return false;
}
auth_info->flavors[auth_info->flavor_len++] = flavor;
return true;
} | false | false | false | false | false | 0 |
dwarf_formblock(Dwarf_Attribute attr,
Dwarf_Block ** return_block, Dwarf_Error * error)
{
Dwarf_CU_Context cu_context = 0;
Dwarf_Debug dbg = 0;
Dwarf_Unsigned length = 0;
Dwarf_Small *data = 0;
Dwarf_Word leb128_length = 0;
Dwarf_Block *ret_block = 0;
int res = get_attr_dbg(&dbg,&cu_context,attr,error);
if(res != DW_DLV_OK) {
return res;
}
switch (attr->ar_attribute_form) {
case DW_FORM_block1:
length = *(Dwarf_Small *) attr->ar_debug_ptr;
data = attr->ar_debug_ptr + sizeof(Dwarf_Small);
break;
case DW_FORM_block2:
READ_UNALIGNED(dbg, length, Dwarf_Unsigned,
attr->ar_debug_ptr, sizeof(Dwarf_Half));
data = attr->ar_debug_ptr + sizeof(Dwarf_Half);
break;
case DW_FORM_block4:
READ_UNALIGNED(dbg, length, Dwarf_Unsigned,
attr->ar_debug_ptr, sizeof(Dwarf_ufixed));
data = attr->ar_debug_ptr + sizeof(Dwarf_ufixed);
break;
case DW_FORM_block:
length = _dwarf_decode_u_leb128(attr->ar_debug_ptr,
&leb128_length);
data = attr->ar_debug_ptr + leb128_length;
break;
default:
_dwarf_error(cu_context->cc_dbg, error, DW_DLE_ATTR_FORM_BAD);
return (DW_DLV_ERROR);
}
/* Check that block lies within current cu in .debug_info. */
if (attr->ar_debug_ptr + length >=
dbg->de_debug_info.dss_data + cu_context->cc_debug_offset +
cu_context->cc_length + cu_context->cc_length_size +
cu_context->cc_extension_size) {
_dwarf_error(dbg, error, DW_DLE_ATTR_FORM_SIZE_BAD);
return (DW_DLV_ERROR);
}
ret_block = (Dwarf_Block *) _dwarf_get_alloc(dbg, DW_DLA_BLOCK, 1);
if (ret_block == NULL) {
_dwarf_error(dbg, error, DW_DLE_ALLOC_FAIL);
return (DW_DLV_ERROR);
}
ret_block->bl_len = length;
ret_block->bl_data = (Dwarf_Ptr) data;
ret_block->bl_from_loclist = 0;
ret_block->bl_section_offset = data - dbg->de_debug_info.dss_data;
*return_block = ret_block;
return (DW_DLV_OK);
} | false | false | false | false | false | 0 |
url_encode(char * buffer, size_t buflen,
const char * source, size_t srclen) {
if (NULL == buffer)
return srclen * 3 + 1;
if (buflen <= 0)
return 0;
size_t srcpos = 0, bufpos = 0;
while ((srcpos < srclen) && (bufpos + 1 < buflen)) {
unsigned char ch = source[srcpos++];
if ((ch < 128) && (ASCII_CLASS[ch] & URL_UNSAFE)) {
if (bufpos + 3 >= buflen) {
break;
}
buffer[bufpos+0] = '%';
buffer[bufpos+1] = hex_encode((ch >> 4) & 0xF);
buffer[bufpos+2] = hex_encode((ch ) & 0xF);
bufpos += 3;
} else {
buffer[bufpos++] = ch;
}
}
buffer[bufpos] = '\0';
return bufpos;
} | false | false | false | false | false | 0 |
evdns_count_nameservers(void)
{
const struct nameserver *server = server_head;
int n = 0;
if (!server)
return 0;
do {
++n;
server = server->next;
} while (server != server_head);
return n;
} | false | false | false | false | false | 0 |
dact_hdr_ext_alloc(uint32_t size) {
if (dact_hdr_ext_val==NULL) {
if (!(dact_hdr_ext_val=malloc(DACT_HEADER_BLKSIZE))) {
dact_hdr_ext_val=NULL;
return(0);
}
dact_hdr_ext_sze=DACT_HEADER_BLKSIZE;
}
if ((dact_hdr_ext_pos+size)>(dact_hdr_ext_sze)) {
dact_hdr_ext_sze=(((dact_hdr_ext_pos+size-1)/DACT_HEADER_BLKSIZE)+1)*DACT_HEADER_BLKSIZE;
dact_hdr_ext_val=realloc(dact_hdr_ext_val,dact_hdr_ext_sze);
}
return(1);
} | false | false | false | false | false | 0 |
kvm_vcpu_running(struct kvm_vcpu *vcpu)
{
return (vcpu->arch.mp_state == KVM_MP_STATE_RUNNABLE &&
!vcpu->arch.apf.halted);
} | false | false | false | false | false | 0 |
BIO_nread0(BIO *bio, char **buf)
{
long ret;
if (!bio->init)
{
BIOerr(BIO_F_BIO_NREAD0, BIO_R_UNINITIALIZED);
return -2;
}
ret = BIO_ctrl(bio, BIO_C_NREAD0, 0, buf);
if (ret > INT_MAX)
return INT_MAX;
else
return (int) ret;
} | false | false | false | false | false | 0 |
HdlrFunc19 (
Obj self,
Obj a_arg )
{
Obj t_1 = 0;
Obj t_2 = 0;
Obj t_3 = 0;
Obj t_4 = 0;
Obj t_5 = 0;
Bag oldFrame;
OLD_BRK_CURR_STAT
/* allocate new stack frame */
SWITCH_TO_NEW_FRAME(self,0,0,oldFrame);
REM_BRK_CURR_STAT();
SET_BRK_CURR_STAT(0);
/* if not IsType( arg[1] ) then */
t_4 = GF_IsType;
C_ELM_LIST_FPL( t_5, a_arg, INTOBJ_INT(1) )
t_3 = CALL_1ARGS( t_4, t_5 );
CHECK_FUNC_RESULT( t_3 )
CHECK_BOOL( t_3 )
t_2 = (Obj)(UInt)(t_3 != False);
t_1 = (Obj)(UInt)( ! ((Int)t_2) );
if ( t_1 ) {
/* Error( "<type> must be a type" ); */
t_1 = GF_Error;
C_NEW_STRING( t_2, 21, "<type> must be a type" )
CALL_1ARGS( t_1, t_2 );
}
/* fi */
/* if LEN_LIST( arg ) = 2 then */
t_3 = GF_LEN__LIST;
t_2 = CALL_1ARGS( t_3, a_arg );
CHECK_FUNC_RESULT( t_2 )
t_1 = (Obj)(UInt)(EQ( t_2, INTOBJ_INT(2) ));
if ( t_1 ) {
/* return Subtype2( arg[1], arg[2] ); */
t_2 = GF_Subtype2;
C_ELM_LIST_FPL( t_3, a_arg, INTOBJ_INT(1) )
C_ELM_LIST_FPL( t_4, a_arg, INTOBJ_INT(2) )
t_1 = CALL_2ARGS( t_2, t_3, t_4 );
CHECK_FUNC_RESULT( t_1 )
RES_BRK_CURR_STAT();
SWITCH_TO_OLD_FRAME(oldFrame);
return t_1;
}
/* else */
else {
/* return Subtype3( arg[1], arg[2], arg[3] ); */
t_2 = GF_Subtype3;
C_ELM_LIST_FPL( t_3, a_arg, INTOBJ_INT(1) )
C_ELM_LIST_FPL( t_4, a_arg, INTOBJ_INT(2) )
C_ELM_LIST_FPL( t_5, a_arg, INTOBJ_INT(3) )
t_1 = CALL_3ARGS( t_2, t_3, t_4, t_5 );
CHECK_FUNC_RESULT( t_1 )
RES_BRK_CURR_STAT();
SWITCH_TO_OLD_FRAME(oldFrame);
return t_1;
}
/* fi */
/* return; */
RES_BRK_CURR_STAT();
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
/* return; */
RES_BRK_CURR_STAT();
SWITCH_TO_OLD_FRAME(oldFrame);
return 0;
} | false | false | false | false | false | 0 |
readresp(char c, netbuf *nControl)
{
char match[5];
if (readline(nControl->response,256,nControl) == -1)
{
perror("Control socket read failed");
return 0;
}
if (ftplib_debug > 1)
fprintf(stderr,"%s",nControl->response);
if (nControl->response[3] == '-')
{
strncpy(match,nControl->response,3);
match[3] = ' ';
match[4] = '\0';
do
{
if (readline(nControl->response,256,nControl) == -1)
{
perror("Control socket read failed");
return 0;
}
if (ftplib_debug > 1)
fprintf(stderr,"%s",nControl->response);
}
while (strncmp(nControl->response,match,4));
}
if (nControl->response[0] == c)
return 1;
return 0;
} | false | false | false | false | false | 0 |
__ecereMethod_Debugger_UpdateRemovedBreakpoint(struct __ecereNameSpace__ecere__com__Instance * this, struct Breakpoint * bp)
{
struct Debugger * __ecerePointer_Debugger = (struct Debugger *)(this ? (((char *)this) + __ecereClass_Debugger->offset) : 0);
;
if(__ecerePointer_Debugger->targeted && bp->inserted)
{
int oldState = __ecerePointer_Debugger->state;
switch(__ecerePointer_Debugger->state)
{
case 3:
if(targetProcessId)
__ecereMethod_Debugger_GdbDebugBreak(this, 0x1);
case 4:
case 2:
__ecereMethod_Debugger_UnsetBreakpoint(this, bp);
break;
}
if(oldState == 3)
__ecereMethod_Debugger_GdbExecContinue(this, 0x0);
}
} | false | false | false | true | false | 1 |
floor_log10 (mpfr_srcptr x)
{
mpfr_t y;
mpfr_exp_t exp;
/* make sure first that y can represent a mpfr_exp_t exactly
and can compare with x */
mpfr_prec_t prec = sizeof (mpfr_exp_t) * CHAR_BIT;
mpfr_init2 (y, MAX (prec, MPFR_PREC (x)));
exp = mpfr_ceil_mul (MPFR_GET_EXP (x), 10, 1) - 1;
mpfr_set_exp_t (y, exp, MPFR_RNDU);
/* The following call to mpfr_ui_pow should be fast: y is an integer
(not too large), so that mpfr_pow_z will be used internally. */
mpfr_ui_pow (y, 10, y, MPFR_RNDU);
if (mpfr_cmpabs (x, y) < 0)
exp--;
mpfr_clear (y);
return exp;
} | false | false | false | false | false | 0 |
exec_simple_check_plan(PLpgSQL_expr *expr)
{
_SPI_plan *spi_plan = (_SPI_plan *) expr->plan;
Plan *plan;
TargetEntry *tle;
expr->expr_simple_expr = NULL;
/*
* 1. We can only evaluate queries that resulted in one single execution
* plan
*/
if (list_length(spi_plan->ptlist) != 1)
return;
plan = (Plan *) linitial(spi_plan->ptlist);
/*
* 2. It must be a RESULT plan --> no scan's required
*/
if (plan == NULL) /* utility statement produces this */
return;
if (!IsA(plan, Result))
return;
/*
* 3. Can't have any subplan or qual clause, either
*/
if (plan->lefttree != NULL ||
plan->righttree != NULL ||
plan->initPlan != NULL ||
plan->qual != NULL ||
((Result *) plan)->resconstantqual != NULL)
return;
/*
* 4. The plan must have a single attribute as result
*/
if (list_length(plan->targetlist) != 1)
return;
tle = (TargetEntry *) linitial(plan->targetlist);
/*
* 5. Check that all the nodes in the expression are non-scary.
*/
if (!exec_simple_check_node((Node *) tle->expr))
return;
/*
* Yes - this is a simple expression. Mark it as such, and initialize
* state to "not valid in current transaction".
*/
expr->expr_simple_expr = tle->expr;
expr->expr_simple_state = NULL;
expr->expr_simple_in_use = false;
expr->expr_simple_id = -1;
/* Also stash away the expression result type */
expr->expr_simple_type = exprType((Node *) tle->expr);
} | false | false | false | false | false | 0 |
constructSubrangeDIE(DIE &Buffer, const DISubrange *SR,
DIE *IndexTy) {
DIE &DW_Subrange = createAndAddDIE(dwarf::DW_TAG_subrange_type, Buffer);
addDIEEntry(DW_Subrange, dwarf::DW_AT_type, *IndexTy);
// The LowerBound value defines the lower bounds which is typically zero for
// C/C++. The Count value is the number of elements. Values are 64 bit. If
// Count == -1 then the array is unbounded and we do not emit
// DW_AT_lower_bound and DW_AT_count attributes.
int64_t LowerBound = SR->getLowerBound();
int64_t DefaultLowerBound = getDefaultLowerBound();
int64_t Count = SR->getCount();
if (DefaultLowerBound == -1 || LowerBound != DefaultLowerBound)
addUInt(DW_Subrange, dwarf::DW_AT_lower_bound, None, LowerBound);
if (Count != -1)
// FIXME: An unbounded array should reference the expression that defines
// the array.
addUInt(DW_Subrange, dwarf::DW_AT_count, None, Count);
} | false | false | false | false | false | 0 |
digest_to_hex(const uint8_t digest[SHA1_DIGEST_SIZE], char *output)
{
int i,j;
char *c = output;
for (i = 0; i < SHA1_DIGEST_SIZE/4; i++) {
for (j = 0; j < 4; j++) {
sprintf(c,"%02X", digest[i*4+j]);
c += 2;
}
sprintf(c, " ");
c += 1;
}
*(c - 1) = '\0';
} | false | false | false | false | false | 0 |
oggpack_read1(oggpack_buffer *b){
u32 ret;
if(b->endbyte>=b->storage){
/* not the main path */
ret=(u32) (-1);
goto overflow;
}
ret=(b->ptr[0]>>b->endbit)&1;
overflow:
b->endbit++;
if(b->endbit>7){
b->endbit=0;
b->ptr++;
b->endbyte++;
}
return(ret);
} | false | false | false | false | false | 0 |
nautilus_view_get_containing_window (NautilusView *view)
{
GtkWidget *window;
g_assert (NAUTILUS_IS_VIEW (view));
window = gtk_widget_get_ancestor (GTK_WIDGET (view), GTK_TYPE_WINDOW);
if (window == NULL) {
return NULL;
}
return GTK_WINDOW (window);
} | false | false | false | false | false | 0 |
soc_remove_component(struct snd_soc_component *component)
{
if (!component->card)
return;
/* This is a HACK and will be removed soon */
if (component->codec)
list_del(&component->codec->card_list);
if (component->remove)
component->remove(component);
snd_soc_dapm_free(snd_soc_component_get_dapm(component));
soc_cleanup_component_debugfs(component);
component->card = NULL;
module_put(component->dev->driver->owner);
} | false | false | false | false | false | 0 |
ai_new(alloc_info *ai, int size, bool sec)
{
if(size < 0)
return false;
ai->size = size;
ai->sec = sec;
if(size == 0)
{
ai->sbuf = 0;
ai->qbuf = 0;
ai->data = 0;
return true;
}
if(sec)
{
try
{
ai->sbuf = new Botan::SecureVector<Botan::byte>((Botan::u32bit)size + 1);
}
catch(std::exception &)
{
botan_throw_abort();
return false; // never get here
}
(*(ai->sbuf))[size] = 0;
ai->qbuf = 0;
Botan::byte *bp = (Botan::byte *)(*(ai->sbuf));
ai->data = (char *)bp;
}
else
{
ai->sbuf = 0;
ai->qbuf = new QByteArray(size, 0);
ai->data = ai->qbuf->data();
}
return true;
} | false | false | false | false | false | 0 |
address_length (struct sockaddr *address)
{
struct sockaddr_un* unix_address = (struct sockaddr_un*)address;
int length = 0;
switch (address->sa_family) {
case AF_INET:
length = sizeof(struct sockaddr_in);
break;
case AF_INET6:
length = sizeof(struct sockaddr_in6);
break;
case AF_UNIX:
#ifdef SUN_LEN
length = SUN_LEN(unix_address);
#else
length = strlen(unix_address->sun_path) + sizeof(unix_address->sun_family);
#endif
break;
default:
assert(0 && "Unsupported socket family");
}
return length;
} | false | false | false | false | false | 0 |
CDB___usermem(listp, db_malloc)
char ***listp;
void *(*db_malloc) __P((size_t));
{
size_t len;
int ret;
char **array, **arrayp, **orig, *strp;
/* Find out how much space we need. */
for (len = 0, orig = *listp; *orig != NULL; ++orig)
len += sizeof(char *) + strlen(*orig) + 1;
len += sizeof(char *);
/* Allocate it and set up the pointers. */
if ((ret = CDB___os_malloc(len, db_malloc, &array)) != 0)
return (ret);
strp = (char *)(array + (orig - *listp) + 1);
/* Copy the original information into the new memory. */
for (orig = *listp, arrayp = array; *orig != NULL; ++orig, ++arrayp) {
len = strlen(*orig);
memcpy(strp, *orig, len + 1);
*arrayp = strp;
strp += len + 1;
CDB___os_freestr(*orig);
}
/* NULL-terminate the list. */
*arrayp = NULL;
CDB___os_free(*listp, 0);
*listp = array;
return (0);
} | false | false | false | false | false | 0 |
gtk_progress_dialog_set_button_close_enabled(GtkProgressDialog* dialog, gboolean enabled)
{
g_return_if_fail(dialog!=NULL);
g_return_if_fail(GTK_IS_PROGRESS_DIALOG(dialog));
GtkWidget* widget;
widget = gtk_dialog_get_widget_for_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
gtk_widget_set_sensitive (widget, enabled);
while (gtk_events_pending()) {
gtk_main_iteration();
}
} | false | false | false | false | false | 0 |
play_autoplay_media (DriveButton *self, const char *autoplay_key,
const char *dflt)
{
GConfClient *gconf_client = gconf_client_get_default ();
char *command = gconf_client_get_string (gconf_client,
autoplay_key, NULL);
if (!command)
command = g_strdup (dflt);
run_command (self, command);
g_free (command);
g_object_unref (gconf_client);
} | false | false | false | false | false | 0 |
awele_destroy_all_items ()
{
int i;
if (boardRootItem != NULL)
goo_canvas_item_remove(boardRootItem);
boardRootItem = NULL;
if(graphsElt)
{
for (i = 0; i < NBHOLE / 2; i++)
{
#if GDK_PIXBUF_MAJOR <= 2 && GDK_PIXBUF_MINOR <= 24
gdk_pixbuf_unref(graphsElt->pixbufButton[i]);
gdk_pixbuf_unref(graphsElt->pixbufButtonNotify[i]);
gdk_pixbuf_unref(graphsElt->pixbufButtonClicked[i]);
#else
g_object_unref(graphsElt->pixbufButton[i]);
g_object_unref(graphsElt->pixbufButtonNotify[i]);
g_object_unref(graphsElt->pixbufButtonClicked[i]);
#endif
}
g_free(graphsElt);
graphsElt = NULL;
}
} | false | false | false | false | false | 0 |
singleCompactStage3(MBCSData *mbcsData) {
uint16_t *stage3=(uint16_t *)mbcsData->fromUBytes;
/* this array maps the ordinal number of a stage 3 block to its new stage 2 index */
uint16_t map[0x1000];
uint16_t i, start, prevEnd, newStart;
/* enter the all-unassigned first stage 3 block into the map */
map[0]=0;
/* begin with the first block after the all-unassigned one */
start=newStart=16;
while(start<mbcsData->stage3Top) {
prevEnd=(uint16_t)(newStart-1);
/* find the size of the overlap */
for(i=0; i<16 && stage3[start+i]==0 && stage3[prevEnd-i]==0; ++i) {}
if(i>0) {
map[start>>4]=(uint16_t)(newStart-i);
/* move the non-overlapping indexes to their new positions */
start+=i;
for(i=(uint16_t)(16-i); i>0; --i) {
stage3[newStart++]=stage3[start++];
}
} else if(newStart<start) {
/* move the indexes to their new positions */
map[start>>4]=newStart;
for(i=16; i>0; --i) {
stage3[newStart++]=stage3[start++];
}
} else /* no overlap && newStart==start */ {
map[start>>4]=start;
start=newStart+=16;
}
}
/* adjust stage3Top */
if(VERBOSE && newStart<mbcsData->stage3Top) {
printf("compacting stage 3 from stage3Top=0x%lx to 0x%lx, saving %ld bytes\n",
(unsigned long)mbcsData->stage3Top, (unsigned long)newStart,
(long)(mbcsData->stage3Top-newStart)*2);
}
mbcsData->stage3Top=newStart;
/* now adjust stage 2 */
for(i=0; i<mbcsData->stage2Top; ++i) {
mbcsData->stage2Single[i]=map[mbcsData->stage2Single[i]>>4];
}
} | false | false | false | false | false | 0 |
db__driver_open_database(dbHandle * handle)
{
char msg[OD_MSG];
const char *name;
char *emsg = NULL;
SQLRETURN ret;
SQLINTEGER err;
dbConnection connection;
/* Open connection */
if (open_connection() != DB_OK)
return DB_FAILED;
db_get_connection(&connection);
name = db_get_handle_dbname(handle);
/* if name is empty use connection.databaseName */
if (strlen(name) == 0) {
name = connection.databaseName;
}
/* Connect to the datasource */
ret = SQLConnect(ODconn, (SQLCHAR *) name, SQL_NTS,
(SQLCHAR *) connection.user, SQL_NTS,
(SQLCHAR *) connection.password, SQL_NTS);
if ((ret != SQL_SUCCESS) && (ret != SQL_SUCCESS_WITH_INFO)) {
SQLGetDiagRec(SQL_HANDLE_DBC, ODconn, 1, NULL, &err, msg, sizeof(msg),
NULL);
G_asprintf(&emsg, "SQLConnect():\n%s (%d)\n", msg, (int)err);
report_error(emsg);
G_free(emsg);
return DB_FAILED;
}
return DB_OK;
} | false | false | false | false | false | 0 |
SkipDBRecord_dealloc(SkipDBRecord *self)
{
#ifdef SKIPDB_DEBUG
if (!deallocedRecords) deallocedRecords = List_new();
printf("SkipDBRecord_dealloc(%p)\n", (void *)self);
List_append_(deallocedRecords, self);
#endif
SkipDB_noteWillFreeRecord_((SkipDB *)(self->sdb), self);
if (self->pointers)
{
// Commented out since we should not touch records linked
// from here, because they may have already been freed.
// (e.g. see SkipDB_freeAllCachedRecords or SkipDB_freeExcessCachedRecords).
// SkipDBPointer *next = self->pointers + 0;
//
// if (next && next->record)
// {
// next->record->previousRecord = NULL;
// }
free(self->pointers);
}
if (self->ownsKey) // is this correct?
{
UArray_free(self->key);
}
UArray_free(self->value);
#ifdef SKIPDB_DEBUG
return;
#endif
free(self);
} | false | false | false | false | false | 0 |
check_bases_and_members (tree t)
{
/* Nonzero if we are not allowed to generate a default constructor
for this case. */
int cant_have_default_ctor;
/* Nonzero if the implicitly generated copy constructor should take
a non-const reference argument. */
int cant_have_const_ctor;
/* Nonzero if the the implicitly generated assignment operator
should take a non-const reference argument. */
int no_const_asn_ref;
tree access_decls;
/* By default, we use const reference arguments and generate default
constructors. */
cant_have_default_ctor = 0;
cant_have_const_ctor = 0;
no_const_asn_ref = 0;
/* Check all the base-classes. */
check_bases (t, &cant_have_default_ctor, &cant_have_const_ctor,
&no_const_asn_ref);
/* Check all the data member declarations. */
check_field_decls (t, &access_decls,
&cant_have_default_ctor,
&cant_have_const_ctor,
&no_const_asn_ref);
/* Check all the method declarations. */
check_methods (t);
/* A nearly-empty class has to be vptr-containing; a nearly empty
class contains just a vptr. */
if (!TYPE_CONTAINS_VPTR_P (t))
CLASSTYPE_NEARLY_EMPTY_P (t) = 0;
/* Do some bookkeeping that will guide the generation of implicitly
declared member functions. */
TYPE_HAS_COMPLEX_INIT_REF (t)
|= (TYPE_HAS_INIT_REF (t)
|| TYPE_USES_VIRTUAL_BASECLASSES (t)
|| TYPE_POLYMORPHIC_P (t));
TYPE_NEEDS_CONSTRUCTING (t)
|= (TYPE_HAS_CONSTRUCTOR (t)
|| TYPE_USES_VIRTUAL_BASECLASSES (t)
|| TYPE_POLYMORPHIC_P (t));
CLASSTYPE_NON_AGGREGATE (t) |= (TYPE_HAS_CONSTRUCTOR (t)
|| TYPE_POLYMORPHIC_P (t));
CLASSTYPE_NON_POD_P (t)
|= (CLASSTYPE_NON_AGGREGATE (t) || TYPE_HAS_DESTRUCTOR (t)
|| TYPE_HAS_ASSIGN_REF (t));
TYPE_HAS_REAL_ASSIGN_REF (t) |= TYPE_HAS_ASSIGN_REF (t);
TYPE_HAS_COMPLEX_ASSIGN_REF (t)
|= TYPE_HAS_ASSIGN_REF (t) || TYPE_CONTAINS_VPTR_P (t);
/* Synthesize any needed methods. Note that methods will be synthesized
for anonymous unions; grok_x_components undoes that. */
add_implicitly_declared_members (t, cant_have_default_ctor,
cant_have_const_ctor,
no_const_asn_ref);
/* Create the in-charge and not-in-charge variants of constructors
and destructors. */
clone_constructors_and_destructors (t);
/* Process the using-declarations. */
for (; access_decls; access_decls = TREE_CHAIN (access_decls))
handle_using_decl (TREE_VALUE (access_decls), t);
/* Build and sort the CLASSTYPE_METHOD_VEC. */
finish_struct_methods (t);
/* Figure out whether or not we will need a cookie when dynamically
allocating an array of this type. */
TYPE_LANG_SPECIFIC (t)->u.c.vec_new_uses_cookie
= type_requires_array_cookie (t);
} | false | false | false | false | false | 0 |
run_test (void *user_data)
{
gint prev;
GstClock *sysclock = GST_CLOCK_CAST (user_data);
while (running) {
gst_clock_get_time (sysclock);
prev = g_atomic_int_add (&count, 1);
if (prev == G_MAXINT)
g_warning ("overflow");
}
g_thread_exit (NULL);
return NULL;
} | false | false | false | false | false | 0 |
remove_method(klass, mid)
VALUE klass;
ID mid;
{
NODE *body;
if (klass == rb_cObject) {
rb_secure(4);
}
if (ruby_safe_level >= 4 && !OBJ_TAINTED(klass)) {
rb_raise(rb_eSecurityError, "Insecure: can't remove method");
}
if (OBJ_FROZEN(klass)) rb_error_frozen("class/module");
if (mid == __id__ || mid == __send__ || mid == init) {
rb_warn("removing `%s' may cause serious problem", rb_id2name(mid));
}
if (!st_delete(RCLASS(klass)->m_tbl, &mid, (st_data_t *)&body) ||
!body->nd_body) {
rb_name_error(mid, "method `%s' not defined in %s",
rb_id2name(mid), rb_class2name(klass));
}
rb_clear_cache_for_undef(klass, mid);
if (FL_TEST(klass, FL_SINGLETON)) {
rb_funcall(rb_iv_get(klass, "__attached__"), singleton_removed, 1, ID2SYM(mid));
}
else {
rb_funcall(klass, removed, 1, ID2SYM(mid));
}
} | false | false | false | false | false | 0 |
bid_keyword_list(const char *p, ssize_t len, int unset, int last_is_path)
{
int l;
int keycnt = 0;
while (len > 0 && *p) {
int blank = 0;
/* Test whether there are blank characters in the line. */
while (len >0 && (*p == ' ' || *p == '\t')) {
++p;
--len;
blank = 1;
}
if (*p == '\n' || *p == '\r')
break;
if (p[0] == '\\' && (p[1] == '\n' || p[1] == '\r'))
break;
if (!blank && !last_is_path) /* No blank character. */
return (-1);
if (last_is_path && len == 0)
return (keycnt);
if (unset) {
l = bid_keycmp(p, "all", len);
if (l > 0)
return (1);
}
/* Test whether there is a correct key in the line. */
l = bid_keyword(p, len);
if (l == 0)
return (-1);/* Unknown keyword was found. */
p += l;
len -= l;
keycnt++;
/* Skip value */
if (*p == '=') {
int value = 0;
++p;
--len;
while (len > 0 && *p != ' ' && *p != '\t') {
++p;
--len;
value = 1;
}
/* A keyword should have a its value unless
* "/unset" operation. */
if (!unset && value == 0)
return (-1);
}
}
return (keycnt);
} | false | false | false | false | false | 0 |
full_daytime_range(lList **dtrl) {
lListElem *tmr;
DENTER(TOP_LAYER, "full_daytime_range");
if (!*dtrl)
*dtrl = lCreateList("full day", TMR_Type);
/* DPRINTF(("FULL_DAYTIME_RANGE\n")); */
tmr = lCreateElem(TMR_Type);
lAddSubUlong(tmr, TM_hour, 0, TMR_begin, TM_Type);
lAddSubUlong(tmr, TM_hour, 24, TMR_end, TM_Type);
lAppendElem(*dtrl, tmr);
DRETURN_VOID;
} | false | false | false | false | false | 0 |
_discover_create_message(discover_error_t **status, char *message)
{
if((*status)->message) {
free((*status)->message);
}
(*status)->message = _discover_xmalloc(strlen(message) + 1);
strcpy((*status)->message, message);
} | false | true | false | false | false | 1 |
lookup(enum wakefulness wakefulness,
const tw_instr *q, INT n, INT r, INT m)
{
twid *p;
for (p = twlist[hash(n,r)];
p && !ok_twid(p, wakefulness, q, n, r, m);
p = p->cdr)
;
return p;
} | false | false | false | false | false | 0 |
drawCylinder(bool vertical, GLfloat* pos, GLfloat len, GLfloat rad) {
GLUquadricObj* x = gluNewQuadric();
glPushMatrix();
glTranslatef(pos[0], pos[1], pos[2]);
if (vertical) {
glRotated(-90., 1., 0., 0.);
} else {
glRotated(90., 0., 1., 0.);
}
gluCylinder(x, rad, rad, len, 20, 1);
gluDeleteQuadric(x);
glPopMatrix();
} | false | false | false | false | false | 0 |
af9005_get_post_vit_err_cw_count(struct dvb_frontend *fe,
u32 * post_err_count,
u32 * post_cw_count,
u16 * abort_count)
{
struct af9005_fe_state *state = fe->demodulator_priv;
int ret;
u32 err_count;
u32 cw_count;
u8 temp, temp0, temp1, temp2;
u16 loc_abort_count;
*post_err_count = 0;
*post_cw_count = 0;
/* check if error bit count is ready */
ret =
af9005_read_register_bits(state->d, xd_r_fec_rsd_ber_rdy,
fec_rsd_ber_rdy_pos, fec_rsd_ber_rdy_len,
&temp);
if (ret)
return ret;
if (!temp) {
deb_info("rsd counter not ready\n");
return 100;
}
/* get abort count */
ret =
af9005_read_ofdm_register(state->d,
xd_r_fec_rsd_abort_packet_cnt_7_0,
&temp0);
if (ret)
return ret;
ret =
af9005_read_ofdm_register(state->d,
xd_r_fec_rsd_abort_packet_cnt_15_8,
&temp1);
if (ret)
return ret;
loc_abort_count = ((u16) temp1 << 8) + temp0;
/* get error count */
ret =
af9005_read_ofdm_register(state->d, xd_r_fec_rsd_bit_err_cnt_7_0,
&temp0);
if (ret)
return ret;
ret =
af9005_read_ofdm_register(state->d, xd_r_fec_rsd_bit_err_cnt_15_8,
&temp1);
if (ret)
return ret;
ret =
af9005_read_ofdm_register(state->d, xd_r_fec_rsd_bit_err_cnt_23_16,
&temp2);
if (ret)
return ret;
err_count = ((u32) temp2 << 16) + ((u32) temp1 << 8) + temp0;
*post_err_count = err_count - (u32) loc_abort_count *8 * 8;
/* get RSD packet number */
ret =
af9005_read_ofdm_register(state->d, xd_p_fec_rsd_packet_unit_7_0,
&temp0);
if (ret)
return ret;
ret =
af9005_read_ofdm_register(state->d, xd_p_fec_rsd_packet_unit_15_8,
&temp1);
if (ret)
return ret;
cw_count = ((u32) temp1 << 8) + temp0;
if (cw_count == 0) {
err("wrong RSD packet count");
return -EIO;
}
deb_info("POST abort count %d err count %d rsd packets %d\n",
loc_abort_count, err_count, cw_count);
*post_cw_count = cw_count - (u32) loc_abort_count;
*abort_count = loc_abort_count;
return 0;
} | false | false | false | false | false | 0 |
_glewInit_GL_NV_conditional_render (GLEW_CONTEXT_ARG_DEF_INIT)
{
GLboolean r = GL_FALSE;
r = ((glBeginConditionalRenderNV = (PFNGLBEGINCONDITIONALRENDERNVPROC)glewGetProcAddress((const GLubyte*)"glBeginConditionalRenderNV")) == NULL) || r;
r = ((glEndConditionalRenderNV = (PFNGLENDCONDITIONALRENDERNVPROC)glewGetProcAddress((const GLubyte*)"glEndConditionalRenderNV")) == NULL) || r;
return r;
} | false | false | false | false | false | 0 |
CsfSeekAttrSpace(
MAP *m, /* map handle */
CSF_ATTR_ID id, /* attribute identification only for check if avalaible */
size_t size) /* size to be seeked to */
{
ATTR_CNTRL_BLOCK b;
CSF_FADDR currBlockPos, prevBlockPos=USED_UNINIT_ZERO, newPos, endBlock, resultPos=0;
int noPosFound;
int i;
if (MattributeAvail(m ,id))
{
M_ERROR(ATTRDUPL);
goto error;
}
if (! WRITE_ENABLE(m))
{
M_ERROR(NOACCESS);
goto error;
}
currBlockPos = m->main.attrTable;
noPosFound = 1;
while (noPosFound)
{
if (currBlockPos == 0)
{
if (m->main.attrTable == 0)
{ /* FIRST BLOCK */
newPos =( (CSF_FADDR)(m->raster.nrRows)*
(CSF_FADDR)(m->raster.nrCols)*
(CSF_FADDR)(CELLSIZE(RgetCellRepr(m))))
+ ADDR_DATA;
m->main.attrTable = newPos;
}
else
{ /* NEW/NEXT BLOCK */
newPos = b.attrs[LAST_ATTR_IN_BLOCK].attrOffset
+
b.attrs[LAST_ATTR_IN_BLOCK].attrSize;
b.next = newPos;
if (CsfWriteAttrBlock(m, prevBlockPos, &b))
{
M_ERROR(WRITE_ERROR);
resultPos = 0;
}
}
InitBlock(&b);
b.attrs[0].attrOffset =
newPos + SIZE_OF_ATTR_CNTRL_BLOCK;
currBlockPos = newPos;
noPosFound = 0;
}
else
CsfReadAttrBlock(m, currBlockPos, &b);
i = 0; /* this is also the right index if a new block
is added ! */
while (noPosFound && i < NR_ATTR_IN_BLOCK)
switch (b.attrs[i].attrId)
{
case END_OF_ATTRS:
POSTCOND(i >= 1);
/* i >= 1 , no block otherwise */
b.attrs[i].attrOffset =
b.attrs[i-1].attrOffset +
b.attrs[i-1].attrSize;
noPosFound = 0;
break;
case ATTR_NOT_USED:
if (i == NR_ATTR_IN_BLOCK)
endBlock = b.next;
else
endBlock = b.attrs[i+1].attrOffset;
if (( endBlock - b.attrs[i].attrOffset)
>= size)
/* this position can
hold the attr */
noPosFound = 0;
else
i++;
break;
default:
i++;
} /* switch */
/* if (b.next == 0)
? When did I change this CW
remember this block position since it may be have
to rewritten
*/
prevBlockPos = currBlockPos;
if (noPosFound)
currBlockPos = b.next;
} /* while */
b.attrs[i].attrSize = size;
b.attrs[i].attrId = id;
resultPos = b.attrs[i].attrOffset;
if (CsfWriteAttrBlock(m, currBlockPos, &b))
{
M_ERROR(WRITE_ERROR);
resultPos = 0;
}
fseek(m->fp, (long)resultPos, SEEK_SET); /* fsetpos() is better */
error: return resultPos;
} | false | false | false | false | false | 0 |
getCenter()
{
Vec3 Center=Vec3(0.0,0.0,0.0);
for(vector<Vec3>::iterator iter=m_points.begin();
iter!=m_points.end();
iter++){
Center+=(*iter);
}
Center=Center/m_points.size();
return Center;
} | false | false | false | false | false | 0 |
add_substrings(char *buffer, size_t *length, ms_MediaCode *code,
const ms_Flag *flag_list)
{
int j;
size_t l;
j = 0;
buffer = strchr(buffer, '\0');
while (flag_list[j].code != 0) {
if (flag_list[j].code & *code) {
l = strlen(flag_list[j].name);
if (*length < l) {
errno = ERANGE;
return -1;
}
*code &= ~flag_list[j].code;
strcpy(buffer, flag_list[j].name);
buffer += l;
*length -= l;
}
j++;
}
return 0;
} | false | true | false | false | false | 1 |
read_string (int star_if_braced)
{
char *stringbuf;
int saw_paren = 0;
int c, old_lineno;
c = read_skip_spaces ();
if (c == '(')
{
saw_paren = 1;
c = read_skip_spaces ();
}
old_lineno = read_md_lineno;
if (c == '"')
stringbuf = read_quoted_string ();
else if (c == '{')
{
if (star_if_braced)
obstack_1grow (&string_obstack, '*');
stringbuf = read_braced_string ();
}
else
fatal_with_file_and_line ("expected `\"' or `{', found `%c'", c);
if (saw_paren)
{
c = read_skip_spaces ();
if (c != ')')
fatal_expected_char (')', c);
}
set_md_ptr_loc (stringbuf, read_md_filename, old_lineno);
return stringbuf;
} | false | false | false | false | false | 0 |
consider(JoinPointLoc* jpl, JPL_Aspect &hi, JPL_Aspect &lo) {
#endif
JoinPointPlan* jp_plan = jpl->plan();
if (jp_plan) {
ACAspectInfo *h = TI_Aspect::of (hi)->aspect_info ();
ACAspectInfo *l = TI_Aspect::of (lo)->aspect_info ();
jp_plan->consider(*h, *l);
}
} | false | false | false | false | false | 0 |
vmw_gmrid_man_init(struct ttm_mem_type_manager *man,
unsigned long p_size)
{
struct vmw_private *dev_priv =
container_of(man->bdev, struct vmw_private, bdev);
struct vmwgfx_gmrid_man *gman =
kzalloc(sizeof(*gman), GFP_KERNEL);
if (unlikely(gman == NULL))
return -ENOMEM;
spin_lock_init(&gman->lock);
gman->used_gmr_pages = 0;
ida_init(&gman->gmr_ida);
switch (p_size) {
case VMW_PL_GMR:
gman->max_gmr_ids = dev_priv->max_gmr_ids;
gman->max_gmr_pages = dev_priv->max_gmr_pages;
break;
case VMW_PL_MOB:
gman->max_gmr_ids = VMWGFX_NUM_MOB;
gman->max_gmr_pages = dev_priv->max_mob_pages;
break;
default:
BUG();
}
man->priv = (void *) gman;
return 0;
} | false | false | false | false | false | 0 |
j2k_read_rgn (
opj_j2k_t *p_j2k,
OPJ_BYTE * p_header_data,
OPJ_UINT32 p_header_size,
struct opj_event_mgr * p_manager
)
{
OPJ_UINT32 l_nb_comp;
opj_image_t * l_image = 00;
opj_cp_t *l_cp = 00;
opj_tcp_t *l_tcp = 00;
OPJ_UINT32 l_comp_room;
OPJ_UINT32 l_comp_no;
OPJ_UINT32 l_roi_sty;
// preconditions
assert(p_header_data != 00);
assert(p_j2k != 00);
assert(p_manager != 00);
l_image = p_j2k->m_image;
l_nb_comp = l_image->numcomps;
if
(l_nb_comp <= 256)
{
l_comp_room = 1;
}
else
{
l_comp_room = 2;
}
if
(p_header_size != 2 + l_comp_room)
{
opj_event_msg(p_manager, EVT_ERROR, "Error reading RGN marker\n");
return false;
}
l_cp = &(p_j2k->m_cp);
l_tcp = (p_j2k->m_specific_param.m_decoder.m_state == J2K_DEC_STATE_TPH) ? &l_cp->tcps[p_j2k->m_current_tile_number] : p_j2k->m_specific_param.m_decoder.m_default_tcp;
opj_read_bytes(p_header_data,&l_comp_no,l_comp_room); /* Crgn */
p_header_data+=l_comp_room;
opj_read_bytes(p_header_data,&l_roi_sty,1); /* Srgn */
++p_header_data;
#ifdef USE_JPWL
if (p_j2k->m_cp->correct) {
/* totlen is negative or larger than the bytes left!!! */
if (compno >= numcomps) {
opj_event_msg(p_j2k->cinfo, EVT_ERROR,
"JPWL: bad component number in RGN (%d when there are only %d)\n",
compno, numcomps);
if (!JPWL_ASSUME || JPWL_ASSUME) {
opj_event_msg(p_j2k->cinfo, EVT_ERROR, "JPWL: giving up\n");
return;
}
}
};
#endif /* USE_JPWL */
opj_read_bytes(p_header_data,(OPJ_UINT32 *) (&(l_tcp->tccps[l_comp_no].roishift)),1); /* SPrgn */
++p_header_data;
return true;
} | false | false | false | false | false | 0 |
cib_remote_callback_dispatch(gpointer user_data)
{
cib_t *cib = user_data;
cib_remote_opaque_t *private = cib->variant_opaque;
xmlNode *msg = NULL;
int disconnected = 0;
crm_info("Message on callback channel");
crm_remote_recv(&private->callback, -1, &disconnected);
msg = crm_remote_parse_buffer(&private->callback);
while (msg) {
const char *type = crm_element_value(msg, F_TYPE);
crm_trace("Activating %s callbacks...", type);
if (safe_str_eq(type, T_CIB)) {
cib_native_callback(cib, msg, 0, 0);
} else if (safe_str_eq(type, T_CIB_NOTIFY)) {
g_list_foreach(cib->notify_list, cib_native_notify, msg);
} else {
crm_err("Unknown message type: %s", type);
}
free_xml(msg);
msg = crm_remote_parse_buffer(&private->callback);
}
if (disconnected) {
return -1;
}
return 0;
} | false | false | false | false | false | 0 |
setupdefmt (filename, statbuf)
char * filename; /* File to open, if non-NULL */
struct stat * statbuf; /* Buffer to hold file status */
{
FILE* filteredfile; /* Access to the filtered file */
int inputfd; /* Fd for access to file to open */
int savedstdin; /* File descriptor saving stdin */
sourcefile = NULL;
if (defmtpgm == NULL)
{
/*
* There is no deformatter. Return either stdin or an open file.
*/
if (filename == NULL)
filteredfile = stdin;
else
filteredfile = fopen (filename, "r");
if (statbuf != NULL && filteredfile != NULL
&& fstat (fileno (filteredfile), statbuf) == -1)
statbuf->st_mode = DEFAULT_FILE_MODE;
return filteredfile;
}
else if (filename == NULL)
{
/*
* We are reading from standard input. Switch over to a
* filtered version of stdin.
*/
if (statbuf != NULL && fstat (fileno (stdin), statbuf) == -1)
statbuf->st_mode = DEFAULT_FILE_MODE;
return popen (defmtpgm, "r");
}
else
{
/*
* This is the tricky case. We need to get the deformatter to
* read from the input file and filter it to us. Doing so
* requires several steps:
*
* 1. Preserve file descriptor 0 by duplicating it.
* 2. Close file descriptor 0, and reopen it on the file to be
* filtered.
* 3. Open a pipe to the deformat program.
* 4. Restore file descriptor 0.
*
* Because we do all of this without ever letting the stdio
* library know that we've been mucking around with file
* descriptors, we won't bother its access to stdin.
*/
sourcefile = fopen (filename, "r");
if (sourcefile == NULL)
return NULL;
if (statbuf != NULL && fstat (fileno (sourcefile), statbuf) == -1)
statbuf->st_mode = DEFAULT_FILE_MODE;
savedstdin = dup (0);
inputfd = open (filename, 0);
if (inputfd < 0)
return NULL; /* Failed to open the file */
else if (dup2 (inputfd, 0) != 0)
{
(void) fprintf (stderr, ISPELL_C_UNEXPECTED_FD, filename,
MAYBE_CR (stderr));
exit (1);
}
filteredfile = popen (defmtpgm, "r");
if (dup2 (savedstdin, 0) != 0)
{
(void) fprintf (stderr, ISPELL_C_UNEXPECTED_FD, filename,
MAYBE_CR (stderr));
exit (1);
}
close (savedstdin);
return filteredfile;
}
} | false | false | false | false | false | 0 |
cin_isfuncdecl(sp, first_lnum)
char_u **sp;
linenr_T first_lnum;
{
char_u *s;
linenr_T lnum = first_lnum;
int retval = FALSE;
if (sp == NULL)
s = ml_get(lnum);
else
s = *sp;
while (*s && *s != '(' && *s != ';' && *s != '\'' && *s != '"')
{
if (cin_iscomment(s)) /* ignore comments */
s = cin_skipcomment(s);
else
++s;
}
if (*s != '(')
return FALSE; /* ';', ' or " before any () or no '(' */
while (*s && *s != ';' && *s != '\'' && *s != '"')
{
if (*s == ')' && cin_nocode(s + 1))
{
/* ')' at the end: may have found a match
* Check for he previous line not to end in a backslash:
* #if defined(x) && \
* defined(y)
*/
lnum = first_lnum - 1;
s = ml_get(lnum);
if (*s == NUL || s[STRLEN(s) - 1] != '\\')
retval = TRUE;
goto done;
}
if (*s == ',' && cin_nocode(s + 1))
{
/* ',' at the end: continue looking in the next line */
if (lnum >= curbuf->b_ml.ml_line_count)
break;
s = ml_get(++lnum);
}
else if (cin_iscomment(s)) /* ignore comments */
s = cin_skipcomment(s);
else
++s;
}
done:
if (lnum != first_lnum && sp != NULL)
*sp = ml_get(first_lnum);
return retval;
} | false | false | false | false | false | 0 |
GDE_freeali(NA_Alignment *dataset) {
if (dataset) {
GDE_free((void**)&dataset->id);
GDE_free((void**)&dataset->description);
GDE_free((void**)&dataset->authority);
GDE_free((void**)&dataset->cmask);
GDE_free((void**)&dataset->selection_mask);
GDE_free((void**)&dataset->alignment_name);
for (unsigned long i=0;i<dataset->numelements;i++) {
GDE_freesequ(dataset->element+i);
}
}
} | false | false | false | false | false | 0 |
calcBotBorderThick(void)
{
m_iBotThick = 0;
if(getBlock() && !getBlock()->hasBorders())
{
m_iBotThick = 0;
}
else if(getBlock() && canDrawBotBorder())
{
m_iBotThick = getBlock()->getBottom().m_thickness + getBlock()->getBottom().m_spacing;
}
return m_iBotThick;
} | false | false | false | false | false | 0 |
style_symbol_draw(struct style *style, cairo_t *cairoctx, guint keyval, gdouble w, gdouble h)
{
START_FUNC
GSList *item=style->symbols;
gchar name[7];
guint keyval2=keyval;
while (item && !style_symbol_matches((struct symbol *)item->data, gdk_keyval_name(keyval))) {
item=g_slist_next(item);
}
/* No predifined symbol => get the label according to keyval */
if (!item) {
/* find the string representation of keyval */
name[0]='\0';
if (gdk_keyval_name(keyval) && !strncmp(gdk_keyval_name(keyval), "dead_", 5)) {
if (!strcmp(gdk_keyval_name(keyval), "dead_circumflex")) { name[0]='^'; name[1]='\0'; }
else keyval2=gdk_keyval_from_name(gdk_keyval_name(keyval)+5);
}
if (!name[0]) name[g_unichar_to_utf8(gdk_keyval_to_unicode(keyval2), name)]='\0';
/* if (!name[0] && gdk_keyval_name(keyval)) { strncpy(name, gdk_keyval_name(keyval), 3); name[3]='\0'; } */
if (*name) style_draw_text(style, cairoctx, name, w, h);
/* the symbol has a label ==> let's draw it */
} else if (((struct symbol *)item->data)->label) {
style_draw_text(style, cairoctx, ((struct symbol *)item->data)->label, w, h);
/* the symbol must have a svg => draw it */
} else {
style_render_svg(cairoctx, ((struct symbol *)item->data)->svg, w, h, TRUE, NULL);
}
END_FUNC
} | false | false | false | false | false | 0 |
snd_em28xx_hw_capture_free(struct snd_pcm_substream *substream)
{
struct em28xx *dev = snd_pcm_substream_chip(substream);
struct em28xx_audio *adev = &dev->adev;
dprintk("Stop capture, if needed\n");
if (atomic_read(&adev->stream_started) > 0) {
atomic_set(&adev->stream_started, 0);
schedule_work(&adev->wq_trigger);
}
return 0;
} | false | false | false | false | false | 0 |
do_auth(const char *_login, const char *password, const char *service, const char *realm) {
struct cache_result lkup_result;
char *response;
int cached = 0;
char login_buff[MAX_LOGIN_REALM_LEN];
char *login;
/***********************************************************
* Check to concat the login and realm into a single login.
* Aka, login: foo realm: bar becomes login: foo@bar.
* We do this because some mechs have no concept of a realm.
* Ie. auth_pam and friends.
***********************************************************/
if ((flags & CONCAT_LOGIN_REALM) && realm && realm[0] != '\0') {
strlcpy(login_buff, _login, sizeof(login_buff));
strlcat(login_buff, "@", sizeof(login_buff));
strlcat(login_buff, realm, sizeof(login_buff));
login = login_buff;
} else {
login = (char *)_login;
}
if (cache_lookup(login, realm, service, password, &lkup_result) == CACHE_OK) {
response = strdup("OK");
cached = 1;
} else {
response = auth_mech->authenticate(login, password, service, realm);
if (response == NULL) {
logger(L_ERR, L_FUNC, "internal mechanism failure: %s", auth_mech->name);
response = strdup("NO internal mechanism failure");
}
}
if (strncmp(response, "OK", 2) == 0) {
cache_commit(&lkup_result);
if (flags & VERBOSE) {
if (cached)
logger(L_DEBUG, L_FUNC, "auth success (cached): [user=%s] [service=%s] [realm=%s]", \
login, service, realm);
else
logger(L_DEBUG, L_FUNC, "auth success: [user=%s] [service=%s] [realm=%s] [mech=%s]", \
login, service, realm, auth_mech->name);
}
return response;
}
if (strncmp(response, "NO", 2) == 0) {
logger(L_INFO, L_FUNC, "auth failure: [user=%s] [service=%s] [realm=%s] [mech=%s] [reason=%s]", \
login, service, realm, auth_mech->name,
strlen(response) >= 4 ? response+3 : "Unknown");
return response;
}
logger(L_ERR, L_FUNC, "mechanism returned unknown response: %s", auth_mech->name);
response = strdup("NO internal mechanism failure");
return response;
} | false | false | false | false | false | 0 |
write_buf(fd, buf, cnt)
int fd;
voidp buf;
unsigned cnt;
{
unsigned n;
while ((n = write_buffer (fd, buf, cnt)) != cnt) {
if (n == (unsigned)(-1)) {
write_error();
}
cnt -= n;
buf = (voidp)((char*)buf+n);
}
} | false | false | false | false | false | 0 |
addJobs( AbstractJobProvider* provider, int count )
{
QMutexLocker locker( &m_mutex );
int pos = 0;
int priority = provider->priority();
while ( pos < m_pendingProviders.count() && m_pendingProviders[ pos ]->priority() >= priority )
pos++;
for ( int i = 0; i < count; i++ )
m_pendingProviders.insert( pos, provider );
m_hasPendingProviders.wakeAll();
} | false | false | false | false | false | 0 |
settings_gui_save_panes(void)
{
guint i;
for (i = 0; i < G_N_ELEMENTS(panes); i++) {
GtkPaned *paned;
paned = GTK_PANED(gui_main_window_lookup(panes[i].name));
if (GTK_WIDGET_VISIBLE(gtk_paned_get_child1(paned)))
paned_save_position(paned, panes[i].prop);
}
} | false | false | false | false | false | 0 |
transDo(m,e,qs) /* Translate do { qs ; e } */
Cell m;
Cell e;
List qs; {
if (nonNull(qs)) {
Cell q = hd(qs);
Cell qs1 = tl(qs);
switch (fst(q)) {
case FROMQUAL : { Cell ld = NIL;
Cell hVar = inventVar();
if (!failFree(fst(snd(q)))) {
Cell str = mkStr(findText("match fails"));
ld = cons(pair(singleton(WILDCARD),
ap2(nameMFail,m,str)),
ld);
}
ld = cons(pair(singleton(fst(snd(q))),
transDo(m,e,qs1)),
ld);
return ap(LETREC,
pair(singleton(pair(hVar,ld)),
ap(ap(ap(nameBind,
m),
translate(snd(snd(q)))),
hVar)));
}
case DOQUAL : return ap(ap(ap(nameThen,m),
translate(snd(q))),
transDo(m,e,qs1));
case QWHERE : return
expandLetrec(ap(LETREC,
pair(snd(q),
transDo(m,e,qs1))));
case BOOLQUAL : return
ap(COND,
triple(translate(snd(q)),
transDo(m,e,qs1),
ap2(nameMFail,m,
mkStr(findText("guard fails")))));
}
}
return e;
} | false | false | false | false | false | 0 |
tty_ldisc_put(struct tty_ldisc *ld)
{
if (WARN_ON_ONCE(!ld))
return;
put_ldops(ld->ops);
kfree(ld);
} | false | false | false | false | false | 0 |
midgard_object_is_in_tree(MidgardObject *self, guint rootid, guint id)
{
g_return_val_if_fail(self != NULL, FALSE);
if(!MGD_OBJECT_CNC (self)) {
g_warning("Object has no connection pointer!");
return FALSE;
}
const gchar *table =
midgard_core_class_get_table(MIDGARD_DBOBJECT_GET_CLASS(self));
const gchar *upfield = MIDGARD_DBOBJECT (self)->dbpriv->storage_data->upfield;
if(table == NULL || upfield == NULL)
return FALSE;
gboolean rv =
_midgard_tree_exists(MGD_OBJECT_CNC (self), table,
upfield, rootid, id);
return rv;
} | false | false | false | false | false | 0 |
_glcpp_parser_expand_node (glcpp_parser_t *parser,
token_node_t *node,
token_node_t **last)
{
token_t *token = node->token;
const char *identifier;
macro_t *macro;
/* We only expand identifiers */
if (token->type != IDENTIFIER) {
/* We change any COMMA into a COMMA_FINAL to prevent
* it being mistaken for an argument separator
* later. */
if (token->type == ',') {
token->type = COMMA_FINAL;
token->value.ival = COMMA_FINAL;
}
return NULL;
}
/* Look up this identifier in the hash table. */
identifier = token->value.str;
macro = hash_table_find (parser->defines, identifier);
/* Not a macro, so no expansion needed. */
if (macro == NULL)
return NULL;
/* Finally, don't expand this macro if we're already actively
* expanding it, (to avoid infinite recursion). */
if (_active_list_contains (parser->active, identifier)) {
/* We change the token type here from IDENTIFIER to
* OTHER to prevent any future expansion of this
* unexpanded token. */
char *str;
token_list_t *expansion;
token_t *final;
str = ralloc_strdup (parser, token->value.str);
final = _token_create_str (parser, OTHER, str);
expansion = _token_list_create (parser);
_token_list_append (expansion, final);
*last = node;
return expansion;
}
if (! macro->is_function)
{
*last = node;
/* Replace a macro defined as empty with a SPACE token. */
if (macro->replacements == NULL)
return _token_list_create_with_one_space (parser);
return _token_list_copy (parser, macro->replacements);
}
return _glcpp_parser_expand_function (parser, node, last);
} | false | false | false | false | false | 0 |
clock_t_to_secs (t, sp, sfp)
clock_t t;
time_t *sp;
int *sfp;
{
static long clk_tck = -1;
if (clk_tck == -1)
clk_tck = get_clk_tck ();
*sfp = t % clk_tck;
*sfp = (*sfp * 1000) / clk_tck;
*sp = t / clk_tck;
/* Sanity check */
if (*sfp >= 1000)
{
*sp += 1;
*sfp -= 1000;
}
} | false | false | false | false | false | 0 |
mimetype( const KUrl& url )
{
kDebug(7113) << url;
if (!maybeSetRequestUrl(url))
return;
resetSessionSettings();
m_request.method = HTTP_HEAD;
m_request.cacheTag.policy= CC_Cache;
if (proceedUntilResponseHeader()) {
httpClose(m_request.isKeepAlive);
finished();
}
kDebug(7113) << m_mimeType;
} | false | false | false | false | false | 0 |
instance_destructor(void *obj)
{
struct ast_rtp_instance *instance = obj;
/* Pass us off to the engine to destroy */
if (instance->data && instance->engine->destroy(instance)) {
ast_debug(1, "Engine '%s' failed to destroy RTP instance '%p'\n", instance->engine->name, instance);
return;
}
if (instance->srtp) {
res_srtp->destroy(instance->srtp);
}
ast_rtp_codecs_payloads_destroy(&instance->codecs);
/* Drop our engine reference */
ast_module_unref(instance->engine->mod);
ast_debug(1, "Destroyed RTP instance '%p'\n", instance);
} | false | false | false | false | false | 0 |
visitMachineBasicBlockAfter(const MachineBasicBlock *MBB) {
MBBInfoMap[MBB].regsLiveOut = regsLive;
regsLive.clear();
if (Indexes) {
SlotIndex stop = Indexes->getMBBEndIdx(MBB);
if (!(stop > lastIndex)) {
report("Block ends before last instruction index", MBB);
errs() << "Block ends at " << stop
<< " last instruction was at " << lastIndex << '\n';
}
lastIndex = stop;
}
} | false | false | false | false | false | 0 |
mt9v022_init(struct i2c_client *client)
{
struct mt9v022 *mt9v022 = to_mt9v022(client);
int ret;
/*
* Almost the default mode: master, parallel, simultaneous, and an
* undocumented bit 0x200, which is present in table 7, but not in 8,
* plus snapshot mode to disable scan for now
*/
mt9v022->chip_control |= 0x10;
ret = reg_write(client, MT9V022_CHIP_CONTROL, mt9v022->chip_control);
if (!ret)
ret = reg_write(client, MT9V022_READ_MODE, 0x300);
/* All defaults */
if (!ret)
/* AEC, AGC on */
ret = reg_set(client, MT9V022_AEC_AGC_ENABLE, 0x3);
if (!ret)
ret = reg_write(client, MT9V022_ANALOG_GAIN, 16);
if (!ret)
ret = reg_write(client, MT9V022_TOTAL_SHUTTER_WIDTH, 480);
if (!ret)
ret = reg_write(client, mt9v022->reg->max_total_shutter_width, 480);
if (!ret)
/* default - auto */
ret = reg_clear(client, MT9V022_BLACK_LEVEL_CALIB_CTRL, 1);
if (!ret)
ret = reg_write(client, MT9V022_DIGITAL_TEST_PATTERN, 0);
if (!ret)
return v4l2_ctrl_handler_setup(&mt9v022->hdl);
return ret;
} | false | false | false | false | false | 0 |
appendBuffer (Buffer b, Buffer **buffs, int *newSpot, int *curLen)
{
if (*newSpot == *curLen)
{
*curLen += 10 ;
*buffs = xrealloc (*buffs, sizeof(Buffer) * *curLen) ;
}
(*buffs) [(*newSpot)++] = b ;
} | false | false | false | false | false | 0 |
check_client_encoding(char **newval, void **extra, GucSource source)
{
int encoding;
const char *canonical_name;
/* Look up the encoding by name */
encoding = pg_valid_client_encoding(*newval);
if (encoding < 0)
return false;
/* Get the canonical name (no aliases, uniform case) */
canonical_name = pg_encoding_to_char(encoding);
/*
* If we are not within a transaction then PrepareClientEncoding will not
* be able to look up the necessary conversion procs. If we are still
* starting up, it will return "OK" anyway, and InitializeClientEncoding
* will fix things once initialization is far enough along. After
* startup, we'll fail. This would only happen if someone tries to change
* client_encoding in postgresql.conf and then SIGHUP existing sessions.
* It seems like a bad idea for client_encoding to change that way anyhow,
* so we don't go out of our way to support it.
*
* Note: in the postmaster, or any other process that never calls
* InitializeClientEncoding, PrepareClientEncoding will always succeed,
* and so will SetClientEncoding; but they won't do anything, which is OK.
*/
if (PrepareClientEncoding(encoding) < 0)
{
if (IsTransactionState())
{
/* Must be a genuine no-such-conversion problem */
GUC_check_errcode(ERRCODE_FEATURE_NOT_SUPPORTED);
GUC_check_errdetail("Conversion between %s and %s is not supported.",
canonical_name,
GetDatabaseEncodingName());
}
else
{
/* Provide a useful complaint */
GUC_check_errdetail("Cannot change \"client_encoding\" now.");
}
return false;
}
/*
* Replace the user-supplied string with the encoding's canonical name.
* This gets rid of aliases and case-folding variations.
*
* XXX Although canonicalizing seems like a good idea in the abstract, it
* breaks pre-9.1 JDBC drivers, which expect that if they send "UNICODE"
* as the client_encoding setting then it will read back the same way. As
* a workaround, don't replace the string if it's "UNICODE". Remove that
* hack when pre-9.1 JDBC drivers are no longer in use.
*/
if (strcmp(*newval, canonical_name) != 0 &&
strcmp(*newval, "UNICODE") != 0)
{
free(*newval);
*newval = strdup(canonical_name);
if (!*newval)
return false;
}
/*
* Save the encoding's ID in *extra, for use by assign_client_encoding.
*/
*extra = malloc(sizeof(int));
if (!*extra)
return false;
*((int *) *extra) = encoding;
return true;
} | false | false | false | false | false | 0 |
convolve_bytes (
PCONV_INST g, /* ptr to our instance variables */
PBYTE pbDest) /* output buffer */
{
PBYTE pbSrc, pbDestAfter;
int iSrcOffset, iSideOffset, iSum;
int *pMatrix;
int row, col;
pbDestAfter = pbDest + g->dwBytesPerRow;
iSrcOffset = 0;
iSideOffset = g->iBytesPerPixel * (g->nCols>>1);
while (pbDest < pbDestAfter) /* for each output pixel ... */
{
iSum = 0;
pMatrix = g->matrix;
for (row=0; row<g->nRows; row++) {
pbSrc = g->apRows[row] + iSrcOffset;
for (col=0; col<g->nCols; col++) {
iSum += (*pMatrix++) * (int)(unsigned)(*pbSrc);
pbSrc += g->iBytesPerPixel;
}
}
iSum = (iSum + (g->iDivisor>>1)) / g->iDivisor;
if (iSum < 0) iSum = 0; else if (iSum > 255) iSum = 255;
*pbDest++ = (BYTE)iSum;
if (g->iBytesPerPixel == 3) {
/* copy chrominance values from the center pixel to the output pixel */
pbSrc = g->apRows[g->nRows>>1] + (iSideOffset + iSrcOffset + 1);
*pbDest++ = *pbSrc++;
*pbDest++ = *pbSrc++;
}
iSrcOffset += g->iBytesPerPixel;
}
} | false | false | false | false | false | 0 |
PK11_DigestFinal(PK11Context *context,unsigned char *data,
unsigned int *outLen, unsigned int length)
{
CK_ULONG len;
CK_RV crv;
SECStatus rv;
/* if we ran out of session, we need to restore our previously stored
* state.
*/
PK11_EnterContextMonitor(context);
if (!context->ownSession) {
rv = pk11_restoreContext(context,context->savedData,
context->savedLength);
if (rv != SECSuccess) {
PK11_ExitContextMonitor(context);
return rv;
}
}
len = length;
switch (context->operation) {
case CKA_SIGN:
crv=PK11_GETTAB(context->slot)->C_SignFinal(context->session,
data,&len);
break;
case CKA_VERIFY:
crv=PK11_GETTAB(context->slot)->C_VerifyFinal(context->session,
data,len);
break;
case CKA_DIGEST:
crv=PK11_GETTAB(context->slot)->C_DigestFinal(context->session,
data,&len);
break;
case CKA_ENCRYPT:
crv=PK11_GETTAB(context->slot)->C_EncryptFinal(context->session,
data, &len);
break;
case CKA_DECRYPT:
crv = PK11_GETTAB(context->slot)->C_DecryptFinal(context->session,
data, &len);
break;
default:
crv = CKR_OPERATION_NOT_INITIALIZED;
break;
}
PK11_ExitContextMonitor(context);
*outLen = (unsigned int) len;
context->init = PR_FALSE; /* allow Begin to start up again */
if (crv != CKR_OK) {
PORT_SetError( PK11_MapError(crv) );
return SECFailure;
}
return SECSuccess;
} | false | false | false | false | false | 0 |
grl_registry_lookup_metadata_key_type (GrlRegistry *registry,
GrlKeyID key)
{
const gchar *key_name;
GParamSpec *key_pspec;
g_return_val_if_fail (GRL_IS_REGISTRY (registry), 0);
key_name = key_id_handler_get_name (®istry->priv->key_id_handler, key);
if (!key_name) {
return G_TYPE_INVALID;
}
key_pspec = g_hash_table_lookup (registry->priv->system_keys, key_name);
if (key_pspec) {
return G_PARAM_SPEC_VALUE_TYPE (key_pspec);
} else {
return G_TYPE_INVALID;
}
} | false | false | false | false | false | 0 |
FcCacheFindByAddrUnlocked (void *object)
{
int i;
FcCacheSkip **next = fcCacheChains;
FcCacheSkip *s;
if (!object)
return NULL;
/*
* Walk chain pointers one level at a time
*/
for (i = fcCacheMaxLevel; --i >= 0;)
while (next[i] && (char *) object >= ((char *) next[i]->cache + next[i]->size))
next = next[i]->next;
/*
* Here we are
*/
s = next[0];
if (s && (char *) object < ((char *) s->cache + s->size))
return s;
return NULL;
} | false | false | false | false | false | 0 |
jxr_set_INTERNAL_CLR_FMT(jxr_image_t image, jxr_color_fmt_t fmt, int channels)
{
switch (fmt) {
case JXR_YONLY:
image->use_clr_fmt = fmt;
image->num_channels = 1;
break;
case JXR_YUV420:
case JXR_YUV422:
case JXR_YUV444:
image->use_clr_fmt = fmt;
image->num_channels = 3;
break;
case JXR_YUVK:
image->use_clr_fmt = fmt;
image->num_channels = 4;
break;
case JXR_OCF_NCOMPONENT:
image->use_clr_fmt = fmt;
image->num_channels = channels;
break;
default:
image->use_clr_fmt = fmt;
image->num_channels = channels;
break;
}
} | false | false | false | false | false | 0 |
job_get_queue_with_task_about_to_exit(lListElem *jep,
lListElem *jatep,
lListElem *petep,
const char *qualified_hostname,
const char *queuename)
{
lListElem *petask;
DENTER(TOP_LAYER, "job_get_queue_with_task_about_to_exit");
for_each(petask, lGetList(jatep, JAT_task_list)) {
lListElem *pe_task_queue = lFirst(lGetList(petask, PET_granted_destin_identifier_list));
if (pe_task_queue != NULL) {
/* if a certain queue is requested, skip non matching tasks */
if (queuename != NULL && strcmp(queuename, lGetString(pe_task_queue, JG_qname)) != 0) {
continue;
} else {
dstring shepherd_about_to_exit = DSTRING_INIT;
SGE_STRUCT_STAT stat_buffer;
u_long32 jobid;
u_long32 jataskid;
const char *petaskid = NULL;
jobid = lGetUlong(jep, JB_job_number);
jataskid = lGetUlong(jatep, JAT_task_number);
petaskid = lGetString(petask, PET_id);
sge_get_active_job_file_path(&shepherd_about_to_exit,
jobid, jataskid, petaskid,
"shepherd_about_to_exit");
DPRINTF(("checking for file %s\n", sge_dstring_get_string(&shepherd_about_to_exit)));
if (SGE_STAT(sge_dstring_get_string(&shepherd_about_to_exit), &stat_buffer) == 0) {
lList *jat_gdil = job_set_queue_info_in_task(qualified_hostname,
lGetString(pe_task_queue, JG_qname), petep);
DPRINTF(("task %s of job %d.%d already exited, using its slot for new task\n",
petaskid, jobid, jataskid));
sge_dstring_free(&shepherd_about_to_exit);
DRETURN(jat_gdil);
}
sge_dstring_free(&shepherd_about_to_exit);
}
}
}
DRETURN(NULL);
} | false | false | false | false | false | 0 |
GetTransferCacheAtIndex(CTransfer*& transferPtr, int index) {
try {
transferPtr = m_TransferCache.at(index);
} catch ( std::out_of_range ) {
transferPtr = NULL;
return -1;
}
return 0;
} | false | false | false | false | false | 0 |
ArchArchiveOpen(const char *archive, const char *mode)
{
struct arfile *ar;
char magic[SARMAG];
ar = emalloc(sizeof(*ar));
ar->fname = estrdup(archive);
ar->mlen = 100;
ar->member = emalloc(ar->mlen);
ar->nametab = NULL;
ar->nametablen = 0;
if ((ar->fp = fopen(ar->fname, mode)) == NULL) {
DEBUGM(ARCH, ("%s", ar->fname));
ArchArchiveClose(ar);
return (NULL);
}
/* read MAGIC */
if (fread(magic, SARMAG, 1, ar->fp) != 1 ||
strncmp(magic, ARMAG, SARMAG) != 0) {
ArchError(("%s: bad archive magic\n", ar->fname));
ArchArchiveClose(ar);
return (NULL);
}
ar->pos = 0;
return (ar);
} | false | false | false | false | false | 0 |
_gst_array_hasvalue_accumulator (GSignalInvocationHint * ihint,
GValue * return_accu, const GValue * handler_return, gpointer dummy)
{
gpointer array;
array = g_value_get_boxed (handler_return);
if (!(ihint->run_type & G_SIGNAL_RUN_CLEANUP))
g_value_set_boxed (return_accu, array);
if (array != NULL)
return FALSE;
return TRUE;
} | false | false | false | false | false | 0 |
StringAllocate(lenpos_t len) {
if (len != measure_length) {
return new char[len + 1];
} else {
return 0;
}
} | false | false | false | false | false | 0 |
op_entry_has_offset_access(Op_entry *op_entry, Module_table *mpt)
{
Iv_table *ipt;
Heap_table *hpt;
switch (op_entry->kind) {
case KIND_VAR :
case KIND_FILE :
return FALSE;
break;
case KIND_ARRAY :
return TRUE;
break;
case KIND_INVISIBLE :
ipt = search_invisible_table(mpt->invisible_head, op_entry->entry);
return ipt->has_offset_access;
break;
case KIND_HEAP :
hpt = search_heap_table(mpt->heap_head, op_entry->entry);
return hpt->has_offset_access;
break;
default :
fatal("unexpected kind\n");
return TRUE;
break;
}
} | false | false | false | false | false | 0 |
image_zoom_cb(PixbufRenderer *pr, gdouble zoom, gpointer data)
{
ImageWindow *imd = data;
if (imd->title_show_zoom) image_update_title(imd);
image_state_set(imd, IMAGE_STATE_IMAGE);
image_update_util(imd);
} | false | false | false | false | false | 0 |
push_front(node *n) {
if (first) {
first->prev = n;
n->prev = NULL;
n->next = first;
first = n;
} else {
assert(!last);
first = last = n;
n->prev = n->next = NULL;
}
n->parent = this;
} | false | false | false | false | false | 0 |
evutil_sockaddr_cmp(const struct sockaddr *sa1, const struct sockaddr *sa2,
int include_port)
{
int r;
if (0 != (r = (sa1->sa_family - sa2->sa_family)))
return r;
if (sa1->sa_family == AF_INET) {
const struct sockaddr_in *sin1, *sin2;
sin1 = (const struct sockaddr_in *)sa1;
sin2 = (const struct sockaddr_in *)sa2;
if (sin1->sin_addr.s_addr < sin2->sin_addr.s_addr)
return -1;
else if (sin1->sin_addr.s_addr > sin2->sin_addr.s_addr)
return 1;
else if (include_port &&
(r = ((int)sin1->sin_port - (int)sin2->sin_port)))
return r;
else
return 0;
}
#ifdef AF_INET6
else if (sa1->sa_family == AF_INET6) {
const struct sockaddr_in6 *sin1, *sin2;
sin1 = (const struct sockaddr_in6 *)sa1;
sin2 = (const struct sockaddr_in6 *)sa2;
if ((r = memcmp(sin1->sin6_addr.s6_addr, sin2->sin6_addr.s6_addr, 16)))
return r;
else if (include_port &&
(r = ((int)sin1->sin6_port - (int)sin2->sin6_port)))
return r;
else
return 0;
}
#endif
return 1;
} | false | false | false | false | false | 0 |
art_rgb_bitmap_affine_opaque (art_u8 *dst,
int x0, int y0, int x1, int y1,
int dst_rowstride,
const art_u8 *src,
int src_width, int src_height, int src_rowstride,
art_u32 rgb,
const double affine[6],
ArtFilterLevel level,
ArtAlphaGamma *alphagamma)
{
/* Note: this is a slow implementation, and is missing all filter
levels other than NEAREST. It is here for clarity of presentation
and to establish the interface. */
int x, y;
double inv[6];
art_u8 *dst_p, *dst_linestart;
const art_u8 *src_p;
ArtPoint pt, src_pt;
int src_x, src_y;
art_u8 r, g, b;
int run_x0, run_x1;
r = rgb >> 16;
g = (rgb >> 8) & 0xff;
b = rgb & 0xff;
dst_linestart = dst;
art_affine_invert (inv, affine);
for (y = y0; y < y1; y++)
{
pt.y = y + 0.5;
run_x0 = x0;
run_x1 = x1;
art_rgb_affine_run (&run_x0, &run_x1, y, src_width, src_height,
inv);
dst_p = dst_linestart + (run_x0 - x0) * 3;
for (x = run_x0; x < run_x1; x++)
{
pt.x = x + 0.5;
art_affine_point (&src_pt, &pt, inv);
src_x = floor (src_pt.x);
src_y = floor (src_pt.y);
src_p = src + (src_y * src_rowstride) + (src_x >> 3);
if (*src_p & (128 >> (src_x & 7)))
{
dst_p[0] = r;
dst_p[1] = g;
dst_p[2] = b;
}
dst_p += 3;
}
dst_linestart += dst_rowstride;
}
} | false | false | false | false | false | 0 |
ai_goal_find_dockpoint(int shipnum, int dock_type)
{
int dock_index = -1;
int loop_count = 0;
ship *shipp = &Ships[shipnum];
object *objp = &Objects[shipp->objnum];
// only check 100 points for sanity's sake
while (loop_count < 100)
{
dock_index = model_find_dock_index(Ship_info[shipp->ship_info_index].model_num, dock_type, dock_index+1);
// not found?
if (dock_index == -1)
{
if (loop_count == 0)
{
// first time around... there are no slots fitting this description
return -1;
}
else
{
// every slot is full
break;
}
}
// we've found something... check if it's occupied
if (dock_find_object_at_dockpoint(objp, dock_index) == NULL)
{
// not occupied... yay, we've found an index
return dock_index;
}
// keep track
loop_count++;
}
// insanity?
if (loop_count >= 100)
Warning(LOCATION, "Too many iterations while looking for a dockpoint on %s.\n", shipp->ship_name);
// if we're here, just return the first dockpoint
return model_find_dock_index(Ship_info[shipp->ship_info_index].model_num, dock_type);
} | false | false | false | false | false | 0 |
event_rest(decorators,n,m,type)
/* rest of n/m in the abc */
int n, m,type;
int decorators[DECSIZE];
{
int num, denom;
num = n;
denom = m;
if (v == NULL) {
event_fatal_error("Internal error : no voice allocated");
};
if (v->inchord) v->chordcount = v->chordcount + 1;
if (tuplecount > 0) {
num = num * tfact_num;
denom = denom * tfact_denom;
if (tnote_num == 0) {
tnote_num = num;
tnote_denom = denom;
} else {
if (tnote_num * denom != num * tnote_denom) {
if (!specialtuple) {
event_warning("Different length notes in tuple");
};
};
};
if ((!gracenotes) && (!v->inchord)) {
tuplecount = tuplecount - 1;
};
};
if (v->chordcount == 1) {
v->chord_num = num*4;
v->chord_denom = denom*(v->default_length);
};
if ((!v->ingrace) && ((!v->inchord)||(v->chordcount==1))) {
addunits(num, denom*(v->default_length));
};
last_num = 3; /* hornpiping (>) cannot follow rest */
addfeature(REST, 0, num*4, denom*(v->default_length));
if (!v->inchord ) {
marknote();
};
} | false | false | false | false | false | 0 |
scm_evict_ports (int fd)
{
long i;
scm_i_scm_pthread_mutex_lock (&scm_i_port_table_mutex);
for (i = 0; i < scm_i_port_table_size; i++)
{
SCM port = scm_i_port_table[i]->port;
if (SCM_FPORTP (port))
{
scm_t_fport *fp = SCM_FSTREAM (port);
if (fp->fdes == fd)
{
fp->fdes = dup (fd);
if (fp->fdes == -1)
scm_syserror ("scm_evict_ports");
scm_set_port_revealed_x (port, scm_from_int (0));
}
}
}
scm_i_pthread_mutex_unlock (&scm_i_port_table_mutex);
} | false | false | false | false | false | 0 |
__ext4_journalled_writepage(struct page *page,
unsigned int len)
{
struct address_space *mapping = page->mapping;
struct inode *inode = mapping->host;
struct buffer_head *page_bufs = NULL;
handle_t *handle = NULL;
int ret = 0, err = 0;
int inline_data = ext4_has_inline_data(inode);
struct buffer_head *inode_bh = NULL;
ClearPageChecked(page);
if (inline_data) {
BUG_ON(page->index != 0);
BUG_ON(len > ext4_get_max_inline_size(inode));
inode_bh = ext4_journalled_write_inline_data(inode, len, page);
if (inode_bh == NULL)
goto out;
} else {
page_bufs = page_buffers(page);
if (!page_bufs) {
BUG();
goto out;
}
ext4_walk_page_buffers(handle, page_bufs, 0, len,
NULL, bget_one);
}
/*
* We need to release the page lock before we start the
* journal, so grab a reference so the page won't disappear
* out from under us.
*/
get_page(page);
unlock_page(page);
handle = ext4_journal_start(inode, EXT4_HT_WRITE_PAGE,
ext4_writepage_trans_blocks(inode));
if (IS_ERR(handle)) {
ret = PTR_ERR(handle);
put_page(page);
goto out_no_pagelock;
}
BUG_ON(!ext4_handle_valid(handle));
lock_page(page);
put_page(page);
if (page->mapping != mapping) {
/* The page got truncated from under us */
ext4_journal_stop(handle);
ret = 0;
goto out;
}
if (inline_data) {
BUFFER_TRACE(inode_bh, "get write access");
ret = ext4_journal_get_write_access(handle, inode_bh);
err = ext4_handle_dirty_metadata(handle, inode, inode_bh);
} else {
ret = ext4_walk_page_buffers(handle, page_bufs, 0, len, NULL,
do_journal_get_write_access);
err = ext4_walk_page_buffers(handle, page_bufs, 0, len, NULL,
write_end_fn);
}
if (ret == 0)
ret = err;
EXT4_I(inode)->i_datasync_tid = handle->h_transaction->t_tid;
err = ext4_journal_stop(handle);
if (!ret)
ret = err;
if (!ext4_has_inline_data(inode))
ext4_walk_page_buffers(NULL, page_bufs, 0, len,
NULL, bput_one);
ext4_set_inode_state(inode, EXT4_STATE_JDATA);
out:
unlock_page(page);
out_no_pagelock:
brelse(inode_bh);
return ret;
} | false | false | false | false | false | 0 |
modem_hw_on(const char* pm_base_dir)
{
LOG(LOG_DEBUG, "Enter");
SYSCHECK(modem_hw_off(pm_base_dir));
sleep(1);
SYSCHECK(modem_hw_(pm_base_dir, "power_on", 1));
sleep(1);
SYSCHECK(modem_hw_(pm_base_dir, "reset", 1));
sleep(1);
SYSCHECK(modem_hw_(pm_base_dir, "reset", 0));
sleep(4);
LOG(LOG_DEBUG, "Leave");
return 0;
} | false | false | false | false | false | 0 |
do_help()
{
Command *c;
int i, col = 0;
if( targc == 1 )
{
lprintf( stdout, "available commands:\n" );
for( c = cmds; c->name != NULL; c++ )
{
i = strlen( c->name ) + 1;
if( col + i >= MAXCOL )
{
lprintf( stdout, "\n" );
col = 0;
}
col += i;
lprintf( stdout, " %s", c->name );
}
lprintf( stdout, "\n" );
}
else
{
for( i = 1; i < targc; i++ )
{
#ifdef TCL_IRSIM
for( c = cmds; c->name != NULL; c++ )
if (!strcmp(targv[i], c->name))
break;
#else
for( c = cmdtbl[ HashCmd( targv[i] ) ]; c != NULL; c = c->next )
{
if( strcmp( targv[i], c->name ) == 0 )
break;
}
#endif
if( c )
lprintf( stdout, "%s %s\n", c->name, c->help );
else
lprintf( stdout, "%s -> UNKNOWN\n", targv[i] );
}
}
return( 0 );
} | false | false | false | false | false | 0 |
symboltype(char *name)
{
GLOBAL *sp;
if (findparam(name) >= 0)
return SYM_PARAM;
if (findlocal(name) >= 0)
return SYM_LOCAL;
sp = findglobal(name);
if (sp) {
if (sp->g_filescope == SCOPE_GLOBAL)
return SYM_GLOBAL;
return SYM_STATIC;
}
return SYM_UNDEFINED;
} | false | false | false | false | false | 0 |
AED_undo_cb(AW_window *aw, AW_CL cd1, AW_CL undo_type){
GB_ERROR error = GB_undo(GLOBAL_gb_main,(GB_UNDO_TYPE)undo_type);
if (error) aw_message(error);
else{
GB_begin_transaction(GLOBAL_gb_main);
GB_commit_transaction(GLOBAL_gb_main);
aed_expose(aw,cd1,0);
}
} | false | false | false | false | false | 0 |
wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd,
int seconds)
{
int i;
struct megasas_header *frame_hdr = &cmd->frame->hdr;
struct fusion_context *fusion;
u32 msecs = seconds * 1000;
fusion = instance->ctrl_context;
/*
* Wait for cmd_status to change
*/
for (i = 0; (i < msecs) && (frame_hdr->cmd_status == 0xff); i += 20) {
rmb();
msleep(20);
}
if (frame_hdr->cmd_status == MFI_STAT_INVALID_STATUS)
return DCMD_TIMEOUT;
else if (frame_hdr->cmd_status == MFI_STAT_OK)
return DCMD_SUCCESS;
else
return DCMD_FAILED;
} | false | false | false | false | false | 0 |
analyze_array()
{
int i;
check_last_first(1);
for(i = 0; i < MAX_ARRAY_DIM; i++)
{
analyze_expr(0, RS_NONE);
if (!PATTERN_is(*current, RS_COMMA))
break;
current++;
}
if (!PATTERN_is(*current, RS_RSQR))
THROW("Missing ']'");
current++;
add_operator(RS_LSQR, i + 2);
} | false | false | false | false | false | 0 |
do_rsync_out (const char *src_orig, const char *remote,
int archive, int deletedest)
{
CLEANUP_FREE char *src = NULL;
src = sysroot_path (src_orig);
if (!src) {
reply_with_perror ("malloc");
return -1;
}
if (!(optargs_bitmask & GUESTFS_RSYNC_OUT_ARCHIVE_BITMASK))
archive = 0;
if (!(optargs_bitmask & GUESTFS_RSYNC_OUT_DELETEDEST_BITMASK))
deletedest = 0;
return rsync (src, src_orig, remote, remote, archive, deletedest);
} | false | false | false | false | false | 0 |
SetInteractive()
{
if(!top_level)
return;
bool def=feeder?feeder->IsInteractive():false;
SetInteractive(ResMgr::QueryTriBool("cmd:interactive",0,def));
} | false | false | false | false | false | 0 |
CompileAtomString(RegExpNode **ptr)
{
int c;
for (;;)
{
c=curchar();
if (c == 0 || c == '|' || c == ')' || c == '!')
break;
ptr=CompileElement(ptr);
}
return (ptr);
} | false | false | false | false | false | 0 |
check_temp(char *output_table)
{
if (output_table[0] == 'b' &&
output_table[1] == '2' &&
is_an_integer(output_table + 2))
{
return true;
}
return false;
} | false | false | false | false | false | 0 |
image_loaded (MonoProfiler *prof, MonoImage *image, int result)
{
uint64_t now;
const char *name;
int nlen;
LogBuffer *logbuffer;
if (result != MONO_PROFILE_OK)
return;
name = mono_image_get_filename (image);
nlen = strlen (name) + 1;
logbuffer = ensure_logbuf (
EVENT_SIZE /* event */ +
LEB128_SIZE /* time */ +
EVENT_SIZE /* type */ +
LEB128_SIZE /* image */ +
LEB128_SIZE /* flags */ +
nlen /* name */
);
now = current_time ();
ENTER_LOG (logbuffer, "image");
emit_byte (logbuffer, TYPE_END_LOAD | TYPE_METADATA);
emit_time (logbuffer, now);
emit_byte (logbuffer, TYPE_IMAGE);
emit_ptr (logbuffer, image);
emit_value (logbuffer, 0); /* flags */
memcpy (logbuffer->data, name, nlen);
logbuffer->data += nlen;
//printf ("loaded image %p (%s)\n", image, name);
EXIT_LOG (logbuffer);
if (logbuffer->next)
safe_send (prof, logbuffer);
process_requests (prof);
} | false | true | false | false | false | 1 |
bnad_vlan_rx_kill_vid(struct net_device *netdev, __be16 proto, u16 vid)
{
struct bnad *bnad = netdev_priv(netdev);
unsigned long flags;
if (!bnad->rx_info[0].rx)
return 0;
mutex_lock(&bnad->conf_mutex);
spin_lock_irqsave(&bnad->bna_lock, flags);
clear_bit(vid, bnad->active_vlans);
bna_rx_vlan_del(bnad->rx_info[0].rx, vid);
spin_unlock_irqrestore(&bnad->bna_lock, flags);
mutex_unlock(&bnad->conf_mutex);
return 0;
} | false | false | false | false | false | 0 |
Init(trpgr_Archive *inArch)
{
archive = inArch;
// We're resetting everything. In general, Init should only
// be called once, but it'll work fine if you call it more than once.
lastLoad = None;
lastTile = NULL;
lastLod = -1;
// Need to know the number of terrain LODs
const trpgHeader *head = archive->GetHeader();
int numLod;
head->GetNumLods(numLod);
head->GetVersion(majorVersion, minorVersion);
// Reset the terrain LOD paging classes.
valid = true;
pageInfo.resize(numLod);
for (int i=0;i<numLod;i++) {
if(i > 3)
pageInfo[i].Init(archive,i,scale, 4);
else
pageInfo[i].Init(archive,i,scale);
}
} | false | false | false | false | false | 0 |
SQLGetPrivateProfileString (LPCSTR lpszSection, LPCSTR lpszEntry,
LPCSTR lpszDefault, LPSTR lpszRetBuffer, int cbRetBuffer,
LPCSTR lpszFilename)
{
char pathbuf[1024];
int len = 0;
/* Check input parameters */
CLEAR_ERROR ();
if (!lpszRetBuffer || !cbRetBuffer)
{
PUSH_ERROR (ODBC_ERROR_INVALID_BUFF_LEN);
goto quit;
}
if (!lpszDefault)
{
PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
goto quit;
}
/* Else go through user/system odbc.ini */
switch (configMode)
{
case ODBC_USER_DSN:
wSystemDSN = USERDSN_ONLY;
if (lpszFilename)
{
len =
GetPrivateProfileString (lpszSection, lpszEntry, lpszDefault,
lpszRetBuffer, cbRetBuffer, lpszFilename);
goto quit;
}
if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, FALSE))
len =
GetPrivateProfileString (lpszSection, lpszEntry, lpszDefault,
lpszRetBuffer, cbRetBuffer, pathbuf);
goto quit;
case ODBC_SYSTEM_DSN:
wSystemDSN = SYSTEMDSN_ONLY;
if (lpszFilename)
{
len =
GetPrivateProfileString (lpszSection, lpszEntry, lpszDefault,
lpszRetBuffer, cbRetBuffer, lpszFilename);
goto quit;
}
if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, FALSE))
len =
GetPrivateProfileString (lpszSection, lpszEntry, lpszDefault,
lpszRetBuffer, cbRetBuffer, pathbuf);
goto quit;
case ODBC_BOTH_DSN:
wSystemDSN = USERDSN_ONLY;
if (lpszFilename)
{
len =
GetPrivateProfileString (lpszSection, lpszEntry, lpszDefault,
lpszRetBuffer, cbRetBuffer, lpszFilename);
if (!len)
{
CLEAR_ERROR ();
wSystemDSN = SYSTEMDSN_ONLY;
len =
GetPrivateProfileString (lpszSection, lpszEntry,
lpszDefault, lpszRetBuffer, cbRetBuffer, lpszFilename);
}
goto quit;
}
if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, FALSE))
{
len =
GetPrivateProfileString (lpszSection, lpszEntry, lpszDefault,
lpszRetBuffer, cbRetBuffer, pathbuf);
if (len)
goto quit;
}
CLEAR_ERROR ();
wSystemDSN = SYSTEMDSN_ONLY;
if (_iodbcadm_getinifile (pathbuf, sizeof (pathbuf), FALSE, FALSE))
{
len =
GetPrivateProfileString (lpszSection, lpszEntry, lpszDefault,
lpszRetBuffer, cbRetBuffer, pathbuf);
}
goto quit;
}
PUSH_ERROR (ODBC_ERROR_GENERAL_ERR);
goto quit;
quit:
wSystemDSN = USERDSN_ONLY;
configMode = ODBC_BOTH_DSN;
return len;
} | true | true | false | false | false | 1 |
linedup(xchar ax, xchar ay, xchar bx, xchar by)
{
tbx = ax - bx; /* These two values are set for use */
tby = ay - by; /* after successful return. */
/* sometimes displacement makes a monster think that you're at its
own location; prevent it from throwing and zapping in that case */
if (!tbx && !tby) return false;
if((!tbx || !tby || abs(tbx) == abs(tby)) /* straight line or diagonal */
&& distmin(tbx, tby, 0, 0) < BOLT_LIM) {
if(ax == u.ux && ay == u.uy) return((bool)(couldsee(bx,by)));
else if(clear_path(ax,ay,bx,by)) return true;
}
return false;
} | false | false | false | false | false | 0 |
fd_kill (EV_P_ int fd)
{
ev_io *w;
while ((w = (ev_io *)anfds [fd].head))
{
ev_io_stop (EV_A_ w);
ev_feed_event (EV_A_ (W)w, EV_ERROR | EV_READ | EV_WRITE);
}
} | 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.