summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorStefan Reinauer <stepan@coresystems.de>2009-09-25 21:59:57 +0000
committerStefan Reinauer <stepan@openbios.org>2009-09-25 21:59:57 +0000
commit6bd571e060d65257c9a7ba0f87c991dbdac0b582 (patch)
tree34fd5def5a7b6dd586004fdd0b8a92e40336182c /src/lib
parent0a181fd642d0c0780b4b88654d732cf625d1c862 (diff)
downloadcoreboot-6bd571e060d65257c9a7ba0f87c991dbdac0b582.tar.xz
drop some dead code, clarify small comments and small cleanups to malloc.c
Signed-off-by: Stefan Reinauer <stepan@coresystems.de> Acked-by: Stefan Reinauer <stepan@coresystems.de> git-svn-id: svn://svn.coreboot.org/coreboot/trunk@4677 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/malloc.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/lib/malloc.c b/src/lib/malloc.c
index 347ef0d67b..8c77fd396e 100644
--- a/src/lib/malloc.c
+++ b/src/lib/malloc.c
@@ -10,36 +10,27 @@ extern unsigned char _heap, _eheap;
static void *free_mem_ptr = &_heap; /* Start of heap */
static void *free_mem_end_ptr = &_eheap; /* End of heap */
-
-void malloc_mark(malloc_mark_t *place)
-{
- *place = (malloc_mark_t)free_mem_ptr;
- printk_spew("malloc_mark %p\n", free_mem_ptr);
-}
-
-void malloc_release(malloc_mark_t *ptr)
-{
- free_mem_ptr = (void *)*ptr;
- printk_spew("malloc_release %p\n", free_mem_ptr);
-}
-
void *malloc(size_t size)
{
void *p;
MALLOCDBG("%s Enter, size %ld, free_mem_ptr %p\n", __func__, size, free_mem_ptr);
+
+ /* Checking arguments */
if (size < 0)
- die("Error! malloc: Size < 0");
+ die("Error! malloc: size < 0");
+
+ /* Overzealous linker check */
if (free_mem_ptr <= 0)
die("Error! malloc: Free_mem_ptr <= 0");
- free_mem_ptr = (void *)(((unsigned long)free_mem_ptr + 3) & ~3); /* Align */
+ free_mem_ptr = (void *)ALIGN((unsigned long)free_mem_ptr, 4);
p = (void *) free_mem_ptr;
free_mem_ptr += size;
if (free_mem_ptr >= free_mem_end_ptr)
- die("Error! malloc: free_mem_ptr >= free_mem_end_ptr");
+ die("Error! malloc: Out of memory (free_mem_ptr >= free_mem_end_ptr)");
MALLOCDBG("malloc %p\n", p);
@@ -49,4 +40,5 @@ void *malloc(size_t size)
void free(void *where)
{
/* Don't care */
+ MALLOCDBG("free %p\n", where);
}