Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utcs!oscvax!rico From: rico@oscvax.UUCP Newsgroups: net.micro.amiga Subject: Re: Pointers and AllocMem with Aztec Message-ID: <418@oscvax.UUCP> Date: Sat, 14-Jun-86 14:48:14 EDT Article-I.D.: oscvax.418 Posted: Sat Jun 14 14:48:14 1986 Date-Received: Sat, 14-Jun-86 16:22:40 EDT References: <1868@gitpyr.UUCP> Reply-To: rico@oscvax.UUCP (Rico Mariani) Organization: Ontario Science Centre, Toronto Lines: 52 Summary: In article <1868@gitpyr.UUCP> lbg@gitpyr.UUCP writes: > >I have spent all day trying to get AllocMem to work with my Aztec >compiler. I refuse to break down and use 32-bit integers. So >what am I supposed to do?? I have tried the code in the RKM, >which does not work. I have tried declaring AllocMem() as: > extern APTR long APTR > extern APTR * long * APTR * > struct APTR * char void > struct APTR char * void * > >None of them work. They all return a NULL pointer! BTW, I am not >as dumb as this looks. I knew that void would not work. But take a >look at Aztec's list of Amiga functions AND at the functions.h file >in the include directory -- they both list AllocMem as a void of all >things!! > >Thanks, dudes and dudettes! > >Lee Even though Lee asked for replies by mail I thought I'd post this as well just in case anyone else is stuck on this. Lee's problem is probably not how he is declaring Allocmem "char *AllocMem()" should be fine, with Aztec and 16 bit int's you must be careful how you *call* Allocmem or any other Resident library routine. The Amiga library routines all expect to be passed 32 bit objects i.e. "longs"... so don't use a call like this: wrong: foo = (struct bar *) Allocmem( sizeof(struct bar) ); correct: foo = (struct bar *) Allocmem( (long)sizeof(struct bar) ); be especially careful if you are using constants, if you want to allocate 10 bytes, don't say foo = Allocmem(10); say foo = Allocmem(10L); Another warning to novice Aztec users, if you compile with +l to get 32 bit ints, don't forget to link with the 32 bit library... use c32.lib and m32.lib they are on the second disk... That's all folks... -Rico ...{ihnp4|allegra|decvax|linus|watmath}!utzoo!oscvax!rico