Merged revisions 192279 via svnmerge from

https://origsvn.digium.com/svn/asterisk/trunk

........
  r192279 | kpfleming | 2009-05-05 10:51:06 +0200 (Tue, 05 May 2009) | 5 lines
  
  Ensure that string pools allocated to hold stringfields are properly accounted in MALLOC_DEBUG mode
  
  This commit modifies the stringfield pool allocator to remember the 'owner' of the stringfield manager the pool is being allocated for, and ensures that pools allocated in the future when fields are populated are owned by that file/function.
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@192281 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Kevin P. Fleming
2009-05-05 09:15:13 +00:00
parent ed00c79ed0
commit 8e6c32f048
2 changed files with 62 additions and 25 deletions

View File

@@ -138,6 +138,11 @@ struct ast_string_field_mgr {
size_t size; /*!< the total size of the current pool */
size_t used; /*!< the space used in the current pool */
ast_string_field last_alloc; /*!< the last field allocated */
#if defined(__AST_DEBUG_MALLOC)
const char *owner_file; /*!< filename of owner */
const char *owner_func; /*!< function name of owner */
int owner_line; /*!< line number of owner */
#endif
};
/*!
@@ -234,15 +239,18 @@ void __ast_string_field_ptr_build_va(struct ast_string_field_mgr *mgr,
\return 0 on success, non-zero on failure
*/
#define ast_string_field_init(x, size) \
__ast_string_field_init(&(x)->__field_mgr, &(x)->__field_mgr_pool, size)
__ast_string_field_init(&(x)->__field_mgr, &(x)->__field_mgr_pool, size, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*! \brief free all memory - to be called before destroying the object */
#define ast_string_field_free_memory(x) \
__ast_string_field_init(&(x)->__field_mgr, &(x)->__field_mgr_pool, -1)
__ast_string_field_init(&(x)->__field_mgr, &(x)->__field_mgr_pool, -1, NULL, 0, NULL)
/*! \internal \brief internal version of ast_string_field_init */
int __ast_string_field_init(struct ast_string_field_mgr *mgr,
struct ast_string_field_pool **pool_head, int needed);
/*!
* \internal
* \brief internal version of ast_string_field_init
*/
int __ast_string_field_init(struct ast_string_field_mgr *mgr, struct ast_string_field_pool **pool_head,
int needed, const char *file, int lineno, const char *func);
/*!
\brief Set a field to a simple string value