david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[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.
This commit is contained in:
Michael Brown 2009-01-31 07:32:20 +00:00
parent b111bdfb00
commit d2b0081740
1 changed files with 5 additions and 0 deletions

View File

@ -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 );