MSC 6.0 malloc question

JT Anderson jta at locus.com
Thu Jun 7 13:59:03 AEST 1990


You cannot allocate 65535 bytes using malloc or its brethren in Microsoft
C.  The largest chunk you can allocate is somewhere in the neighborhood
of 65520 bytes, and you can be sure the pointer will NOT have a 0 offset.

If you need to allocate a full segment there are a couple of choices.  You
can use halloc, which will return a pointer with a zero offset under most
circumstances.  The offset will certainly be 0 if you pass a size parameter
of 1.  However, this is not guaranteed by the function definition.

Another choice is to use the _dos_allocmem function.  This function will
provide you with a segment value, which you must use to construct a far
pointer.



More information about the Comp.lang.c mailing list