From: Simon Glass Date: Tue, 8 Sep 2015 23:52:46 +0000 (-0600) Subject: malloc_simple: Add debug() information X-Git-Tag: v2016.01-rc1~298^2~59 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=836ac74c29b04a18fc51c92a18e383cf18a36d63;p=oweals%2Fu-boot.git malloc_simple: Add debug() information It's useful to get a a trace of memory allocations in early init. Add a debug() call to provide that. It can be enabled by adding '#define DEBUG' to the top of the file. Signed-off-by: Simon Glass Reviewed-by: Bin Meng --- diff --git a/common/malloc_simple.c b/common/malloc_simple.c index c74586376d..dd1119f8cf 100644 --- a/common/malloc_simple.c +++ b/common/malloc_simple.c @@ -19,10 +19,13 @@ void *malloc_simple(size_t bytes) void *ptr; new_ptr = gd->malloc_ptr + bytes; + debug("%s: size=%zx, ptr=%lx, limit=%lx\n", __func__, bytes, new_ptr, + gd->malloc_limit); if (new_ptr > gd->malloc_limit) return NULL; ptr = map_sysmem(gd->malloc_base + gd->malloc_ptr, bytes); gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr)); + return ptr; } @@ -37,6 +40,7 @@ void *memalign_simple(size_t align, size_t bytes) return NULL; ptr = map_sysmem(addr, bytes); gd->malloc_ptr = ALIGN(new_ptr, sizeof(new_ptr)); + return ptr; }