[comp.sys.mac.programmer] THINK C and Mac

CAH0@bunny.gte.com (Chuck Hoffman) (10/20/90)

I'm using THINK C to open a resource on a file.  When the resource fork is 
large, as on an application program file, I get a system error code -108, 
memFullErr, Not enough memory in heap zone.  When I try to do a printf on 
a subsequent statement, everything stops.  The code looks like this:

intmyFileID;               /* returned ID number of file   */
intResErrorNo;             /* return code from error routine*/
Str255  myfilnam;            /* file name in Pascal format   */
   .
     .
     .
myFileID = OpenResFile (myfilnam); /* open the resource file*/
ResErrorNo = ResError();
PtoCstr((char *) myfilnam);        /* convert to C string for display*/
printf("\nThe file name is: %s",myfilnam);

*** bomb ***

Can anyone explain / help?  I'm new to Mac programming.
-Chuck


- Chuck Hoffman, GTE Laboratories, Inc.  |  I'm not sure why we're here,
cah0@bunny.gte.com                       |  but I am sure that while we're
Telephone (U.S.A.) 617-466-2131          |  here, we're supposed to help
GTE VoiceNet: 679-2131                   |  each other.
GTE Telemail: C.HOFFMAN                  |

d88-jwa@dront.nada.kth.se (Jon W{tte) (10/20/90)

The resource file may have some resources with the "preload"
bit set, which makes the resource manager instantly read them
in at open. You can avoid this by calling SetResLoad(FALSE)

Remember to SetResLoad(TRUE) again. Read IM about this.

Happy hacking,

						h+
h+@nada.kth.se
"Moof!(tm)"

roland@dna.lth.se (Roland Mansson) (10/20/90)

In article <9917@bunny.GTE.COM> CAH0@bunny.gte.com (Chuck Hoffman) writes:
>I'm using THINK C to open a resource on a file.  When the resource fork is 
>large, as on an application program file, I get a system error code -108, 
>memFullErr, Not enough memory in heap zone.  When I try to do a printf on 
>a subsequent statement, everything stops.  The code looks like this:
>
I don't know if this is your problem, but there is a nasty bug with
OpenResFile. Check TN 232. Basically, you have to call StripAddress on
the pointer to the file name. Not very obvious :-) :-)

-- 
Roland Mansson, Lund University Computing Center, Box 783, S220 07 Lund, Sweden
Phone: +46-46107436   Fax: +46-46138225   Bitnet: roland_m@seldc52
Internet: roland.mansson@ldc.lu.se   or   roland.mansson%ldc.lu.se@uunet.uu.net
UUCP: {uunet,mcvax}!sunic!ldc.lu.se!roland.mansson    AppleLink: SW0022