From 4dcdb73c4b76a3413730649ddf4039ec964466b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Thu, 29 Dec 2016 01:48:13 +0100 Subject: map: implement map_prefix_delete --- map.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'map.c') diff --git a/map.c b/map.c index f6e5c64..7994f34 100644 --- a/map.c +++ b/map.c @@ -288,6 +288,19 @@ const Map *map_prefix(const Map *map, const char *prefix) return top; } +bool map_prefix_delete(Map *map, const char *prefix) +{ + bool ret = false; + do { + const char *conflict = NULL; + const Map *conflicts = map_prefix(map, prefix); + if (!map_first(conflicts, &conflict)) + break; + ret = map_delete(map, conflict); + } while (ret); + return ret; +} + static void clear(Map n) { if (!n.v) { -- cgit v1.2.3