From 5303acd6965335d17bd9115a4c6981e2bd373af6 Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Thu, 12 Apr 2007 18:35:11 +0000 Subject: [PATCH] Fix cosmetic issues and add some Doxygen comments (trivial). Signed-off-by: Uwe Hermann Acked-by: Uwe Hermann git-svn-id: svn://coreboot.org/repository/LinuxBIOSv3@277 f3766cd6-281f-0410-b1cd-43a5c92072e9 --- lib/malloc.c | 42 +++++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/lib/malloc.c b/lib/malloc.c index 9db64eca3b..32ab3c1edf 100644 --- a/lib/malloc.c +++ b/lib/malloc.c @@ -30,30 +30,40 @@ #if 0 #define MALLOCDBG(x...) #else -#define MALLOCDBG(x...) printk (BIOS_SPEW, x) +#define MALLOCDBG(x...) printk(BIOS_SPEW, x) #endif -/* instead of ldscript magic, just declare an array. The array - * will consume no bytes in the image, and it won't run into trouble - * the way the V2 allocator could. We do not provide zero'd memory. - * note that the execute-in-place code in top of flash is not allowed to call malloc, - * since we can't link this in to it. The FLASH-based code should always be dead simple. - * (in fact, it's not clear we need malloc at all any more -- we're doing our best to - * remove all usage of it -- the only real users were elfboot and lzma, and we have - * removed its usage in elfboot, and will try to remove its usage in lzma). +/* + * Instead of ldscript magic, just declare an array. The array will consume + * no bytes in the image, and it won't run into trouble the way the v2 + * allocator could. We do not provide zero'd memory. + * + * Note that the execute-in-place (XIP) code in top of flash is not allowed + * to call malloc(), since we can't link this in to it. The flash-based code + * should always be dead simple (in fact, it's not clear we need malloc() at + * all any more -- we're doing our best to remove all usage of it -- the + * only real users were elfboot and lzma, and we have removed its usage in + * elfboot, and will try to remove its usage in lzma). */ -#define HEAPSIZE (256*1024) +#define HEAPSIZE (256 * 1024) static unsigned char heap[HEAPSIZE]; static unsigned char *free_mem_ptr = heap; static unsigned long freebytes = HEAPSIZE; +/** + * Allocate 'size' bytes of memory. The memory is not zero'd. + * If not enough memory is available, just die. + * + * @param size The number of bytes to allocate. + * @return A pointer to the allocated memory. + */ void *malloc(size_t size) { void *p; - MALLOCDBG("%s Enter, size %d, free_mem_ptr %p\n", - __FUNCTION__, size, free_mem_ptr); + MALLOCDBG("%s Enter, size %d, free_mem_ptr %p\n", + __FUNCTION__, size, free_mem_ptr); if (size > freebytes) { die("Out of memory.\n"); @@ -70,7 +80,13 @@ void *malloc(size_t size) return p; } +/** + * Free the specified memory area. + * This is a no-op, we don't care about freeing memory. + * + * @param where A pointer to the memory area to free. + */ void free(void *where) { - /* Don't care */ + /* Don't care. */ }