[GRASS-SVN] r42122 - grass/trunk/vector/v.generalize
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed May 5 10:06:30 EDT 2010
Author: mmetz
Date: 2010-05-05 10:06:29 -0400 (Wed, 05 May 2010)
New Revision: 42122
Modified:
grass/trunk/vector/v.generalize/matrix.c
grass/trunk/vector/v.generalize/smoothing.c
Log:
do not crash, give out of memory messages
Modified: grass/trunk/vector/v.generalize/matrix.c
===================================================================
--- grass/trunk/vector/v.generalize/matrix.c 2010-05-05 13:30:34 UTC (rev 42121)
+++ grass/trunk/vector/v.generalize/matrix.c 2010-05-05 14:06:29 UTC (rev 42122)
@@ -18,6 +18,8 @@
****************************************************************/
#include <string.h>
+#include <grass/gis.h>
+#include <grass/glocale.h>
#include "matrix.h"
int matrix_init(int rows, int cols, MATRIX * res)
@@ -139,8 +141,10 @@
int i, j;
/* initialize output matrix to the identity matrix */
- if (!matrix_init(a.rows, a.rows, res))
+ if (!matrix_init(a.rows, a.rows, res)) {
+ G_fatal_error(_("Out of memory"));
return 0;
+ }
for (i = 0; i < a.rows; i++) {
memset(res->a[i], 0, sizeof(double) * a.cols);
res->a[i][i] = 1;
Modified: grass/trunk/vector/v.generalize/smoothing.c
===================================================================
--- grass/trunk/vector/v.generalize/smoothing.c 2010-05-05 13:30:34 UTC (rev 42121)
+++ grass/trunk/vector/v.generalize/smoothing.c 2010-05-05 14:06:29 UTC (rev 42122)
@@ -405,12 +405,30 @@
G_fatal_error(_("Out of memory"));
return n;
}
- matrix_init(n + 2 * plus, 1, &xcoord);
- matrix_init(n + 2 * plus, 1, &ycoord);
- matrix_init(n + 2 * plus, 1, &zcoord);
- matrix_init(n + 2 * plus, 1, &xout);
- matrix_init(n + 2 * plus, 1, &yout);
- matrix_init(n + 2 * plus, 1, &zout);
+ if (!matrix_init(n + 2 * plus, 1, &xcoord)) {
+ G_fatal_error(_("Out of memory"));
+ return n;
+ }
+ if (!matrix_init(n + 2 * plus, 1, &ycoord)) {
+ G_fatal_error(_("Out of memory"));
+ return n;
+ }
+ if (!matrix_init(n + 2 * plus, 1, &zcoord)) {
+ G_fatal_error(_("Out of memory"));
+ return n;
+ }
+ if (!matrix_init(n + 2 * plus, 1, &xout)) {
+ G_fatal_error(_("Out of memory"));
+ return n;
+ }
+ if (!matrix_init(n + 2 * plus, 1, &yout)) {
+ G_fatal_error(_("Out of memory"));
+ return n;
+ }
+ if (!matrix_init(n + 2 * plus, 1, &zout)) {
+ G_fatal_error(_("Out of memory"));
+ return n;
+ }
double x0 = Points->x[0];
double y0 = Points->y[0];
More information about the grass-commit
mailing list