示例#1
0
PJ *PROJECTION(bonne) {
    double c;
    struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque)));
    if (nullptr==Q)
        return pj_default_destructor (P, ENOMEM);
    P->opaque = Q;
    P->destructor = destructor;

    Q->phi1 = pj_param(P->ctx, P->params, "rlat_1").f;
    if (fabs(Q->phi1) < EPS10)
        return destructor (P, PJD_ERR_LAT1_IS_ZERO);

    if (P->es != 0.0) {
        Q->en = pj_enfn(P->es);
        if (nullptr==Q->en)
            return destructor(P, ENOMEM);
        Q->m1 = pj_mlfn(Q->phi1, Q->am1 = sin(Q->phi1),
            c = cos(Q->phi1), Q->en);
        Q->am1 = c / (sqrt(1. - P->es * Q->am1 * Q->am1) * Q->am1);
        P->inv = e_inverse;
        P->fwd = e_forward;
    } else {
        if (fabs(Q->phi1) + EPS10 >= M_HALFPI)
            Q->cphi1 = 0.;
        else
            Q->cphi1 = 1. / tan(Q->phi1);
        P->inv = s_inverse;
        P->fwd = s_forward;
    }
    return P;
}
示例#2
0
int main(){
    Employee *pEmp = (Employee *) malloc(sizeof(Employee));
    pEmp->homeAddress = (Address *) malloc(sizeof(Address));
    pEmp->workAddress = (Address *) malloc(sizeof(Address));

    //Filling in a value for Employee and Address(home & work)
    strcpy(pEmp->firstName, "John");
    strcpy(pEmp->lastName, "Rasay");
    pEmp->height = 5.10;
    //Home Address
    strcpy(pEmp->homeAddress->street,"1724 C North School St");
    strcpy(pEmp->homeAddress->city,"Honolulu");
    strcpy(pEmp->homeAddress->state,"Hi");
    strcpy(pEmp->homeAddress->country,"United States");
    pEmp->homeAddress->zipcode = 96819;
    //Work Address
    strcpy(pEmp->workAddress->street,"98-1005 Moanalua Road Aiea");
    strcpy(pEmp->workAddress->city,"Honolulu");
    strcpy(pEmp->workAddress->state,"Hi");
    strcpy(pEmp->workAddress->country,"United States");
    pEmp->workAddress->zipcode = 96701;

    //Prints the info of the Employee
    printinfo(pEmp);
    
    //Free memory
    destructor(pEmp);


	printf("\n\nPress any key to continue.");
	getchar();
	exit(0);

}
int main(){

	int n;
		
	printf("\nCuantas personas van hacer la encuesta?\n");
	scanf("%d", &n);

	persona *personas = (persona *) malloc(n * N * sizeof(persona));
	preguntas = (char **) malloc(10 * N * sizeof(char *));
	*(preguntas + 0) = "Pregunta 1";
        *(preguntas + 1) = "Pregunta 2";
        *(preguntas + 2) = "Pregunta 3";
        *(preguntas + 3) = "Pregunta 4";
        *(preguntas + 4) = "Pregunta 5";
        *(preguntas + 5) = "Pregunta 6";
        *(preguntas + 6) = "Pregunta 7";
        *(preguntas + 7) = "Pregunta 8";
        *(preguntas + 8) = "Pregunta 9";
        *(preguntas + 9) = "Pregunta 10";
	srand((int) time(NULL));

	agregar(personas, n);
	histograma(personas, n);
	destructor(personas, n);
	free(preguntas);
	return 0;
}
/*
 * Function: globus_handle_table_destroy()
 *
 * Description: Destroy a handle table
 *
 * Parameters:
 *
 * Returns:
 */
int
globus_handle_table_destroy(
    globus_handle_table_t *             e_handle_table)
{
    int                                 i;
    globus_l_handle_entry_t **          table;
    globus_l_handle_entry_t *           inactive;
    globus_l_handle_entry_t *           save;
    globus_handle_destructor_t          destructor;
    globus_l_handle_table_t *		handle_table;

    if(!e_handle_table)
    {
        return GLOBUS_FAILURE;
    }

    handle_table = *e_handle_table;

    if(!handle_table)
    {
        return GLOBUS_FAILURE;
    }

    /* first free all active handles */
    table = handle_table->table;
    destructor = handle_table->destructor;
    i = handle_table->next_slot;
    while(--i > GLOBUS_NULL_HANDLE)
    {
        if(table[i])
        {
            if(destructor)
            {
                destructor(table[i]->value);
            }
            
            globus_libc_free(table[i]);
        }
    }

    /* then free inactive handles */
    inactive = handle_table->inactive;
    while(inactive)
    {
        save = inactive->pnext;
        globus_libc_free(inactive);
        inactive = save;
    }

    /* free the table */
    globus_libc_free(table);

    /* free the table handle */
    globus_libc_free(handle_table);

    /* finally, invalidate the handle */
    *e_handle_table = NULL;

    return GLOBUS_SUCCESS;
}
示例#5
0
/*
 * mowgli_object_unref
 *
 * Decrement the reference counter on an object.
 *
 * Inputs:
 *      - the object to refcount
 *
 * Outputs:
 *      - none
 *
 * Side Effects:
 *      - if the refcount is 0, the object is destroyed.
 */
void
mowgli_object_unref(void *object)
{
	mowgli_object_t *obj = mowgli_object(object);

	return_if_fail(object != NULL);

	obj->refcount--;

	if (obj->refcount <= 0)
	{
		mowgli_object_message_broadcast(obj, "destroy");

		if (obj->name != NULL)
			free(obj->name);

		if (obj->klass != NULL)
		{
			mowgli_destructor_t destructor = obj->klass->destructor;

			if (obj->klass->dynamic == TRUE)
				mowgli_object_class_destroy(obj->klass);

			if (destructor != NULL)
				destructor(obj);
			else
				free(obj);
		}
		else
		{
			mowgli_log_warning("invalid object class");
		}
	}
}
示例#6
0
文件: test.c 项目: mumu3w/MinixFsImg
int main(int argc, char *argv[])
{
	struct m_inode *mip;
	FILE *fp;
	
	if(argc != 5)
	{
		panic(__FILE__, __LINE__, 
				"Usage: %s Image super_block_id pathname filename\n", 
				argv[0]);
	}
	
	fp = fopen(argv[4], "rb");
	if(!fp)
	{
		panic(__FILE__, __LINE__, "Can't open %s\n", argv[4]);
	}
	
	constructor(argv[1]);
	
	add_file(fp, atoi(argv[2]), argv[3]);
	
	destructor();
	return 0;
}
示例#7
0
文件: lcca.cpp 项目: OSGeo/proj.4
PJ *PROJECTION(lcca) {
    double s2p0, N0, R0, tan0;
    struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque)));
    if (nullptr==Q)
        return pj_default_destructor (P, ENOMEM);
    P->opaque = Q;

    (Q->en = pj_enfn(P->es));
    if (!Q->en)
        return pj_default_destructor (P, ENOMEM);

    if (P->phi0 == 0.) {
        return destructor(P, PJD_ERR_LAT_0_IS_ZERO);
    }
    Q->l = sin(P->phi0);
    Q->M0 = pj_mlfn(P->phi0, Q->l, cos(P->phi0), Q->en);
    s2p0 = Q->l * Q->l;
    R0 = 1. / (1. - P->es * s2p0);
    N0 = sqrt(R0);
    R0 *= P->one_es * N0;
    tan0 = tan(P->phi0);
    Q->r0 = N0 / tan0;
    Q->C = 1. / (6. * R0 * N0);

    P->inv = lcca_e_inverse;
    P->fwd = lcca_e_forward;
    P->destructor = destructor;

    return P;
}
示例#8
0
void QThreadStorageData::finish(void **p)
{
    QMap<int, void *> *tls = reinterpret_cast<QMap<int, void *> *>(p);
    if (!tls || tls->isEmpty() || !mutex())
        return; // nothing to do

    DEBUG_MSG("QThreadStorageData: Destroying storage for thread %p", QThread::currentThread());

    QMap<int, void *>::iterator it = tls->begin();
    while (it != tls->end()) {
        int id = it.key();
        void *q = it.value();
        it.value() = 0;
        ++it;

        if (!q) {
            // data already deleted
            continue;
        }

        mutex()->lock();
        void (*destructor)(void *) = destructors()->value(id);
        mutex()->unlock();

        if (!destructor) {
            if (QThread::currentThread())
                qWarning("QThreadStorage: Thread %p exited after QThreadStorage %d destroyed",
                         QThread::currentThread(), id);
            continue;
        }
        destructor(q);
    }
    tls->clear();
}
示例#9
0
文件: adt_list.c 项目: cogu/adt
void  adt_list_destroy(adt_list_t *self)
{
   if (self != 0)
   {
      adt_list_elem_t *iter = self->pFirst;
      void (*destructor)(void*) = (void (*)(void*)) 0;
      if (iter == 0)
      {
         return; //empty list
      }
      if ( (self->destructorEnable != false) && (self->pDestructor != 0) )
      {
         destructor = self->pDestructor;
      }
      while( iter != 0 )
      {
         adt_list_elem_t *pNext = iter->pNext;
         if (destructor != 0)
         {
            destructor(iter->pItem);
         }
         adt_list_elem_delete(iter);
         iter=pNext;
      }
   }
}
示例#10
0
/** Internal deinitialization */
static
void _su_home_deinit(su_home_t *home)
{
  if (home->suh_blocks) {
    size_t i;
    su_block_t *b;
    void *suh_lock = home->suh_lock;

    home->suh_lock = NULL;

     if (home->suh_blocks->sub_destructor) {
      void (*destructor)(void *) = home->suh_blocks->sub_destructor;
      home->suh_blocks->sub_destructor = NULL;
      destructor(home);
    }

    b = home->suh_blocks;
#ifdef DEBUG
    SU_DEBUG_9(("%s: block %p sub_used is %ld sub_n %ld used %d\n", __func__, b, b->sub_used, b->sub_n, su_get_used_count(b))) ;
#endif
    su_home_check_blocks(b);

    for (i = 0; i < b->sub_n; i++) {
      if (b->sub_nodes[i].sua_data) {
	if (b->sub_nodes[i].sua_home) {
	  su_home_t *subhome = b->sub_nodes[i].sua_data;
	  su_block_t *subb = MEMLOCK(subhome);

	  assert(subb); assert(subb->sub_ref >= 1);
#if 0
	  if (subb->sub_ref > 0)
	    SU_DEBUG_7(("su_home_unref: subhome %p with destructor %p has still %u refs\n",
			subhome, subb->sub_destructor, subb->sub_ref));
#endif
	  subb->sub_ref = 0;	/* zap them all */
	  _su_home_deinit(subhome);
	}
	else if (su_is_preloaded(b, b->sub_nodes[i].sua_data))
	  continue;
	safefree(b->sub_nodes[i].sua_data);
      }
    }

    if (b->sub_preload && !b->sub_preauto)
      free(b->sub_preload);
    if (b->sub_stats)
      free(b->sub_stats);
    if (!b->sub_auto)
      free(b);

    home->suh_blocks = NULL;

    if (suh_lock) {
      /* Unlock, or risk assert() or leak handles on Windows */
      _su_home_unlocker(suh_lock);
      _su_home_destroy_mutexes(suh_lock);
    }
  }
}
示例#11
0
PJ *PROJECTION(imw_p) {
    double del, sig, s, t, x1, x2, T2, y1, m1, m2, y2;
    int err;
    struct pj_opaque *Q = static_cast<struct pj_opaque*>(pj_calloc (1, sizeof (struct pj_opaque)));
    if (nullptr==Q)
        return pj_default_destructor (P, ENOMEM);
    P->opaque = Q;

    if (!(Q->en = pj_enfn(P->es))) return pj_default_destructor (P, ENOMEM);
    if( (err = phi12(P, &del, &sig)) != 0) {
        return destructor(P, err);
    }
    if (Q->phi_2 < Q->phi_1) { /* make sure P->phi_1 most southerly */
        del = Q->phi_1;
        Q->phi_1 = Q->phi_2;
        Q->phi_2 = del;
    }
    if (pj_param(P->ctx, P->params, "tlon_1").i)
        Q->lam_1 = pj_param(P->ctx, P->params, "rlon_1").f;
    else { /* use predefined based upon latitude */
        sig = fabs(sig * RAD_TO_DEG);
        if (sig <= 60)      sig = 2.;
        else if (sig <= 76) sig = 4.;
        else                sig = 8.;
        Q->lam_1 = sig * DEG_TO_RAD;
    }
    Q->mode = NONE_IS_ZERO;
    if (Q->phi_1 != 0.0)
        xy(P, Q->phi_1, &x1, &y1, &Q->sphi_1, &Q->R_1);
    else {
        Q->mode = PHI_1_IS_ZERO;
        y1 = 0.;
        x1 = Q->lam_1;
    }
    if (Q->phi_2 != 0.0)
        xy(P, Q->phi_2, &x2, &T2, &Q->sphi_2, &Q->R_2);
    else {
        Q->mode = PHI_2_IS_ZERO;
        T2 = 0.;
        x2 = Q->lam_1;
    }
    m1 = pj_mlfn(Q->phi_1, Q->sphi_1, cos(Q->phi_1), Q->en);
    m2 = pj_mlfn(Q->phi_2, Q->sphi_2, cos(Q->phi_2), Q->en);
    t = m2 - m1;
    s = x2 - x1;
    y2 = sqrt(t * t - s * s) + y1;
    Q->C2 = y2 - T2;
    t = 1. / t;
    Q->P = (m2 * y1 - m1 * y2) * t;
    Q->Q = (y2 - y1) * t;
    Q->Pp = (m2 * x1 - m1 * x2) * t;
    Q->Qp = (x2 - x1) * t;

    P->fwd = e_forward;
    P->inv = e_inverse;
    P->destructor = destructor;

    return P;
}
示例#12
0
文件: sub.c 项目: Distrotech/icmake
void fun_sub ()
{
    VAR_ rval = *copyCons(top());    /* make a copy              */
    pop();                          /* remove the r-operand     */

    subtract(top(), &rval);         /* subtract the rval to the top  */
    destructor(&rval);              /* remove the local var     */
}
示例#13
0
文件: PJ_laea.c 项目: ampimis/RtkGps
PJ *PROJECTION(laea) {
    double t;
    struct pj_opaque *Q = pj_calloc (1, sizeof (struct pj_opaque));
    if (0==Q)
        return pj_default_destructor (P, ENOMEM);
    P->opaque = Q;
    P->destructor = destructor;

    t = fabs(P->phi0);
    if (fabs(t - M_HALFPI) < EPS10)
        Q->mode = P->phi0 < 0. ? S_POLE : N_POLE;
    else if (fabs(t) < EPS10)
        Q->mode = EQUIT;
    else
        Q->mode = OBLIQ;
    if (P->es != 0.0) {
        double sinphi;

        P->e = sqrt(P->es);
        Q->qp = pj_qsfn(1., P->e, P->one_es);
        Q->mmf = .5 / (1. - P->es);
        Q->apa = pj_authset(P->es);
        if (0==Q->apa)
            return destructor(P, ENOMEM);
        switch (Q->mode) {
        case N_POLE:
        case S_POLE:
            Q->dd = 1.;
            break;
        case EQUIT:
            Q->dd = 1. / (Q->rq = sqrt(.5 * Q->qp));
            Q->xmf = 1.;
            Q->ymf = .5 * Q->qp;
            break;
        case OBLIQ:
            Q->rq = sqrt(.5 * Q->qp);
            sinphi = sin(P->phi0);
            Q->sinb1 = pj_qsfn(sinphi, P->e, P->one_es) / Q->qp;
            Q->cosb1 = sqrt(1. - Q->sinb1 * Q->sinb1);
            Q->dd = cos(P->phi0) / (sqrt(1. - P->es * sinphi * sinphi) *
               Q->rq * Q->cosb1);
            Q->ymf = (Q->xmf = Q->rq) / Q->dd;
            Q->xmf *= Q->dd;
            break;
        }
        P->inv = e_inverse;
        P->fwd = e_forward;
    } else {
        if (Q->mode == OBLIQ) {
            Q->sinb1 = sin(P->phi0);
            Q->cosb1 = cos(P->phi0);
        }
        P->inv = s_inverse;
        P->fwd = s_forward;
    }

    return P;
}
int main() {
    barcos = 0;

    embarcacion *embarcaciones = (embarcacion *) malloc(N * L * L * sizeof(embarcaciones));
    menu(embarcaciones);

    destructor(embarcaciones);
    return 0;
}
示例#15
0
void __attribute__ ((destructor)) default_impl_destroy(void){
#else
void __attribute__ ((destructor(1000))) default_impl_destroy(void){
#endif

    free_default_device_storage_path();
    free_default_device_info();

}
示例#16
0
SensorsList& SensorsList::operator=(const SensorsList& other)
{
    if(this != &other)
    {
        destructor();
        constructor(other);
    }
    return *this;
}
示例#17
0
void popElement( const char* name ){
	ASSERT_MESSAGE( string_equal( name, "entity" ), PARSE_ERROR );
	NodeSmartReference entity( m_entityTable.createEntity( GlobalEntityClassManager().findOrInsert( Node_getEntity( node() )->getKeyValue( "classname" ), node_is_group( node() ) ) ) );

	{
		EntityCopyingVisitor visitor( *Node_getEntity( entity ) );
		Node_getEntity( node() )->forEachKeyValue( visitor );
	}

	if ( Node_getTraversable( entity ) != 0 && !Node_getEntity( entity )->getEntityClass().fixedsize ) {
		parentBrushes( node(), entity );
	}

	Node_getTraversable( m_parent )->insert( entity );

	destructor( primitive() );
	destructor( node() );
}
示例#18
0
slab*
ObjectCache::InitSlab(slab* slab, void* pages, size_t byteCount, uint32 flags)
{
	TRACE_CACHE(this, "construct (%p, %p .. %p, %lu)", slab, pages,
		((uint8*)pages) + byteCount, byteCount);

	slab->pages = pages;
	slab->count = slab->size = byteCount / object_size;
	slab->free = NULL;

	size_t spareBytes = byteCount - (slab->size * object_size);

	if ((this->flags & CACHE_ALIGN_ON_SIZE) != 0) {
		slab->offset = cache_color_cycle;

		if (slab->offset > spareBytes)
			cache_color_cycle = slab->offset = 0;
		else
			cache_color_cycle += kCacheColorPeriod;
	} else
		slab->offset = 0;

	TRACE_CACHE(this, "  %lu objects, %lu spare bytes, offset %lu",
		slab->size, spareBytes, slab->offset);

	uint8* data = ((uint8*)pages) + slab->offset;

	CREATE_PARANOIA_CHECK_SET(slab, "slab");

	for (size_t i = 0; i < slab->size; i++) {
		status_t status = B_OK;
		if (constructor)
			status = constructor(cookie, data);

		if (status != B_OK) {
			data = ((uint8*)pages) + slab->offset;
			for (size_t j = 0; j < i; j++) {
				if (destructor)
					destructor(cookie, data);
				data += object_size;
			}

			DELETE_PARANOIA_CHECK_SET(slab);

			return NULL;
		}

		_push(slab->free, object_to_link(data, object_size));

		ADD_PARANOIA_CHECK(PARANOIA_SUSPICIOUS, slab,
			&object_to_link(data, object_size)->next, sizeof(void*));

		data += object_size;
	}

	return slab;
}
示例#19
0
/**
 * @brief Destroy a List Element
 * @param elt The element to destroy
 * @param destructor The Destructor Function to clean Element Item (can be NULL)
 */
static void wbxml_elt_destroy(WBXMLListElt *elt, WBXMLListEltCleaner *destructor)
{
    if (elt == NULL)
        return;

    if (destructor != NULL)
        destructor(elt->item);

    wbxml_free(elt);
}
示例#20
0
void 
_thread_cleanupspecific(void)
{
	struct pthread	*curthread = _get_curthread();
	const_key_destructor_t destructor;
	const void	*data = NULL;
	int		key;
	int		i;

	if (curthread->specific == NULL)
		return;

	/* Lock the key table: */
	THR_LOCK_ACQUIRE(curthread, &_keytable_lock);
	for (i = 0; (i < PTHREAD_DESTRUCTOR_ITERATIONS) &&
	    (curthread->specific_data_count > 0); i++) {
		for (key = 0; (key < PTHREAD_KEYS_MAX) &&
		    (curthread->specific_data_count > 0); key++) {
			destructor = NULL;

			if (_thread_keytable[key].allocated &&
			    (curthread->specific[key].data != NULL)) {
				if (curthread->specific[key].seqno ==
				    _thread_keytable[key].seqno) {
					data = curthread->specific[key].data;
					destructor = (const_key_destructor_t)
					    _thread_keytable[key].destructor;
				}
				curthread->specific[key].data = NULL;
				curthread->specific_data_count--;
			}

			/*
			 * If there is a destructore, call it
			 * with the key table entry unlocked:
			 */
			if (destructor != NULL) {
				/*
				 * Don't hold the lock while calling the
				 * destructor:
				 */
				THR_LOCK_RELEASE(curthread, &_keytable_lock);
				destructor(data);
				THR_LOCK_ACQUIRE(curthread, &_keytable_lock);
			}
		}
	}
	THR_LOCK_RELEASE(curthread, &_keytable_lock);
	free(curthread->specific);
	curthread->specific = NULL;
	if (curthread->specific_data_count > 0)
		stderr_debug("Thread %p has exited with leftover "
		    "thread-specific data after %d destructor iterations\n",
		    curthread, PTHREAD_DESTRUCTOR_ITERATIONS);
}
示例#21
0
void popElement( const char* name ){
	if ( string_equal( name, "epair" ) ) {
	}
	else
	{
		m_importer->popElement( name );

		destructor( subprimitive() );
		m_importer = 0;
	}
}
示例#22
0
SceneGraph::~SceneGraph()
{
    /* User destructor(s) */
    if( destructor ) {
        destructor(destructor_context);
    }

    /* Delete Frames */
    for( auto &pair : frame_map ) delete pair.second;

    /* Delete Limits */
    for( auto &pair : limits_map ) free(pair.second);
}
示例#23
0
void
pthread_exit(void *value_ptr) {
	struct __cleanup_handler				*handler;
	int										loop, again;
	volatile struct _thread_local_storage	*tls = LIBC_TLS();

	// Disable pthread_cancel and set cancel type to deferred
	atomic_set(&tls->__flags, PTHREAD_CANCEL_DISABLE);
	atomic_clr(&tls->__flags, PTHREAD_CANCEL_ASYNCHRONOUS); /* make defered */

	// call the cleanup handlers
	while((handler = tls->__cleanup)) {
		tls->__cleanup = handler->__next;
		handler->__routine(handler->__save);
	}

	// Call the thread_specific_data destructor functions
	for(loop = 0, again = 1; again && loop < PTHREAD_DESTRUCTOR_ITERATIONS; loop++) {
		int										i;
		int										num;

		again = 0;
		num = min(tls->__numkeys, _key_count);
		for(i = 0; i < num; i++) {
			void									*data;
			void									(*destructor)(void *);

			if((destructor = _key_destructor[i]) && (destructor != _KEY_NONE) && (data = tls->__keydata[i])) {
				// Setting the data to NULL was the intention of the POSIX
				// committe, but did not make it into the POSIX spec. Doing
				// this still keeps our implementation POSIX complient, but
				// allow non-POSIX complient applications to be more efficient.
				tls->__keydata[i] = 0;

				destructor(data);
				again = 1;
			}
		}
	}

	// Unlock hanging file mutexes before exiting
	_Unlockfilemtx();

	// Unlock hanging system mutexes before exiting
	_Unlocksysmtx();

	(void)ThreadDestroy_r(0, -1, value_ptr);
#ifdef __GNUC__
	for( ;; ) ; /* Get gcc to shut up about a noreturn function returning */
#endif
}
示例#24
0
文件: sf_list.c 项目: Sachs27/sf
void sf_list_destroy(struct sf_list *l, sf_list_destructor_t *destructor) {
    struct sf_list_node *node;

    while (l->nelts) {
        node = l->head->next;
        if (destructor) {
            destructor(node->elt);
        }
        remove_node(node);
        free(node);
        --l->nelts;
    }
    free(l);
}
示例#25
0
GLXOSD::~GLXOSD() {
	for_each(pluginDestructors->begin(), pluginDestructors->end(),
			[this](PluginDestructor destructor) {
				destructor(this);
			});
	delete configurationManager;
	for_each(pluginSharedObjectHandles->begin(),
			pluginSharedObjectHandles->end(), [](void* handle) {
				dlclose(handle);
			});
	delete pluginSharedObjectHandles;
	delete pluginDataProviders;
	delete drawableHandlers;
	glxosdInstance = nullptr;
}
示例#26
0
// Given the (data) address of an array, the number of elements, and the
// size of its elements, call the given destructor on each element. If the
// destructor throws an exception, call terminate(). The destructor pointer
// may be NULL, in which case this routine does nothing.
_LIBCXXABI_FUNC_VIS void __cxa_vec_cleanup(void *array_address,
                                           size_t element_count,
                                           size_t element_size,
                                           void (*destructor)(void *)) {
    if ( NULL != destructor ) {
        char *ptr = static_cast <char *> (array_address);
        size_t idx = element_count;
        st_terminate exception_guard;
        
        ptr += element_count * element_size;    // one past the last element
        while ( idx-- > 0 ) {
            ptr -= element_size;
            destructor ( ptr );
            }
        exception_guard.release ();     // We're done!
    }
}
示例#27
0
文件: list.c 项目: armic/erpts
void list_destroy(List *list, list_item_destructor_t *destructor)
{
    void *item;

    if (list == NULL)
        return;

    if (destructor != NULL) {
        while ((item = list_extract_first(list)) != NULL)
            destructor(item);
    }

    mutex_destroy(list->permanent_lock);
    mutex_destroy(list->single_operation_lock);
    pthread_cond_destroy(&list->nonempty);
    gw_free(list->tab);
    gw_free(list);
}
void DecorationRegistry::construct(DecorationContainer* decorable) const {
    auto iter = _decorationInfo.cbegin();
    try {
        for (; iter != _decorationInfo.cend(); ++iter) {
            iter->constructor(decorable->getDecoration(iter->descriptor));
        }
    } catch (...) {
        try {
            while (iter != _decorationInfo.cbegin()) {
                --iter;
                iter->destructor(decorable->getDecoration(iter->descriptor));
            }
        } catch (...) {
            std::terminate();
        }
        throw;
    }
}
示例#29
0
struct sk_buff *__skb_try_recv_from_queue(struct sock *sk,
					  struct sk_buff_head *queue,
					  unsigned int flags,
					  void (*destructor)(struct sock *sk,
							   struct sk_buff *skb),
					  int *peeked, int *off, int *err,
					  struct sk_buff **last)
{
	bool peek_at_off = false;
	struct sk_buff *skb;
	int _off = 0;

	if (unlikely(flags & MSG_PEEK && *off >= 0)) {
		peek_at_off = true;
		_off = *off;
	}

	*last = queue->prev;
	skb_queue_walk(queue, skb) {
		if (flags & MSG_PEEK) {
			if (peek_at_off && _off >= skb->len &&
			    (_off || skb->peeked)) {
				_off -= skb->len;
				continue;
			}
			if (!skb->len) {
				skb = skb_set_peeked(skb);
				if (unlikely(IS_ERR(skb))) {
					*err = PTR_ERR(skb);
					return NULL;
				}
			}
			*peeked = 1;
			refcount_inc(&skb->users);
		} else {
			__skb_unlink(skb, queue);
			if (destructor)
				destructor(sk, skb);
		}
		*off = _off;
		return skb;
	}
	return NULL;
}
示例#30
0
int main(int argc, char* argv[])
{

	assert(argc == REQUIRED_ARGUMENTS_NUMBER);
	//the std::vector which will hold the songs
	std::vector<Song*> songCollection;
	std::map<std::string, GradingCategory*> gradersCollection;
	std::ifstream processedFile;

	for(int i = 1; i < argc; i ++)
	{
		std::string filePath = argv[i];

		processedFile.open(filePath, std::ifstream::in);
		if(processedFile.is_open())
		{
			switch(i)
			{
				case (SONGS_FILE_ARGV_INDX): //songs data file
					SongParser::initillizer();
					songCollection = SongParser::parseSong(processedFile);
					break;
				case (LEARNED_PARAM_FILE_ARGV_INDX):
					ParametersParser::getInstance();
					gradersCollection = ParametersParser::_parseParameterFile(processedFile);
					break;
				case (QUERIES_FILE_ARGV_INDX):
					SongGrader::getSongGraderInstance();
					SongGrader::parseQueryFile(processedFile);
					SongGrader::runGrading(songCollection, gradersCollection);
					break;
			}
			processedFile.close();
		}
		else
		{
			fileLoadFailure();
			break;
		}
	}

	destructor(songCollection, gradersCollection);
	return 0;
}