[asterisk-commits] qwell: branch qwell/router_removal r390474 - /team/qwell/router_removal/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jun 5 09:57:21 CDT 2013


Author: qwell
Date: Wed Jun  5 09:57:19 2013
New Revision: 390474

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390474
Log:
Implement/use OBJ_KEY.

Modified:
    team/qwell/router_removal/main/stasis_message_router.c

Modified: team/qwell/router_removal/main/stasis_message_router.c
URL: http://svnview.digium.com/svn/asterisk/team/qwell/router_removal/main/stasis_message_router.c?view=diff&rev=390474&r1=390473&r2=390474
==============================================================================
--- team/qwell/router_removal/main/stasis_message_router.c (original)
+++ team/qwell/router_removal/main/stasis_message_router.c Wed Jun  5 09:57:19 2013
@@ -55,16 +55,18 @@
 static int route_hash(const void *obj, const int flags)
 {
 	const struct stasis_message_route *route = obj;
-
-	return ast_str_hash(stasis_message_type_name(route->message_type));
+	const struct stasis_message_type *message_type = (flags & OBJ_KEY) ? obj : route->message_type;
+
+	return ast_str_hash(stasis_message_type_name(message_type));
 }
 
 static int route_cmp(void *obj, void *arg, int flags)
 {
 	const struct stasis_message_route *left = obj;
 	const struct stasis_message_route *right = arg;
-
-	return (left->message_type == right->message_type) ? CMP_MATCH | CMP_STOP : 0;
+	const struct stasis_message_type *message_type = (flags & OBJ_KEY) ? arg : right->message_type;
+
+	return (left->message_type == message_type) ? CMP_MATCH | CMP_STOP : 0;
 }
 
 /*! \internal */
@@ -94,16 +96,7 @@
 
 static struct stasis_message_route *find_route(struct stasis_message_router *router, struct stasis_message_type *message_type)
 {
-	struct stasis_message_route route;
-
-	if (message_type == NULL) {
-		return NULL;
-	}
-
-	memset(&route, 0, sizeof(route));
-	route.message_type = message_type;
-
-	return ao2_find(router->routes, &route, OBJ_POINTER);
+	return ao2_find(router->routes, message_type, OBJ_KEY);
 }
 
 static void router_dispatch(void *data,




More information about the asterisk-commits mailing list