- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Everyone,
I am using a cyble-224116-01 BLE module along with PSOC Creator 4.2. I include the stdlib.h library and my code compiles correctly, however, a call to calloc() or malloc() always returns null. I was wondering if I had to do anything special for it to work properly? Or is calloc() and malloc() not operable for my device?
Regards, Uziel.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you changed the heap size?
Go to Design Wide Resources > Systems Tab > Heap Size
Set it to 0x800 bytes for example, but you can allocate more based on your requirements.
After that let me know if the allocation works or not.
Regards,
Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Have you changed the heap size?
Go to Design Wide Resources > Systems Tab > Heap Size
Set it to 0x800 bytes for example, but you can allocate more based on your requirements.
After that let me know if the allocation works or not.
Regards,
Dheeraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you for your reply! I did try that and it was working returning me an address, I tried it again today, and get null returned once again. What can be the problem?
Regards,
Uziel.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using malloc() frequently and I never had any issues with it. As Dheera stated it is essential to set the heap size to the required amount (plus some extra for malloc's housekeeping). Only when there is no contiguous block of memory with the requires size is found NULL will be returned. When there are still any doubts, please post your complete project or a shortened version that shows the error so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Are you saying that the memory allocations are working sometimes and other times you receive a NULL? If this is the case, then it be specific to your project in which something is utilizing the heap and hence the allocation is failing.
Regards,
Dheeraj