diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2009-05-18 09:13:26 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2011-04-11 15:57:51 +0200 |
commit | 523daf675a2d9a1fd01edc854c98eb4ad2726962 (patch) | |
tree | 17b8ca4137deb248f048dbbcfa35ac12b1dc8372 /common/dummy_malloc.c | |
parent | 2a3762495056381e1ef1809b482b670fcd45b6d5 (diff) | |
download | barebox-523daf675a2d9a1fd01edc854c98eb4ad2726962.tar.gz barebox-523daf675a2d9a1fd01edc854c98eb4ad2726962.tar.xz |
add dummy_malloc functions
For some environments the dummy malloc functions offer a very small
alternative implementation. malloc will get its memory from sbrk()
and never frees memory again.
This of course is not suitable for interactive environments and thus
depends on CONFIG_SHELL_NONE
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/dummy_malloc.c')
-rw-r--r-- | common/dummy_malloc.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/common/dummy_malloc.c b/common/dummy_malloc.c new file mode 100644 index 0000000000..213e51d851 --- /dev/null +++ b/common/dummy_malloc.c @@ -0,0 +1,26 @@ +#include <common.h> +#include <malloc.h> + +void *memalign(size_t alignment, size_t bytes) +{ + unsigned long mem = (unsigned long)sbrk(bytes + alignment); + + mem = (mem + alignment) & ~(alignment - 1); + + return (void *)mem; +} + +void *malloc(size_t size) +{ + return memalign(8, size); +} + +void free(void *ptr) +{ +} + +void *realloc(void *ptr, size_t size) +{ + BUG(); +} + |