[comp.sys.ibm.pc] Arrays > 64k revisited

LC.YRS@forsythe.stanford.edu (Richard Stanton) (11/18/89)

SOmeone suggested that the Quick C malloc function would work with
arrays > 64k in the huge model.

I wrote a simple test program to try this, using either halloc/hfree
or malloc/free to allocate 100000 bytes, fill them with ASCII 0,
write the contents of the array to disk, then free the storage.

THe program worked fine using halloc. Using malloc, the allocation
seemed to go OK (NULL was not returned), but when the program ended,
I had to reboot as everything I tried to do produced a message
saying I was out of memory.

I looked in my manual, but it seemed less than informative.

Does anyone know the answer? Must you use halloc, or should malloc
work? If the latter, is there a bug in the free function?

Thanks

Richard Stanton

pstanton@gsb-what.stanford.edu

bmarsh@cod.NOSC.MIL (William C. Marsh) (11/18/89)

In article <5860@lindy.Stanford.EDU> LC.YRS@forsythe.stanford.edu (Richard Stanton) writes:
+SOmeone suggested that the Quick C malloc function would work with
+arrays > 64k in the huge model.

+I wrote a simple test program to try this, using either halloc/hfree
+or malloc/free to allocate 100000 bytes, fill them with ASCII 0,

+THe program worked fine using halloc. Using malloc, the allocation
+seemed to go OK (NULL was not returned), but when the program ended,
+I had to reboot as everything I tried to do produced a message
+saying I was out of memory.

Since malloc() only expects an unsigned, and since 100000 > 65535, malloc()
cannot be used to allocate a huge array.  halloc() expects a long...

Bill Marsh, Naval Ocean Systems Center, San Diego, CA
{arpa,mil}net: bmarsh@cod.nosc.mil
uucp: {ihnp4,akgua,decvax,dcdwest,ucbvax}!sdcsvax!nosc!bmarsh

"If everything seems to be coming your way, you're probably in the wrong lane."