EXPORTED void mailbox_annot_changed(struct mailbox *mailbox,
                           unsigned int uid,
                           const char *entry,
                           const char *userid,
                           const struct buf *oldval,
                           const struct buf *newval,
                           int silent)
{
    /* update sync_crc - NOTE, only per-message annotations count */
    if (uid) {
        /* check that the record isn't already expunged */
        struct index_record record;
        int r = mailbox_find_index_record(mailbox, uid, &record);
        if (r || record.internal_flags & FLAG_INTERNAL_EXPUNGED)
            return;
        if (!mailbox_is_virtannot(mailbox, entry)) {
            if (oldval->len)
                mailbox->i.synccrcs.annot ^= crc_annot(uid, entry, userid, oldval);
            if (newval->len)
                mailbox->i.synccrcs.annot ^= crc_annot(uid, entry, userid, newval);
        }
    }

    if (!silent) {
        /* we are dirtying modseq for any annotation change */
        mailbox_modseq_dirty(mailbox);
        /* and we're dirtying foldermodseq if it's a mailbox level annotation */
        if (!uid) mboxlist_update_foldermodseq(mailbox_name(mailbox), mailbox->i.highestmodseq);
    }
    /* we always dirty the quota */
    mailbox_quota_dirty(mailbox);

    /* corruption prevention - check we don't go negative */
    if (mailbox->i.quota_annot_used > (quota_t)oldval->len)
        mailbox->i.quota_annot_used -= oldval->len;
    else
        mailbox->i.quota_annot_used = 0;

    mailbox->i.quota_annot_used += newval->len;
}
EXPORTED void mailbox_annot_changed(struct mailbox *mailbox,
                           unsigned int uid,
                           const char *entry,
                           const char *userid,
                           const struct buf *oldval,
                           const struct buf *newval,
                           int silent)
{
     
    if (uid) {
         
        struct index_record record;
        int r = mailbox_find_index_record(mailbox, uid, &record);
        if (r || record.internal_flags & FLAG_INTERNAL_EXPUNGED)
            return;
        if (!mailbox_is_virtannot(mailbox, entry)) {
            if (oldval->len)
                mailbox->i.synccrcs.annot ^= crc_annot(uid, entry, userid, oldval);
            if (newval->len)
                mailbox->i.synccrcs.annot ^= crc_annot(uid, entry, userid, newval);
        }
    }

    if (!silent) {
         
        mailbox_modseq_dirty(mailbox);
         
        if (!uid) mboxlist_update_foldermodseq(mailbox_name(mailbox), mailbox->i.highestmodseq);
    }
     
    mailbox_quota_dirty(mailbox);

     
    if (mailbox->i.quota_annot_used > (quota_t)oldval->len)
        mailbox->i.quota_annot_used -= oldval->len;
    else
        mailbox->i.quota_annot_used = 0;

    mailbox->i.quota_annot_used += newval->len;
}