Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!sdd.hp.com!decwrl!fernwood!oracle!news From: sstorkel@dvlseq.oracle.com (Scott Storkel) Newsgroups: comp.sys.mac.programmer Subject: Re: Resource Fork data storage--related question Message-ID: Date: 23 Jul 90 23:49:56 GMT References: <1990Jul17.172044.20361@Neon.Stanford.EDU> <1715MAYER-A@RICEVM1> <1990Jul22.230744.14761@Neon.Stanford.EDU> <19475@orstcs.CS.ORST.EDU> Sender: news@oracle.com Distribution: na Organization: Oracle Corporation, Belmont, CA Lines: 25 In article <19475@orstcs.CS.ORST.EDU> boerned@mist.CS.ORST.EDU (Dan Boerner) writes: >In his response Philip asks > >> Why not store the result of GetResource directly into the array? > >I believe the answer is that GetResource allocates memory for a resource only >once. The second time you call GetResource, it will return a handle to the >same memory block as it did the first time. Therefore, you must copy the >results of GetResource into a different block of memory for each different >copy of the resource you want. > Sorry for jumping into the middle of this discussion. Did somebody say something about multiple uses? The correct way to do what Philip suggests is to call DetachResource and then use the handle as a handle to an array. By calling DetachResource, you make the resource manager "forget" about the resource. That way you could call GetResource again to get a new copy of the resource (don't know why you'd want to do that) and the resource manager won't release the memory out from under you (if you close the resource file for example). -- Scott Storkel