Changeset 13499

Show
Ignore:
Timestamp:
01/08/08 17:02:11 (6 months ago)
Author:
rouault
Message:

Use VSIMalloc2/3 in gcore (RFC-19)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/gdal/gcore/gdaldriver.cpp

    r13353 r13499  
    188188    CPLErr         eErr = CE_None; 
    189189 
    190     pData = VSIMalloc(nXSize * GDALGetDataTypeSize(eType) / 8); 
     190    pData = VSIMalloc2(nXSize, GDALGetDataTypeSize(eType) / 8); 
    191191    if( pData == NULL ) 
    192192    { 
    193193        CPLError( CE_Failure, CPLE_OutOfMemory, 
    194                   "CreateCopy(): Out of memory allocating %d byte line buffer.\n", 
    195                   nXSize * GDALGetDataTypeSize(eType) / 8 ); 
     194                  "CopyBandImageData(): Out of memory.\n"); 
    196195        eErr = CE_Failure; 
    197196    } 
  • trunk/gdal/gcore/gdalnodatamaskband.cpp

    r11975 r13499  
    108108    CPLErr eErr; 
    109109 
    110     pabySrc = (GByte *) 
    111         CPLMalloc( (GDALGetDataTypeSize(eWrkDT)/8)*nBlockXSize*nBlockYSize ); 
     110    pabySrc = (GByte *) VSIMalloc3( GDALGetDataTypeSize(eWrkDT)/8, nBlockXSize, nBlockYSize ); 
     111    if (pabySrc == NULL) 
     112    { 
     113        CPLError( CE_Failure, CPLE_OutOfMemory, 
     114                  "GDALNoDataMaskBand::IReadBlock: Out of memory for buffer." ); 
     115        return CE_Failure; 
     116    } 
    112117 
    113118    eErr = poParent->ReadBlock( nXBlockOff, nYBlockOff, pabySrc ); 
  • trunk/gdal/gcore/gdalrasterblock.cpp

    r12425 r13499  
    358358    int         nCurCacheMax = GDALGetCacheMax(); 
    359359 
     360    //FIXME? : risk of overflow in multiplication 
    360361    nSizeInBytes = nXSize * nYSize * (GDALGetDataTypeSize(eType) / 8); 
    361362 
     
    364365    { 
    365366        CPLError( CE_Failure, CPLE_OutOfMemory,  
    366                   "Out of memory allocating %d byte raster cache block.", 
    367                   nSizeInBytes ); 
     367                  "GDALRasterBlock::Internalize : Out of memory allocating %d bytes.", 
     368                  nSizeInBytes); 
    368369        return( CE_Failure ); 
    369370    }