Rockbox.org home
release
dev builds
extras
themes manual
wiki
device status forums
mailing lists
IRC bugs
patches
dev guide



Rockbox mail archive

Subject: Re: Dynamic memory allocation?

Re: Dynamic memory allocation?

From: Tobias Heimann <tobias.heimann_at_gmx.net>
Date: 2006-01-03

Thanks everybody for the answers!
Since I've got an upper limit for the memory that I might need, I will
just use a static memory allocation of that maximum size (it's not that
much anyway)...

Cheers,
Tobias

Bluechip wrote:
> As someone once said to me, if you want malloc/free/etc code them.
> After about 10 minutes of thinking on the problem I realised just how
> much of my 32K of memory such algorithms would cost me and decided to
> write my code with static memory allocations set at compile time.
>
> Tobias, if you need any thoughts on how to live without malloc (and I
> really do recommend it in this case) I am happy to help here or offline.
>
> BC
>
>> The (much argued over) view of the rockbox dev'ers is that dynamic
>> memory allocation is a bad idea in embedded systems, like Rockbox.
>>
>> The reason usually given is that you have to deal with the 'worst
>> case' scenario anyway (ie, all resources are needed), therefore you
>> need at least this much ram available, in case everything is happening
>> at once. If this is the case, you might as well statically allocate
>> it.
>>
>> Oh, and its a lot simpler to not have malloc etc :)
>>
>> I guess if you know that 2 things are never going to need the same
>> memory at the same time (maybe mp3 decoding and ogg decoding), why not
>> just allocate a static buffer of mp3_or_ogg_buffer
>>
>> g
>>
>>
>> On 1/2/06, Tobias Heimann <tobias.heimann@gmx.net> wrote:
>> > Hi guys,
>> >
>> > I've just started to develop a plugin for rockbox and stumbled over
>> the
>> > memory allocation:
>> > Is there anything like malloc() and free() in rockbox and if yes,
>> which
>> > headers do I have to include for that?
>> >
>> > So far, I've only found buffer_alloc() in buffer.h, but that
>> results in
>> > an undefined reference error.
>> > I'm building for the coldfire m68k btw.
>> >
>> > Thanks for any help,
>> > Tobias
>> >
>> >
>
>
>
Received on Tue Jan 3 12:17:28 2006


Page was last modified "Jan 10 2012" The Rockbox Crew
aaa