[asterisk-commits] mmichelson: branch group/CCSS r226238 - /team/group/CCSS/main/ccss.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Oct 27 17:20:05 CDT 2009


Author: mmichelson
Date: Tue Oct 27 17:20:00 2009
New Revision: 226238

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=226238
Log:
Use different syntax for state_change_funcs to ensure
proper placement of function pointers in the array.

Thanks again to Richard for the idea.


Modified:
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=226238&r1=226237&r2=226238
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Tue Oct 27 17:20:00 2009
@@ -2503,24 +2503,16 @@
 	return 0;
 }
 
-/* The order of items in this table
- * is very important and must correspond
- * to the order of the states in the
- * cc_state enum.
- */
-static struct cc_function_table {
-	enum cc_state state;
-	int (*func)(struct cc_core_instance *, struct cc_state_change_args *, enum cc_state previous_state);
-} state_change_funcs[] = {
-	{CC_AVAILABLE, cc_available},
-	{CC_CALLER_OFFERED, cc_caller_offered},
-	{CC_CALLER_REQUESTED, cc_caller_requested},
-	{CC_ACTIVE, cc_active},
-	{CC_CALLEE_READY, cc_callee_ready},
-	{CC_CALLER_BUSY, cc_caller_busy},
-	{CC_RECALLING, cc_recalling},
-	{CC_COMPLETE, cc_complete},
-	{CC_FAILED, cc_failed},
+int (*state_change_funcs [])(struct cc_core_instance *, struct cc_state_change_args *, enum cc_state previous_state) = {
+	[CC_AVAILABLE] = cc_available,
+	[CC_CALLER_OFFERED] = cc_caller_offered,
+	[CC_CALLER_REQUESTED] = cc_caller_requested,
+	[CC_ACTIVE] = cc_active,
+	[CC_CALLEE_READY] = cc_callee_ready,
+	[CC_CALLER_BUSY] = cc_caller_busy,
+	[CC_RECALLING] = cc_recalling,
+	[CC_COMPLETE] = cc_complete,
+	[CC_FAILED] = cc_failed,
 };
 
 static int cc_do_state_change(void *datap)
@@ -2548,7 +2540,7 @@
 		return -1;
 	}
 
-	res = state_change_funcs[core_instance->current_state].func(core_instance, args, previous_state);
+	res = state_change_funcs[core_instance->current_state](core_instance, args, previous_state);
 
 	ast_free(args);
 	cc_unref(core_instance, "Unref since state change has completed"); /* From ao2_find */




More information about the asterisk-commits mailing list