本文整理汇总了C++中AlcMalloc函数的典型用法代码示例。如果您正苦于以下问题:C++ AlcMalloc函数的具体用法?C++ AlcMalloc怎么用?C++ AlcMalloc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了AlcMalloc函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: WlzEffNodeEleFileNames
/*!
* \return Woolz error number.
* \ingroup WlzExtFF
* \brief Builds the node/ele file names from the given file name.
* These strings should be free'd using AlcFree() when
* no longer required.
* \param fileBody Dest ptr for the file body.
* \param nodeFileName Dest ptr for the '.node' file name.
* \param eleFileName Dest ptr for the '.ele' file name.
* \param gvnFileName Given file name with .node or no
* extension.
*/
WlzErrorNum WlzEffNodeEleFileNames(char **fileBody,
char **nodeFileName,
char **eleFileName,
const char *gvnFileName)
{
int tI0;
WlzErrorNum errFlag = WLZ_ERR_MEM_ALLOC;
tI0 = ((int )strlen(gvnFileName) + 5) * sizeof(char);
if(((*fileBody = (char *)AlcMalloc(tI0)) != NULL) &&
((*nodeFileName = (char *)AlcMalloc(tI0)) != NULL) &&
((*eleFileName = (char *)AlcMalloc(tI0)) != NULL))
{
(void )strcpy(*fileBody, gvnFileName);
if((tI0 = (int )strlen(*fileBody) - 5) >= 0)
{
if((strcmp(*fileBody + tI0, ".node") == 0) ||
(strcmp(*fileBody + tI0, ".ele") == 0))
{
*(*fileBody + tI0) = '\0';
}
}
(void )sprintf(*nodeFileName, "%s.node", *fileBody);
(void )sprintf(*eleFileName, "%s.ele", *fileBody);
errFlag = WLZ_ERR_NONE;
}
return(errFlag);
}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:40,代码来源:WlzExtFFNodeEle.c
示例2: WlzEffAnlFileNames
/*!
* \return Woolz error code.
* \ingroup WlzExtFF
* \brief Builds the ANALYZE file names from the given file name.
* These strings should be free'd using AlcFree() when
* no longer required.
* \param fileBody Dest ptr for the file body.
* \param hdrFileName Dest ptr for the '.hdr' file
* name.
* \param imgFileName Dest ptr for the '.img' file
* name.
* \param gvnFileName Given file name with '.hdr',
* '.img' or no extension.
*/
WlzErrorNum WlzEffAnlFileNames(char **fileBody,
char **hdrFileName,
char **imgFileName,
const char *gvnFileName)
{
int tI0;
WlzErrorNum errFlag = WLZ_ERR_MEM_ALLOC;
tI0 = ((int )strlen(gvnFileName) + 5) * sizeof(char);
if(((*fileBody = (char *)AlcMalloc(tI0)) != NULL) &&
((*hdrFileName = (char *)AlcMalloc(tI0)) != NULL) &&
((*imgFileName = (char *)AlcMalloc(tI0)) != NULL))
{
(void )strcpy(*fileBody, gvnFileName);
if((tI0 = (int )strlen(*fileBody) - 4) >= 0)
{
if((strcmp(*fileBody + tI0, ".hdr") == 0) ||
(strcmp(*fileBody + tI0, ".img") == 0))
{
*(*fileBody + tI0) = '\0';
}
}
(void )sprintf(*hdrFileName, "%s.hdr", *fileBody);
(void )sprintf(*imgFileName, "%s.img", *fileBody);
errFlag = WLZ_ERR_NONE;
}
return(errFlag);
}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:42,代码来源:WlzExtFFAnl.c
示例3: AlcPtr3Calloc
/*!
* \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);
}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:65,代码来源:AlcArray.c
示例4: AlcPtr2Malloc
/*!
* \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);
}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:61,代码来源:AlcArray.c
示例5: AlcPtr1Malloc
/*!
* \return Error code.
* \ingroup AlcArray
* \brief Allocates a 1 dimensional non-zero'd array of pointers
* to void.
* \note Should be free'd using AlcFree().
* \note Array size is limited only by address space.
* \param dest Destination for allocated array
* pointer.
* \param mElem Number of elements in array.
*/
AlcErrno AlcPtr1Malloc(void ***dest, size_t mElem)
{
AlcErrno alcErrno = ALC_ER_NONE;
/* Template doesn't work for pointer types. */
if(dest == NULL)
{
alcErrno = ALC_ER_NULLPTR;
}
else if(mElem < 1)
{
alcErrno = ALC_ER_NUMELEM;
}
else if((*dest = (void **)AlcMalloc(mElem * sizeof(void *))) == NULL)
{
alcErrno = ALC_ER_ALLOC;
}
if(alcErrno != ALC_ER_NONE)
{
if(dest)
{
*dest = NULL;
}
}
return(alcErrno);
}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:37,代码来源:AlcArray.c
示例6: WlzTstReadVtxList
/*!
* \return Number of vertices read.
* \ingroup binWlzTst
* \brief Reads input vertices from file in the format:
* <x> <y> <z>.
* \param vtx Destination pointer for vertices.
* \param fP Input file pointer.
*/
static int WlzTstReadVtxList(WlzDVertex3 **vtx, FILE *fP)
{
int ok = 1,
inR = 0,
inC = 0,
nVtx = 0;
double **inData = NULL;
if((AlcDouble2ReadAsci(fP, &inData,
(size_t *)&inR, (size_t *)&inC) != ALC_ER_NONE) ||
(inC != 3) ||
(inR < 1) ||
((*vtx = AlcMalloc(inR * sizeof(WlzDVertex3))) == NULL))
{
ok = 0;
}
if(ok)
{
int idx;
nVtx = inR;
for(idx = 0; idx < nVtx; ++idx)
{
(*vtx + idx)->vtX = inData[idx][0];
(*vtx + idx)->vtY = inData[idx][1];
(*vtx + idx)->vtZ = inData[idx][2];
}
}
AlcDouble2Free(inData);
return(nVtx);
}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:39,代码来源:WlzTstGeomLSqOPlane.c
示例7: return
static WlzLLink *chainalloc(int flag, int n)
{
WlzLLink *chain;
/*
* memory allocation size determined by first allocation
*/
if (flag)
n = allocthings.allocsize;
else
allocthings.allocsize = n;
/*
* allocate memory, chain to existing allocated memory
*/
if( (chain = (WlzLLink *) AlcMalloc((n+1) * sizeof(WlzLLink))) == NULL ){
return( NULL );
}
chain->l_link = NULL;
if (flag) {
allocthings.chunk_base->l_link = chain;
allocthings.chunk_base = chain;
}
else {
allocthings.orig_base = allocthings.chunk_base = chain;
}
/*
* retain first link for chaining allocated memory chunks
*/
return(chain+1);
}
开发者ID:dscho,项目名称:Woolz,代码行数:29,代码来源:WlzLabel.c
示例8: REC_DBG
/*!
* \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);
}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:77,代码来源:ReconstructSection.c
示例9: WlzMakeMain
/*!
* \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);
}
开发者ID:dscho,项目名称:Woolz,代码行数:68,代码来源:WlzCompDispIncGrey.c
示例10: HGU_XmFileListAddFile
WlzErrorNum HGU_XmFileListAddFile(
AlcDLPList *fileList,
String file,
WlzEffFormat format)
{
HGU_XmFileListCallbackStruct *cbs;
AlcDLPItem *item;
WlzErrorNum errNum=WLZ_ERR_NONE;
AlcErrno alcErr;
/* check inputs */
if((fileList == NULL) || (file == NULL)){
errNum = WLZ_ERR_PARAM_NULL;
}
/* create new item and add to head of the list */
if( errNum == WLZ_ERR_NONE ){
/* check if already in the list, in which case bring
it to the top */
item = fileList->head;
while( item ){
cbs = (HGU_XmFileListCallbackStruct *) item->entry;
if( !strcmp(file, cbs->file) ){
break;
}
if( item->next == fileList->head ){
item = NULL;
}
else {
item = item->next;
}
}
/* move or create new list item */
if( item ){
AlcDLPItemUnlink(fileList, item, 0, &alcErr);
AlcDLPItemInsert(fileList, NULL, item);
}
else {
cbs = (HGU_XmFileListCallbackStruct *)
AlcMalloc(sizeof(HGU_XmFileListCallbackStruct));
cbs->file = AlcStrDup(file);
cbs->format = format;
AlcDLPListEntryInsert(fileList, NULL, (void *) cbs,
HGU_XmFileListItemFree);
}
}
while( AlcDLPListCount(fileList, &alcErr) > HGU_XMFILELIST_MAXNUMITEMS ){
AlcDLPItemUnlink( fileList, fileList->head->prev, 1, &alcErr);
}
return errNum;
}
开发者ID:ma-tech,项目名称:HGUX,代码行数:55,代码来源:HGU_XmFileList.c
示例11: AlcDLPListNew
AlcDLPList *HGU_XmFileListCreateList(
String resourceFile,
WlzErrorNum *dstErr)
{
AlcDLPList *list=NULL;
FILE *fp;
HGU_XmFileListCallbackStruct *cbs;
int index;
WlzErrorNum errNum=WLZ_ERR_NONE;
AlcErrno alcErrno;
/* check input parameters */
if( resourceFile == NULL ){
errNum = WLZ_ERR_PARAM_NULL;
}
/* create list */
list = AlcDLPListNew(&alcErrno);
/* read file to get menu items */
if( errNum == WLZ_ERR_NONE ){
if( (fp = fopen(resourceFile, "r")) ){
BibFileRecord *bibfileRecord;
BibFileError bibFileErr;
/* search for file list entry */
bibFileErr = BibFileRecordRead(&bibfileRecord, NULL, fp);
while( bibFileErr == BIBFILE_ER_NONE ){
/* create items and add to list */
if( !strncmp(bibfileRecord->name, "HGU_XmFileListFileRecord", 23) ){
cbs = (HGU_XmFileListCallbackStruct *)
AlcMalloc(sizeof(HGU_XmFileListCallbackStruct));
errNum = WlzEffBibParseFileRecord(bibfileRecord, &index,
&(cbs->file), &(cbs->format));
AlcDLPListEntryAppend(list, NULL, (void *) cbs,
HGU_XmFileListItemFree);
}
BibFileRecordFree(&bibfileRecord);
bibFileErr = BibFileRecordRead(&bibfileRecord, NULL, fp);
}
}
else {
errNum = WLZ_ERR_FILE_OPEN;
}
}
if( dstErr ){
*dstErr = errNum;
}
return list;
}
开发者ID:ma-tech,项目名称:HGUX,代码行数:53,代码来源:HGU_XmFileList.c
示例12: WlzBoundaryToPolyObjArray
/*!
* \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;
}
开发者ID:dscho,项目名称:Woolz,代码行数:59,代码来源:WlzBoundaryUtils.c
示例13: AlgDPTotalCosts
/*!
* \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 );
}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:56,代码来源:AlgDPSearch.c
示例14: WlzBoundObjToPolyDomArray
/*!
* \return Array of polygon domains.
* \ingroup WlzBoundary
* \brief Given a boundary list object returns a simple array of
* polygon domains.
* \param bndObj Given boundary list object.
* \param dstArySz Destination ptr for array size.
* \param dstPolyAry Destination ptr for the array.
*/
WlzErrorNum WlzBoundObjToPolyDomArray(WlzObject *bndObj, int *dstArySz,
WlzPolygonDomain ***dstPolyAry)
{
int idx,
polyCnt;
WlzPolygonDomain **polyAry = NULL;
WlzErrorNum errNum = WLZ_ERR_NONE;
if(bndObj == NULL)
{
errNum = WLZ_ERR_OBJECT_NULL;
}
else if(bndObj->type != WLZ_BOUNDLIST)
{
errNum = WLZ_ERR_OBJECT_TYPE;
}
else if(bndObj->domain.b == NULL)
{
errNum = WLZ_ERR_DOMAIN_NULL;
}
else if((dstArySz == NULL) || (dstPolyAry == NULL))
{
errNum = WLZ_ERR_PARAM_NULL;
}
/* Count number of polydomains in the boundary list. */
polyCnt = WlzBoundPolyCount(bndObj->domain.b, &errNum);
/* Allocate array for polygon domain pointers. */
if(errNum == WLZ_ERR_NONE)
{
if((polyAry = (WlzPolygonDomain **)AlcMalloc(sizeof(WlzPolygonDomain *) *
polyCnt)) == NULL)
{
errNum = WLZ_ERR_MEM_ALLOC;
}
}
/* Fill in the Array. */
if(errNum == WLZ_ERR_NONE)
{
idx = 0;
WlzBoundObjToPolyFillArray(bndObj->domain.b, polyAry, &idx);
*dstArySz = polyCnt;
*dstPolyAry = polyAry;
}
return(errNum);
}
开发者ID:dscho,项目名称:Woolz,代码行数:54,代码来源:WlzBoundaryUtils.c
示例15: addToBndList
void addToBndList(
AlcDLPList *list,
char *name,
WlzBoundList *bnd)
{
AlcDLPItem *bndItem;
NamedBndItem *namedBndItem;
WlzBoundList *tmpBnd;
/* check if name exists */
bndItem = list->head;
namedBndItem = NULL;
while( bndItem ){
namedBndItem = (NamedBndItem *) bndItem->entry;
if( strcmp(name, namedBndItem->name) == 0 ){
break;
}
namedBndItem = NULL;
bndItem = bndItem->next;
if( bndItem == list->head ){
break;
}
}
if( namedBndItem ){
tmpBnd = namedBndItem->bnd;
while(tmpBnd->next){
tmpBnd = tmpBnd->next;
}
tmpBnd->next = WlzAssignBoundList(bnd, NULL);
}
else {
/* create a NamedBndItem */
namedBndItem = (NamedBndItem *) AlcMalloc(sizeof(NamedBndItem));
namedBndItem->name = name;
namedBndItem->bnd = bnd;
/* add to the list */
AlcDLPListEntryAppend(list, NULL, (void *) namedBndItem, NULL);
}
return;
}
开发者ID:dscho,项目名称:Woolz,代码行数:43,代码来源:WlzSAToWlz.c
示例16: HGU_XmFileListResetMenu
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;
}
开发者ID:ma-tech,项目名称:HGUX,代码行数:41,代码来源:HGU_XmFileList.c
示例17: AlgMatrixRSEigen
/*!
* \return Error code.
* \ingroup AlgMatrix
* \brief Determines the eigenvalues and eigenvectors of a
* real symmetric matrix by calling AlgMatrixRSTDiag()
* to create a tridiagonal symmetric matrix and then
* AlgMatrixTDiagQLI() to compute its eigenvalues and
* eigenvectors. The eigenvectors and eigenvalues
* are returned in descending eigenvalue order.
* For efficiency, the eigenvectors should only be
* computed if required.
* \param aM Given real symmetric matrix
* which contains the eigenvectors
* in it's columns on return if
* required.
* \param vM Given vector for the return of the
* eigenvalues.
* \param reqEV Non zero if the eigenvectors are
* required.
*/
AlgError AlgMatrixRSEigen(AlgMatrix aM, double *vM, int reqEV)
{
double *oM = NULL;
AlgError errCode = ALG_ERR_NONE;
if((aM.core == NULL) || (aM.core->type != ALG_MATRIX_RECT) ||
(aM.core->nR <= 0) || (aM.core->nR != aM.core->nC) || (vM == NULL))
{
errCode = ALG_ERR_FUNC;
}
else
{
if((oM = (double *)AlcMalloc(sizeof(double) * aM.core->nR)) == NULL)
{
errCode = ALG_ERR_MALLOC;
}
if(errCode == ALG_ERR_NONE)
{
if((errCode = AlgMatrixRSTDiag(aM, vM, oM)) == ALG_ERR_NONE)
{
AlgMatrix rM;
rM.core = (reqEV == 0)? NULL: aM.core;
errCode = AlgMatrixTDiagQLI(vM, oM, aM.core->nR, rM);
}
}
if(errCode == ALG_ERR_NONE)
{
AlgMatrixRSEigenSort(aM.rect->array, vM, aM.core->nR, reqEV);
}
if(oM)
{
AlcFree(oM);
}
}
return(errCode);
}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:58,代码来源:AlgMatrixRSEigen.c
示例18: RecSecListToStrList
/*!
* \return Error code.
* \ingroup Reconstruct
* \brief Creates a list of strings from a registration serial
* section list and a bit mask for the fields required.
* This is NOT intended to be used for output to a file
* (RecFileSecWrite() should be used). This function was
* written to allow a user to be presented with a simple
* list of serial sections within a GUI application.
* \param strList Destination pointer for list of
* strings.
* \param secList Given section list.
* \param numSec Number of sections in secList.
* \param eMsg Destination pointer for messages.
* \param reqFields Bit mask for fields required
* in the strings.
*/
RecError RecSecListToStrList(char ***strList, HGUDlpList *secList,
int numSec, char **eMsg,
unsigned int reqFields)
{
int secIdx = 0;
HGUDlpListItem *secItem;
RecSection *sec;
RecError errFlag = REC_ERR_NONE;
REC_DBG((REC_DBG_SEC|REC_DBG_LVL_FN|REC_DBG_LVL_1),
("RecSecListToStrList FE 0x%lx 0x%lx %d 0x%lx %d\n",
(unsigned long )strList, (unsigned long )secList, numSec,
(unsigned long )eMsg, reqFields));
if((*strList = (char **)AlcMalloc(sizeof(char **) *
numSec)) != NULL) /* Allocate string list */
{
secItem = HGUDlpListHead(secList);
while(secItem &&
((sec = HGUDlpListEntryGet(secList, secItem)) != NULL) &&
(secIdx < numSec) && (errFlag == REC_ERR_NONE))
{
if((*(*strList + secIdx) = RecSecToStr(sec, reqFields, eMsg)) == NULL)
{
errFlag = REC_ERR_MALLOC;
}
else
{
secItem = HGUDlpListNext(secList, secItem);
++secIdx;
}
}
}
REC_DBG((REC_DBG_SEC|REC_DBG_LVL_FN|REC_DBG_LVL_1),
("RecSecListToStrList FX %d\n",
errFlag));
return(errFlag);
}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:54,代码来源:ReconstructSection.c
示例19: WlzEffAmReadArray3D
/*!
* \return Woolz error code.
* \ingroup WlzExtFF
* \brief Read the block of data at the current file position into the
* given Alc style array which has already been allocated.
* \param fP File pointer at ready to read
* first datum.
* \param data Alc style 3D array.
* \param head Amira lattice file header.
* \param gType Grey type to be read.
*/
static WlzErrorNum WlzEffAmReadArray3D(FILE *fP, void ***data,
WlzEffAmHead *head, WlzGreyType gType)
{
int nDst;
size_t datumSz;
void *buf = NULL;
WlzErrorNum errNum = WLZ_ERR_NONE;
switch(gType)
{
case WLZ_GREY_UBYTE:
datumSz = sizeof(WlzUByte);
break;
case WLZ_GREY_SHORT:
datumSz = sizeof(short);
break;
default:
errNum = WLZ_ERR_READ_INCOMPLETE;
break;
}
if(errNum == WLZ_ERR_NONE)
{
switch(head->latComp)
{
case WLZEFF_AM_LATCOMP_NONE:
if(fread(**data, datumSz, head->latBytes, fP) != head->latBytes)
{
errNum = WLZ_ERR_READ_INCOMPLETE;
}
if((errNum == WLZ_ERR_NONE) &&
(gType == WLZ_GREY_SHORT) &&
(head->endian = WLZEFF_AM_ENDIAN_LITTLE))
{
WlzEffAmSwapBytes(buf, head->latBytes);
}
break;
case WLZEFF_AM_LATCOMP_HXBYTERLE:
if((buf = AlcMalloc(datumSz * head->latBytes)) == NULL)
{
errNum = WLZ_ERR_MEM_ALLOC;
}
else if(fread(buf, datumSz, head->latBytes, fP) != head->latBytes)
{
errNum = WLZ_ERR_MEM_ALLOC;
}
else
{
if((gType == WLZ_GREY_SHORT) &&
(head->endian = WLZEFF_AM_ENDIAN_LITTLE))
{
WlzEffAmSwapBytes(buf, head->latBytes);
}
nDst = head->latSize.vtX * head->latSize.vtY * head->latSize.vtZ;
switch(gType)
{
case WLZ_GREY_UBYTE:
WlzEffAmBufDecodeHXByteRLEUByte(**(WlzUByte ***)data,
(WlzUByte *)buf,
nDst, head->latBytes);
break;
case WLZ_GREY_SHORT:
WlzEffAmBufDecodeHXByteRLEShort(**(short ***)data, (short *)buf,
nDst, head->latBytes);
break;
default:
break;
}
}
AlcFree(buf);
break;
default:
errNum = WLZ_ERR_READ_INCOMPLETE;
break;
}
}
return(errNum);
}
开发者ID:dscho,项目名称:Woolz,代码行数:88,代码来源:WlzExtFFAm.c
示例20: D
//.........这里部分代码省略.........
s = (double )(u[1]) / (double )u01;
}
break;
case WLZ_RCC_ENC:
/* |\Omega_0 \cup \Omega_1^{\circ}|/|\Omega_0| =
* v_0 / u_0 */
if(u[1] >= 0)
{
s = (double )(v[0]) / (double )(u[0]);
}
break;
case WLZ_RCC_ENCI:
/* |\Omega_0^{\circ} \cup \Omega_1|/|\Omega_1| =
* v_1 / u_1 */
if(v[1] >= 0)
{
s = (double )(v[1]) / (double )(u[1]);
}
break;
default:
break;
}
if(errNum == WLZ_ERR_NONE)
{
stats[i] = s;
}
}
}
}
/* If offset is required check for it and add to both the classification
* mask and statistics. */
if((errNum == WLZ_ERR_NONE) && (noOst == 0) &&
((cls & WLZ_RCC_EQ) == 0))
{
int ostQ[3];
errNum = WlzRCCOffset(o, t,
maxOstDist, &(ostQ[0]), &(ostQ[1]), &(ostQ[2]));
if(errNum == WLZ_ERR_NONE)
{
#ifdef WLZ_RCC_DEBUG_OST
(void )fprintf(stderr,
"WLZ_RCC_DEBUG_OST %d %d %d\n",
ostQ[0], ostQ[1], ostQ[2]);
#endif
if((ostQ[1] > 0) && (ostQ[1] < maxOstDist) && (ostQ[2] >= ostQ[0]))
{
const double eps = 1.0e-06;
if(ostQ[2] > ostQ[0])
{
stats[WLZ_RCCIDX_OST] = (double )ostQ[1] /
(double )(ostQ[2] + ostQ[1] - ostQ[0]);
}
else
{
stats[WLZ_RCCIDX_OST] = 1.0;
}
if(stats[WLZ_RCCIDX_OST] > (0.5 - eps))
{
cls |= WLZ_RCC_OST;
}
}
}
}
/* Free objects. */
for(i = 0; i < WLZ_RCCTOIDX_CNT; ++i)
{
(void )WlzFreeObj(t[i]);
}
for(i = 0; i <= 8; ++i)
{
(void )WlzFreeObj(c[i]);
}
for(i = 0; i < 2; ++i)
{
(void )WlzFreeObj(o[i]);
}
if((errNum == WLZ_ERR_NONE) && (dstStatAry != NULL))
{
if((*dstStatAry = (double *)
AlcMalloc(sizeof(double) * WLZ_RCCIDX_CNT)) == NULL)
{
errNum = WLZ_ERR_MEM_ALLOC;
}
else
{
(void )memcpy(*dstStatAry, stats, sizeof(double) * WLZ_RCCIDX_CNT);
if(dstStatCnt)
{
*dstStatCnt = WLZ_RCCIDX_CNT;
}
}
}
if(dstErr)
{
*dstErr = errNum;
}
return(cls);
}
开发者ID:VirtualFlyBrain,项目名称:Woolz,代码行数:101,代码来源:WlzRegConCalc.c
注:本文中的AlcMalloc函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论