Re:Calloc or Malloc? Any thoughts?
by orib on Wednesday August 13, 2008 @11:18AM
(#275037)
First: Lose the cast. It's not needed in C, clutters the code, and can hide real problems (like implicit declarations of the functions -- this can cause crashes on 64-bit architectures). A void* exists solely so it can be assigned to any type* without casts. It's useless for any other purpose.
Yes, they are effectively the same. I'd suspect that on most systems (glibc, certainly) calloc more or less does:
Re:Calloc or Malloc? Any thoughts?
by sysop073 on Thursday August 14, 2008 @02:07AM
(#275869)
He didn't actually say he was using C, and I always include the cast. It's more portable, and doesn't really clutter the code since everyone is used to seeing that exact expression
Yes, they are effectively the same. I'd suspect that on most systems (glibc, certainly) calloc more or less does: