Cool, thanks for the informative reply!

--Jim Preston

"Danny Epstein" <[EMAIL PROTECTED]> wrote in message
news:42460@palm-dev-forum...
>
> "James Preston" <[EMAIL PROTECTED]> wrote in message
> news:42442@palm-dev-forum...
> > But the question remains, what is the "proper" way to address the
> situation?
> > Is the extraneous call to DmGetRecord the best/most efficient way?
>
> In my opinion, yes. If DmResizeRecord didn't return a handle at all, this
> would seem completely natural. There used to be multiple storage heaps,
and
> DmResizeRecord would move the record to a different heap if necessary.
> That's why it returns a handle.
>
> > Assuming
> > that I know that I need to resize the record, and that I don't already
> have
> > a writable handle, is there a significant difference between:
> >
> > VoidHand nameRecHan = DmGetRecord(gNameDB, recIdx);
> > nameRecHan = DmResizeRecord( gNameDB, recIdx, . . .
> >
> > and this:
> >
> > VoidHand nameRecHan = DmResizeRecord(gNameDB, recIdx, . . .
> > nameRecHan = DmGetRecord(gNameDB, recIdx);
> >
> > If the resizing moves the record, the subsequent get should get the new
> > handle, right? So the two cases should be equivalent. Is one to be
> preferred
> > for some reason, or is it just a wash?
>
> They are, for all practical purposes, equivalent. However, the former is
> preferred because resizing a record is considered an "edit", just like
> DmWrite. One day, Palm OS may actually require the busy bit to be set
before
> a record is edited, either via DmWrite or via DmResizeRecord.
>
> > In one of the previous threads on this topic (thanks, Danny, for the
> > pointers to them), Jason Dawes included a code snippet in which he did a
> > get, then a release before the resize. It seems to me that the
intervening
> > release is unnecessary (not to mention self-defeating for overcoming the
> > assert in question). Doesn't DmReleaseRecord basically just unset the
busy
> > bit and optionally set the dirty bit?
>
> You are correct. Here's Jason's code for reference:
> > hRec = DmGetRecord(db, idx);
> > if (MemHandleSize(hRec) != size_needed)
> > {
> >     DmReleaseRecord(db, idx, false);
> >     hRec = DmResizeRecord(db, idx, size_needed);
> > }
> > ptr = MemHandleLock(hRec);
> > // do stuff
> > MemPtrUnlock(ptr);
> > DmReleaseRecord(db, idx, modified);
>
> On Palm OS 4.0 debug ROM's, the final call to DmReleaseRecord should
> complain when the record was resized. I'd just get rid of the first call
to
> DmReleaseRecord.
> --
> 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