> > > --- "Mark A. Peters" wrote:
> > > > [MemLocalIDToLockedPtr done on a database ID yields NULL]

> > > "Joe" wrote:

> [...] That is not correct.  There must be something wrong in either the
code
> that stashes the LocalID or the code that retrieves it.

Yep, you're right: I had the order of the inputs to MemLocalIDToLockedPtr
reversed!

> > 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.

Now that I'm using MemLocalIDToLockedPtr properly, I tried my original
experiment (do MemLocalIDToLockedPtr on a dbID that doesn't correspond to a
database) again.  This yielded a non-null pointer and no runtime error, but
the pointer pointed to somewhere in the middle of some other database's
header.

This means that heuristics will have to be used to verify that a dbID still
corresponds to the same database, like requiring a match on the database
name, creator ID and db type.  This isn't guaranteed to work, though, since
there is a non-zero possibility that random bytes in memory will pass such a
test.  It also makes the code dependent on the structure of a database
header.

Mark Peters



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

Reply via email to