Path: utzoo!attcan!uunet!munnari!murdu!strasser From: strasser@murdu.OZ (Mike Strasser) Newsgroups: comp.sys.mac.programmer Subject: LSC malloc returning garbage? Message-ID: <1451@murdu.OZ> Date: 9 Sep 88 05:10:41 GMT Reply-To: strasser@munnari.UUCP (Mike Strasser) Organization: Forestry Section, University of Melbourne Lines: 35 A month or so ago I posted a query about a program I'd ported to LSC which had run extensively under VAX/VMS, Unix and MS-DOS, and which was hanging. Today I've had more time to check it out, and it seems that malloc() is returning nonsense. It is called and the result cast to a pointer to a structure I use: Sp = (Species *) malloc( sizeof( Species ) ); I check for a NULL return, which does not happen. Instead, Sp is loaded the value 0x00000003 every time on repeated calls! I'm assuming that the statement: printf( "Sp is %08X\n", (unsigned long) Sp ); is OK as a way of checking the address (yes, I'm still using stdio). 00000003 is not a legal address is it? malloc() certainly shouldn't be returning the same value on repeated calls (no use of free() in between)? I have put in complete prototype checking (although in LSC 2.15 I had to write full prototypes for the library functions so the compiler would pass them!) but it has not helped. I still only have LSC 2.15 (waiting for 3.0). Any ideas? Have I missed something? --------------------------------------------------------------------------- Mike Strasser ACSnet, CSnet: strasser@murdu.oz Internet: strasser%murdu.oz@uunet.uu.net Forestry Section University of Melbourne Creswick, Victoria. 3363 Phone: (053) 45 2405 A u s t r a l i a +61 53 45 2405 ---------------------------------------------------------------------------