diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-07-13 15:58:03 +0200 |
---|---|---|
committer | Andreas Baumann <mail@andreasbaumann.cc> | 2017-07-13 15:58:03 +0200 |
commit | 7162c5eed91a8e22a4b768110011df28bfd86455 (patch) | |
tree | 759c67681e777f9848a136ccc5ba9924fbb4db3e /tests | |
parent | ebb0e5f9fe6707133dacbe70f80831cd1aa5c974 (diff) | |
download | abaos-7162c5eed91a8e22a4b768110011df28bfd86455.tar.gz abaos-7162c5eed91a8e22a4b768110011df28bfd86455.tar.bz2 |
forgot to add test_malloc.c
remove buffer memory functions again (can be done with a simple cast in the caller)
Diffstat (limited to 'tests')
-rw-r--r-- | tests/libc/test_malloc.c | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/tests/libc/test_malloc.c b/tests/libc/test_malloc.c new file mode 100644 index 0000000..0f74fad --- /dev/null +++ b/tests/libc/test_malloc.c @@ -0,0 +1,24 @@ +#include "stdlib.h" +#include "string.h" + +#define HEAP_SIZE 128 * 1024 + +int main( void ) +{ + memory_manager_t memory_manager; + char buf[HEAP_SIZE]; + uint32_t heap_offset = (uint32_t)&buf; + size_t heap_size = HEAP_SIZE; + memory_manager_init( &memory_manager, heap_offset, heap_size ); + __stdlib_set_memory_manager( &memory_manager ); + + char *s; + char *s1 = "test_string"; + + s = (char *)malloc( strlen( s1 ) + 1 ); + size_t n = strlcpy( s, s1, strlen( s1 ) + 1 ); + if( n != 11 ) return 1; + if( strcmp( s, s1 ) != 0 ) return 1; + + return 0; +} |