[asterisk-commits] rmudgett: branch 12 r405541 - /branches/12/main/strings.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Jan 14 15:44:16 CST 2014


Author: rmudgett
Date: Tue Jan 14 15:44:10 2014
New Revision: 405541

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=405541
Log:
string container: Remove unnecessary RAII_VAR usage and string object lock.

Modified:
    branches/12/main/strings.c

Modified: branches/12/main/strings.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/strings.c?view=diff&rev=405541&r1=405540&r2=405541
==============================================================================
--- branches/12/main/strings.c (original)
+++ branches/12/main/strings.c Tue Jan 14 15:44:10 2014
@@ -177,19 +177,21 @@
 
 int ast_str_container_add(struct ao2_container *str_container, const char *add)
 {
-	RAII_VAR(char *, ao2_add, ao2_alloc(strlen(add) + 1, NULL), ao2_cleanup);
+	char *ao2_add;
 
+	/* The ao2_add object is immutable so it doesn't need a lock of its own. */
+	ao2_add = ao2_alloc_options(strlen(add) + 1, NULL, AO2_ALLOC_OPT_LOCK_NOLOCK);
 	if (!ao2_add) {
 		return -1;
 	}
+	strcpy(ao2_add, add);/* Safe */
 
-	/* safe strcpy */
-	strcpy(ao2_add, add);
 	ao2_link(str_container, ao2_add);
+	ao2_ref(ao2_add, -1);
 	return 0;
 }
 
 void ast_str_container_remove(struct ao2_container *str_container, const char *remove)
 {
-	ao2_find(str_container, remove, OBJ_KEY | OBJ_NODATA | OBJ_UNLINK);
+	ao2_find(str_container, remove, OBJ_SEARCH_KEY | OBJ_NODATA | OBJ_UNLINK);
 }




More information about the asterisk-commits mailing list