Path: utzoo!attcan!uunet!yale!husc6!endor!singer From: singer@endor.harvard.edu (Rich Siegel) Newsgroups: comp.sys.mac.programmer Subject: Re: LSC malloc returning garbage? Message-ID: <327@husc6.harvard.edu> Date: 11 Sep 88 01:06:11 GMT References: <1451@murdu.OZ> Sender: news@husc6.harvard.edu Reply-To: singer@endor.UUCP (Rich Siegel) Organization: Symantec/THINK Technologies, Bedford, MA Lines: 31 In article <1451@murdu.OZ> strasser@munnari.UUCP (Mike Strasser) writes: > >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 You probably need to pre-declare malloc(): void * malloc()); before you call it. Otherwise, the compiler will assume that malloc() returns an int instead of a pointer-type, and only that int gets assigned to your pointer variable. Odds are, the high word if the result is a 3.... R. Rich Siegel Staff Software Developer THINK Technologies Division, Symantec Corp. Internet: singer@endor.harvard.edu UUCP: ..harvard!endor!singer Phone: (617) 275-4800 x305 Any opinions stated in this article do not necessarily reflect the views or policies of Symantec Corporation or its employees.