avr-gcc-list
[Top][All Lists]
Advanced

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

Re: [avr-gcc-list] fdevopen() uses calloc?


From: J.C. Wren
Subject: Re: [avr-gcc-list] fdevopen() uses calloc?
Date: Wed, 21 Jan 2004 11:44:08 -0500
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20040110 Thunderbird/0.4

E. Weddington wrote:

On 21 Jan 2004 at 16:06, Joerg Wunsch wrote:

"J.C. Wren" <address@hidden> wrote:

fdevopen() is using calloc(), which pulls in a lot of extra code.
Is there any reason this couldn't use a static, instead?
It's been on my medium-priority todo list for some time to provide an
fdevopen() implementation that can handle only stdin/stdout/ stderr,
but has the struct __file for them pre-defined.

OTOH, it's probably of only limited use.  Anyone who's going to use
printf() is certainly running a larger device than an ATmega2313 ;-),
and perhaps is using malloc() already anyway.

Perhaps not so.

I could easily see using printf, limited to those available streams, but not wanting to include malloc.

The main reason why I don't use printf *is* because it uses malloc and I don't want to get into that.

Eric

_______________________________________________
avr-gcc-list mailing list
address@hidden
http://www.avr1.org/mailman/listinfo/avr-gcc-list
What about something like this? Create fdevopens(), which is basically identical to fdevopen(), except uses an internal static __file instance. Move the __iob declaration to another file. Use fdevopen() if you're already using malloc(), or have some reason where the dynamic allocation make sense. Use fdevopens() if you only plan on using stdin/stdout/stderr or just want the smaller footprint.

Another alternative would be to rename fdevopen() to fdevopend(), and by default define fdevopen as fdevopend. If you want to use the small version, #define FDEVOPEN_SMALL (or somesuch) prior to including stdio.h, that merely redefines fdevopen to fdevopens.

   --jc


reply via email to

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