From 22628b176d993daa3fb770ed94250a227ced1ff9 Mon Sep 17 00:00:00 2001 From: Andreas Baumann Date: Tue, 1 Aug 2017 13:39:16 +0200 Subject: memory_manager_allocate takes an alignment parameter now added C11 aligned_alloc to stdlib --- src/libc/stdlib.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/libc/stdlib.c') diff --git a/src/libc/stdlib.c b/src/libc/stdlib.c index 4fea56e..1316152 100644 --- a/src/libc/stdlib.c +++ b/src/libc/stdlib.c @@ -86,7 +86,7 @@ static memory_manager_t *stdlib_memory_manager = NULL; void *malloc( size_t size ) { - return memory_manager_allocate( stdlib_memory_manager, size ); + return memory_manager_allocate( stdlib_memory_manager, size, 1 ); } void free( void *p ) @@ -94,7 +94,18 @@ void free( void *p ) memory_manager_deallocate( stdlib_memory_manager, &p ); } +void *aligned_alloc( size_t alignment, size_t size ) +{ + if( size % alignment != 0 ) { + kernel_panic( "Illegal call to 'aligned_alloc' with size %d and alignment %d!", + size, alignment ); + } + + return memory_manager_allocate( stdlib_memory_manager, size, alignment ); +} + void __stdlib_set_memory_manager( memory_manager_t *memory_manager ) { stdlib_memory_manager = memory_manager; } + -- cgit v1.2.3-54-g00ecf