summaryrefslogtreecommitdiff
path: root/main/astobj2_private.h
diff options
context:
space:
mode:
authorCorey Farrell <git@cfware.com>2015-04-17 03:16:59 -0400
committerCorey Farrell <git@cfware.com>2015-04-27 18:37:26 -0400
commit5c1d07baf083fd791c8f717209551d9227413ef7 (patch)
tree7eff8c651efb82e89fd7918038102b84fe888ced /main/astobj2_private.h
parentd7f4788341f08f386341416aa3944c7f9bc0dc1b (diff)
Astobj2: Allow reference debugging to be enabled/disabled by config.
* The REF_DEBUG compiler flag no longer has any effect on code that uses Astobj2. It is used to determine if reference debugging is enabled by default. Reference debugging can be enabled or disabled in asterisk.conf. * Caller information is provided in logger errors for ao2 bad magic numbers. * Optimizes AO2 by merging internal functions with the public counterpart. This was possible now that we no longer require a dual ABI. ASTERISK-24974 #close Reported by: Corey Farrell Change-Id: Icf3552721fe999365ba8a8cf00a965aa6b897cc1
Diffstat (limited to 'main/astobj2_private.h')
-rw-r--r--main/astobj2_private.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/main/astobj2_private.h b/main/astobj2_private.h
index 0583faf7f..ef47ed774 100644
--- a/main/astobj2_private.h
+++ b/main/astobj2_private.h
@@ -43,7 +43,24 @@ struct ao2_stats {
extern struct ao2_stats ao2;
#endif /* defined(AO2_DEBUG) */
-int is_ao2_object(void *user_data);
+void log_bad_ao2(void *user_data, const char *file, int line, const char *func);
+int internal_is_ao2_object(void *user_data);
+
+#define __is_ao2_object(user_data, file, line, func) \
+ ({ \
+ int ret ## __LINE__ = 0; \
+ if (user_data) { \
+ ret ## __LINE__ = internal_is_ao2_object(user_data); \
+ } \
+ if (!ret ## __LINE__) { \
+ log_bad_ao2(user_data, file, line, func); \
+ } \
+ (ret ## __LINE__); \
+ })
+
+#define is_ao2_object(user_data) \
+ __is_ao2_object(user_data, __FILE__, __LINE__, __PRETTY_FUNCTION__)
+
enum ao2_lock_req __adjust_lock(void *user_data, enum ao2_lock_req lock_how, int keep_stronger);
#endif /* ASTOBJ2_PRIVATE_H_ */