aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-05-05 13:00:04 +0000
committerkpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b>2009-05-05 13:00:04 +0000
commit12f6b763d206e5a57e07f45eabd90c7f8c61fd49 (patch)
treed3359456f178cd1af1e2b160bf2674b9334b95f8 /include
parenta01063165d8e8500f6a55f4abafe5e52f72e7596 (diff)
Merged revisions 192318 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r192318 | kpfleming | 2009-05-05 12:34:19 +0200 (Tue, 05 May 2009) | 5 lines Properly account for memory allocated for channels and datastores As in previous commits, when channels are allocated (with ast_channel_alloc) or datastores are allocated (with ast_datastore_alloc) properly account for the memory being owned by the caller, instead of the allocator function itself. ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.2@192355 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/astobj2.h29
-rw-r--r--include/asterisk/channel.h13
-rw-r--r--include/asterisk/datastore.h5
3 files changed, 36 insertions, 11 deletions
diff --git a/include/asterisk/astobj2.h b/include/asterisk/astobj2.h
index 4b14615ec..0b0bf84b1 100644
--- a/include/asterisk/astobj2.h
+++ b/include/asterisk/astobj2.h
@@ -402,10 +402,15 @@ typedef void (*ao2_destructor_fn)(void *);
* @{
*/
-#if defined(REF_DEBUG) || defined(__AST_DEBUG_MALLOC)
+#if defined(REF_DEBUG)
-#define ao2_t_alloc(data_size, destructor_fn, debug_msg) _ao2_alloc_debug((data_size), (destructor_fn), (debug_msg), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define ao2_alloc(data_size, destructor_fn) _ao2_alloc_debug((data_size), (destructor_fn), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_t_alloc(data_size, destructor_fn, debug_msg) _ao2_alloc_debug((data_size), (destructor_fn), (debug_msg), __FILE__, __LINE__, __PRETTY_FUNCTION__, 1)
+#define ao2_alloc(data_size, destructor_fn) _ao2_alloc_debug((data_size), (destructor_fn), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 1)
+
+#elif defined(__AST_DEBUG_MALLOC)
+
+#define ao2_t_alloc(data_size, destructor_fn, debug_msg) _ao2_alloc_debug((data_size), (destructor_fn), (debug_msg), __FILE__, __LINE__, __PRETTY_FUNCTION__, 0)
+#define ao2_alloc(data_size, destructor_fn) _ao2_alloc_debug((data_size), (destructor_fn), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 0)
#else
@@ -414,8 +419,10 @@ typedef void (*ao2_destructor_fn)(void *);
#endif
-void *_ao2_alloc_debug(const size_t data_size, ao2_destructor_fn destructor_fn, char *tag, char *file, int line, const char *funcname);
+void *_ao2_alloc_debug(const size_t data_size, ao2_destructor_fn destructor_fn, char *tag,
+ const char *file, int line, const char *funcname, int ref_debug);
void *_ao2_alloc(const size_t data_size, ao2_destructor_fn destructor_fn);
+
/*! @} */
/*! \brief
@@ -698,10 +705,15 @@ struct ao2_container;
* destructor is set implicitly.
*/
-#if defined(REF_DEBUG) || defined(__AST_DEBUG_MALLOC)
+#if defined(REF_DEBUG)
+
+#define ao2_t_container_alloc(arg1,arg2,arg3,arg4) _ao2_container_alloc_debug((arg1), (arg2), (arg3), (arg4), __FILE__, __LINE__, __PRETTY_FUNCTION__, 1)
+#define ao2_container_alloc(arg1,arg2,arg3) _ao2_container_alloc_debug((arg1), (arg2), (arg3), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 1)
+
+#elif defined(__AST_DEBUG_MALLOC)
-#define ao2_t_container_alloc(arg1,arg2,arg3,arg4) _ao2_container_alloc_debug((arg1), (arg2), (arg3), (arg4), __FILE__, __LINE__, __PRETTY_FUNCTION__)
-#define ao2_container_alloc(arg1,arg2,arg3) _ao2_container_alloc_debug((arg1), (arg2), (arg3), "", __FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ao2_t_container_alloc(arg1,arg2,arg3,arg4) _ao2_container_alloc_debug((arg1), (arg2), (arg3), (arg4), __FILE__, __LINE__, __PRETTY_FUNCTION__, 0)
+#define ao2_container_alloc(arg1,arg2,arg3) _ao2_container_alloc_debug((arg1), (arg2), (arg3), "", __FILE__, __LINE__, __PRETTY_FUNCTION__, 0)
#else
@@ -714,7 +726,8 @@ struct ao2_container *_ao2_container_alloc(const unsigned int n_buckets,
ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn);
struct ao2_container *_ao2_container_alloc_debug(const unsigned int n_buckets,
ao2_hash_fn *hash_fn, ao2_callback_fn *cmp_fn,
- char *tag, char *file, int line, const char *funcname);
+ char *tag, char *file, int line, const char *funcname,
+ int ref_debug);
/*! \brief
* Returns the number of elements in a container.
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 1c40efd42..432b1a1e0 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -653,7 +653,7 @@ enum channelreloadreason {
* \deprecated You should use the ast_datastore_alloc() generic function instead.
* \version 1.6.1 deprecated
*/
-struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
+struct ast_datastore * attribute_malloc ast_channel_datastore_alloc(const struct ast_datastore_info *info, const char *uid)
__attribute__((deprecated));
/*!
@@ -713,7 +713,16 @@ int ast_setstate(struct ast_channel *chan, enum ast_channel_state);
* \note By default, new channels are set to the "s" extension
* and "default" context.
*/
-struct ast_channel *ast_channel_alloc(int needqueue, int state, const char *cid_num, const char *cid_name, const char *acctcode, const char *exten, const char *context, const int amaflag, const char *name_fmt, ...) __attribute__((format(printf, 9, 10)));
+struct ast_channel * attribute_malloc __attribute__((format(printf, 12, 13)))
+ __ast_channel_alloc(int needqueue, int state, const char *cid_num,
+ const char *cid_name, const char *acctcode,
+ const char *exten, const char *context,
+ const int amaflag, const char *file, int line,
+ const char *function, const char *name_fmt, ...);
+
+#define ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, amaflag, ...) \
+ __ast_channel_alloc(needqueue, state, cid_num, cid_name, acctcode, exten, context, amaflag, \
+ __FILE__, __LINE__, __FUNCTION__, __VA_ARGS__)
/*!
* \brief Queue an outgoing frame
diff --git a/include/asterisk/datastore.h b/include/asterisk/datastore.h
index 6da1bd0bb..5f7e52348 100644
--- a/include/asterisk/datastore.h
+++ b/include/asterisk/datastore.h
@@ -65,7 +65,10 @@ struct ast_datastore {
* \param[in] uid unique identifer
* \version 1.6.1 moved here and renamed from ast_channel_datastore_alloc
*/
-struct ast_datastore *ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid);
+struct ast_datastore * attribute_malloc __ast_datastore_alloc(const struct ast_datastore_info *info, const char *uid,
+ const char *file, int line, const char *function);
+
+#define ast_datastore_alloc(info, uid) __ast_datastore_alloc(info, uid, __FILE__, __LINE__, __PRETTY_FUNCTION__)
/*!
* \brief Free a data store object