News for hackers. Stuff that matters.
Re:Memory management in C programs by pcwalton on Monday March 17, 2014 @03:19AM (#7413614)
On the other hand, if it's available, Valgrind will do a better job of catching uninitialized memory use if you use malloc instead of calloc.

(IMO, explicit initialization is better than just zeroing stuff out, because there's no guarantee that zeroed memory is valid. Especially when pointers are involved—dereferencing a null pointer in C is undefined behavior, so compilers are free to wreak havoc on any code that it can prove attempts to do that...)

Re:Memory management in C programs by thepumpkin1979 on Monday March 17, 2014 @03:26AM (#7413629)
That's true. I usually initialize the struct in the stack and then assign it to the pointer, then pass the pointer around.