> > --- "Mark A. Peters" wrote:
> > > I have tried using the Memory Manager functions for
> > > converting LocalID's to pointers for this, but they
> > > always return a NULL value when given even a valid dbID.

> > "Joe" wrote:
> > That's surprising.  In the following code, MemLocalIDToLockedPtr()
> > doesn't return NULL when I run it:
> >
> >   MemPtr p;
> >   LocalID local;
> >   UInt16 cardNo = 0;
> >
> >   local = DmFindDatabase( cardNo, "Memo Pad" );
> >   p = MemLocalIDToLockedPtr( local, cardNo );


--- "Mark A. Peters" <[EMAIL PROTECTED]> wrote:
> I'm trying to avoid DmFindDatabase.  

I only used DmFindDatabase to keep the example short.  The point was:
if you have a LocalID, MemLocalIDToLockedPtr() does not always return
0.

> For example, if an app initially discovers a database's 
> local ID via DmFindDatabase, stashes the ID in a record 
> in another database, quits, and then in some subsequent 
> invocation wants to use the stashed ID.  For that to be 
> safe, there has to be a way to validate the ID before 
> using it, but doing a MemLocalIDToLockedPtr returns NULL 
> in that context.

That is not correct.  There must be something wrong in either the code
that stashes the LocalID or the code that retrieves it.  You are
correct that you have to verify the LocalID because that app could have
been deleted between the time you obtain it and the time you retrieve
it.  

> Another poster pointed out that this won't work anyway, 
> because even if MemLocalIDToLockedPtr could be used to show that
> _some_ database has that ID, it won't necessarily be the same 
> database as it was originally.

Once you have a locked pointer to the database, it is easy to look at
it to see if it is the one you expected.

> I think now that using DmFindDatabase is unavoidable.

That may be, but I think it would have to be due to some other problem.
 For example, if the card was removable, then a LocalID obtained from
one card would be meaningless on another card.


__________________________________________________
Do You Yahoo!?
Yahoo! Tax Center - online filing with TurboTax
http://taxes.yahoo.com/

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

Reply via email to