Sfoglia il codice sorgente

[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.
tags/v0.9.7
Michael Brown 16 anni fa
parent
commit
d2b0081740
1 ha cambiato i file con 5 aggiunte e 0 eliminazioni
  1. 5
    0
      src/core/settings.c

+ 5
- 0
src/core/settings.c Vedi File

@@ -183,12 +183,17 @@ static void reprioritise_settings ( struct settings *settings ) {
183 183
  * @ret rc		Return status code
184 184
  */
185 185
 int register_settings ( struct settings *settings, struct settings *parent ) {
186
+	struct settings *old_settings;
186 187
 
187 188
 	/* NULL parent => add to settings root */
188 189
 	assert ( settings != NULL );
189 190
 	if ( parent == NULL )
190 191
 		parent = &settings_root;
191 192
 
193
+	/* Remove any existing settings with the same name */
194
+	if ( ( old_settings = find_child_settings ( parent, settings->name ) ))
195
+		unregister_settings ( old_settings );
196
+
192 197
 	/* Add to list of settings */
193 198
 	ref_get ( settings->refcnt );
194 199
 	ref_get ( parent->refcnt );

Loading…
Annulla
Salva