The key difference is that asking for type simply to take sizeof(type) can be error prone (and the errors can be hard to debug) and is redundant when the size of the type can be determined by taking sizeof() of a variable known to be of the same type in the structure passed to us. It is also sweeter syntax, as an aside.
Also, why do we use trust malloc()/realloc() to always succeed ?
For instance, the following :
can be rewritten as :
The key difference is that asking for
type
simply to takesizeof(type)
can be error prone (and the errors can be hard to debug) and is redundant when the size of the type can be determined by takingsizeof()
of a variable known to be of the same type in the structure passed to us. It is also sweeter syntax, as an aside.Also, why do we use trust
malloc()
/realloc()
to always succeed ?