"Richard.Johnstone" <[EMAIL PROTECTED]> wrote in message
news:45743@palm-dev-forum...
> However I run out of memory and when I reset, it shows all the records
still
> in there.

Are you running out of storage heap or dynamic heap. How do you know you're
running out of space? Try using "hd 1", "dir 0", and "listrecords <access
ptr>" in the console when you run out of space.

> Does DMRemoveRecord just flag things for deletion?? It say in the manual
it
> diposes of the chunk.

That's correct. DmDeleteRecord flags the record for deletion. DmRemoveRecord
actually deletes it.

You quoted a snippet of your code which didn't include the loop. You might
have a problem with modifying the collection you're iterating over; I can't
tell.

>       recH = DmQueryNextInCategory(PackedDB,&index, dmAllCategories);
...<snipped>...
>       Error = DmRemoveRecord(PackedDB, 0);

You're calling DmQueryNextInCategory, which can (but shouldn't in this case)
tweak the index, but then you're using index zero in your call do
DmRemoveRecord. I don't see where you set index.

If you're not using DmDeleteRecord, you won't have any deleted records, so
using DmQueryNextInCategory with dmAllCategories is a little odd. Your
records should have record numbers starting at zero and going up to
DmNumRecords() - 1. You can just use DmQueryRecord to access them, starting
at the beginning or the end. Something like this:

while (1)
{
    h = DmQueryRecord(PackedDB, 0);
    if (h == NULL) break;
    ...create a record at the end of the new database using h...
    DmRemoveRecord(PackedDB, 0);
}

- OR -

index = DmNumRecords(PackedDB);
while (index > 0)
{
    index--;
    DmQueryRecord(PackedDB, index);
    ...create a record at the beginning of the new database using h...
    DmRemoveRecord(PackedDB, index);
}

This code hasn't been run through a compiler, so treat it as pseudo-code.
And don't follow my example when it comes to (not) handling errors. :)
--
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