Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!gatech!udel!haven!mimsy!mojo!russotto From: russotto@eng.umd.edu (Matthew T. Russotto) Newsgroups: comp.sys.mac.programmer Subject: Re: Novice question about malloc() in Think C Message-ID: <1991Feb26.020133.3926@eng.umd.edu> Date: 26 Feb 91 02:01:33 GMT References: <1991Feb25.103404.3662@Neon.Stanford.EDU> <12591@helios.TAMU.EDU> <5813@husc6.harvard.edu> Sender: news@eng.umd.edu (C-News) Distribution: usa Organization: College of Engineering, Maryversity of Uniland, College Park Lines: 24 In article <5813@husc6.harvard.edu> siegel@endor.UUCP (Rich Siegel) writes: > > This is not correct. The original poster's problem is that he needs >to include the appropriate header file which contains the prototype for >malloc, namely . The problem is in code which assumes that pointers >and ints are the same size, and which therefore doesn't prototype a return-type >for malloc. The result is the returned pointer is invalid. Including >or adding a "extern char *malloc()" declaration will suffice to fix this >problem. > >R. > Rich Siegel Symantec Languages Group Internet: siegel@endor.harvard.edu > >"I was just trying to be subtle. That's my job, isn't it?" Wouldn't extern char *malloc(long); be better-- I have had at least as many problems messing up the parameter type-- if the return type is wrong at least you often get an error. (Of course, including the headers is the best way) -- Matthew T. Russotto russotto@eng.umd.edu russotto@wam.umd.edu .sig under construction, like the rest of this campus.