Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!udel!haven!mimsy!mojo!russotto From: russotto@eng.umd.edu (Matthew T. Russotto) Newsgroups: comp.sys.mac.programmer Subject: Re: I can't malloc Message-ID: <1990Aug21.200130.13084@eng.umd.edu> Date: 21 Aug 90 20:01:30 GMT References: <14983@csli.Stanford.EDU> Sender: news@eng.umd.edu (The News System) Organization: College of Engineering, Maryversity of Uniland, College Park Lines: 19 In article <14983@csli.Stanford.EDU> dmr@csli.Stanford.EDU (Daniel M. Rosenberg) writes: >calloc and malloc don't seem to return anything, so I figured I did it wrong. >I then said to me, hey, why not be Mac-like, and try NewHandle? Which >I did, and got a pointer to a pointer to some area of memory, which I promptly >filled up (I asked for 5000 * 2 bytes and filled it with 5000 words) >and which promptly crashed the machine. If someone is collecting a list of frequently asked questions, this one is at the top. To use malloc and calloc in Think C, you must #include . To use the Mac memory routines, #include . The problem you are running into is that malloc, calloc, NewHandle, and NewPtr all expect a long and return a pointer, and that by default, Think C will pass an int (calloc and malloc only) and return an int (all of them). -- Matthew T. Russotto russotto@eng.umd.edu russotto@wam.umd.edu ][, ][+, ///, ///+, //e, //c, IIGS, //c+ --- Any questions?