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>
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;
*
* 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 */