Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cmcl2!yale!think.com!linus!agate!violet.berkeley.edu!lindahl From: lindahl@violet.berkeley.edu (Ken Lindahl 642-0866) Newsgroups: comp.sys.mac.programmer Subject: Re: Novice question about malloc() in Think C Message-ID: <1991Feb25.181503.16865@agate.berkeley.edu> Date: 25 Feb 91 18:15:03 GMT References: <1991Feb25.103404.3662@Neon.Stanford.EDU> <12591@helios.TAMU.EDU> Sender: usenet@agate.berkeley.edu (USENET Administrator) Distribution: usa Organization: University of California, Berkeley Lines: 34 In article <12591@helios.TAMU.EDU> n138ct@tamuts.tamu.edu (Brent Burton) writes: >Your code is perfect. > >I have had this problem too. I don't know what it is, but I looked at >the alloc.c file and tried to figure it out. It's been a while, but I think >it returns null if it can't get the block and also if the block requested >is under a certain size. Don't quote me on this nor flame me, people. > >What I did was to surround every malloc() call with this: > >#ifdef THINK_C > x = (char *)NewPtr((long)sizeof(char)); >#else > x = (char *)malloc(sizeof(char)); >#endif > >I also added this: >#ifdef THINK_C >#define free(x) DisposPtr((x)) >#endif > >This has relieved me of all problems. I'm going to, someday, examine the >THINK C code and try to fix it myself. > >BTW, I did add the 4.02 patches. > +----------------------+--------------------------+ > | Brent P. Burton | n138ct@tamuts.tamu.edu | > | Texas A&M University | Computer Science/Physics | > +----------------------+--------------------------+ Ken Lindahl lindahl@violet.berkeley.edu Advanced Technology Planning, Information Systems and Technology University of California at Berkeley