|
From: | Russell Shaw |
Subject: | Re: [avr-libc-dev] making malloc() and free() reentrant safe |
Date: | Sun, 03 Jul 2005 18:57:09 +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:What stdio functions call malloc?Currently, fdevopen() ..., and the full-featured (...) versions of vfscanf() and vfprintf(). ...If the prolog stack-checking code gets done, then it could revert to just using the stack.Curious, what would happen if space on stack is tight then?
Then the normal behaviour of whatever happens now with short heap space would happen. Atleast stack allocation is much faster and more efficient than heap allocation. It is just idealogical unsound to use the heap then throw it away in a short period of time;)
Right now, these functions simply skip any floating-point formatting command if they cannot allocate the buffer, but continue to operate normally for the remaining parts of the format string. Also, the buffer is *only* allocated when a floating-point command is encountered first (during the current call to vfprintf()), so any simple ``printf("Hi there, this is round %d\n", counter);'' would not try to allocate the buffer at all. Perhaps if the stack checking works, we could use alloca() instead? I think it's a builtin in GCC, so no additional code is needed, yet the remaining behaviour would continue the way it is now.
[Prev in Thread] | Current Thread | [Next in Thread] |