Dear Keith, Dan and Greg,
Thank you very much for your response. I know what I should do then.
philip
Greg Winton wrote:
> At 04:11 PM 6/9/99 +0800, you wrote:
> >Suppose,
> >// dbRef is the database with 100 records, each of size 15k
> >for (i=0;i<100;i++)
> > {
> > recordH=DmQueryRecord(dbRef,i);
> > recordPtr=MemHandleLock(recordH);
> > myPtr[i]=(CharPtr)recordPtr;
> > MemHandleUnlock(recordH);
> > }
> >
> >Is it very unsafe to access myPtr after this FOR loop? Is the answer of
> >this question depends on whether I would have to create new record or
> >increasing the size of record after this FOR loop? OR, is the answer of
> >the question depends on whether I have plenty of free storage heap
> >memory or not?
> >
> It is unsafe to access myPtr [i] after you have called MemHandleUnlock ( ).
> Once you unlock a memory handle, the memory the pointer is no longer
> guaranteed to point to that memory.
>
> >I think I would just leave MemHandleUnlock to happen when I exit my
> >application. Am I correct?
> >
> You want to lock memory only so long as you absolutely have to. When you
> are done with the pointer, unlock it and let the OS do its job.
>
> Hope this helps!
>
> Greg
>
> Greg Winton
> Bachmann Software and Services, LLC
> mailto:[EMAIL PROTECTED]
> http://www.bachmannsoftware.com
> Software Development for Handheld & Mobile Computing, Windows and the Internet
> Home of Bachmann Print Manager, the only graphical printing solution for
> the Palm Computing Platform