Use standard C library malloc and free in Ateml Studio?

Moderator: nferre

rayher
Posts: 4
Joined: Sun Jul 05, 2015 2:30 pm

Use standard C library malloc and free in Ateml Studio?

Wed Oct 14, 2015 7:56 am

hello world :

I am building a project on SAM4S Xplained to test SAM4S CPU. The environment is very simple:
1. install latest Atmel Studio,
2. create an ASF project, no OS of course,
3. write some code and encountered a problem...

I want to use standard C library memory functions, such as malloc realloc, and free functions, but i can not that even I #include stdlib.h.

The only thing i found is ...

Code: Select all

#include <alloca.h>
...
uint32_t * mptr = alloca( 256 );//
...
UNUSED( ptr ); //not sure this works well to replace free( ptr )
Does Ateml Studio support these functions? or i have to include any other header files?

thanks for your help :)
rayher
Posts: 4
Joined: Sun Jul 05, 2015 2:30 pm

Re: Use standard C library malloc and free in Ateml Studio?

Thu Oct 15, 2015 5:05 am

i got an answer here,

step 1. use ASF Wizard to install MEMBAG module.
stpe 2. in the code :

#include "membag.h"
membag_init( );//must do this first
pointer = membag_alloc( size_in_byte );//allocate
membag_free( pointer );//free the pointer

for your reference, thanks all :)

Return to “SAM9-based”

Who is online

Users browsing this forum: No registered users and 2 guests