aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-17 22:24:10 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2006-10-17 22:24:10 +0000
commited8ca6e7bcc35a5311ed46f314d4ecffe041b059 (patch)
treeef7e12bbf96ba7099e860497a27a213106551c31 /include
parent6ecd4809b7c31e2b5f2c5e7af51edd0bdb3f4ce3 (diff)
optimize the 'quick response' code a bit more... no more malloc() or memset() for each response
expand stringfields API a bit to allow reusing the stringfield pool on a structure when needed, and remove some unnecessary code when the structure was being freed git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@45408 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/stringfields.h26
1 files changed, 21 insertions, 5 deletions
diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h
index 9b5fbc6df..bf4c0a055 100644
--- a/include/asterisk/stringfields.h
+++ b/include/asterisk/stringfields.h
@@ -248,6 +248,7 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
} \
} while (0)
#endif
+
/*!
\brief Set a field to a simple string value
\param x Pointer to a structure containing fields
@@ -262,6 +263,7 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
#define ast_string_field_logset(x, field, data, logstr) \
ast_string_field_index_logset(x, ast_string_field_index(x, field), data, logstr)
#endif
+
/*!
\brief Set a field to a complex (built) value
\param x Pointer to a structure containing fields
@@ -312,7 +314,7 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
ast_string_field_index_free(x, ast_string_field_index(x, field))
/*!
- \brief Free all fields (and the storage pool) in a structure
+ \brief Free the stringfield storage pools attached to a structure
\param x Pointer to a structure containing fields
\return nothing
@@ -320,15 +322,29 @@ void __ast_string_field_index_build(struct ast_string_field_mgr *mgr,
structure; it should only be called immediately before freeing
the structure itself.
*/
-#define ast_string_field_free_all(x) do { \
- int index; \
+#define ast_string_field_free_pools(x) do { \
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) { \
prev = this->prev; \
free(this); \
} \
} while(0)
+/*!
+ \brief Free the stringfields in a structure
+ \param x Pointer to a structure containing fields
+ \return nothing
+
+ After calling this macro, the most recently allocated pool
+ attached to the structure will be available for use by
+ stringfields again.
+*/
+#define ast_string_field_free_all(x) do { \
+ int index; \
+ for (index = 0; index < ast_string_field_count(x); index++) \
+ ast_string_field_index_free(x, index); \
+ (x)->__field_mgr.used = 0; \
+ (x)->__field_mgr.space = (x)->__field_mgr.size; \
+ } while(0)
+
#endif /* _ASTERISK_STRINGFIELDS_H */