diff options
author | Stefan Reinauer <stepan@coresystems.de> | 2009-09-25 21:59:57 +0000 |
---|---|---|
committer | Stefan Reinauer <stepan@openbios.org> | 2009-09-25 21:59:57 +0000 |
commit | 6bd571e060d65257c9a7ba0f87c991dbdac0b582 (patch) | |
tree | 34fd5def5a7b6dd586004fdd0b8a92e40336182c /src | |
parent | 0a181fd642d0c0780b4b88654d732cf625d1c862 (diff) | |
download | coreboot-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')
-rw-r--r-- | src/boot/selfboot.c | 1 | ||||
-rw-r--r-- | src/include/stdlib.h | 7 | ||||
-rw-r--r-- | src/include/string.h | 9 | ||||
-rw-r--r-- | src/lib/malloc.c | 24 |
4 files changed, 13 insertions, 28 deletions
diff --git a/src/boot/selfboot.c b/src/boot/selfboot.c index 6f2d282cf1..9f5fb5c440 100644 --- a/src/boot/selfboot.c +++ b/src/boot/selfboot.c @@ -394,6 +394,7 @@ static int build_self_segment_list( segment++; + // FIXME: Explain what this is for(ptr = head->next; ptr != head; ptr = ptr->next) { if (new->s_srcaddr < ntohl((u32) segment->load_addr)) break; diff --git a/src/include/stdlib.h b/src/include/stdlib.h index c3052bd209..63a316f186 100644 --- a/src/include/stdlib.h +++ b/src/include/stdlib.h @@ -12,13 +12,8 @@ #define MAX(a,b) ((a) > (b) ? (a) : (b)) #ifndef __ROMCC__ -extern void *malloc(size_t size); +void *malloc(size_t size); void free(void *ptr); - -/* Extensions to malloc... */ -typedef size_t malloc_mark_t; -void malloc_mark(malloc_mark_t *place); -void malloc_release(malloc_mark_t *place); #endif #endif /* STDLIB_H */ diff --git a/src/include/string.h b/src/include/string.h index c7902e1f95..1b092a6c2a 100644 --- a/src/include/string.h +++ b/src/include/string.h @@ -8,14 +8,11 @@ void *memcpy(void *dest, const void *src, size_t n); void *memmove(void *dest, const void *src, size_t n); void *memset(void *s, int c, size_t n); int memcmp(const void *s1, const void *s2, size_t n); +#ifndef __ROMCC__ int sprintf(char * buf, const char *fmt, ...); +#endif -// yes, linux has fancy ones. We don't care. This stuff gets used -// hardly at all. And the pain of including those files is just too high. - -//extern inline void strcpy(char *dst, char *src) {while (*src) *dst++ = *src++;} - -//extern inline int strlen(char *src) { int i = 0; while (*src++) i++; return i;} +// simple string functions static inline size_t strnlen(const char *src, size_t max) { 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); } |