INF: Cannot Allocate More Than 64K with Calloc()

ID Number: Q58933

5.10 6.00 6.00a 6.00ax 7.00 | 5.10 6.00 6.00a

MS-DOS | OS/2

Summary:

In Microsoft C versions 5.1, 6.0, 6.0a, 6.0ax, and C/C++ version 7.0,

although calloc() takes two unsigned integers as parameters, it does not

allocate more than 64K. Calloc() determines the size you are attempting

to allocate by multiplying the two arguments. If the size is greater

than 64K, it will return NULL.

The confusion typically arises because, with malloc(), it is

impossible to ask for more than 64K because of the size of the

argument malloc() takes. Malloc() takes an unsigned int as an

argument; therefore, the largest number you can pass it cannot be

greater than 64K. This is not the case with calloc(), and the

assumption could be made that you CAN allocate more than 64K with

calloc(). This is not the case.

Additional reference words: 5.10 6.00 6.00a 6.00ax 7.00