[Top][All Lists]

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

Re: [avr-gcc-list] Minimal malloc implementation

From: Joerg Wunsch
Subject: Re: [avr-gcc-list] Minimal malloc implementation
Date: Wed, 4 Jun 2003 10:45:20 +0200 (MET DST)

Tom Harris <address@hidden> wrote:

> I have a minimal malloc that may be useful to others. The behaviour
> is as the standard malloc(), except that allocated memory is never
> tracked, so once malloc'ed, its yours for good. The free() function
> is a no-op.

I also thought of including it as an alternative malloc()
implementation into the library.

I see you're even using my copyright :), so i guess it should be easy
to #ifdef-derive it from the original version.  That would simplify
maintenance (see the vfprintf implementation which has three variants
within a single source).

> This is useful for the class of embedded apps that allocate memory
> at startup and never thereafter.

Is it really that useful?

> The stdio functions use malloc for a buffer, that is never
> free'ed, ...

If that's your only concern, i already thought about providing yet
another alternative of the stdio stuff that uses three statically
allocated descriptors (stdin/stdout/stderr) instead of the flexible

Note that combining your malloc() with the floating-point printf
Implementation would be fatal since this one uses malloc /and/ free.

> I would have preferred to have the free() implementation generate an
> error, as if you are calling free() from your code, you can expect
> to run out of memory, but I do not see a way of doing this easily.

Call abort()?  By default, this results in an endless loop.
J"org Wunsch                                           Unix support engineer
address@hidden        http://www.interface-systems.de/~j/

reply via email to

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