summaryrefslogtreecommitdiff
path: root/include/asterisk/stringfields.h
diff options
context:
space:
mode:
authorKevin P. Fleming <kpfleming@digium.com>2009-05-05 08:51:06 +0000
committerKevin P. Fleming <kpfleming@digium.com>2009-05-05 08:51:06 +0000
commitd8182202efdc2f292f64718cc038eee982850786 (patch)
tree32bb84ae78de69f9dca21f2f436cb90c10eba737 /include/asterisk/stringfields.h
parent0d44a848705c0a39344b6527a20a1fb4a1d944f8 (diff)
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/trunk@192279 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk/stringfields.h')
-rw-r--r--include/asterisk/stringfields.h20
1 files changed, 14 insertions, 6 deletions
diff --git a/include/asterisk/stringfields.h b/include/asterisk/stringfields.h
index c48e9382a..3d59ea12c 100644
--- a/include/asterisk/stringfields.h
+++ b/include/asterisk/stringfields.h
@@ -137,7 +137,12 @@ struct ast_string_field_pool {
\brief Structure used to manage the storage for a set of string fields.
*/
struct ast_string_field_mgr {
- ast_string_field last_alloc; /*!< the last field allocated */
+ 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
};
/*!
@@ -235,15 +240,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);
/*!
\internal