summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9e68a77)
raw | patch | inline | side by side (parent: 9e68a77)
author | Sebastian Harl <sh@tokkee.org> | |
Wed, 2 Jul 2008 14:29:07 +0000 (16:29 +0200) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Sun, 6 Jul 2008 12:28:34 +0000 (14:28 +0200) |
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@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
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@tokkee.org>
Signed-off-by: Florian Forster <octo@huhu.verplant.org>
src/utils_complain.c | patch | blob | history | |
src/utils_complain.h | patch | blob | history |
diff --git a/src/utils_complain.c b/src/utils_complain.c
index 9d0f46690dba60bd5bb8486000a57ad8ad2d2796..118245ccca21bab915e21ef00b9064ee1e50c214 100644 (file)
--- a/src/utils_complain.c
+++ b/src/utils_complain.c
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 56e74eabac3400d729df19d80ed7636157ede56b..e93d823e2ae8a52cb30cb15ff4be67c57308a184 100644 (file)
--- a/src/utils_complain.h
+++ b/src/utils_complain.h
*
* 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 */