summaryrefslogtreecommitdiff
path: root/src/libc/stdlib.c
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-08-01 13:39:16 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-08-01 13:39:16 +0200
commit22628b176d993daa3fb770ed94250a227ced1ff9 (patch)
tree9d86b11a0cf23aa87054ebf95616550cdda9d1a0 /src/libc/stdlib.c
parent40a9f29c441cbae2d574c075579c811d07e892e7 (diff)
downloadabaos-22628b176d993daa3fb770ed94250a227ced1ff9.tar.gz
abaos-22628b176d993daa3fb770ed94250a227ced1ff9.tar.bz2
memory_manager_allocate takes an alignment parameter now
added C11 aligned_alloc to stdlib
Diffstat (limited to 'src/libc/stdlib.c')
-rw-r--r--src/libc/stdlib.c13
1 files changed, 12 insertions, 1 deletions
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;
}
+