|
|
Wiki > Main > AllocatingRAM (compare)
| |||||||||||||||||||||||||||||||||||
Difference: AllocatingRAM (r2 vs. r1)Different ways to allocate RAM usage for your featureRockbox has a "No Malloc" policy you can read about at WhyNoMalloc but sometimes you really do need to grab some buffer possibly temporarily. This page will explain the different methods available. This list shows the sections in a compiled
Allocate on the HeapThis is the easiest way, (i.e add a global variable "static char my_buffer[BUFFER_SIZE]" to your file.c) Pro:
Cons:
Allocate on boot up (buffer_alloc(size_t size) )Next easiest way. call buffer_alloc() in your "init" method and make sure thats calle before playback starts. Pro:
Cons:
Steal a BufferTemporarily steal the talk/plugin/audio buffer, each has its own size and cons... Talk buffer ( talk_buffer_steal() )Plugin Buffer ( plugin_get_buffer() )Pros:Cons:
Audio Buffer ( plugin_get_audio_buffer() )Pros:Cons:
dynamic allocation like "malloc()" (bufalloc())Most frowned-on method of allocation, use this carefully... The buffer is allocated as a handle in the playback buffer and could be moving around the buffer as playback advances. Pro:
Cons:
r4 - 28 May 2011 - 01:30:28 - SeanBartell
Revision r2 - 28 Mar 2011 - 23:39 - SeanBartellRevision r1 - 03 Aug 2008 - 02:09 - JonathanGordon Copyright © by the contributing authors.
|