This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: How to destroy _reent structure

Hello Corinna,

On 04/24/2013 12:26 PM, Corinna Vinschen wrote:
On Apr 24 10:04, Sebastian Huber wrote:

there is _REENT_INIT_PTR() for initialization, but how can I destroy
a _reent structure.  Is this _wrapup_reent()?

Try _reclaim_reent.  But it's not the same as _REENT_INIT_PTR since
_REENT_INIT_PTR does not allocate any memory.


so for initialization we can use:

struct _reent *p = malloc(sizeof(*p));
if (p != NULL) {

For destruction we can use:


What is the purpose of _wrapup_reent()? Its not called from within Newlib and I don't find a function that can register an atexit handler in a non-global _reent structure. There is also no public header file for this function.

In RTEMS we currently use this:

static int newlib_free_buffers(
  FILE *fp
  switch ( fileno(fp) ) {
    case 0:
    case 1:
    case 2:
      if (fp->_flags & __SMBF) {
        free( fp->_bf._base );
        fp->_flags &= ~__SMBF;
        fp->_bf._base = fp->_p = (unsigned char *) NULL;
  return 0;

void newlib_delete_hook(
  rtems_tcb *current_task,
  rtems_tcb *deleted_task
  struct _reent *ptr;

  ptr = deleted_task->libc_reent;
  deleted_task->libc_reent = NULL;

   *  Just in case there are some buffers lying around.
  _fwalk(ptr, newlib_free_buffers);


So this looks pretty wrong.

Sebastian Huber, embedded brains GmbH

Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone   : +49 89 189 47 41-16
Fax     : +49 89 189 47 41-09
E-Mail  :
PGP     : Public key available on request.

Diese Nachricht ist keine geschÃftliche Mitteilung im Sinne des EHUG.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]