[asterisk-commits] rmudgett: trunk r405542 - in /trunk: ./ main/strings.c

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


Author: rmudgett
Date: Tue Jan 14 15:46:50 2014
New Revision: 405542

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

Merged revisions 405541 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/main/strings.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/main/strings.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/strings.c?view=diff&rev=405542&r1=405541&r2=405542
==============================================================================
--- trunk/main/strings.c (original)
+++ trunk/main/strings.c Tue Jan 14 15:46:50 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