[collectd] [PATCH] utils_complain: Changed c_release() into a macro.
Sebastian Harl
sh at tokkee.org
Wed Jul 2 16:29:07 CEST 2008
While the c_complain*() functions are usually used in error conditions only,
c_release() is usually used whenever things went right (which should be the
more common case ;-)). In order to minimize the overhead in the latter case,
c_release() has been changed into a macro which checks if the complaint
actually has to be released and calls c_do_release() in that case. This
function then takes care of reporting the release-message (this is the
original implementation of c_release()). So, we remove the overhead of a
function call in the usual case, i.e. when we don't have to report any
messages.
Signed-off-by: Sebastian Harl <sh at tokkee.org>
---
src/utils_complain.c | 2 +-
src/utils_complain.h | 7 ++++++-
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/utils_complain.c b/src/utils_complain.c
index 9d0f466..118245c 100644
--- a/src/utils_complain.c
+++ b/src/utils_complain.c
@@ -79,7 +79,7 @@ void c_complain_once (int level, c_complain_t *c, const char *format, ...)
va_end (ap);
} /* c_complain_once */
-void c_release (int level, c_complain_t *c, const char *format, ...)
+void c_do_release (int level, c_complain_t *c, const char *format, ...)
{
char message[512];
va_list ap;
diff --git a/src/utils_complain.h b/src/utils_complain.h
index 56e74ea..e93d823 100644
--- a/src/utils_complain.h
+++ b/src/utils_complain.h
@@ -83,7 +83,12 @@ void c_complain_once (int level, c_complain_t *c, const char *format, ...);
*
* See `c_complain' for a description of the parameters.
*/
-void c_release (int level, c_complain_t *c, const char *format, ...);
+void c_do_release (int level, c_complain_t *c, const char *format, ...);
+#define c_release(level, c, ...) \
+ do { \
+ if ((c)->interval != 0) \
+ c_do_release(level, c, __VA_ARGS__); \
+ } while (0)
#endif /* UTILS_COMPLAIN_H */
--
1.5.6.rc2
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20080702/cfbb085f/attachment.pgp
More information about the collectd
mailing list