asprintf in low memory situations
Fri Jul 16 18:44:00 GMT 2004
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
Many thanks in advance,
LOYTEC electronics GmbH
More information about the Newlib