[asterisk-commits] rmudgett: branch 1.8 r282098 - in /branches/1.8: include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Aug 12 17:06:10 CDT 2010


Author: rmudgett
Date: Thu Aug 12 17:06:06 2010
New Revision: 282098

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=282098
Log:
Separate call completion config parameter allocation and default initialization.

If you ever have a need to reset the call completion config parameters
to defaults, now you can.

And no Virginia, C++ idioms do not always work in C.

Modified:
    branches/1.8/include/asterisk/ccss.h
    branches/1.8/main/ccss.c

Modified: branches/1.8/include/asterisk/ccss.h
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/include/asterisk/ccss.h?view=diff&rev=282098&r1=282097&r2=282098
==============================================================================
--- branches/1.8/include/asterisk/ccss.h (original)
+++ branches/1.8/include/asterisk/ccss.h Thu Aug 12 17:06:06 2010
@@ -189,6 +189,21 @@
 
 /*!
  * \since 1.8
+ * \brief Set the specified CC config params to default values.
+ *
+ * \details
+ * This is just like ast_cc_copy_config_params() and could be used in place
+ * of it if you need to set the config params to defaults instead.
+ * You are simply "copying" defaults into the destination.
+ *
+ * \param params CC config params to set to default values.
+ *
+ * \return Nothing
+ */
+void ast_cc_default_config_params(struct ast_cc_config_params *params);
+
+/*!
+ * \since 1.8
  * \brief copy CCSS configuration parameters from one structure to another
  *
  * \details
@@ -199,8 +214,8 @@
  *
  * \param src The structure from which data is copied
  * \param dest The structure to which data is copied
- * \retval -1 Copy failed (no way for this to happen yet)
- * \retval 0 Copy succeeded
+ *
+ * \return Nothing
  */
 void ast_cc_copy_config_params(struct ast_cc_config_params *dest, const struct ast_cc_config_params *src);
 

Modified: branches/1.8/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/ccss.c?view=diff&rev=282098&r1=282097&r2=282098
==============================================================================
--- branches/1.8/main/ccss.c (original)
+++ branches/1.8/main/ccss.c Thu Aug 12 17:06:06 2010
@@ -501,38 +501,45 @@
 	return 0;
 }
 
-static const unsigned int CC_OFFER_TIMER_DEFAULT = 20u;
-static const unsigned int CCNR_AVAILABLE_TIMER_DEFAULT = 7200u;
-static const unsigned int CCBS_AVAILABLE_TIMER_DEFAULT = 4800u;
-static const unsigned int CC_RECALL_TIMER_DEFAULT = 20u;
-static const unsigned int CC_MAX_AGENTS_DEFAULT = 5u;
-static const unsigned int CC_MAX_MONITORS_DEFAULT = 5u;
-static const unsigned int GLOBAL_CC_MAX_REQUESTS_DEFAULT = 20u;
+#define CC_OFFER_TIMER_DEFAULT			20		/* Seconds */
+#define CCNR_AVAILABLE_TIMER_DEFAULT	7200	/* Seconds */
+#define CCBS_AVAILABLE_TIMER_DEFAULT	4800	/* Seconds */
+#define CC_RECALL_TIMER_DEFAULT			20		/* Seconds */
+#define CC_MAX_AGENTS_DEFAULT			5
+#define CC_MAX_MONITORS_DEFAULT			5
+#define GLOBAL_CC_MAX_REQUESTS_DEFAULT	20
+
+static const struct ast_cc_config_params cc_default_params = {
+	.cc_agent_policy = AST_CC_AGENT_NEVER,
+	.cc_monitor_policy = AST_CC_MONITOR_NEVER,
+	.cc_offer_timer = CC_OFFER_TIMER_DEFAULT,
+	.ccnr_available_timer = CCNR_AVAILABLE_TIMER_DEFAULT,
+	.ccbs_available_timer = CCBS_AVAILABLE_TIMER_DEFAULT,
+	.cc_recall_timer = CC_RECALL_TIMER_DEFAULT,
+	.cc_max_agents = CC_MAX_AGENTS_DEFAULT,
+	.cc_max_monitors = CC_MAX_MONITORS_DEFAULT,
+	.cc_callback_macro = "",
+	.cc_agent_dialstring = "",
+};
+
+void ast_cc_default_config_params(struct ast_cc_config_params *params)
+{
+	*params = cc_default_params;
+}
 
 struct ast_cc_config_params *__ast_cc_config_params_init(const char *file, int line, const char *function)
 {
 #if defined(__AST_DEBUG_MALLOC)
-	struct ast_cc_config_params *params = __ast_calloc(1, sizeof(*params), file, line, function);
+	struct ast_cc_config_params *params = __ast_malloc(sizeof(*params), file, line, function);
 #else
-	struct ast_cc_config_params *params = ast_calloc(1, sizeof(*params));
+	struct ast_cc_config_params *params = ast_malloc(sizeof(*params));
 #endif
 
 	if (!params) {
 		return NULL;
 	}
 
-	/* Yeah, I could use the get/set functions, but what's the point since
-	 * I have direct access to the structure fields in this file.
-	 */
-	params->cc_agent_policy = AST_CC_AGENT_NEVER;
-	params->cc_monitor_policy = AST_CC_MONITOR_NEVER;
-	params->cc_offer_timer = CC_OFFER_TIMER_DEFAULT;
-	params->ccnr_available_timer = CCNR_AVAILABLE_TIMER_DEFAULT;
-	params->ccbs_available_timer = CCBS_AVAILABLE_TIMER_DEFAULT;
-	params->cc_recall_timer = CC_RECALL_TIMER_DEFAULT;
-	params->cc_max_agents = CC_MAX_AGENTS_DEFAULT;
-	params->cc_max_monitors = CC_MAX_MONITORS_DEFAULT;
-	/* No need to set cc_callback_macro since calloc will 0 it out anyway */
+	ast_cc_default_config_params(params);
 	return params;
 }
 




More information about the asterisk-commits mailing list