diff options
author | Max Kellermann <max@duempel.org> | 2013-12-02 12:46:48 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-12-02 12:46:48 +0100 |
commit | 20ebacf489333933ce752d66ffb6068434a846f5 (patch) | |
tree | 2cc9b1e04e44bd247c8af8ae6e234373a15a0917 /src/tag/Tag.cxx | |
parent | c6ef0e88879d2cd203a74cfda2a574e949486877 (diff) | |
download | mpd-20ebacf489333933ce752d66ffb6068434a846f5.tar.gz mpd-20ebacf489333933ce752d66ffb6068434a846f5.tar.xz mpd-20ebacf489333933ce752d66ffb6068434a846f5.zip |
Tag: add methods RemoveAll(), RemoveType()
Diffstat (limited to 'src/tag/Tag.cxx')
-rw-r--r-- | src/tag/Tag.cxx | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/tag/Tag.cxx b/src/tag/Tag.cxx index 6bf070429..0fb7ea93b 100644 --- a/src/tag/Tag.cxx +++ b/src/tag/Tag.cxx @@ -223,3 +223,23 @@ Tag::AddItem(TagType type, const char *value) { AddItem(type, value, strlen(value)); } + +void +Tag::RemoveType(TagType type) +{ + auto dest = items, src = items, end = items + num_items; + + tag_pool_lock.lock(); + while (src != end) { + TagItem *item = *src++; + if (item->type == type) + /* remove it */ + tag_pool_put_item(item); + else + /* keep it */ + *dest++ = item; + } + tag_pool_lock.unlock(); + + num_items = dest - items; +} |