Commit 0458cf14 authored by Pekka Pessi's avatar Pekka Pessi

nua: using HAVE_MEMLEAK_LOG

Logging nua_handle_ref() and nua_handle_unref().

darcs-hash:20080903175522-db55f-7e0c674a44dd485bc6d7b379a88e21353502385a.gz
parent 92b32097
......@@ -163,8 +163,47 @@ static void nh_destructor(void *arg)
SU_DEBUG_0(("nh_destructor(%p)\n", (void *)nh));
}
#undef nua_handle_ref
#undef nua_handle_unref
#if HAVE_MEMLEAK_LOG
nua_handle_t *
_nua_handle_ref_by(nua_handle_t *nh,
char const *file, unsigned line,
char const *function)
{
if (nh)
SU_DEBUG_0(("%p - nua_handle_ref() => "MOD_ZU" by %s:%u: %s()\n",
nh, su_home_refcount((su_home_t *)nh) + 1, file, line, by));
return (nua_handle_t *)su_home_ref((su_home_t *)nh);
}
int
_nua_handle_unref_by(nua_handle_t *nh,
char const *file, unsigned line,
char const *function)
{
if (nh) {
size_t refcount = su_home_refcount((su_home_t *)nh) - 1;
int freed = su_home_unref((su_home_t *)nh);
if (freed) refcount = 0;
SU_DEBUG_0(("%p - nua_handle_unref() => "MOD_ZU" by %s:%u: %s()\n",
nh, refcount, file, line, by));
return freed;
}
return 0;
}
nua_handle_t *nua_handle_ref(nua_handle_t *nh)
{
return _nua_handle_ref_by(nh, "<app>", 0, "<app>")
}
int nua_handle_unref(nua_handle_t *nh)
{
return _nua_handle_unref_by(nh, "<app>", 0, "<app>")
}
#else
/** Make a new reference to handle.
*
......@@ -198,6 +237,8 @@ int nua_handle_unref(nua_handle_t *nh)
return su_home_unref(nh->nh_home);
}
#endif
/** Generate an instance identifier. */
char const *nua_generate_instance_identifier(su_home_t *home)
{
......
......@@ -103,37 +103,6 @@ typedef struct register_usage nua_registration_t;
TAG_IF((include) && (soa) && soa_is_remote_chat_active(soa) >= 0, \
SOATAG_ACTIVE_CHAT(soa_is_remote_chat_active(soa)))
#if HAVE_NUA_HANDLE_DEBUG
#define nua_handle_ref(nh) nua_handle_ref_by((nh), __func__)
#define nua_handle_unref(nh) nua_handle_unref_by((nh), __func__)
su_inline nua_handle_t *nua_handle_ref_by(nua_handle_t *nh,
char const *by)
{
if (nh)
SU_DEBUG_0(("nua_handle_ref(%p) => "MOD_ZU" by %s\n", nh,
su_home_refcount((su_home_t *)nh) + 1,
by));
return (nua_handle_t *)su_home_ref((su_home_t *)nh);
}
su_inline int nua_handle_unref_by(nua_handle_t *nh, char const *by)
{
if (nh) {
size_t refcount = su_home_refcount((su_home_t *)nh) - 1;
int freed = su_home_unref((su_home_t *)nh);
if (freed) refcount = 0;
SU_DEBUG_0(("nua_handle_unref(%p) => "MOD_ZU" by %s\n",
nh, refcount, by));
return freed;
}
return 0;
}
#endif
/** @internal @brief NUA handle.
*
*/
......@@ -277,6 +246,20 @@ struct nua_s {
#define __func__ "nua"
#endif
#if HAVE_MEMLEAK_LOG
#define nua_handle_ref(nh) \
_nua_handle_ref_by((nh), __FILE__, __LINE__, __func__)
#define nua_handle_unref(nh) \
_nua_handle_unref_by((nh), __FILE__, __LINE__, __func__)
nua_handle_t *_nua_handle_ref_by(
nua_handle_t *nh, char const *file, unsigned line, char const *by);
int _nua_handle_unref_by(
nua_handle_t *nh, char const *file, unsigned line, char const *by);
#endif
su_inline nua_t *nua_stack_ref(nua_t *nua)
{
return (nua_t *)su_home_ref(nua->nua_home);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment