> Does is make a difference if database.stringP is declared const Char*??
no.. let me explain.
> >> stringP = GetLockedPtr (whateverField);
> >> if (stringP)
> >> {
> >> database.stringP = stringP;
at this point, stringP is valid, as.. it is pointing to a locked
chunk of memory. both database.stringP and stringP hold the same
value (ie: point to the same locked chunk of memory)
> >> MemPtrUnlock (stringP);
at this point, the operating system "unlocks" the chunk, and
the area pointed to by stringP is now invalid. if MemPtrUnlock
sets it to NULL or whateverm its irrelevant to the issue here.
database.stringP contains a value, and that hasn't changed.
but.. the minute you try and use it, the operating system
says "wtf? the handle this pointer is referencing has gone bye-bye"
= crash.
> > In general I think it's advised that you store handles rather than pointers
> > in database records and even these are questionable since they might be
> > referred to after a restart when that handle might no longer be allocated
> > (although since I've never tried to do this I can't state that it's not
> > valid).
i have done this type of stuff for ages, and.. this is what you do.
store everything as a Handle.. and *if* you want it.. you do something
like this:
...
Char *p = (Char *)MemHandleLock(handle);
... use p
MemPtrUnlock(p);
...
the "handle" is what you should have stored somewhere. lock and unlock
it as you use it - then you wont have any problems.
// az
[EMAIL PROTECTED]
http://www.ardiri.com/ <--- free games!
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/