devices: add index based device removal function

The undo machinery will need a method to remove devices based
on their index instead of their name. Add it.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-10-24 22:46:36 +02:00 committed by Dirk Hohndel
parent fa7dfa3710
commit 3a2f1b17b6
2 changed files with 8 additions and 0 deletions

View file

@ -319,6 +319,13 @@ extern "C" int remove_device(struct device_table *device_table, const struct dev
}
}
extern "C" void remove_from_device_table(struct device_table *device_table, int idx)
{
if (idx < 0 || idx >= (int)device_table->devices.size())
return;
device_table->devices.erase(device_table->devices.begin() + idx);
}
extern "C" void clear_device_table(struct device_table *device_table)
{
device_table->devices.clear();