summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVolker Lendecke <vlendec@samba.org>2006-11-18 17:46:32 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:15:54 -0500
commitcbc03ec6df1865fa980d1bc64769f8920cbd1d82 (patch)
tree6c2aa2f3a8a5577e522f7c218fe1b11d7e4e2f3b
parent09ec562a09e4195e58b051a74a90d113aa0e0ac7 (diff)
downloadsamba-cbc03ec6df1865fa980d1bc64769f8920cbd1d82.tar.gz
samba-cbc03ec6df1865fa980d1bc64769f8920cbd1d82.tar.bz2
samba-cbc03ec6df1865fa980d1bc64769f8920cbd1d82.zip
r19777: Make regsubkey_ctr_addkey return WERROR. Nobody checks this so far, but this
will change. Volker (This used to be commit 17c7c337f64b082c1bf1045a4093c279deeec958)
-rw-r--r--source3/registry/reg_objects.c42
1 files changed, 22 insertions, 20 deletions
diff --git a/source3/registry/reg_objects.c b/source3/registry/reg_objects.c
index 83fd85658f..94b7a4df95 100644
--- a/source3/registry/reg_objects.c
+++ b/source3/registry/reg_objects.c
@@ -41,35 +41,37 @@
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 )
- return ctr->num_subkeys;
+ char **newkeys;
+
+ if ( !keyname ) {
+ return WERR_OK;
+ }
/* make sure the keyname is not already there */
- if ( regsubkey_ctr_key_exists( ctr, keyname ) )
- return ctr->num_subkeys;
-
- /* 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 ( regsubkey_ctr_key_exists( ctr, keyname ) ) {
+ return WERR_OK;
}
- if (!ctr->subkeys) {
- ctr->num_subkeys = 0;
- return 0;
+ if (!(newkeys = TALLOC_REALLOC_ARRAY(ctr, ctr->subkeys, char *,
+ ctr->num_subkeys+1))) {
+ return WERR_NOMEM;
}
- /* allocate the string and save it in the array */
-
- ctr->subkeys[ctr->num_subkeys] = talloc_strdup( ctr, keyname );
+ ctr->subkeys = newkeys;
+
+ 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++;
-
- return ctr->num_subkeys;
+
+ return WERR_OK;
}
/***********************************************************************