Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!romp!auschs!awdprime!engshien.austin.ibm.com!eswu From: eswu@engshien.austin.ibm.com (Eng-Shien Wu) Newsgroups: comp.sys.mac.programmer Subject: Re: malloc() in Think C programming on the Mac Message-ID: <4978@awdprime.UUCP> Date: 26 Jan 91 00:13:54 GMT References: <1991Jan24.060336.12684@nlm.nih.gov> Sender: news@awdprime.UUCP Reply-To: eswu@ub.cc.umich.edu Distribution: comp Organization: IBM Austin, TX Lines: 22 [In article 12426, werner@bio.NLM.NIH.GOV (Craig Werner) asks why he gets NULL when he calls malloc() in THINK C.] The problem lies in the THINK C libraries. In their implementation of malloc, they have an if-test to see if you are allocating more than 16K of memory. If so, it just returns NULL with no check of available system resources. [Pretty arbitrary. Also, this restriction is not mentioned in their docs. Fortunately, they supply source code to their libraries.] I've been using NewPtr() and NewHandle() instead of malloc(). Does any ``real'' Mac programmer know what we are really suppose to use, especially for programs that really beat on garbage collectors? -- Eng-Shien Wu, "My views only, does not represent IBM's" X Windows, IBM Advanced Workstations Div, Austin, Texas Internet: eswu@ub.cc.umich.edu VNET: ausvmq(engshien)