to store a calloc in a pointer

If you have a simple question and just want an answer.
themech
Member++
Posts: 17
Joined: Tue Sep 23, 2014 12:17 pm

to store a calloc in a pointer

Post by themech »

I am trying to allocate data in the memory and store the pointer in a variable: 

int * unsafe pdata = (int *)calloc(1, sizeof(int));

But I always get a warning like this:

C36258: pointer cast to type of larger alignment

Which alignment is used in xc, and how do i implement malloc/calloc right?

User avatar
sethu_jangala
XCore Expert
Posts: 589
Joined: Wed Feb 29, 2012 10:03 am

Post by sethu_jangala »

That message is just a warning and, in this case, it is safe to ignore. The memory returned by calloc is 32bit aligned so the cast is safe.

For the benefit of others.Posting the answer in Q&A section, which has been resolved in the following post : http://www.xcore.com/forum/viewtopic.php?f=26&t=3048