Zzingoh Posted December 15, 2020 Share Posted December 15, 2020 Hi, I have an Vitis application that is using calloc and free frequently. Calloc is working fine just one time and second time it returns NULL Do you have any idea on this? Here is my design information. On Vivado, I am using 64KB local memory when I created microblaze In Vivado - Basys3 - 64KB local memory In Vitis - standalone application, here are two functions. So Set() called first and then Get() called as a pair. 1st pair : Set()->Get() works 2nd pair : Set()-> falied due to cmalloc error - Null returned!!! void Get() { if (get.body) free(get.body); } void Set() { pBody = (u8 *)calloc(len, sizeof(u8)); if (!pBody) { xil_printf("cmalloc error - NULL returned \r\n"); return; } get.body = pBody; } Is this because of no available heap size? how to check and increase it? Thanks Link to comment Share on other sites More sharing options...
artvvb Posted December 18, 2020 Share Posted December 18, 2020 @Zzingoh Assuming that you are doing a baremetal design, you can find the heap size (and stack size) in the application project's linker script file, lscript.ld. Thanks, Arthur Link to comment Share on other sites More sharing options...
Question
Zzingoh
Hi,
I have an Vitis application that is using calloc and free frequently.
Calloc is working fine just one time and second time it returns NULL
Do you have any idea on this?
Here is my design information.
On Vivado, I am using 64KB local memory when I created microblaze
In Vivado - Basys3 - 64KB local memory
In Vitis - standalone application, here are two functions. So Set() called first and then Get() called as a pair.
1st pair : Set()->Get() works
2nd pair : Set()-> falied due to cmalloc error - Null returned!!!
void Get()
{
if (get.body)
free(get.body);
}
void Set()
{
pBody = (u8 *)calloc(len, sizeof(u8));
if (!pBody)
{
xil_printf("cmalloc error - NULL returned \r\n");
return;
}
get.body = pBody;
}
Is this because of no available heap size? how to check and increase it?
Thanks
Link to comment
Share on other sites
1 answer to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.