mirror of
https://github.com/samba-team/samba.git
synced 2024-12-25 23:21:54 +03:00
r19777: Make regsubkey_ctr_addkey return WERROR. Nobody checks this so far, but this
will change. Volker
This commit is contained in:
parent
e2a35ceffe
commit
17c7c337f6
@ -41,35 +41,37 @@
|
|||||||
Add a new key to the array
|
Add a new key to the array
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
int regsubkey_ctr_addkey( REGSUBKEY_CTR *ctr, const char *keyname )
|
WERROR regsubkey_ctr_addkey( REGSUBKEY_CTR *ctr, const char *keyname )
|
||||||
{
|
{
|
||||||
if ( !keyname )
|
char **newkeys;
|
||||||
return ctr->num_subkeys;
|
|
||||||
|
if ( !keyname ) {
|
||||||
|
return WERR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
/* make sure the keyname is not already there */
|
/* make sure the keyname is not already there */
|
||||||
|
|
||||||
if ( regsubkey_ctr_key_exists( ctr, keyname ) )
|
if ( regsubkey_ctr_key_exists( ctr, keyname ) ) {
|
||||||
return ctr->num_subkeys;
|
return WERR_OK;
|
||||||
|
|
||||||
/* allocate a space for the char* in the array */
|
|
||||||
|
|
||||||
if (ctr->subkeys == NULL) {
|
|
||||||
ctr->subkeys = TALLOC_P(ctr, char *);
|
|
||||||
} else {
|
|
||||||
ctr->subkeys = TALLOC_REALLOC_ARRAY(ctr, ctr->subkeys, char *, ctr->num_subkeys+1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ctr->subkeys) {
|
if (!(newkeys = TALLOC_REALLOC_ARRAY(ctr, ctr->subkeys, char *,
|
||||||
ctr->num_subkeys = 0;
|
ctr->num_subkeys+1))) {
|
||||||
return 0;
|
return WERR_NOMEM;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* allocate the string and save it in the array */
|
ctr->subkeys = newkeys;
|
||||||
|
|
||||||
ctr->subkeys[ctr->num_subkeys] = talloc_strdup( ctr, keyname );
|
if (!(ctr->subkeys[ctr->num_subkeys] = talloc_strdup(ctr->subkeys,
|
||||||
|
keyname ))) {
|
||||||
|
/*
|
||||||
|
* Don't shrink the new array again, this wastes a pointer
|
||||||
|
*/
|
||||||
|
return WERR_NOMEM;
|
||||||
|
}
|
||||||
ctr->num_subkeys++;
|
ctr->num_subkeys++;
|
||||||
|
|
||||||
return ctr->num_subkeys;
|
return WERR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
|
Loading…
Reference in New Issue
Block a user