[GRASS-SVN] r52704 - grass/branches/releasebranch_6_4/lib/gis

svn_grass at osgeo.org svn_grass at osgeo.org
Fri Aug 17 06:23:49 PDT 2012


Author: neteler
Date: 2012-08-17 06:23:48 -0700 (Fri, 17 Aug 2012)
New Revision: 52704

Modified:
   grass/branches/releasebranch_6_4/lib/gis/alloc.c
Log:
libgis: out-of-memory is usually caused by too many cells, print current rows, cols; doxygen cosmetics (backport from trunk, r52595)

Modified: grass/branches/releasebranch_6_4/lib/gis/alloc.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/gis/alloc.c	2012-08-17 13:23:47 UTC (rev 52703)
+++ grass/branches/releasebranch_6_4/lib/gis/alloc.c	2012-08-17 13:23:48 UTC (rev 52704)
@@ -1,25 +1,21 @@
-
-/**
- * \file alloc.c
+/*!
+ * \file lib/gis/alloc.c
  *
  * \brief GIS Library - Memory allocation routines.
  *
- * (C) 2001-2008 by the GRASS Development Team
+ * (C) 1999-2009 by the GRASS Development Team
  *
  * This program is free software under the GNU General Public License
  * (>=v2). Read the file COPYING that comes with GRASS for details.
  *
- * \author GRASS GIS Development Team
- *
- * \date 1999-2008
+ * \author Original author CERL
  */
 
 #include <stdlib.h>
 #include <grass/gis.h>
 #include <grass/glocale.h>
 
-
-/**
+/*!
  * \brief Memory allocation.
  *
  * Allocates a block of
@@ -39,14 +35,21 @@
 	n = 1;			/* make sure we get a valid request */
 	
     buf = malloc(n);
-    if (!buf)
-	G_fatal_error(_("G_malloc: unable to allocate %lu bytes at %s:%d"),
+    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;
 }
 
-/**
+/*!
  * \brief Memory allocation.
  *
  * Allocates a
@@ -72,15 +75,22 @@
 	n = 1;
 
     buf = calloc(m, n);
-    if (!buf)
-	G_fatal_error(_("G_calloc: unable to allocate %lu * %lu bytes at %s:%d"),
+    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;
 }
 
 
-/**
+/*!
  * \brief Memory reallocation.
  *
  * Changes the
@@ -97,9 +107,7 @@
  *
  * \param[in,out] buf buffer holding original data
  * \param[in] n array size
- * \return void * 
  */
-
 void *G__realloc(const char *file, int line, void *buf, size_t n)
 {
     if (n <= 0)
@@ -110,15 +118,22 @@
     else
 	buf = realloc(buf, n);
 
-    if (!buf)
-	G_fatal_error(_("G_realloc: unable to allocate %lu bytes at %s:%d"),
+    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;
 }
 
 
-/**
+/*!
  * \brief Free allocated memory.
  *
  * \param[in,out] buf buffer holding original data



More information about the grass-commit mailing list