On Thu, 17 Jun 1999, Sudipta Ghose wrote:
> After you unlock a memory handle, the pointer becomes invalid, as the system
> can move around the chunks. You actually need to store the memory handle in
> your structure. When you need the data just lock it and get your pointer.
Let me ask a question about this. You say 'the pointer becomes invalid'.
Is it just that the pointer variable becomes invalid after unlocking and
that the actual memory allocated is STILL valid, somewhere (referenced by
the handle)?
If so, when and/or where should that chunck be released to free up memory,
when no longer used? Does exiting a program release it? Is it even
necessary to manage the deletion of these chuncks?
> >I have a programming dilemma....
> >
> >I have defined an array
> >
> >typedef struct {
> > long value;
> > CharPtr text;
> >} MyType;
> >
> >MyType MyArray[10];
> >
> >To set the text property, I ...
> >
> >MyArray[0].value = 5;
> >VoidHand h = MemHandleNew(StrLen("Bob") + 1);
> >CharPtr s = MemHandleLock(h);
> >StrCopy(s, "Bob");
> >MyArray[0].text = s;
> >MemHandleUnlock(h);
> >
> >Now, I get away with that. But, when I want to use 'text' again
> >later...
> >
> >VoidHand h = FldGetTextHandle(someField);
> >CharPtr s = MemHandleLock(h);
> >StrCopy(s, MyArray[0].text); <<<<<<<<<<<<< Error: Accessing >unlocked
> >memory
> >MemHandleUnlock(h);
> >
> >I get the indicated error when using POSE (which is great, because it
> >picks ...............
> >
> >
> >Please! and Thanks!
> >
> >Jason
>
>
> ______________________________________________________
> Get Your Private, Free Email at http://www.hotmail.com
>
>
----------------------------------------------------
Shoot-to-Win
Protect the 2nd Amendment
----------------------------------------------------