[svn-commits] rizzo: branch rizzo/video_v2 r87625 - /team/rizzo/video_v2/include/asterisk/
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Oct 30 13:23:16 CDT 2007
Author: rizzo
Date: Tue Oct 30 13:23:16 2007
New Revision: 87625
URL: http://svn.digium.com/view/asterisk?view=rev&rev=87625
Log:
stringfield cleanup - put back the const in AST_STRING_FIELD,
and document the internal management of fields as entries of
an array.
Modified:
team/rizzo/video_v2/include/asterisk/stringfields.h
Modified: team/rizzo/video_v2/include/asterisk/stringfields.h
URL: http://svn.digium.com/view/asterisk/team/rizzo/video_v2/include/asterisk/stringfields.h?view=diff&rev=87625&r1=87624&r2=87625
==============================================================================
--- team/rizzo/video_v2/include/asterisk/stringfields.h (original)
+++ team/rizzo/video_v2/include/asterisk/stringfields.h Tue Oct 30 13:23:16 2007
@@ -184,7 +184,7 @@
\brief Declare a string field
\param name The field name
*/
-#define AST_STRING_FIELD(name) ast_string_field name // was const ast_string ...
+#define AST_STRING_FIELD(name) const ast_string_field name
/*!
\brief Declare the fields needed in a structure
@@ -193,11 +193,14 @@
followed by individual string fields, and then a struct ast_string_field_mgr
which describes the space allocated.
We split the two variables so they can be used as markers around the
- field_list, and this allows us to play various tricks with them.
-
- \note: we rely on __field_mgr_pool to be a non-const pointer,
- so we know its size is the same as sizeof(ast_string_field) and we
- can cast it to char * when writing to the fields.
+ field_list, and this allows us to determine how many entries are in
+ the field, and play with them.
+ In particular, for writing to the field, we rely on __field_mgr_pool to be
+ a non-const pointer, so 1) we know it has the same size as ast_string_field,
+ and 2) we can cast it to const char * and use it as the base of an array to
+ write to the fields.
+ Because of this, the low-level functions to manipulate stringfields
+ use the index instead of the name of the field.
*/
#define AST_DECLARE_STRING_FIELDS(field_list) \
struct ast_string_field_pool *__field_mgr_pool; \
@@ -312,7 +315,8 @@
pointer is just changed to point to an empty string.
*/
#define ast_string_field_index_free(x, index) do { \
- (x)->__begin_field[index] = __ast_string_field_empty; \
+ const char **__p__ = (const char **)&(x)->__field_mgr_pool + 1 + index; \
+ *__p__ = __ast_string_field_empty; \
} while(0)
/*!
@@ -326,7 +330,7 @@
pointer is just changed to point to an empty string.
*/
#define ast_string_field_free(x, field) do { \
- (x)->field = __ast_string_field_empty ; \
+ ast_string_field_index_free(x, ast_string_field_index(x, field)) ; \
} while (0)
/*!
More information about the svn-commits
mailing list