From d2b0081740de9e31fb28f7c6761bbf78835c07d7 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Sat, 31 Jan 2009 07:32:20 +0000 Subject: [PATCH] [settings] Avoid duplicate settings block names Automatically unregister any settings with the same name (and position within the settings tree) as a newly registered settings block. This functionality is generalised out from dhcp.c. --- src/core/settings.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/core/settings.c b/src/core/settings.c index 09033bd9..2c886fdf 100644 --- a/src/core/settings.c +++ b/src/core/settings.c @@ -183,12 +183,17 @@ static void reprioritise_settings ( struct settings *settings ) { * @ret rc Return status code */ int register_settings ( struct settings *settings, struct settings *parent ) { + struct settings *old_settings; /* NULL parent => add to settings root */ assert ( settings != NULL ); if ( parent == NULL ) parent = &settings_root; + /* Remove any existing settings with the same name */ + if ( ( old_settings = find_child_settings ( parent, settings->name ) )) + unregister_settings ( old_settings ); + /* Add to list of settings */ ref_get ( settings->refcnt ); ref_get ( parent->refcnt );