for( account = first_account, accnum = 0; account; account = account->next, accnum++ )
…dispose_account(account);
void cleanup_accounts( void )
{
ACCOUNT_DATA *account;
ACCOUNT_DATA *next_acc;
char buf[MSL];
int count = 0, accnum = 0;
sprintf( buf, "%s initiated", __FUNCTION__ );
log_string(buf);
for( account = first_account, accnum = 0; account; account = next_acc, accnum++ )
{
next_acc = account->next;
if( !account->first_acc_char )
{
sprintf( buf, "Removing Account %s", account->name );
log_string(buf);
count++;
dispose_account(account);
}
}
sprintf( buf, "%s: %d of %d accounts removed. %d remaining.", __FUNCTION__, count, accnum, accnum-count );
log_string(buf);
return;
}
The command appears to work, but when the line I've marked above is commented, this is the output. It doesn't actually delete the accounts, but reports it correctly:
Basically, when I uncomment the line that actually deletes the unused account, it'll delete the first bad account and end. If I comment the line, it'll report all problem accounts but it won't actually delete them (obviously, since I uncommented it). I suspect the problem is obviously in dispose_account somewhere, but I'm unsure as to what it is. Can anyone point me in the right direction? Thanks in advance..
Edit: To remove break from code.. wasn't supposed to be there.