I'd guess that this is probably history and predates the times where C had prototypes for functions. At these times without a prototype the arguments basically had to be int
, the typedef
size_t
probably wasn't even yet invented. But then INTMAX
is the largest chunk you could allocate with malloc
and splitting it up in two just gives you more flexibility and allows you to allocate really large arrays. Even at that times there were methods to obtain large pages from the system that where zeroed out by default, so efficiency was not so much a problem with calloc
than for malloc
.
Nowadays, with size_t
and the function prototype at hand, this is just a daily reminder of the rich history of C.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…