On Thu, Jun 23, 2005 at 01:05:37PM -0000, Dr. Vesselin Bontchev wrote:

> My application enumerates all databases in the main memory of the
> device, using a DmGetNextDatabaseByTypeCreator loop. Each database
> found is examined and, if it meets certain criteria, is deleted.
> 
> Problem is, deleting (or creating, for that matter) a database screws up
> the DmGetNextDatabaseByTypeCreator loop. There are two obvious solutions
> to this:
> 
> 1) Collect the IDs of the databases that should be deleted and delete
>    them after the DmGetNextDatabaseByTypeCreator loop completes.
> 
> 2) Restart the search loop every time a database is deleted.

DmGetNextDatabaseByTypeCreator function just iterates from the first
database to the last and saves the iteration state in the state
variable. You could easily write your own loop that iterates from the
last database to the first, deleting databases as you find them:

 for (UInt16 i = ::DmNumDatabases(0); i > 0; --i) {
   ::LocalId dbid(::DmGetDatabase(0, i-1));
   ::DmDatabaseInfo(0, dbid, ....);
   if (info-meets-criteria) {
     ::DmDeleteDatabase(0, dbid);
   }
 }

-- 
Dave Carrigan
Seattle, WA, USA
[EMAIL PROTECTED] | http://www.rudedog.org/ | ICQ:161669680
UNIX-Apache-Perl-Linux-Firewalls-LDAP-C-C++-DNS-PalmOS-PostgreSQL-MySQL

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

Reply via email to