* doc/sdccman.lyx: added note on dynamic memory heap initialization
authorjesusc <jesusc@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 30 Aug 2006 18:37:26 +0000 (18:37 +0000)
committerjesusc <jesusc@4a8a32a2-be11-0410-ad9d-d568d2c75423>
Wed, 30 Aug 2006 18:37:26 +0000 (18:37 +0000)
git-svn-id: https://sdcc.svn.sourceforge.net/svnroot/sdcc/trunk/sdcc@4347 4a8a32a2-be11-0410-ad9d-d568d2c75423

ChangeLog
doc/sdccman.lyx

index 4f21b28c850121069870efdca1a5f6db5cef3fcf..caefe81ee8acce71e2490bd2751923410ccc6241 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2006-08-30 Jesus Calvino-Fraga <jesusc at ece.ubc.ca>
+
+       * doc/sdccman.lyx: added note on dynamic memory heap initialization
+
 2006-08-27 Maarten Brock <sourceforge.brock AT dse.nl>
 
        * src/mcs51/gen.c (genAnd, genOr, genXor): fixed bug 1546986
index 1cef55158fa6e3631254c2e38758bdaed73cb691..9d5e87c04bea2a3c255511e6e2fd109a8ab18f84 100644 (file)
@@ -15465,6 +15465,100 @@ and
 not
 \emph default 
  support long variables and field widths).
+\layout Subsubsection
+
+<malloc.h>
+\begin_inset LatexCommand \index{malloc.h}
+
+\end_inset 
+
+
+\layout Standard
+
+Before using dynamic
+\begin_inset LatexCommand \index{dynamic}
+
+\end_inset 
+
+ memory allocation with SDCC, you have to provide heap
+\begin_inset LatexCommand \index{heap}
+
+\end_inset 
+
+ space for malloc to allocate memory from
+\family typewriter 
+.
+\family default 
+You can acomplish this by including the following code into your source:
+\layout Verse
+
+
+\family typewriter 
+#include <malloc.h>
+\begin_inset LatexCommand \index{malloc.h}
+
+\end_inset 
+
+ /* calloc
+\begin_inset LatexCommand \index{calloc}
+
+\end_inset 
+
+, malloc
+\begin_inset LatexCommand \index{malloc}
+
+\end_inset 
+
+, realloc
+\begin_inset LatexCommand \index{realloc}
+
+\end_inset 
+
+, and free
+\begin_inset LatexCommand \index{free}
+
+\end_inset 
+
+ */ 
+\newline 
+
+\newline 
+#define HEAPSIZE 0x1000 /* Adjust depending on available memory */ 
+\newline 
+unsigned char xdata myheap[HEAPSIZE]; /* The actual heap for dynamic memory
+ */ 
+\newline 
+
+\newline 
+void main (void) 
+\newline 
+{ 
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+/* Your variable declarations come here*/
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+...
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+init_dynamic_memory((MEMHEADER xdata *)myheap, HEAPSIZE);
+\newline 
+\SpecialChar ~
+\SpecialChar ~
+\SpecialChar ~
+...
+ /* Rest of your code*/
+\newline 
+} 
+\newline 
+
 \layout Subsection
 
 Math functions (sinf, powf, sqrtf etc.)