IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 28, 2004, 3:09:53 PM (22 years ago)
Author:
desonia
Message:

renamed psImageRealloc to psImageRecycle. Realloc may infer that the data is preserved, which is not a requirement.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/image/psImage.c

    r791 r812  
    99 *  @author Ross Harman, MHPCC
    1010 *
    11  *  @version $Revision: 1.18 $ $Name: not supported by cvs2svn $
    12  *  @date $Date: 2004-05-26 22:55:46 $
     11 *  @version $Revision: 1.19 $ $Name: not supported by cvs2svn $
     12 *  @date $Date: 2004-05-29 01:09:53 $
    1313 *
    1414 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    7575    }
    7676
     77    if (image->type.type == PS_TYPE_PTR) {
     78        // 2-D array of pointers -- must dereference
     79        unsigned int oldNumRows = image->numRows;
     80        unsigned int oldNumCols = image->numCols;
     81        psPTR* rowPtr;
     82
     83        for(unsigned int row=0;row<oldNumRows;row++) {
     84            rowPtr = image->data.PTR[row];
     85            for (unsigned int col=0;col<oldNumCols;col++) {
     86                psMemDecrRefCounter(rowPtr[col]);
     87            }
     88        }
     89    }
     90
    7791    psImageFreeChildren(image);
    7892
     
    8498}
    8599
    86 psImage* psImageRealloc(psImage* old,unsigned int numCols, unsigned int numRows,
     100psImage* psImageRecycle(psImage* old,
     101                        unsigned int numCols,
     102                        unsigned int numRows,
    87103                        const psElemType type)
    88104{
     
    96112
    97113    if (old->type.dimen != PS_DIMEN_IMAGE) {
    98         psError(__func__,"Can not realloc image because image is not an image.");
    99         return NULL;
     114        psError(__func__,"Can not realloc image because input is not an image.");
     115        return NULL;
     116    }
     117
     118    if (old->type.type == PS_TYPE_PTR) {
     119        // 2-D array of pointers -- must dereference
     120        unsigned int oldNumRows = old->numRows;
     121        unsigned int oldNumCols = old->numCols;
     122        psPTR* rowPtr;
     123
     124        for(unsigned int row=0;row<oldNumRows;row++) {
     125            rowPtr = old->data.PTR[row];
     126            for (unsigned int col=0;col<oldNumCols;col++) {
     127                psMemDecrRefCounter(rowPtr[col]);
     128                rowPtr[col] = NULL;
     129            }
     130        }
    100131    }
    101132
     
    163194    elementSize = PSELEMTYPE_SIZEOF(image->type.type);
    164195
    165     out = psImageRealloc(out,numCols,numRows,image->type.type);
     196    out = psImageRecycle(out,numCols,numRows,image->type.type);
    166197
    167198    // set the parent information into the child output image
     
    245276    }
    246277
    247     output = psImageRealloc(output,numCols,numRows,type);
     278    output = psImageRecycle(output,numCols,numRows,type);
    248279
    249280    // cover the trival case of copy of the same datatype.
     
    470501    switch (bitPix) {
    471502    case BYTE_IMG:
    472         psImageRealloc(output,numCols,numRows,PS_TYPE_U8);
     503        psImageRecycle(output,numCols,numRows,PS_TYPE_U8);
    473504        (void)fits_read_subset(fptr, TBYTE, firstPixel, lastPixel, increment,
    474505                               NULL, output->data.v, &anynull, &status);
    475506        break;
    476507    case SHORT_IMG:
    477         psImageRealloc(output,numCols,numRows,PS_TYPE_S16);
     508        psImageRecycle(output,numCols,numRows,PS_TYPE_S16);
    478509        (void)fits_read_subset(fptr, TSHORT, firstPixel, lastPixel, increment,
    479510                               NULL, output->data.v, &anynull, &status);
    480511        break;
    481512    case LONG_IMG:
    482         psImageRealloc(output,numCols,numRows,PS_TYPE_S32);
     513        psImageRecycle(output,numCols,numRows,PS_TYPE_S32);
    483514        (void)fits_read_subset(fptr, TINT, firstPixel, lastPixel, increment,
    484515                               NULL, output->data.v, &anynull, &status);
    485516        break;
    486517    case FLOAT_IMG:
    487         psImageRealloc(output,numCols,numRows,PS_TYPE_F32);
     518        psImageRecycle(output,numCols,numRows,PS_TYPE_F32);
    488519        (void)fits_read_subset(fptr, TFLOAT, firstPixel, lastPixel, increment,
    489520                               NULL, output->data.v, &anynull, &status);
    490521        break;
    491522    case DOUBLE_IMG:
    492         psImageRealloc(output,numCols,numRows,PS_TYPE_F64);
     523        psImageRecycle(output,numCols,numRows,PS_TYPE_F64);
    493524        (void)fits_read_subset(fptr, TDOUBLE, firstPixel, lastPixel, increment,
    494525                               NULL, output->data.v, &anynull, &status);
Note: See TracChangeset for help on using the changeset viewer.