5 ms·
What observable difference is there between malloc(0) and malloc((size_t)0)?
by dhhwrongagain 6y ago
What observable difference is there between malloc(0) and malloc((size_t)0)?
- saagarjha 6y agoNone.
- dhhwrongagain 6y agoI agree but he said the types needed to be corrected. As far as I know the types were already correct.
- DougGwyn 6y agoThe argument "0" is not automatically converted to the right type unless there is a prototype in scope. It isn't as important in this case because it is highly likely that the appropriate prototype has been #included, but it is a bigger deal if we're dealing with arguments for a variadic function. Anyway, it's good to be reminded what the declared types are.
- dhhwrongagain 6y agoAre you serious? Of course the question comes with the reasonable assumption that the proper declaration has been made especially since it’s a well known standard function. Additionally memset() is not a variadic function. You said the types were corrected, you didn’t say you were reminding about the declaration types. The types were correct from the start.