diff --git a/src/ini_load.cpp b/src/ini_load.cpp --- a/src/ini_load.cpp +++ b/src/ini_load.cpp @@ -101,6 +101,29 @@ IniItem *IniGroup::GetItem(const std::st } /** + * Remove the item with the given name. + * @param name Name of the item to remove. + */ +void IniGroup::RemoveItem(const std::string &name) +{ + IniItem **prev = &this->item; + + for (IniItem *item = this->item; item != nullptr; prev = &item->next, item = item->next) { + if (item->name != name) continue; + + *prev = item->next; + if (this->last_item == &this->item) { + this->last_item = &item->next; + } + + item->next = nullptr; + delete item; + + return; + } +} + +/** * Clear all items in the group */ void IniGroup::Clear()