Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!helios!tamuts!n138ct From: n138ct@tamuts.tamu.edu (Brent Burton) Newsgroups: comp.sys.mac.programmer Subject: Re: Novice question about malloc() in Think C Message-ID: <12591@helios.TAMU.EDU> Date: 25 Feb 91 17:34:33 GMT References: <1991Feb25.103404.3662@Neon.Stanford.EDU> Sender: usenet@helios.TAMU.EDU Distribution: usa Organization: Texas A&M University Lines: 28 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 | +----------------------+--------------------------+