[asterisk-commits] branch kpfleming/stringfields - r7767 in /team/kpfleming/stringfields: channe...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Tue Jan 3 22:24:59 CST 2006


Author: kpfleming
Date: Tue Jan  3 22:24:58 2006
New Revision: 7767

URL: http://svn.digium.com/view/asterisk?rev=7767&view=rev
Log:
make string fields read only so code won't be written to modify them

Modified:
    team/kpfleming/stringfields/channels/chan_sip.c
    team/kpfleming/stringfields/include/asterisk/stringfields.h

Modified: team/kpfleming/stringfields/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/channels/chan_sip.c?rev=7767&r1=7766&r2=7767&view=diff
==============================================================================
--- team/kpfleming/stringfields/channels/chan_sip.c (original)
+++ team/kpfleming/stringfields/channels/chan_sip.c Tue Jan  3 22:24:58 2006
@@ -11571,7 +11571,7 @@
 	build_callid_pvt(p);
 	
 	/* We have an extension to call, don't use the full contact here */
-	/* This to enable dialling registered peers with extension dialling,
+	/* This to enable dialing registered peers with extension dialling,
 	   like SIP/peername/extension 	
 	   SIP/peername will still use the full contact */
 	if (ext) {

Modified: team/kpfleming/stringfields/include/asterisk/stringfields.h
URL: http://svn.digium.com/view/asterisk/team/kpfleming/stringfields/include/asterisk/stringfields.h?rev=7767&r1=7766&r2=7767&view=diff
==============================================================================
--- team/kpfleming/stringfields/include/asterisk/stringfields.h (original)
+++ team/kpfleming/stringfields/include/asterisk/stringfields.h Tue Jan  3 22:24:58 2006
@@ -31,7 +31,7 @@
 #include "asterisk/compiler.h"
 #include "asterisk/compat.h"
 
-typedef const char const * ast_string_field;
+typedef const char * ast_string_field;
 
 static const char *__ast_string_field_empty = '\0';
 
@@ -49,7 +49,7 @@
 
 #define AST_STRING_FIELD_DEFAULT_POOL 1024
 
-#define AST_STRING_FIELD(name) ast_string_field name;
+#define AST_STRING_FIELD(name) const ast_string_field name;
 
 #define AST_DECLARE_STRING_FIELDS(field_list) \
 	ast_string_field __begin_field[0]; \
@@ -66,23 +66,13 @@
 #define ast_string_field_init(x) \
 	__ast_string_field_init(&x->__field_pool, AST_STRING_FIELD_DEFAULT_POOL, &x->__begin_field[0], ast_string_field_count(x))
 
-#define ast_string_field_set(x, field, data) do { \
-	if ((x->field = __ast_string_field_alloc_space(&x->__field_pool, strlen(data) + 1, &x->__begin_field[0], ast_string_field_count(x)))) \
-		strcpy((char *) x->field, data); \
-	} while (0)
-
 #define ast_string_field_index_set(x, index, data) do { \
 	if ((x->__begin_field[index] = __ast_string_field_alloc_space(&x->__field_pool, strlen(data) + 1, &x->__begin_field[0], ast_string_field_count(x)))) \
 		strcpy((char *) x->__begin_field[index], data); \
 	} while (0)
 
-#define ast_string_field_build(x, field, fmt, args...) do { \
-	char s; \
-	size_t needed; \
-	needed = snprintf(&s, 1, fmt, args) + 1; \
-	if ((x->field = __ast_string_field_alloc_space(&x->__field_pool, needed, &x->__begin_field[0], ast_string_field_count(x)))) \
-		sprintf((char *) x->field, fmt, args); \
-	} while (0)
+#define ast_string_field_set(x, field, data) \
+	ast_string_field_index_set(x, ast_string_field_index(x, field), data)
 
 #define ast_string_field_index_build(x, index, fmt, args...) do { \
 	char s; \
@@ -92,13 +82,15 @@
 		sprintf((char *) x->__begin_field[index], fmt, args); \
 	} while (0)
 
-#define ast_string_field_free(x, field) do { \
-	x->field = __ast_string_field_empty; \
-	} while(0)
+#define ast_string_field_build(x, field, fmt, args...) \
+	ast_string_field_index_build(x, ast_string_field_index(x, field), fmt, args)
 
 #define ast_string_field_index_free(x, index) do { \
 	x->__begin_field[index] = __ast_string_field_empty; \
 	} while(0)
+
+#define ast_string_field_free(x, field) \
+	ast_string_field_index_free(x, ast_string_field_index(x, field))
 
 #define ast_string_field_free_all(x) do { \
 	int index; \



More information about the asterisk-commits mailing list