"Roberto Amorim" <[EMAIL PROTECTED]> wrote in message
news:10340@palm-dev-forum...
> I have pointer and I allocated space using MemPtrNew.
>
> static char **PtrPed;
> PtrPed=MemPtrNew(100);

You probably want something like (NumRegsPed * sizeof(char *)) instead of
100.

> Now, I need fill up with code key of my records.
> I needed to allocate space for each member again to use StrCopy?

Yes. You've allocated an array of pointers.

> for (i=0;i<NumRegsPed;i++)
>    {
>    HandlePed = DmQueryRecord(PVPed, i);
>    RegPed=MemHandleLock(HandleTemp);
>    UnPackPedido(RegPed, MemHandleLock(HandlePed));
>    if (StrCompare(RegCli->CGCCli,RegPed->CgcCpf)==0)
>       {
>       PtrPed[i]=(CharPtr)MemPtrNew(10); // Now I allocate
> again***************
> //************************************
> //
> //      If I just use PrtPed[i]=RegPed->NrPed I will damage my db when I
free the
> //      pointer?

No, but you'll have to keep the record's handle locked. You can't
dereference a pointer once it's handle is unlocked.

> //      If I free PtrPed I'm doing for all of its members?

No. Freeing an array of pointers won't iterate through the pointers. You'll
have to do that yourself.

> //******************************
>       StrCopy(PtrPed[i],RegPed->NrPed);
>       iNumPedCli++;
>    }
>    MemHandleUnlock(HandlePed);
>    MemHandleUnlock(HandleTemp);
> }
> MemHandleFree(HandleTemp);
> LstSetListChoices(LstPed, PtrPed, iNumPedCli);

You're effectively copying the entire database into the dynamic heap. This
probably isn't a good idea. Dynamic heap space is limited, so you should try
to work directly with the database. If you have to, copy a single record to
the dynamic heap while it's being edited.

Hope this helps.
--
Danny Epstein
OS Engineer, Palm Inc.


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to