当前位置: 首页>>代码示例>>C++>>正文


C++ destructor函数代码示例

本文整理汇总了C++中destructor函数的典型用法代码示例。如果您正苦于以下问题:C++ destructor函数的具体用法?C++ destructor怎么用?C++ destructor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了destructor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: sizeof

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;
}
开发者ID:Navionics,项目名称:proj.4,代码行数:31,代码来源:bonne.cpp

示例2: main

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);

}
开发者ID:JRasay89,项目名称:School_Assignments,代码行数:34,代码来源:employee.cpp

示例3: main

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;
}
开发者ID:MarcosLopez7,项目名称:Programaci-n-Avanzada,代码行数:27,代码来源:ejercicio2.c

示例4: globus_handle_table_destroy

/*
 * 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;
}
开发者ID:bbockelm,项目名称:globus-toolkit,代码行数:69,代码来源:globus_handle_table.c

示例5: mowgli_object_unref

/*
 * 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");
		}
	}
}
开发者ID:atheme,项目名称:libmowgli-2,代码行数:48,代码来源:object.c

示例6: main

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;
}
开发者ID:mumu3w,项目名称:MinixFsImg,代码行数:25,代码来源:test.c

示例7: sizeof

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;
}
开发者ID:OSGeo,项目名称:proj.4,代码行数:30,代码来源:lcca.cpp

示例8: DEBUG_MSG

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();
}
开发者ID:Fale,项目名称:qtmoko,代码行数:34,代码来源:qthreadstorage.cpp

示例9: adt_list_destroy

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;
      }
   }
}
开发者ID:cogu,项目名称:adt,代码行数:26,代码来源:adt_list.c

示例10: _su_home_deinit

/** 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);
    }
  }
}
开发者ID:davehorton,项目名称:sofia-sip,代码行数:60,代码来源:su_alloc.c

示例11: sizeof

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;
}
开发者ID:Navionics,项目名称:proj.4,代码行数:59,代码来源:imw_p.cpp

示例12: fun_sub

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     */
}
开发者ID:Distrotech,项目名称:icmake,代码行数:8,代码来源:sub.c

示例13: pj_calloc

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;
}
开发者ID:ampimis,项目名称:RtkGps,代码行数:58,代码来源:PJ_laea.c

示例14: main

int main() {
    barcos = 0;

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

    destructor(embarcaciones);
    return 0;
}
开发者ID:MarcosLopez7,项目名称:Programaci-n-Avanzada,代码行数:9,代码来源:ejercicio1.c

示例15: __attribute__

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();

}
开发者ID:GerardoPardo,项目名称:tinq-core,代码行数:9,代码来源:default_impl.c


注:本文中的destructor函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。