[asterisk-commits] bbryant: branch group/data_api_gsoc2009 r202839 - /team/group/data_api_gsoc20...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jun 23 18:40:35 CDT 2009


Author: bbryant
Date: Tue Jun 23 18:40:32 2009
New Revision: 202839

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=202839
Log:
A few formatting changes.

Modified:
    team/group/data_api_gsoc2009/main/data.c

Modified: team/group/data_api_gsoc2009/main/data.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/data_api_gsoc2009/main/data.c?view=diff&rev=202839&r1=202838&r2=202839
==============================================================================
--- team/group/data_api_gsoc2009/main/data.c (original)
+++ team/group/data_api_gsoc2009/main/data.c Tue Jun 23 18:40:32 2009
@@ -672,7 +672,8 @@
  * \param ptr
  */
 static struct ast_data *__ast_data_add(struct ast_data *root, const char *name,
-	enum ast_data_type type, void *ptr) {
+	enum ast_data_type type, void *ptr)
+{
 	struct ast_data *node;
 	size_t namelen = 1 + (ast_strlen_zero(name) ? 0 : strlen(name));
 
@@ -683,11 +684,7 @@
 		return NULL;
 	}
 
-	if (namelen > 1) {
-		strcpy(node->name, name);
-	} else {
-		node->name[0] = '\0';
-	}
+	strcpy(node->name, (ast_strlen_zero(name) ? "" : name));
 
 	switch (type) {
 		case AST_DATA_INTEGER:
@@ -745,11 +742,14 @@
 struct ast_data *ast_data_add_str(struct ast_data *root, const char *childname, const char *value)
 {
 	char *name;
-
-	if (!(name = ast_malloc(1 + (ast_strlen_zero(value) ? 0 : strlen(value)))))
-		return NULL;
-
-	strcpy(name, value);
+	size_t namelen = 1 + (ast_strlen_zero(value) ? 0 : strlen(value));
+
+	if (!(name = ast_malloc(namelen))) {
+		return NULL;
+	}
+
+	strcpy(name, (ast_strlen_zero(value) ? "" : value));
+
 	return __ast_data_add(root, childname, AST_DATA_STRING, name);
 }
 
@@ -783,8 +783,9 @@
 		case AST_DATA_CONTAINER:
 			i = ao2_iterator_init(root->children, 0);
 
-			while ((child = ao2_iterator_next(&i)))
+			while ((child = ao2_iterator_next(&i))) {
 				ao2_ref(child, -2);
+			}
 
 			break;
 




More information about the asterisk-commits mailing list