[geos-devel] Memory leak in Polygon::getArea()?

Manuel Prieto Villegas mprieto at dap.es
Fri Feb 27 03:47:47 EST 2004


Hi all!

I've downloaded geos-cvs this week and I've found what seems a memory leak. Currently Polygon::getArea() calls LineString::getCoordinates() but that memory is never deleted.

I've changed Polygon::getArea() in the following way

/**
*  Returns the area of this <code>Polygon</code>
*
*@return the area of the polygon
*/
double Polygon::getArea() const {
	double area=0.0;
	CoordinateList *s=shell->getCoordinates();
	area+=fabs(CGAlgorithms::signedArea(s));
	delete s;
	for(unsigned int i=0;i<holes->size();i++) {
	CoordinateList *h=(*holes)[i]->getCoordinates();
                area-=fabs(CGAlgorithms::signedArea(h));
	delete h;
	}
	return area;
}

and it works correctly for me.





 -----------------------------------------------------
  Este correo electrónico y, en su caso, cualquier fichero anexo
  al mismo, contiene información de carácter confidencial
  exclusivamente dirigida a su destinatario o destinatarios. Queda
  prohibida su divulgación, copia o distribución a terceros sin la
  previa autorización escrita de Dap. En el caso de haber
  recibido este correo electrónico por error, se ruega notifíquese
  inmediatamente esta circunstancia mediante reenvío a la dirección
  electrónica del remitente.
  ----------------------------------------------------------
  The information in this e-mail and in any attachments is confidential
  and solely for the attention and use of the named addressee(s).
  You are hereby notified that any dissemination, distribution or copy
  of this communication is prohibited without the prior written consent 
  of Dap. If you have received this communication in error,
  please, notify the sender by reply e-mail.
  -------------------------------------------------------------






More information about the geos-devel mailing list