IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 13, 2006, 4:26:25 PM (20 years ago)
Author:
drobbin
Message:

Added str check test for error handling of psString fxns, namely stringSubstitute. Edited memory and type to include MemCheck's for string, line, and region. Added is_psType function to check for NULLs and native types first. <-will have to update all fxns next wrt to this change. Added psStringAlloc, stringFree, regionFree. Added doxygen comments.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/sys/psMemory.c

    r7617 r7901  
    88*  @author Robert Lupton, Princeton University
    99*
    10 *  @version $Revision: 1.73 $ $Name: not supported by cvs2svn $
    11 *  @date $Date: 2006-06-21 21:40:12 $
     10*  @version $Revision: 1.74 $ $Name: not supported by cvs2svn $
     11*  @date $Date: 2006-07-14 02:26:25 $
    1212*
    1313*  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    2424#include "psAbort.h"
    2525#include "psLogMsg.h"
    26 
    2726#include "psBitSet.h"
    28 //#include "psArray.h"
    29 //#include "psImage.h"
    30 //#include "psList.h"
    31 //#include "psLookupTable.h"
    32 //#include "psHash.h"
    33 
    34 //#include "psMetadata.h"
    3527#include "psFits.h"
    3628#include "psPixels.h"
    37 //#include "psScalar.h"
    38 //#include "psVector.h"
    39 //#include "psTime.h"
    40 //#include "psCoord.h"
    4129#include "psSphereOps.h"
    42 //#include "psStats.h"
    4330#include "psMinimizeLMM.h"
    4431#include "psImageConvolve.h"
    4532#include "psTime.h"
    46 
     33#include "psLine.h"
     34#include "psRegion.h"
    4735#include "psErrorText.h"
    4836
     
    837825}
    838826
     827bool is_psType(psPtr ptr)
     828{
     829    if (ptr == NULL) {
     830        return false;
     831    }
     832    psMemBlock* m = ((psMemBlock* ) ptr) - 1;
     833    if (m->startblock != P_PS_MEMMAGIC || m->endblock != P_PS_MEMMAGIC) {
     834        return false; //Probably not a psAllocated-Type
     835    } else {
     836        return true;
     837    }
     838}
     839
    839840bool psMemCheckType(psDataType type,
    840841                    psPtr ptr)
    841842{
     843    if (!is_psType(ptr)) {
     844        return false;
     845    }
     846
    842847    switch(type) {
    843848    case PS_DATA_ARRAY:
     
    905910            break;
    906911        }
     912    case PS_DATA_LINE:
     913        if ( psMemCheckLine(ptr) )
     914            return true;
     915        else {
     916            psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     917                    "Incorrect pointer.  Datatypes do not match.\n");
     918            break;
     919        }
    907920    case PS_DATA_LIST:
    908921        if ( psMemCheckList(ptr) )
     
    10171030            break;
    10181031        }
     1032    case PS_DATA_REGION:
     1033        if ( psMemCheckRegion(ptr) )
     1034            return true;
     1035        else {
     1036            psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     1037                    "Incorrect pointer.  Datatypes do not match.\n");
     1038            break;
     1039        }
    10191040    case PS_DATA_SCALAR:
    10201041        if ( psMemCheckScalar(ptr) )
     
    10511072    case PS_DATA_STATS:
    10521073        if ( psMemCheckStats(ptr) )
     1074            return true;
     1075        else {
     1076            psError(PS_ERR_BAD_PARAMETER_VALUE, false,
     1077                    "Incorrect pointer.  Datatypes do not match.\n");
     1078            break;
     1079        }
     1080    case PS_DATA_STRING:
     1081        if ( psMemCheckString(ptr) )
    10531082            return true;
    10541083        else {
Note: See TracChangeset for help on using the changeset viewer.