diff options
Diffstat (limited to 'source3/registry/reg_objects.c')
-rw-r--r-- | source3/registry/reg_objects.c | 35 |
1 files changed, 23 insertions, 12 deletions
diff --git a/source3/registry/reg_objects.c b/source3/registry/reg_objects.c index 582a696529..7ee2cd8414 100644 --- a/source3/registry/reg_objects.c +++ b/source3/registry/reg_objects.c @@ -114,7 +114,6 @@ BOOL regsubkey_ctr_key_exists( REGSUBKEY_CTR *ctr, const char *keyname ) } return False; - } /*********************************************************************** @@ -276,10 +275,24 @@ TALLOC_CTX* regval_ctr_getctx( REGVAL_CTR *val ) if ( !val ) return NULL; - return val->ctx; -} + return val->ctx; } /*********************************************************************** + Check for the existance of a value + **********************************************************************/ + +BOOL regval_ctr_key_exists( REGVAL_CTR *ctr, const char *value ) +{ + int i; + + for ( i=0; i<ctr->num_values; i++ ) { + if ( strequal( ctr->values[i]->valuename, value) ) + return True; + } + + return False; +} +/*********************************************************************** Add a new registry value to the array **********************************************************************/ @@ -291,6 +304,10 @@ int regval_ctr_addvalue( REGVAL_CTR *ctr, const char *name, uint16 type, if ( !name ) return ctr->num_values; + /* Delete the current value (if it exists) and add the new one */ + + regval_ctr_delvalue( ctr, name ); + /* allocate a slot in the array of pointers */ if ( ctr->num_values == 0 ) @@ -366,7 +383,7 @@ int regval_ctr_delvalue( REGVAL_CTR *ctr, const char *name ) return 0; for ( i=0; i<ctr->num_values; i++ ) { - if ( strcmp( ctr->values[i]->valuename, name ) == 0) + if ( strequal( ctr->values[i]->valuename, name ) ) break; } @@ -376,15 +393,9 @@ int regval_ctr_delvalue( REGVAL_CTR *ctr, const char *name ) return ctr->num_values; /* just shift everything down one */ - - for ( /* use previous i */; i<(ctr->num_values-1); i++ ) - memcpy( ctr->values[i], ctr->values[i+1], sizeof(REGISTRY_VALUE) ); - - /* paranoia */ - - ZERO_STRUCTP( ctr->values[i] ); - ctr->num_values--; + if ( ctr->num_values ) + memmove( ctr->values[i], ctr->values[i+1], sizeof(REGISTRY_VALUE)*(ctr->num_values-i) ); return ctr->num_values; } |