[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avr-libc-dev] making malloc() and free() reentrant safe

From: Russell Shaw
Subject: Re: [avr-libc-dev] making malloc() and free() reentrant safe
Date: Thu, 30 Jun 2005 16:08:59 +1000
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050513 Debian/1.7.8-1

Joerg Wunsch wrote:
As Russell Shaw wrote:

If you need stdio functions that call malloc, hmm, I think that'll
put something else onto your list of non-reentrant functions ;-),
but still, you could just import the implementations for
malloc/free into your own application, and make them thread-safe.

What stdio functions call malloc?

Currently, fdevopen() (though I always meant to provide an additional
interface that doesn't need malloc()), and the full-featured (floating
point) versions of vfscanf() and vfprintf().  The latter need a rather
large buffer, and the idea behind malloc()'ing it is that if you setup
__malloc_margin correctly, you could at least fail and bail out if the
memory isn't available (unlike for an automatic variable).  The memory
is released before returning, so there's no risk for memory
fragmentation resulting out if it.

If the prolog stack-checking code gets done, then it could revert to
just using the stack.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]