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.
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?
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.
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.