/*! * \ingroup Reconstruct * \brief Free's the given section. * \param sec Section to free. */ void RecSecFree(RecSection *sec) { REC_DBG((REC_DBG_SEC|REC_DBG_LVL_FN|REC_DBG_LVL_1), ("RecSecFree FE 0x%lx\n", (unsigned long )sec)); if(sec) { REC_DBG((REC_DBG_SEC|REC_DBG_LVL_3), ("RecSecFree 01 %d\n", sec->linkcount)); if(--(sec->linkcount) <= 0) { if(sec->imageFile) { AlcFree(sec->imageFile); } if(sec->transform) { REC_DBG((REC_DBG_SEC|REC_DBG_LVL_3), ("RecSecFree 02 %d\n", sec->transform->linkcount)); (void )WlzFreeAffineTransform(sec->transform); } if(sec->obj) { REC_DBG((REC_DBG_SEC|REC_DBG_LVL_3), ("RecSecFree 03 %d\n", sec->obj->linkcount)); (void )WlzFreeObj(sec->obj); } if(sec->transObj) { REC_DBG((REC_DBG_SEC|REC_DBG_LVL_3), ("RecSecFree 04 %d\n", sec->transObj->linkcount)); (void )WlzFreeObj(sec->transObj); } if(sec->cumTransform) { REC_DBG((REC_DBG_SEC|REC_DBG_LVL_3), ("RecSecFree 05 %d\n", sec->cumTransform->linkcount)); (void )WlzFreeAffineTransform(sec->cumTransform); } if(sec->cumTransObj && (sec->cumTransObj->linkcount > 0)) { REC_DBG((REC_DBG_SEC|REC_DBG_LVL_3), ("RecSecFree 05 %d\n", sec->cumTransObj->linkcount)); (void )WlzFreeObj(sec->cumTransObj); } AlcFree(sec); } } REC_DBG((REC_DBG_SEC|REC_DBG_LVL_FN|REC_DBG_LVL_1), ("RecSecFree FX\n")); }
/*! * \return Woolz error code. * \ingroup WlzFeatures * \brief Computes any combination of the directed Hausdorff, mean * nearest neighbour, median nearest neighbour and minimum * nearest neighbour distances * between the vertices of the given geometric models. * See WlzDistMetricDirVertex2D() for details of the metrics. * \param model0 First geometric model. * \param model1 Second geometric model. * \param dstDistH Destination pointer for the directed * Hausdorff distance, may be NULL. * \param dstDistM Destination pointer for the directed * mean nearest neighbour distance, may * be NULL. * \param dstDistN Destination pointer for the directed * median nearest neighbour distance, may * be NULL. * \param dstDistI Destination pointer for the minimum * nearest neighbour distance, may * be NULL. */ WlzErrorNum WlzDistMetricDirGM(WlzGMModel *model0, WlzGMModel *model1, double *dstDistH, double *dstDistM, double *dstDistN, double *dstDistI) { int nV[2]; WlzVertexP vP[2]; WlzVertexType vType[2]; WlzErrorNum errNum = WLZ_ERR_NONE; vP[0].v = vP[1].v = NULL; if((model0 == NULL) || (model1 == NULL)) { errNum = WLZ_ERR_DOMAIN_NULL; } else if(model0->type != model1->type) { errNum = WLZ_ERR_DOMAIN_TYPE; } else { vP[0] = WlzVerticesFromGM(model0, NULL, NULL, nV + 0, vType + 0, &errNum); } if(errNum == WLZ_ERR_NONE) { vP[1] = WlzVerticesFromGM(model1, NULL, NULL, nV + 1, vType + 1, &errNum); } if(errNum == WLZ_ERR_NONE) { if(vType[0] != vType[1]) { errNum = WLZ_ERR_DOMAIN_TYPE; } } if(errNum == WLZ_ERR_NONE) { switch(vType[0]) { case WLZ_VERTEX_D2: errNum = WlzDistMetricDirVertex2D(nV[0], vP[0].d2, nV[1], vP[1].d2, dstDistH, dstDistM, dstDistN, dstDistI); break; case WLZ_VERTEX_D3: errNum = WlzDistMetricDirVertex3D(nV[0], vP[0].d3, nV[1], vP[1].d3, dstDistH, dstDistM, dstDistN, dstDistI); break; default: errNum = WLZ_ERR_DOMAIN_DATA; break; } } AlcFree(vP[0].v); AlcFree(vP[1].v); return(errNum); }
/*! * \return Error code. * \ingroup AlcArray * \brief Allocates a 3 dimensional array of pointers to void. * \note Should be free'd using Alc3Free(). * \note Array size is limited only by address space. * \param dest Destination for allocated array * pointer. * \param mElem Number of 2D arrays. * \param nElem Number of 1D arrays. * \param oElem Number of elements in each 1D * array. */ AlcErrno AlcPtr3Calloc(void *****dest, size_t mElem, size_t nElem, size_t oElem) { size_t index0, index1; void **dump0 = NULL, ***dump1 = NULL, ****dump2 = NULL; AlcErrno alcErrno = ALC_ER_NONE; if((dest) == NULL) { alcErrno = ALC_ER_NULLPTR; } else if((mElem < 1) || (nElem < 1) || (oElem < 1)) { alcErrno = ALC_ER_NUMELEM; } else if(((dump0 = (void **)AlcCalloc(mElem * nElem * oElem, sizeof(void *))) == NULL) || ((dump1 = (void ***)AlcMalloc(mElem * nElem * sizeof(void **))) == NULL) || ((dump2 = (void ****)AlcMalloc(mElem * sizeof(void ***))) == NULL)) { alcErrno = ALC_ER_ALLOC; } if(alcErrno == ALC_ER_NONE) { *(dest) = dump2; for(index0 = 0; index0 < mElem; ++index0) { for(index1=0; index1 < nElem; ++index1) { dump1[index1] = dump0; dump0 += oElem; } (*(dest))[index0] = dump1; dump1 += nElem; } } else { if(dest) { *(dest) = NULL; } AlcFree(dump2); AlcFree(dump1); AlcFree(dump0); } return(alcErrno); }
/*! * \return Woolz error code. * \ingroup WlzBoundary * \brief decomposes a boundary into it's component polygons. * \param bndObj Given boundary. * \param dstNumObjs Destination pointer for the number of polygons. * \param dstObjArray Destination pointer for the array of polygons. */ WlzErrorNum WlzBoundaryToPolyObjArray( WlzObject *bndObj, int *dstNumObjs, WlzObject ***dstObjArray) { WlzErrorNum errNum=WLZ_ERR_NONE; WlzDomain domain; WlzValues values; WlzObject *obj, **objs; WlzPolygonDomain **polyArray; int i, numPolys; /* check inputs */ if( bndObj == NULL ){ errNum = WLZ_ERR_OBJECT_NULL; } else if((dstNumObjs == NULL) || (dstObjArray == NULL)){ errNum = WLZ_ERR_PARAM_NULL; } else { /* generate array of poly domains */ errNum = WlzBoundObjToPolyDomArray(bndObj, &numPolys, &polyArray); } /* convert to polygon objects */ if( errNum == WLZ_ERR_NONE ){ if((objs = (WlzObject **) AlcMalloc(sizeof(WlzObject *)*numPolys)) == NULL){ errNum = WLZ_ERR_MEM_ALLOC; for(i=0; i < numPolys; i++){ WlzFreePolyDmn(polyArray[i]); } AlcFree(polyArray); numPolys = 0; } else { for(i=0; i < numPolys; i++){ domain.poly = polyArray[i]; values.core = NULL; obj = WlzMakeMain(WLZ_2D_POLYGON, domain, values, NULL, NULL, &errNum); objs[i] = WlzAssignObject(obj, NULL); WlzFreePolyDmn(polyArray[i]); } AlcFree(polyArray); } } *dstNumObjs = numPolys; *dstObjArray = objs; return errNum; }
void HGU_XmFileListItemFree( void *entry) { HGU_XmFileListCallbackStruct *cbs; if( entry ){ cbs = (HGU_XmFileListCallbackStruct *) entry; if( cbs->file ){ AlcFree(cbs->file); } AlcFree(cbs); } return; }
void HGU_XmFileListWriteHeader( FILE *fp) { BibFileRecord *bibfileRecord; time_t tmpTime; char *tmpS, tmpBuf[256]; char *dateS = NULL; char *hostS = NULL; char *userS = NULL; static char unknownS[] = "unknown"; /* write some sort of identifier */ bibfileRecord = BibFileRecordMake("Ident", "0", BibFileFieldMakeVa("Text", "HGU_Xm Image File List", "Version", "1.0", NULL)); BibFileRecordWrite(fp, NULL, bibfileRecord); BibFileRecordFree(&bibfileRecord); /* now a comment with user, machine, date etc. */ tmpS = getenv("USER"); (void )sprintf(tmpBuf, "User: %s", tmpS?tmpS:unknownS); userS = AlcStrDup(tmpBuf); tmpTime = time(NULL); tmpS = ctime(&tmpTime); *(tmpS + strlen(tmpS) - 1) = '\0'; (void )sprintf(tmpBuf, "Date: %s", tmpS?tmpS:unknownS); dateS = AlcStrDup(tmpBuf); tmpS = getenv("HOST"); (void )sprintf(tmpBuf, "Host: %s", tmpS?tmpS:unknownS); hostS = AlcStrDup(tmpBuf); bibfileRecord = BibFileRecordMake("Comment", "0", BibFileFieldMakeVa("Text", userS, "Text", dateS, "Text", hostS, NULL)); BibFileRecordWrite(fp, NULL, bibfileRecord); BibFileRecordFree(&bibfileRecord); AlcFree(userS); AlcFree(dateS); AlcFree(hostS); return; }
/*! * \return void * \ingroup WlzAccess * \brief Free's the given grey value work space created by * WlzGreyValueMakeWSp(). * \param gVWSp Given grey value work space. */ void WlzGreyValueFreeWSp(WlzGreyValueWSpace *gVWSp) { WLZ_DBG((WLZ_DBG_LVL_1), ("WlzGreyValueFreeWSp FE %p\n", gVWSp)); if(gVWSp) { (void )WlzFreeAffineTransform(gVWSp->invTrans); AlcFree((void *)(gVWSp->gTabTypes3D)); AlcFree(gVWSp); } WLZ_DBG((WLZ_DBG_LVL_FN|WLZ_DBG_LVL_1), ("WlzGreyValueFreeWSp FX\n")); }
/*! * \return <void> * \ingroup WlzExtFF * \brief Free's entries in the Amira file header data structure * before freeing the header data structure itself. * \param head The given file header data structure. */ static void WlzEffAmFreeHead(WlzEffAmHead *head) { WlzEffAmMaterial *e0; AlcFree(head->imageData); if(head) { e0 = head->materials; while(e0) { AlcFree(e0->name); e0 = e0->next; } } }
/*! * \return Error code. * \ingroup AlcArray * \brief Allocates a 2 dimensional non-zero'd array of pointers * to void. * \note Should be free'd using Alc2Free(). * \note Array size is limited only by address space. * \param dest Destination for allocated array * pointer. * \param mElem Number of 1D arrays. * \param nElem Number of elements in each 1D * array. */ AlcErrno AlcPtr2Malloc(void ****dest, size_t mElem, size_t nElem) { size_t index; void **dump0 = NULL; void ***dump1 = NULL; AlcErrno alcErrno = ALC_ER_NONE; /* Template doesn't work for pointer types. */ if(dest == NULL) { alcErrno = ALC_ER_NULLPTR; } else if((mElem < 1) || (nElem < 1)) { alcErrno = ALC_ER_NUMELEM; } else if(((dump0 = (void **)AlcMalloc(mElem * nElem * sizeof(void *))) == NULL) || ((dump1 = (void ***)AlcMalloc(mElem * sizeof(void **))) == NULL)) { alcErrno = ALC_ER_ALLOC; } if(alcErrno == ALC_ER_NONE) { *dest = dump1; for(index = 0; index < mElem; ++index) { (*dest)[index] = dump0; dump0 += nElem; } } else { if(dest) { *dest = NULL; } if(dump0) { AlcFree(dump0); } if(dump1) { AlcFree(dump1); } } return(alcErrno); }
/*! * \ingroup WlzAllocation * \brief Free's a WlzContour data structure. * * \return Error number, values: WLZ_ERR_NONE, WLZ_ERR_DOMAIN_NULL, WLZ_ERR_DOMAIN_TYPE and from WlzUnlink(). * \param ctr Contour to be freed. * \par Source: * WlzFreeSpace.c */ WlzErrorNum WlzFreeContour(WlzContour *ctr) { WlzErrorNum errNum = WLZ_ERR_NONE; if(ctr == NULL) { errNum = WLZ_ERR_DOMAIN_NULL; } else if(ctr->type != WLZ_CONTOUR) { errNum = WLZ_ERR_DOMAIN_TYPE; } else { if(WlzUnlink(&(ctr->linkcount), &errNum)) { if(ctr->model && WlzUnlink(&(ctr->model->linkcount), &errNum)) { (void )WlzGMModelFree(ctr->model); } AlcFree((void *)ctr); } } return(errNum); }
/*! * \ingroup WlzAllocation * \brief Free a values structure, currently only WlzRagRValues and WlzRectValues DO NOT call this function with any other values structure types! * * \return Error number, values: WLZ_ERR_NONE, WLZ_ERR_VALUES_DATA. * \param values Values union to be freed. * \par Source: * WlzFreeSpace.c */ WlzErrorNum WlzFreeValues(WlzValues values) { WlzErrorNum errNum = WLZ_ERR_NONE; /* check the object pointer and linkcount */ if (values.v == NULL){ return( WLZ_ERR_NONE ); } if( WlzUnlink(&(values.v->linkcount), &errNum) ){ /* if there is a freeptr then free it */ if (values.v->freeptr != NULL){ /* it is illegal for a table to point to itself */ if( values.v->original_table.v != NULL ){ return( WLZ_ERR_VALUES_DATA ); } (void )AlcFreeStackFree(values.v->freeptr); } if( values.v->original_table.v ){ errNum = WlzFreeValues( values.v->original_table ); } AlcFree((void *) values.v); } return( errNum ); }
/*! * \return void * \ingroup WlzValueFilters * \brief Free a recursive filter. * \param ftr Filter to free. */ void WlzRsvFilterFreeFilter(WlzRsvFilter *ftr) { if(ftr != NULL) { AlcFree(ftr); } }
/*! * \ingroup WlzAllocation * \brief Free a voxel value table * * \return Error number, values: WLZ_ERR_NONE, WLZ_ERR_VOXELVALUES_TYPE and from WlzFreeValues(). * \param voxtab * \par Source: * WlzFreeSpace.c */ WlzErrorNum WlzFreeVoxelValueTb(WlzVoxelValues *voxtab) { WlzValues *values; int nplanes; WlzErrorNum errNum = WLZ_ERR_NONE; /* check the object pointer and linkcount */ if (voxtab == NULL){ return( WLZ_ERR_NONE ); } /* check the type */ if( voxtab->type != WLZ_VOXELVALUETABLE_GREY ){ return WLZ_ERR_VOXELVALUES_TYPE; } if( WlzUnlink(&(voxtab->linkcount), &errNum) ){ nplanes = voxtab->lastpl - voxtab->plane1 + 1; values = voxtab->values; while( nplanes-- ){ errNum |= WlzFreeValues(*values); values++; } WlzFreeVoxelValueTb(voxtab->original_table.vox); AlcFreeStackFree(voxtab->freeptr); AlcFree((char *) voxtab); } return( errNum ); }
/*! * \return New registration section. * \ingroup Reconstruct * \brief Makes a registration section using the given member values. * \param index Section index. * \param iterations Number of iterations to find * section transform. * \param correlation Section correlation value. * \param imageFile Image file path, this is duplicated * so that the original may be freed * The image file path must not be NULL. * \param transform Section transform, if NULL an identity * transform is created. * \param obj Woolz object corresponding to the given * image file. This may be NULL without * causing the object to be read from the * associated file. */ RecSection *RecSecMake(int index, int iterations, double correlation, char *imageFile, WlzAffineTransform *transform, WlzObject *obj) { RecSection *sec = NULL; char *newImageFile = NULL; WlzAffineTransform *newTransform = NULL; WlzErrorNum wlzErr = WLZ_ERR_NONE; REC_DBG((REC_DBG_SEC|REC_DBG_LVL_FN|REC_DBG_LVL_1), ("RecSecMake FE %d %d %g 0x%lx 0x%lx 0x%lx\n", index, iterations, correlation, (unsigned long )imageFile, (unsigned long )transform, (unsigned long )obj)); if(imageFile) { newImageFile = AlcStrDup(imageFile); } if(newImageFile && (transform == NULL)) { newTransform = WlzAffineTransformFromPrimVal(WLZ_TRANSFORM_2D_AFFINE, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0, &wlzErr); } if(newImageFile && (newTransform || transform) && (wlzErr == WLZ_ERR_NONE)) { sec = (RecSection *)AlcMalloc(sizeof(RecSection)); } if(sec == NULL) { if(newImageFile) { AlcFree(newImageFile); } if(newTransform) { WlzFreeAffineTransform(newTransform); } } else { sec->linkcount = 0; sec->index = index; sec->iterations = iterations; sec->correl = correlation; sec->obj = WlzAssignObject(obj, NULL); sec->imageFile = newImageFile; sec->transform = WlzAssignAffineTransform(transform? transform: newTransform, NULL); sec->transObj = NULL; sec->cumTransform = NULL; sec->cumTransObj = NULL; } REC_DBG((REC_DBG_SEC|REC_DBG_LVL_FN|REC_DBG_LVL_1), ("RecSecMake FX 0x%lx\n", (unsigned long )sec)); return(sec); }
/************************************************************************ * Function: WlzJavaArray1DFree * Returns: void * Purpose: Free's a temporary native 1D array. * Global refs: - * Parameters: void *aDat: Array data structure. * int aSz: Array size. * int dSKey: Data structure identification. * jboolean isCpy: Copy flag for JNI functions. ************************************************************************/ void WlzJavaArray1DFree(void *aDat, int aSz, int dSKey, jboolean isCpy) { if(isCpy && aDat && (aSz > 0)) { AlcFree(aDat); } }
static int freechain(WlzLLink *l) { if (l != NULL) { freechain(l->l_link); AlcFree((char *) l); } return( 0 ); }
/*! * \return Integer array with values and coordinates from 3D object. * \ingroup WlzValueUtils * \brief Allocates a new array (4 ints per value: 0 = value, * 1 = x coordinate, 2 = y coordinate and 3 = z coordinate. * \param obj Given object which must be a valid * 3D domain object with integer values. * \param dstNAry Destination pointer for the number of * values, must not be NULL. * \param dstErr Destination error pointer, may be NULL. */ static int *WlzCompDispMakeValAry3D(WlzObject *obj, int *dstNAry, WlzErrorNum *dstErr) { int idO, idP, nAry; int *ary, *array = NULL; WlzObject *obj2D; WlzPlaneDomain *pDom; WlzErrorNum errNum = WLZ_ERR_NONE; if((nAry = WlzVolume(obj, &errNum)) <= 0) { errNum = WLZ_ERR_DOMAIN_DATA; } if(errNum == WLZ_ERR_NONE) { if((array = AlcMalloc(nAry * 4 * sizeof(int))) == NULL) { errNum = WLZ_ERR_MEM_ALLOC; } } if(errNum == WLZ_ERR_NONE) { ary = array; pDom = obj->domain.p; for(idP = pDom->plane1; (errNum == WLZ_ERR_NONE) && (idP <= pDom->lastpl); ++idP) { idO = idP - pDom->plane1; obj2D = WlzMakeMain(WLZ_2D_DOMAINOBJ, *(obj->domain.p->domains + idO), *(obj->values.vox->values + idO), NULL, NULL, &errNum); if(errNum == WLZ_ERR_NONE) { errNum = WlzCompDispSetAry(&ary, obj2D, idP, 3); WlzFreeObj(obj2D); } } } if(errNum != WLZ_ERR_NONE) { AlcFree(ary); ary = NULL; } else { *dstNAry = nAry; if(dstErr != NULL) { *dstErr = errNum; } } return(array); }
WlzErrorNum HGU_XmFileListDestroyMenuItems( MenuItem *items) { WlzErrorNum errNum=WLZ_ERR_NONE; int i; /* check inputs */ if( items == NULL ){ errNum = WLZ_ERR_PARAM_NULL; } else { for(i=0; items[i].name != NULL; i++){ AlcFree(items[i].name); } AlcFree(items); } return errNum; }
/*! * \return Duplicated section, NULL on error. * \ingroup Reconstruct * \brief Duplicates the given section. * \param sec Section to be duplicated. */ RecSection *RecSecDup(RecSection *sec) { RecSection *newSec = NULL; WlzErrorNum wlzErr = WLZ_ERR_NONE; REC_DBG((REC_DBG_SEC|REC_DBG_LVL_FN|REC_DBG_LVL_1), ("RecSecDup FE 0x%lx\n", (unsigned long )sec)); if(sec) { if(((newSec = (RecSection *)AlcCalloc(1, sizeof(RecSection))) != NULL) && sec->imageFile && ((newSec->imageFile = AlcStrDup(sec->imageFile)) != NULL) && sec->transform && ((newSec->transform = WlzAssignAffineTransform( WlzAffineTransformFromMatrix(sec->transform->type, sec->transform->mat, &wlzErr), NULL)) != NULL) && (wlzErr == WLZ_ERR_NONE)) { newSec->index = sec->index; newSec->iterations = sec->iterations; newSec->correl = sec->correl; } else { if(newSec) { if(newSec->imageFile) { AlcFree(newSec->imageFile); } AlcFree(newSec); newSec = NULL; } } } REC_DBG((REC_DBG_SEC|REC_DBG_LVL_FN|REC_DBG_LVL_1), ("RecSecDup FX 0x%lx\n", (unsigned long )newSec)); return(newSec); }
/*! * \ingroup WlzAllocation * \brief Free a 3D warp transform. * * \return Error number, values: WLZ_ERR_NONE and from WlzFreePlaneDomain(). * \param obj 3D warp transform object to be freed. * \par Source: * WlzFreeSpace.c */ WlzErrorNum WlzFree3DWarpTrans(Wlz3DWarpTrans *obj) { WlzErrorNum errNum = WLZ_ERR_NONE; if(obj == NULL) { errNum = WLZ_ERR_OBJECT_NULL; } else { if(obj->intptdoms) { (void )AlcFree(obj->intptdoms); } if(obj->pdom) { errNum = WlzFreePlaneDomain(obj->pdom); } (void )AlcFree(obj); } return(errNum); }
/*! * \return Woolz error code. * \ingroup WlzAllocation * \brief Frees an indexed valuetable. * \param ixv Given indexed valuetable. */ WlzErrorNum WlzFreeIndexedValues(WlzIndexedValues *ixv) { WlzErrorNum errNum = WLZ_ERR_NONE; if(ixv == NULL) { errNum = WLZ_ERR_VALUES_NULL; } else if(ixv->type != WLZ_INDEXED_VALUES) { errNum = WLZ_ERR_VALUES_TYPE; } else { (void )AlcVectorFree(ixv->values); if(ixv->rank > 0) { AlcFree(ixv->dim); } AlcFree(ixv); } return(errNum); }
/*! * \return New affine transform initialized to the identity transform. * \ingroup WlzTransform * \brief Allocates and initialises space for a 2D or 3D affine * transform. Sufficient space is always allocated for a * 3D transform. * The transform should be freed using WlzFreeAffineTransform(). * \param type Transform type. * \param dstErr Destination error pointer, may * be null. */ WlzAffineTransform *WlzMakeAffineTransform(WlzTransformType type, WlzErrorNum *dstErr) { WlzAffineTransform *trans=NULL; WlzErrorNum errNum = WLZ_ERR_NONE; switch(type) { case WLZ_TRANSFORM_2D_AFFINE: case WLZ_TRANSFORM_2D_REG: case WLZ_TRANSFORM_2D_TRANS: case WLZ_TRANSFORM_2D_NOSHEAR: case WLZ_TRANSFORM_3D_AFFINE: case WLZ_TRANSFORM_3D_REG: case WLZ_TRANSFORM_3D_TRANS: case WLZ_TRANSFORM_3D_NOSHEAR: break; default: errNum = WLZ_ERR_TRANSFORM_TYPE; break; } if(errNum == WLZ_ERR_NONE) { if(((trans = (WlzAffineTransform *) AlcCalloc(1, sizeof(WlzAffineTransform))) == NULL) || (AlcDouble2Calloc(&trans->mat, 4, 4) != ALC_ER_NONE)) { if(trans) { AlcFree(trans); trans = NULL; } errNum = WLZ_ERR_MEM_ALLOC; } } if(errNum == WLZ_ERR_NONE) { trans->type = type; /* Initialize to the identity transform */ trans->mat[0][0] = 1.0; trans->mat[1][1] = 1.0; trans->mat[2][2] = 1.0; trans->mat[3][3] = 1.0; } if(dstErr) { *dstErr = errNum; } return(trans); }
/*! * \return Error code. * \ingroup AlcKDTree * \brief Free's the given KD-tree data structure and any nodes * in the tree. * \param tree The KD-tree data structure. */ AlcErrno AlcKDTTreeFree(AlcKDTTree *tree) { AlcErrno errNum = ALC_ER_NONE; if(tree) { if(tree->freeStack) { errNum = AlcBlockStackFree(tree->freeStack); } AlcFree(tree); } return(errNum); }
/*! * \return Woolz error code. * \ingroup WlzAllocation * \brief Frees a points valuetable. * \param pv Given points valuetable. */ WlzErrorNum WlzFreePointValues(WlzPointValues *pv) { WlzErrorNum errNum = WLZ_ERR_NONE; if(pv == NULL) { errNum = WLZ_ERR_VALUES_NULL; } else if(pv->type != WLZ_POINT_VALUES) { errNum = WLZ_ERR_VALUES_TYPE; } else { (void )AlcFree(pv->values.v); if(pv->rank > 0) { AlcFree(pv->dim); } AlcFree(pv); } return(errNum); }
/*! * \ingroup WlzAllocation * \brief Free a polygon domain. * * \return Error number, values: WLZ_ERR_NONE and from WlzUnlink(). * \param poly Polygon domain to be freed. * \par Source: * WlzFreeSpace.c */ WlzErrorNum WlzFreePolyDmn(WlzPolygonDomain *poly) { WlzErrorNum errNum=WLZ_ERR_NONE; /* check the object pointer and linkcount */ if (poly == NULL){ return( WLZ_ERR_NONE ); } if( WlzUnlink(&(poly->linkcount), &errNum) ){ AlcFree((void *) poly); } return errNum; }
/*! * \return Woolz error code. * \ingroup WlzTransform * \brief Frees an affine transform allocated by * WlzMakeAffineTransform(). * \param trans Affine transform to free. */ WlzErrorNum WlzFreeAffineTransform(WlzAffineTransform *trans) { WlzErrorNum errNum = WLZ_ERR_NONE; if(trans && WlzUnlink(&(trans->linkcount), &errNum)) { /* Free the matrix - assumes allocated by AlcDouble2Alloc then the structure */ if(trans->mat) { AlcDouble2Free(trans->mat); } AlcFree(trans); } return(errNum); }
void freeDomainListItem( void *item) { DomainListItem *dmnItem = (DomainListItem *) item; if( dmnItem->obj ){ WlzFreeObj(dmnItem->obj); } if( dmnItem->currBound ){ WlzFreeObj(dmnItem->currBound); } XmStringFree(dmnItem->listStr); free(dmnItem->file); AlcFree(item); return; }
/*! * \return zero * \ingroup AlgDPSearch * \brief * \param imax number of points on the path * \param jmax number of locations per path point * \param optimal_cost return for optimal path cost through each point * \param optimal_path return for optimal path through each point. * \param non_local_cost non-local cost function calculated in terms */ int AlgDPTotalCosts( int imax, int jmax, double **optimal_cost, int **optimal_path, double (*non_local_cost)(int, int, int, int **)) { int i, j, jp; double cost, min_cost, *tmp; /* now determine the total optimal-costs for each point */ tmp = (double *) AlcMalloc(sizeof(double) * jmax); for(i=imax-1; i > 0; i--) { for(j=0; j < jmax; j++) { cost = optimal_cost[i][0] - optimal_cost[i-1][optimal_path[i][0]] + (*non_local_cost)(i,0,j,optimal_path) - (*non_local_cost)(i,0,optimal_path[i][0], optimal_path); min_cost = cost; for(jp=1; jp < jmax; jp++) { cost = optimal_cost[i][jp] - optimal_cost[i-1][optimal_path[i][jp]] + (*non_local_cost)(i,jp,j,optimal_path) - (*non_local_cost)(i,jp, optimal_path[i][jp], optimal_path); if( cost < min_cost ) { min_cost = cost; } } tmp[j] = min_cost; } for(j=0; j < jmax; j++) { optimal_cost[i-1][j] += tmp[j]; } } AlcFree( tmp ); return( 0 ); }
/*! * \ingroup WlzAllocation * \brief Recursively free a boundary list. * * \return Error number, values: WLZ_ERR_NONE and from WlzUnlink(). * \param b Boundary list structure to be freed (note this will call WlzFreeBoundList recursively). * \par Source: * WlzFreeSpace.c */ WlzErrorNum WlzFreeBoundList(WlzBoundList *b) { WlzErrorNum errNum = WLZ_ERR_NONE; /* check the object pointer and linkcount */ if (b == NULL){ return( WLZ_ERR_NONE ); } if( WlzUnlink(&(b->linkcount), &errNum) ){ errNum |= WlzFreePolyDmn(b->poly); errNum |= WlzFreeBoundList(b->next); errNum |= WlzFreeBoundList(b->down); AlcFree((void *) b); } return( errNum ); }
WlzErrorNum HGU_XmFileListResetMenu( AlcDLPList *fileList, Widget cascade, XtCallbackProc callbackProc) { WlzErrorNum errNum=WLZ_ERR_NONE; Widget menu=NULL, widget; MenuItem *items; HGU_XmFileListCallbackStruct *cbs; int i; char *strbuf; if( cascade ){ XtVaGetValues(cascade, XmNsubMenuId, &menu, NULL); if( menu ){ XtDestroyWidget(menu); } items = HGU_XmFileListCreateMenuItems(fileList, callbackProc, NULL); menu = HGU_XmBuildPulldownMenu(cascade, XmTEAR_OFF_DISABLED, False, False, items); /* add tool-tips */ for(i=0; items[i].name != NULL; i++){ if( (cbs = (HGU_XmFileListCallbackStruct *) items[i].callback_data) ){ if(strcmp(items[i].name, "separator") && strcmp(items[i].name, "Clear list")){ strbuf = AlcMalloc(sizeof(char)*(strlen(cbs->file)+4)); sprintf(strbuf, "*%s", cbs->file); if((widget = XtNameToWidget(menu, strbuf))){ HGU_XmAddToolTip(HGU_XmGetTopShell(cascade), widget, cbs->file); } AlcFree(strbuf); } } } HGU_XmFileListDestroyMenuItems(items); } return errNum; }