16FXlib
dynamicmem.c
Go to the documentation of this file.
1 
2 //*****************************************************************************
3 // Author : Christian Illy
4 // Created : 18.09.2009
5 // Version : 0.1
6 // Target MCU : Fujitsu MB96300 series
7 //
8 // This program is free software: you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation, either version 3 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 //
21 //*****************************************************************************
22 
23 #include "dynamicmem.h"
24 #include "dynamicmem.cfg.h"
25 #include "inttypes.h"
26 
27 static uint16_t brk_siz = 0;
28 static char _heap[HEAP_SIZE];
29 
30 char* sbrk(int size) {
31  if (brk_siz + size > HEAP_SIZE || brk_siz + size < 0)
32  return ((char*) -1);
33  brk_siz += size;
34  return (_heap + brk_siz - size);
35 }
unsigned int uint16_t
Definition: inttypes.h:50
#define HEAP_SIZE
Number of bytes reserved for the heap.