[GRASS-SVN] r52595 - grass/trunk/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Wed Aug 8 03:37:13 PDT 2012


Author: mmetz
Date: 2012-08-08 03:37:13 -0700 (Wed, 08 Aug 2012)
New Revision: 52595

Modified:
   grass/trunk/lib/gis/alloc.c
Log:
libgis: out-of-memory is usually caused by too many cells, print current rows, cols

Modified: grass/trunk/lib/gis/alloc.c
===================================================================
--- grass/trunk/lib/gis/alloc.c	2012-08-08 10:30:52 UTC (rev 52594)
+++ grass/trunk/lib/gis/alloc.c	2012-08-08 10:37:13 UTC (rev 52595)
@@ -37,9 +37,16 @@
 	n = 1;			/* make sure we get a valid request */
 	
     buf = malloc(n);
-    if (!buf)
+    if (!buf) {
+	struct Cell_head window;
+	
+	G_get_window(&window);
+	G_important_message(_("Current region rows: %d, cols: %d"), 
+		            window.rows, window.cols);
+
 	G_fatal_error(_("G_malloc: unable to allocate %lu bytes of memory at %s:%d"),
 		      (unsigned long) n, file, line);
+    }
 
     return buf;
 }
@@ -72,9 +79,16 @@
 	n = 1;
 
     buf = calloc(m, n);
-    if (!buf)
+    if (!buf) {
+	struct Cell_head window;
+	
+	G_get_window(&window);
+	G_important_message(_("Current region rows: %d, cols: %d"), 
+		            window.rows, window.cols);
+
 	G_fatal_error(_("G_calloc: unable to allocate %lu * %lu bytes of memory at %s:%d"),
 		      (unsigned long) m, (unsigned long) n, file, line);
+    }
 
     return buf;
 }
@@ -111,9 +125,16 @@
     else
 	buf = realloc(buf, n);
 
-    if (!buf)
+    if (!buf) {
+	struct Cell_head window;
+	
+	G_get_window(&window);
+	G_important_message(_("Current region rows: %d, cols: %d"), 
+		            window.rows, window.cols);
+
 	G_fatal_error(_("G_realloc: unable to allocate %lu bytes of memory at %s:%d"),
 		      (unsigned long) n, file, line);
+    }
 
     return buf;
 }



More information about the grass-commit mailing list