Changeset 70

Show
Ignore:
Timestamp:
04/29/08 09:40:11
Author:
mhadji
Message:

Fixed malloc memory leak

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spatialindex/trunk/src/spatialindex/LineSegment.cc

    r67 r70  
    173173void LineSegment::getCenter(Point& out) const 
    174174{ 
    175 //      double coords[m_dimension]; 
    176     double *coords; 
    177     coords = (double*) malloc(m_dimension * sizeof(double)); 
     175        double coords = new double[m_dimension]; 
    178176        for (size_t cDim = 0; cDim < m_dimension; cDim++) 
    179177        { 
     
    183181        } 
    184182 
     183        delete[] coords; 
    185184        out = Point(coords, m_dimension); 
    186185} 
     
    193192void LineSegment::getMBR(Region& out) const 
    194193{ 
    195         //double low[m_dimension]; 
    196         //double high[m_dimension]; 
    197     double *low; 
    198     double *high; 
    199     low = (double*) malloc(m_dimension * sizeof(double)); 
    200     high = (double*) malloc(m_dimension * sizeof(double)); 
     194        double low = new double[m_dimension]; 
     195        double high = new double[m_dimension]; 
    201196        for (size_t cDim = 0; cDim < m_dimension; cDim++) 
    202197        { 
     
    205200        } 
    206201 
     202        delete[] low; 
     203        delete[] high; 
    207204        out = Region(low, high, m_dimension); 
    208205}