瀏覽代碼

libgis: out-of-memory is usually caused by too many cells, print current rows, cols

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@52595 15284696-431f-4ddb-bdfa-cd5b030d7da7
Markus Metz 12 年之前
父節點
當前提交
16ec2d3aae
共有 1 個文件被更改,包括 24 次插入3 次删除
  1. 24 3
      lib/gis/alloc.c

+ 24 - 3
lib/gis/alloc.c

@@ -37,9 +37,16 @@ void *G__malloc(const char *file, int line, size_t n)
 	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 @@ void *G__calloc(const char *file, int line, size_t m, size_t n)
 	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 @@ void *G__realloc(const char *file, int line, void *buf, size_t n)
     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;
 }