From 5daab6ebb368eb4b113da858b9d9e12b8d670c52 Mon Sep 17 00:00:00 2001 From: Andrey Smirnov Date: Mon, 15 Oct 2018 10:00:18 -0700 Subject: dummy_malloc: Make use of PTR_ALIGN Drop explicit type cast and alignement code in favor of PTR_ALIGN Signed-off-by: Andrey Smirnov Signed-off-by: Sascha Hauer --- common/dummy_malloc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'common/dummy_malloc.c') diff --git a/common/dummy_malloc.c b/common/dummy_malloc.c index fa4f5d126c..ab67120180 100644 --- a/common/dummy_malloc.c +++ b/common/dummy_malloc.c @@ -30,11 +30,9 @@ void malloc_stats(void) void *memalign(size_t alignment, size_t bytes) { - unsigned long mem = (unsigned long)sbrk(bytes + alignment); + void *mem = sbrk(bytes + alignment); - mem = (mem + alignment) & ~(alignment - 1); - - return (void *)mem; + return PTR_ALIGN(mem, alignment); } void *malloc(size_t size) -- cgit v1.2.3