[comp.sys.amiga.tech] Manx bug?

bennete@romana.cs.orst.edu (Erik J. Bennett) (11/16/88)

Why doesn't this work?

        objectTable = (struct objectStruct *)
                calloc((unsigned) 9000, 10);

It needs to allocate 90000 bytes.  It doesn't.  It allocate (90000-6553?)
bytes.  I think this is an overflow error.  My real question is, How do
I get around this barrier?

-Erik
bennete@romana.cs.orst.edu

cmcmanis%pepper@Sun.COM (Chuck McManis) (11/17/88)

In article <7392@orstcs.CS.ORST.EDU> (Erik J. Bennett) writes:
>Why doesn't this work?
>        objectTable = (struct objectStruct *)
>                calloc((unsigned) 9000, 10);
>It needs to allocate 90000 bytes.  It doesn't.  It allocate (90000-6553?)
>bytes.  I think this is an overflow error.

You guessed it, 9000 * 10 == 90,000 which is greater than 32,767 or whatever
2^15-1 is. 

> My real question is, How do I get around this barrier?

Several options, 
	1) Buy the Lattice compiler (:-))
	2) Compile with 32 bit ints specified and c32.lib
	3) Switch it to a call to AllocMem(9000L * 10L, MEMF_CLEAR); just
	   remember to call FreeMem(ptr, 9000L * 10L); before you exit.


--Chuck McManis
uucp: {anywhere}!sun!cmcmanis   BIX: cmcmanis  ARPAnet: cmcmanis@sun.com
These opinions are my own and no one elses, but you knew that didn't you.