[asterisk-commits] kmoore: branch kmoore/stasis-mwi r383282 - in /team/kmoore/stasis-mwi: includ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Mar 16 10:30:45 CDT 2013


Author: kmoore
Date: Sat Mar 16 10:30:44 2013
New Revision: 383282

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=383282
Log:
Rework function naming and remove an unnecessary struct member

Modified:
    team/kmoore/stasis-mwi/include/asterisk/stasis.h
    team/kmoore/stasis-mwi/main/app.c
    team/kmoore/stasis-mwi/main/stasis.c

Modified: team/kmoore/stasis-mwi/include/asterisk/stasis.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-mwi/include/asterisk/stasis.h?view=diff&rev=383282&r1=383281&r2=383282
==============================================================================
--- team/kmoore/stasis-mwi/include/asterisk/stasis.h (original)
+++ team/kmoore/stasis-mwi/include/asterisk/stasis.h Sat Mar 16 10:30:44 2013
@@ -392,10 +392,11 @@
 /*!
  * \brief Find or create a topic in the pool
  * \param pool Pool for which to get the topic
- * \param hash_id ID used to identify the topic
- * \retval The stored or allocated topic or NULL if allocation failed
- */
-struct stasis_topic *stasis_topic_pool_get_entry(struct stasis_topic_pool *pool, const char *hash_id);
+ * \param topic_name Name of the topic to get
+ * \retval The already stored or newly allocated topic
+ * \retval NULL if the topic was not found and could not be allocated
+ */
+struct stasis_topic *stasis_topic_pool_get_topic(struct stasis_topic_pool *pool, const char *topic_name);
 
 /*! @} */
 

Modified: team/kmoore/stasis-mwi/main/app.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-mwi/main/app.c?view=diff&rev=383282&r1=383281&r2=383282
==============================================================================
--- team/kmoore/stasis-mwi/main/app.c (original)
+++ team/kmoore/stasis-mwi/main/app.c Sat Mar 16 10:30:44 2013
@@ -2666,7 +2666,7 @@
 
 struct stasis_topic *stasis_mwi_topic(const char *uniqueid)
 {
-	return stasis_topic_pool_get_entry(mwi_topic_pool, uniqueid);
+	return stasis_topic_pool_get_topic(mwi_topic_pool, uniqueid);
 }
 
 int stasis_publish_mwi_state_full(

Modified: team/kmoore/stasis-mwi/main/stasis.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/stasis-mwi/main/stasis.c?view=diff&rev=383282&r1=383281&r2=383282
==============================================================================
--- team/kmoore/stasis-mwi/main/stasis.c (original)
+++ team/kmoore/stasis-mwi/main/stasis.c Sat Mar 16 10:30:44 2013
@@ -474,7 +474,6 @@
 }
 
 struct topic_pool_entry {
-	char *hash_id;
 	struct stasis_subscription *forward;
 	struct stasis_topic *topic;
 };
@@ -482,8 +481,6 @@
 static void topic_pool_entry_dtor(void *obj)
 {
 	struct topic_pool_entry *entry = obj;
-	ast_free(entry->hash_id);
-	entry->hash_id = NULL;
 	entry->forward = stasis_unsubscribe(entry->forward);
 	ao2_cleanup(entry->topic);
 	entry->topic = NULL;
@@ -510,15 +507,15 @@
 
 static int topic_pool_entry_hash(const void *obj, const int flags)
 {
-	const char *hash_id = (flags & OBJ_KEY) ? obj : ((struct topic_pool_entry*) obj)->hash_id;
-	return ast_str_case_hash(hash_id);
+	const char *topic_name= (flags & OBJ_KEY) ? obj : stasis_topic_name(((struct topic_pool_entry*) obj)->topic);
+	return ast_str_case_hash(topic_name);
 }
 
 static int topic_pool_entry_cmp(void *obj, void *arg, int flags)
 {
 	struct topic_pool_entry *opt1 = obj, *opt2 = arg;
-	const char *hash_id = (flags & OBJ_KEY) ? arg : opt2->hash_id;
-	return strcasecmp(opt1->hash_id, hash_id) ? 0 : CMP_MATCH | CMP_STOP;
+	const char *topic_name = (flags & OBJ_KEY) ? arg : stasis_topic_name(opt2->topic);
+	return strcasecmp(stasis_topic_name(opt1->topic), topic_name) ? 0 : CMP_MATCH | CMP_STOP;
 }
 
 struct stasis_topic_pool *stasis_topic_pool_create(struct stasis_topic *pooled_topic)
@@ -535,11 +532,11 @@
 	return pool;
 }
 
-struct stasis_topic *stasis_topic_pool_get_entry(struct stasis_topic_pool *pool, const char *hash_id)
+struct stasis_topic *stasis_topic_pool_get_topic(struct stasis_topic_pool *pool, const char *topic_name)
 {
 	RAII_VAR(struct topic_pool_entry *, topic_pool_entry, NULL, ao2_cleanup);
 	SCOPED_AO2LOCK(topic_container_lock, pool->pool_container);
-	topic_pool_entry = ao2_find(pool->pool_container, hash_id, OBJ_KEY | OBJ_NOLOCK);
+	topic_pool_entry = ao2_find(pool->pool_container, topic_name, OBJ_KEY | OBJ_NOLOCK);
 
 	if (topic_pool_entry) {
 		return topic_pool_entry->topic;
@@ -551,18 +548,13 @@
 		return NULL;
 	}
 
-	topic_pool_entry->topic = stasis_topic_create(hash_id);
+	topic_pool_entry->topic = stasis_topic_create(topic_name);
 	if (!topic_pool_entry->topic) {
 		return NULL;
 	}
 
 	topic_pool_entry->forward = stasis_forward_all(topic_pool_entry->topic, pool->pool_topic);
 	if (!topic_pool_entry->forward) {
-		return NULL;
-	}
-
-	topic_pool_entry->hash_id = ast_strdup(hash_id);
-	if (!topic_pool_entry->hash_id) {
 		return NULL;
 	}
 




More information about the asterisk-commits mailing list