[GRASS-dev] Improving the G_calloc: unable to allocate xx bytes of memory message?

Glynn Clements glynn at gclements.plus.com
Sun Nov 9 22:14:46 PST 2014

Markus Neteler wrote:

> while I am able to make use of your suggestion about ssize_t writen()
> I found back the code snippet concerning errno:
> http://trac.osgeo.org/grass/ticket/2278#comment:5

The reason for copying errno is in case an error occurs within any of
the calls between the one for which the error is being reported and
the G_fatal_error() call.

E.g. in the second hunk of the patch at which that comment was aimed,
the code which handled the error called close(cell_fd) as part of the
clean-up prior to calling G_fatal_error(). If the close() call failed,
the error message would report the error for the close() call rather
than for the original error.

This is less of an issue if the G_fatal_error() call immediately
follows the failed call, but in theory it could arise in the context
of _(...) e.g. if an error occurs while loading the message catalogs
to translate the error message.

Glynn Clements <glynn at gclements.plus.com>

More information about the grass-dev mailing list