asprintf in low memory situations
Thomas Rauscher
trauscher@loytec.com
Fri Jul 16 18:44:00 GMT 2004
Hi,
it seems that NEWLIB's asprintf does not
free an allocated buffer in fp->_bf._base
when a call to _realloc_r() fails.
This is somewhat different to the BSD and GLIBC
implementation. BSD LIBC seems to call free() and
set the return pointer to NULL while GLIBC
(according to man page) seems to call free()
and return the now invalid pointer.
I'm just curious whether this is a design issue or a bug.
However, it is an portability issue.
In the error case one has to call free() on NEWLIB systems,
can call free() on BSD systems and must not call
free() on GLIBC systems.
I've discovered this on a RTEMS target, but it
should be the same for all targets.
Please reply directly, as I'm not a subscriber of this
mailing list.
Many thanks in advance,
Thomas.
--
Thomas Rauscher
LOYTEC electronics GmbH
Stolzenthalergasse 24/3
A-1080 Wien
Austria/Europe
trauscher@loytec.com
www.loytec.com
Phone: +43-1-4020805-15
FAX: +43-1-4020805-99
More information about the Newlib
mailing list