IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 1162


Ignore:
Timestamp:
Jun 30, 2004, 2:14:40 PM (22 years ago)
Author:
harman
Message:

Added psAbort for failed memory allocation

Location:
trunk/psLib/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/collections/psBitSet.c

    r1073 r1162  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-06-23 23:00:15 $
     12 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-07-01 00:14:25 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727#include "psMemory.h"
    2828#include "psError.h"
     29#include "psAbort.h"
    2930
    3031/******************************************************************************/
     
    9091    numBytes = ceil(n/8.0);
    9192    newObj = psAlloc(sizeof(psBitSet));
     93    if(newObj == NULL) {
     94        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
     95    }
    9296    p_psMemSetDeallocator(newObj,(psFreeFcn)bitSetFree);
    9397    newObj->n = numBytes;
     
    96100    /*@i@*/
    97101    newObj->bits = psAlloc(sizeof(char)*numBytes);
     102    if(newObj->bits == NULL) {
     103        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
     104    }
     105
    98106    memset(newObj->bits, numBytes, 0);
    99107
     
    225233    int numBits = inBitSet->n*8;
    226234    char* outString = psAlloc((size_t)numBits+1);
     235    if(outString == NULL) {
     236        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
     237    }
     238
    227239    for(i=0; i<numBits; i++) {
    228240        outString[numBits-i-1] = (psBitSetTest(inBitSet, i) == 1)?'1':'0';
  • trunk/psLib/src/collections/psScalar.c

    r1063 r1162  
    88 *  @author Ross Harman, MHPCC
    99 *
    10  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-06-19 01:59:51 $
     10 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-07-01 00:14:40 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2121#include "psScalar.h"
    2222#include "psLogMsg.h"
     23#include "psAbort.h"
    2324
    2425/******************************************************************************/
     
    6162    // Create scalar
    6263    scalar = (psScalar *)psAlloc(sizeof(psScalar));
     64    if(scalar == NULL) {
     65        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
     66    }
     67
    6368    scalar->type.dimen = PS_DIMEN_SCALAR;
    6469    scalar->type.type = dataType;
  • trunk/psLib/src/mathtypes/psScalar.c

    r1063 r1162  
    88 *  @author Ross Harman, MHPCC
    99 *
    10  *  @version $Revision: 1.2 $ $Name: not supported by cvs2svn $
    11  *  @date $Date: 2004-06-19 01:59:51 $
     10 *  @version $Revision: 1.3 $ $Name: not supported by cvs2svn $
     11 *  @date $Date: 2004-07-01 00:14:40 $
    1212 *
    1313 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2121#include "psScalar.h"
    2222#include "psLogMsg.h"
     23#include "psAbort.h"
    2324
    2425/******************************************************************************/
     
    6162    // Create scalar
    6263    scalar = (psScalar *)psAlloc(sizeof(psScalar));
     64    if(scalar == NULL) {
     65        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
     66    }
     67
    6368    scalar->type.dimen = PS_DIMEN_SCALAR;
    6469    scalar->type.type = dataType;
  • trunk/psLib/src/types/psBitSet.c

    r1073 r1162  
    1010 *  @author Ross Harman, MHPCC
    1111 *
    12  *  @version $Revision: 1.8 $ $Name: not supported by cvs2svn $
    13  *  @date $Date: 2004-06-23 23:00:15 $
     12 *  @version $Revision: 1.9 $ $Name: not supported by cvs2svn $
     13 *  @date $Date: 2004-07-01 00:14:25 $
    1414 *
    1515 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727#include "psMemory.h"
    2828#include "psError.h"
     29#include "psAbort.h"
    2930
    3031/******************************************************************************/
     
    9091    numBytes = ceil(n/8.0);
    9192    newObj = psAlloc(sizeof(psBitSet));
     93    if(newObj == NULL) {
     94        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
     95    }
    9296    p_psMemSetDeallocator(newObj,(psFreeFcn)bitSetFree);
    9397    newObj->n = numBytes;
     
    96100    /*@i@*/
    97101    newObj->bits = psAlloc(sizeof(char)*numBytes);
     102    if(newObj->bits == NULL) {
     103        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
     104    }
     105
    98106    memset(newObj->bits, numBytes, 0);
    99107
     
    225233    int numBits = inBitSet->n*8;
    226234    char* outString = psAlloc((size_t)numBits+1);
     235    if(outString == NULL) {
     236        psAbort(__func__," : Line %d - Failed to allocate memory", __LINE__);
     237    }
     238
    227239    for(i=0; i<numBits; i++) {
    228240        outString[numBits-i-1] = (psBitSetTest(inBitSet, i) == 1)?'1':'0';
Note: See TracChangeset for help on using the changeset viewer.