Tom wrote:
Ok, the way I understand this is when I create a record using the
Palm database manager it gives me a chunk of memory.

When you call DmNewRecord() it creates a chunk of memory and then
gives you a MemHandle that refers to that memory.  The memory is
in the storage heap so that if you lock the handle (with
MemHandleLock()) and get a pointer, you can read the memory
directly but you must use DmWrite() to write to it.  So, it's
not just a chunk of regular memory.

This I can do with whatever I want and then save it back? Now I
am a little fuzzy on this part, it also says that the record can
have a forwarding record? Is this the NEXT record? Or am I just
reading this wrong?

What is the "it" that says this about a forwarding record?  I have
read some but probably not all of the Palm API docs on this subject
and I haven't seen anything about a forwarding record, so I can't
comment on what that might mean.  I can, however, say, that I don't
know what a forwarding record is and I've been able to successfully
use Palm databases without knowing what it is, so it must not be
important.

The other question I have is, if I have a record already stored
with information (all set lengths) and I change one of these
lengths (say a username from Joe to Johnny) which is larger.

Now do I have to reallocate new memory due to these changes
and delete the old record and re-save it? If so then if this
is the first record and I do a save won't this record now
become the last record???

You don't have to allocate a new record.  You can resize the
existing record with DmResizeRecord().  Or you can create a
new record with DmNewRecord(), then copy the data, then delete
the old record.

Each approach has its advantages.  The first approach uses
less temporary memory and could be slightly more efficient.
The second approach could be useful if you have very important
data and you want to ensure that there's always a valid copy
of the data in the database at all times.  The second approach
could also be helpful if you need to read from the old record
to create the new record.

If you do create another new record and then copy to it, you
can insert it at the same position as the old one.  So, for
example, if the old record is at position 15, you pass 15 to
DmNewRecord() (or DmAttachRecord() if you created the storage
with DmNewHandle()).  The it will be the new record #15, and
what was record #15 will be record #16.  So when you go to
delete the old record (assuming you delete after rather
than before), you need to delete record #16.

Basically, think of a Palm database as conceptually a big
array of MemHandles which are handles to memory in the storage
heap.  You can insert a MemHandle into the list, you can delete
one, you can sort them, etc.

  - Logan

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

Reply via email to