本文整理匯總了C++中AlcMalloc函數的典型用法代碼示例。如果您正苦於以下問題:C++ AlcMalloc函數的具體用法?C++ AlcMalloc怎麽用?C++ AlcMalloc使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了AlcMalloc函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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 );
}
示例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);
}
示例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;
}