[svn-commits] kharwell: branch kharwell/gulp_notify r393355 - in /team/kharwell/gulp_notify...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jul 1 15:50:40 CDT 2013


Author: kharwell
Date: Mon Jul  1 15:50:39 2013
New Revision: 393355

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393355
Log:
per review: fixed comment to more accurately describe function, and optimized structures containing strings.

Modified:
    team/kharwell/gulp_notify/include/asterisk/res_sip.h
    team/kharwell/gulp_notify/res/res_sip_notify.c

Modified: team/kharwell/gulp_notify/include/asterisk/res_sip.h
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/gulp_notify/include/asterisk/res_sip.h?view=diff&rev=393355&r1=393354&r2=393355
==============================================================================
--- team/kharwell/gulp_notify/include/asterisk/res_sip.h (original)
+++ team/kharwell/gulp_notify/include/asterisk/res_sip.h Mon Jul  1 15:50:39 2013
@@ -1181,9 +1181,9 @@
 struct ast_sip_endpoint *ast_pjsip_rdata_get_endpoint(pjsip_rx_data *rdata);
 
 /*!
- * \brief Retrieve any endpoints currently loaded by sorcery.
- *
- * \retval Endpoints loaded by sorcery, NULL if no endpoints found.
+ * \brief Retrieve any endpoints available to sorcery.
+ *
+ * \retval Endpoints available to sorcery, NULL if no endpoints found.
  */
 struct ao2_container *ast_sip_get_endpoints(void);
 

Modified: team/kharwell/gulp_notify/res/res_sip_notify.c
URL: http://svnview.digium.com/svn/asterisk/team/kharwell/gulp_notify/res/res_sip_notify.c?view=diff&rev=393355&r1=393354&r2=393355
==============================================================================
--- team/kharwell/gulp_notify/res/res_sip_notify.c (original)
+++ team/kharwell/gulp_notify/res/res_sip_notify.c Mon Jul  1 15:50:39 2013
@@ -43,24 +43,16 @@
 static const char notify_config[] = "sip_notify.conf";
 
 struct notify_option_item {
-	AST_DECLARE_STRING_FIELDS(
-		AST_STRING_FIELD(name);
-		AST_STRING_FIELD(value);
-	);
+	const char *name;
+	const char *value;
+	char buf[0];
 };
 
-static void notify_option_item_destroy(void *obj)
-{
-	struct notify_option_item *item = obj;
-
-	ast_string_field_free_memory(item);
-}
-
 struct notify_option {
-	/*! The name of the notify option */
-	const char *name;
 	/*! Contains header and/or content information */
 	struct ao2_container *items;
+	/*! The name of the notify option */
+	char name[0];
 };
 
 static int notify_option_hash(const void *obj, int flags)
@@ -81,24 +73,21 @@
 static void notify_option_destroy(void *obj)
 {
 	struct notify_option *option = obj;
-
-	ast_free((char *) option->name);
 	ao2_cleanup(option->items);
 }
 
 static void *notify_option_alloc(const char *category)
 {
+	int category_size = strlen(category) + 1;
+
 	struct notify_option *option = ao2_alloc(
-		sizeof(*option), notify_option_destroy);
+		sizeof(*option) + category_size, notify_option_destroy);
 
 	if (!option) {
 		return NULL;
 	}
 
-	if (!(option->name = ast_strdup(category))) {
-		ao2_cleanup(option);
-		return NULL;
-	}
+	ast_copy_string(option->name, category, category_size);
 
 	if (!(option->items = ao2_container_alloc_list(
 		      AO2_ALLOC_OPT_LOCK_NOLOCK,
@@ -120,15 +109,18 @@
 {
 	struct notify_option *option = obj;
 
+	int name_size = strlen(var->name) + 1;
+	int value_size = strlen(var->value) + 1;
+
 	RAII_VAR(struct notify_option_item *, item,
-		 ao2_alloc(sizeof(*item), notify_option_item_destroy), ao2_cleanup);
-
-	if (!item || ast_string_field_init(item, 32)) {
-		return -1;
-	}
-
-	ast_string_field_set(item, name, var->name);
-	ast_string_field_set(item, value, var->value);
+		 ao2_alloc(sizeof(*item) + name_size + value_size,
+			   NULL), ao2_cleanup);
+
+	item->name = item->buf;
+	item->value = item->buf + name_size;
+
+	ast_copy_string(item->buf, var->name, name_size);
+	ast_copy_string(item->buf + name_size, var->value, value_size);
 
 	if (!ao2_link(option->items, item)) {
 		return -1;




More information about the svn-commits mailing list