src/common.[ch]: Pass user data to `walk_directory'.
[collectd.git] / src / common.h
index a5e2167..f463b77 100644 (file)
 #endif
 
 #define sfree(ptr) \
-       if((ptr) != NULL) { \
-               free(ptr); \
-       } \
-       (ptr) = NULL
+       do { \
+               if((ptr) != NULL) { \
+                       free(ptr); \
+               } \
+               (ptr) = NULL; \
+       } while (0)
 
 #define STATIC_ARRAY_SIZE(a) (sizeof (a) / sizeof (*(a)))
 
@@ -201,8 +203,10 @@ int notification_init (notification_t *n, int severity, const char *message,
                        (vl)->host, (vl)->plugin, (vl)->plugin_instance, \
                        (ds)->type, (vl)->type_instance)
 
-typedef int (*dirwalk_callback_f)(const char *filename);
-int walk_directory (const char *dir, dirwalk_callback_f callback);
+typedef int (*dirwalk_callback_f)(const char *dirname, const char *filename,
+               void *user_data);
+int walk_directory (const char *dir, dirwalk_callback_f callback,
+               void *user_data);
 int read_file_contents (const char *filename, char *buf, int bufsize);
 
 #endif /* COMMON_H */