aboutsummaryrefslogtreecommitdiffstats
path: root/include/asterisk/stringfields.h
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-01 23:05:28 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-02-01 23:05:28 +0000
commit21d21f89c04ebaad6822311ceadd13275b357513 (patch)
tree86a6664b5cba70b924fdd1cef2ecbf93226e7d58 /include/asterisk/stringfields.h
parent4d4470fe1560a6d00b17db78798f0cc9790fe74b (diff)
use string fields for some stuff in ast_channel
const-ify some more APIs remove 'type' field from ast_channel, in favor of the one in the channel's tech structure allow string field module users to specify the 'chunk size' for pool allocations update chan_alsa to be compatible with recent const-ification patches git-svn-id: http://svn.digium.com/svn/asterisk/trunk@9060 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include/asterisk/stringfields.h')
-rw-r--r--include/asterisk/stringfields.h22
1 files changed, 9 insertions, 13 deletions
diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h
index 22e066d21..4fb87e4b2 100644
--- a/include/asterisk/stringfields.h
+++ b/include/asterisk/stringfields.h
@@ -168,11 +168,6 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
int index, const char *format, ...);
/*!
- The default amount of storage to be allocated for a field pool.
-*/
-#define AST_STRING_FIELD_DEFAULT_POOL 512
-
-/*!
\brief Declare a string field
\param name The field name
*/
@@ -194,7 +189,7 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
\return the number of fields in the structure's definition
*/
#define ast_string_field_count(x) \
- (offsetof(typeof(*x), __end_field) - offsetof(typeof(*x), __begin_field)) / sizeof(ast_string_field)
+ (offsetof(typeof(*(x)), __end_field) - offsetof(typeof(*(x)), __begin_field)) / sizeof(ast_string_field)
/*!
\brief Get the index of a field in a structure
@@ -209,10 +204,11 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
/*!
\brief Initialize a field pool and fields
\param x Pointer to a structure containing fields
+ \param size Amount of storage to allocate
\return 0 on failure, non-zero on success
*/
-#define ast_string_field_init(x) \
- __ast_string_field_init(&x->__field_mgr, AST_STRING_FIELD_DEFAULT_POOL, &x->__begin_field[0], ast_string_field_count(x))
+#define ast_string_field_init(x, size) \
+ __ast_string_field_init(&(x)->__field_mgr, size, &(x)->__begin_field[0], ast_string_field_count(x))
/*!
\brief Set a field to a simple string value
@@ -222,8 +218,8 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
\return nothing
*/
#define ast_string_field_index_set(x, index, data) do { \
- if ((x->__begin_field[index] = __ast_string_field_alloc_space(&x->__field_mgr, strlen(data) + 1, &x->__begin_field[0], ast_string_field_count(x)))) \
- strcpy((char *) x->__begin_field[index], data); \
+ if (((x)->__begin_field[index] = __ast_string_field_alloc_space(&(x)->__field_mgr, strlen(data) + 1, &(x)->__begin_field[0], ast_string_field_count(x)))) \
+ strcpy((char *) (x)->__begin_field[index], data); \
} while (0)
/*!
@@ -245,7 +241,7 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
\return nothing
*/
#define ast_string_field_index_build(x, index, fmt, args...) \
- __ast_string_field_index_build(&x->__field_mgr, &x->__begin_field[0], ast_string_field_count(x), index, fmt, args)
+ __ast_string_field_index_build(&(x)->__field_mgr, &(x)->__begin_field[0], ast_string_field_count(x), index, fmt, args)
/*!
\brief Set a field to a complex (built) value
@@ -269,7 +265,7 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
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; \
+ (x)->__begin_field[index] = __ast_string_field_empty; \
} while(0)
/*!
@@ -299,7 +295,7 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
struct ast_string_field_pool *this, *prev; \
for (index = 0; index < ast_string_field_count(x); index ++) \
ast_string_field_index_free(x, index); \
- for (this = x->__field_mgr.pool; this; this = prev) { \
+ for (this = (x)->__field_mgr.pool; this; this = prev) { \
prev = this->prev; \
free(this); \
} \