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.

HTH.

-Sugho-

>Date: 16 Jun 1999 21:40:43 -0700
>From: Jason Garrett <[EMAIL PROTECTED]>
>Subject: When to lock a chunk?
>
>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

Reply via email to