Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!jarthur!uunet!unhd.unh.edu!pas From: pas@unhd.unh.edu (Paul A. Sand) Newsgroups: comp.sys.mac.programmer Subject: Re: malloc() in Think C programming on the Mac Message-ID: <1991Jan30.150113.7581@unhd.unh.edu> Date: 30 Jan 91 15:01:13 GMT References: <7335@drutx.ATT.COM> Reply-To: pas@unhd.unh.edu (Paul A. Sand) Distribution: comp Organization: University of New Hampshire Lines: 25 In article <7335@drutx.ATT.COM> ldg@drywit.ATT.COM writes: >I have Think C 3.0, and I get caught by this one every time. >Make sure the value you're passing to malloc() is an int (16 bits) >and not a long. There is another routine (mlalloc ?) which >takes a long. Think C 4.0.x's malloc() has more standard behavior than 3.0's: it expects a size_t (unsigned long) type argument. Of course, it's slightly trickier to pass an unsigned long than an int. It's made even trickier by Think's NON-standard sizeof operator, which returns type int (signed, of course), even in 4.0.x. Grrr. (Now, really, how hard would it have been to fix this?) Moral: protoype that sucker with the line: #include at the top of any file that has calls to malloc(). -- -- Paul A. Sand | -- University of New Hampshire | I ain't here on business, baby. -- uunet!unhd!pas | I'm only here for fun. -- pas@unhd.unh.edu |