static void header_update_counts(struct index_header *i,
                                 const struct index_record *record,
                                 int is_add)
{
    int num = is_add ? 1 : -1;

    /* we don't track counts for EXPUNGED records */
    if (record->internal_flags & FLAG_INTERNAL_EXPUNGED)
        return;

    /* update mailbox header fields */
    if (record->system_flags & FLAG_ANSWERED)
        i->answered += num;

    if (record->system_flags & FLAG_FLAGGED)
        i->flagged += num;

    if (record->system_flags & FLAG_DELETED)
        i->deleted += num;

    if (!(record->system_flags & FLAG_SEEN))
        i->unseen += num;

    if (is_add) {
        i->exists++;
        i->quota_mailbox_used += record->size;
    }
    else {
        if (i->exists) i->exists--;

        /* corruption prevention - check we don't go negative */
        if (i->quota_mailbox_used > record->size)
            i->quota_mailbox_used -= record->size;
        else
            i->quota_mailbox_used = 0;
    }
}
static void header_update_counts(struct index_header *i,
                                 const struct index_record *record,
                                 int is_add)
{
    int num = is_add ? 1 : -1;

     
    if (record->internal_flags & FLAG_INTERNAL_EXPUNGED)
        return;

     
    if (record->system_flags & FLAG_ANSWERED)
        i->answered += num;

    if (record->system_flags & FLAG_FLAGGED)
        i->flagged += num;

    if (record->system_flags & FLAG_DELETED)
        i->deleted += num;

    if (!(record->system_flags & FLAG_SEEN))
        i->unseen += num;

    if (is_add) {
        i->exists++;
        i->quota_mailbox_used += record->size;
    }
    else {
        if (i->exists) i->exists--;

         
        if (i->quota_mailbox_used > record->size)
            i->quota_mailbox_used -= record->size;
        else
            i->quota_mailbox_used = 0;
    }
}