[asterisk-commits] mmichelson: branch mmichelson/rls-config r416665 - /team/mmichelson/rls-confi...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jun 19 10:39:36 CDT 2014


Author: mmichelson
Date: Thu Jun 19 10:39:30 2014
New Revision: 416665

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=416665
Log:
Detect and ignore duplicated list items.


Modified:
    team/mmichelson/rls-config/res/res_pjsip_pubsub.c

Modified: team/mmichelson/rls-config/res/res_pjsip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/rls-config/res/res_pjsip_pubsub.c?view=diff&rev=416665&r1=416664&r2=416665
==============================================================================
--- team/mmichelson/rls-config/res/res_pjsip_pubsub.c (original)
+++ team/mmichelson/rls-config/res/res_pjsip_pubsub.c Thu Jun 19 10:39:30 2014
@@ -2020,6 +2020,19 @@
 	return list;
 }
 
+static int item_in_vector(const struct resource_list *list, const char *item)
+{
+	int i;
+
+	for (i = 0; i < AST_VECTOR_SIZE(&list->items); ++i) {
+		if (!strcmp(item, AST_VECTOR_GET(&list->items, i))) {
+			return 1;
+		}
+	}
+
+	return 0;
+}
+
 static int list_item_handler(const struct aco_option *opt,
 		struct ast_variable *var, void *obj)
 {
@@ -2028,6 +2041,10 @@
 	char *item;
 
 	while ((item = strsep(&items, ","))) {
+		if (item_in_vector(list, item)) {
+			ast_log(LOG_WARNING, "Ignoring duplicated list item '%s'\n", item);
+			continue;
+		}
 		if (AST_VECTOR_APPEND(&list->items, ast_strdup(item))) {
 			return -1;
 		}




More information about the asterisk-commits mailing list