Here is the code.
Still can't figure this one out.
I don't know for sure that I am running out of space but when it crashes I
reset and it shows the initial database and the new database and the space
they take up puts me to the limit. It must be a space issue as it works in
4MB mode in the emulator.
static void ReadDeletePackedDB() {
UInt16 index = 0;
Err Error;
VoidPtr recH;
PackedStructurePtr recP;
PackedStructureType currRec;
int i;
int stringStart = 0;
UInt16 NumberArrayRecs = 0;
UInt16 NumRecords = 0;
while(true) {
recH = DmQueryNextInCategory(PackedDB,&index, dmAllCategories);
if (recH == NULL) {
break;
} // if
recP = MemHandleLock(recH);
currRec = *recP;
NumberArrayRecs = currRec.NumberOfArrayRecs;
MemHandleUnlock(recH);
for (i=0;i<NumberArrayRecs;i++) {
insertUnpackedRow(currRec.RecordsArray[i].LocationRec,currRec.RecordsArray[i
].Size);
}
// delete the packed record
// we don't increment the index if deleting as we read record
// 0 then delete it so the records shift up and we then read
// record 0 again
Error = DmRemoveRecord(PackedDB, index);
if (Error != 0) {
DebugInt("error on deletion record",index);
}
} // while
}
-----Original Message-----
From: Danny Epstein [mailto:[EMAIL PROTECTED]]
Sent: Friday, April 13, 2001 5:45 PM
To: Palm Developer Forum
Subject: Re: DmRemoveRecord : Not removing record
"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/
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/