From ea004e377421d6b9142ef1a8a3ba0193c2888918 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Tue, 20 Sep 2011 18:19:34 -0400 Subject: faq: Fix question on dynamic memory. As of libmaple v0.0.12, dynamic memory is officially supported. Fix the FAQ on malloc() etc. not working to reflect this. --- source/faq.rst | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'source') diff --git a/source/faq.rst b/source/faq.rst index 4b5b605..da67370 100644 --- a/source/faq.rst +++ b/source/faq.rst @@ -21,11 +21,25 @@ of its headers. .. _faq-dynamic-memory: -Why don't ``malloc()``/``new`` work? ------------------------------------- - -Due to our newlib configuration, dynamic memory allocation is -currently not available. +How can I use ``malloc()``/``new``? +----------------------------------- + +For ``malloc()``, just ``#include ``, and everything should +work fine. Be careful, though! This isn't like C programming on a +PC. You're on the bare metal, and probably shouldn't be using dynamic +memory unless you know what you're doing. + +``new`` should work out of the box (the warning about knowing what +you're doing applies here as well). If you find that ``new`` (or +``new[]``, ``delete``, etc.) is broken in some way, that's a bug; +please let us know in the `forum`_. + +Some information on the heap: on boards with an external SRAM chip +(like Maple Native), the heap is located on external SRAM by default. +For other boards, the heap is located immediately after ``.bss``, and +grows towards the stack. (In all cases, statically allocated +variables and the stack are located on internal SRAM, for performance +reasons). .. _faq-flash-tables: -- cgit v1.2.3