For casting return value of malloc(), it's not necessary.
There's no point to cast unless you are going to use C++ compiler.
But, I'd prefer
Code:foo_t *p; p = malloc( sizeof(foo_t) ); // prefer p = malloc( sizeof(*p) ); #define NELEM(array) ( sizeof(array) / sizeof( foo_t) ) // prefer #define NELEM(array) ( sizeof(array) / sizeof( (array)[0]) )