From 8a209fc6904abd3c457f3853dd62ca063bc63fa8 Mon Sep 17 00:00:00 2001 From: MelwareDE Date: Tue, 10 Mar 2009 22:39:04 +0000 Subject: [PATCH] Optimization, omit unnecessary calls to debug functions --- chan_capi_utils.c | 15 ++++++--------- chan_capi_utils.h | 14 +++++++++++++- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/chan_capi_utils.c b/chan_capi_utils.c index 8bcf057..9f81925 100644 --- a/chan_capi_utils.c +++ b/chan_capi_utils.c @@ -45,9 +45,9 @@ static struct peerlink_s { } peerlinkchannel[CAPI_MAX_PEERLINKCHANNELS]; /* - * helper for _verbose with different verbose settings + * helper for _verbose */ -void cc_verbose(int o_v, int c_d, char *text, ...) +void cc_verbose_internal(char *text, ...) { char line[4096]; va_list ap; @@ -55,6 +55,7 @@ void cc_verbose(int o_v, int c_d, char *text, ...) va_start(ap, text); vsnprintf(line, sizeof(line), text, ap); va_end(ap); + line[sizeof(line)-1]=0; #if 0 { @@ -66,13 +67,9 @@ void cc_verbose(int o_v, int c_d, char *text, ...) } #endif - if ((o_v == 0) || (option_verbose > o_v)) { - if ((!c_d) || ((c_d) && (capidebug))) { - cc_mutex_lock(&verbose_lock); - cc_pbx_verbose(line); - cc_mutex_unlock(&verbose_lock); - } - } + cc_mutex_lock(&verbose_lock); + cc_pbx_verbose(line); + cc_mutex_unlock(&verbose_lock); } /* diff --git a/chan_capi_utils.h b/chan_capi_utils.h index 1d20764..74bf640 100644 --- a/chan_capi_utils.h +++ b/chan_capi_utils.h @@ -18,7 +18,19 @@ extern int capidebug; extern char *emptyid; -extern void cc_verbose(int o_v, int c_d, char *text, ...); +extern void cc_verbose_internal(char *text, ...); + +/* + * helper for _verbose with different verbose settings + */ +#define cc_verbose(o_v,c_d,text, args...) do { \ + if ((o_v == 0) || (option_verbose > o_v)) { \ + if ((!c_d) || ((c_d) && (capidebug))) { \ + cc_verbose_internal(text , ## args); \ + } \ + } \ +}while(0) + extern _cword get_capi_MessageNumber(void); extern struct capi_pvt *capi_find_interface_by_msgnum(unsigned short msgnum); extern struct capi_pvt *capi_find_interface_by_plci(unsigned int plci);