[GRASS-SVN] r52702 - grass/branches/develbranch_6/lib/gis
svn_grass at osgeo.org
svn_grass at osgeo.org
Fri Aug 17 06:21:51 PDT 2012
Author: neteler
Date: 2012-08-17 06:21:51 -0700 (Fri, 17 Aug 2012)
New Revision: 52702
Modified:
grass/branches/develbranch_6/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/develbranch_6/lib/gis/alloc.c
===================================================================
--- grass/branches/develbranch_6/lib/gis/alloc.c 2012-08-17 13:20:17 UTC (rev 52701)
+++ grass/branches/develbranch_6/lib/gis/alloc.c 2012-08-17 13:21:51 UTC (rev 52702)
@@ -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)
+ 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)
+ 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)
+ 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