From 696f9ed6770cec3d2a43317c3a0839f6854248a3 Mon Sep 17 00:00:00 2001 From: "Kevin P. Fleming" Date: Tue, 17 Oct 2006 22:24:45 +0000 Subject: Merged revisions 45408 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r45408 | kpfleming | 2006-10-17 17:24:10 -0500 (Tue, 17 Oct 2006) | 3 lines 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: https://origsvn.digium.com/svn/asterisk/trunk@45409 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- include/asterisk/stringfields.h | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) (limited to 'include/asterisk/stringfields.h') 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 */ -- cgit v1.2.3