svn commit: samba r25139 - in branches: SAMBA_3_2/source/registry SAMBA_3_2_0/source/registry

obnox at samba.org obnox at samba.org
Thu Sep 13 22:36:12 GMT 2007


Author: obnox
Date: 2007-09-13 22:36:10 +0000 (Thu, 13 Sep 2007)
New Revision: 25139

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=25139

Log:
Avoid code duplication: let regval_ctr_copyvalue() call regval_ctr_addvalue().
This also corrects regval_ctr_copyvalue() in that it cannot create (invalid)
regval containers with dupliacte entries...

Michael


Modified:
   branches/SAMBA_3_2/source/registry/reg_objects.c
   branches/SAMBA_3_2_0/source/registry/reg_objects.c


Changeset:
Modified: branches/SAMBA_3_2/source/registry/reg_objects.c
===================================================================
--- branches/SAMBA_3_2/source/registry/reg_objects.c	2007-09-13 22:08:59 UTC (rev 25138)
+++ branches/SAMBA_3_2/source/registry/reg_objects.c	2007-09-13 22:36:10 UTC (rev 25139)
@@ -347,43 +347,8 @@
 int regval_ctr_copyvalue( REGVAL_CTR *ctr, REGISTRY_VALUE *val )
 {
 	if ( val ) {
-		/* allocate a slot in the array of pointers */
-		
-		if (  ctr->num_values == 0 ) {
-			ctr->values = TALLOC_P( ctr, REGISTRY_VALUE *);
-		} else {
-			ctr->values = TALLOC_REALLOC_ARRAY( ctr, ctr->values, REGISTRY_VALUE *, ctr->num_values+1 );
-		}
-
-		if (!ctr->values) {
-			ctr->num_values = 0;
-			return 0;
-		}
-
-		/* allocate a new value and store the pointer in the arrya */
-		
-		ctr->values[ctr->num_values] = TALLOC_P( ctr, REGISTRY_VALUE);
-		if (!ctr->values[ctr->num_values]) {
-			ctr->num_values = 0;
-			return 0;
-		}
-
-		/* init the value */
-	
-		fstrcpy( ctr->values[ctr->num_values]->valuename, val->valuename );
-		ctr->values[ctr->num_values]->type = val->type;
-		if (val->size) {
-			ctr->values[ctr->num_values]->data_p = (uint8 *)TALLOC_MEMDUP(
-				ctr, val->data_p, val->size );
-			if (!ctr->values[ctr->num_values]->data_p) {
-				ctr->num_values = 0;
-				return 0;
-			}
-		} else {
-			ctr->values[ctr->num_values]->data_p = NULL;
-		}
-		ctr->values[ctr->num_values]->size = val->size;
-		ctr->num_values++;
+		regval_ctr_addvalue(ctr, val->valuename, val->type,
+				    (char *)val->data_p, val->size);
 	}
 
 	return ctr->num_values;

Modified: branches/SAMBA_3_2_0/source/registry/reg_objects.c
===================================================================
--- branches/SAMBA_3_2_0/source/registry/reg_objects.c	2007-09-13 22:08:59 UTC (rev 25138)
+++ branches/SAMBA_3_2_0/source/registry/reg_objects.c	2007-09-13 22:36:10 UTC (rev 25139)
@@ -347,43 +347,8 @@
 int regval_ctr_copyvalue( REGVAL_CTR *ctr, REGISTRY_VALUE *val )
 {
 	if ( val ) {
-		/* allocate a slot in the array of pointers */
-		
-		if (  ctr->num_values == 0 ) {
-			ctr->values = TALLOC_P( ctr, REGISTRY_VALUE *);
-		} else {
-			ctr->values = TALLOC_REALLOC_ARRAY( ctr, ctr->values, REGISTRY_VALUE *, ctr->num_values+1 );
-		}
-
-		if (!ctr->values) {
-			ctr->num_values = 0;
-			return 0;
-		}
-
-		/* allocate a new value and store the pointer in the arrya */
-		
-		ctr->values[ctr->num_values] = TALLOC_P( ctr, REGISTRY_VALUE);
-		if (!ctr->values[ctr->num_values]) {
-			ctr->num_values = 0;
-			return 0;
-		}
-
-		/* init the value */
-	
-		fstrcpy( ctr->values[ctr->num_values]->valuename, val->valuename );
-		ctr->values[ctr->num_values]->type = val->type;
-		if (val->size) {
-			ctr->values[ctr->num_values]->data_p = (uint8 *)TALLOC_MEMDUP(
-				ctr, val->data_p, val->size );
-			if (!ctr->values[ctr->num_values]->data_p) {
-				ctr->num_values = 0;
-				return 0;
-			}
-		} else {
-			ctr->values[ctr->num_values]->data_p = NULL;
-		}
-		ctr->values[ctr->num_values]->size = val->size;
-		ctr->num_values++;
+		regval_ctr_addvalue(ctr, val->valuename, val->type,
+				    (char *)val->data_p, val->size);
 	}
 
 	return ctr->num_values;



More information about the samba-cvs mailing list