summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e94f5c9)
raw | patch | inline | side by side (parent: e94f5c9)
author | Manuel Luis Sanmartín Rozada <manuel.luis@gmail.com> | |
Mon, 8 Jun 2015 19:12:52 +0000 (21:12 +0200) | ||
committer | Manuel Luis Sanmartín Rozada <manuel.luis@gmail.com> | |
Mon, 8 Jun 2015 19:19:34 +0000 (21:19 +0200) |
src/daemon/plugin.c | patch | blob | history |
diff --git a/src/daemon/plugin.c b/src/daemon/plugin.c
index 0ef6273bf6c2d0d91034a1b20c0bdb17da50d306..255cccc0e97e215aa72b5496dcdc33b9c91b698d 100644 (file)
--- a/src/daemon/plugin.c
+++ b/src/daemon/plugin.c
sfree(cb);
} /* static void plugin_flush_callback_free */
+static char *plugin_flush_callback_name (const char *name)
+{
+ char *flush_prefix = "flush/";
+ size_t prefix_size;
+ char *flush_name;
+ size_t name_size;
+
+ prefix_size = strlen(flush_prefix);
+ name_size = strlen(name);
+
+ flush_name = malloc (sizeof(char) * (name_size + prefix_size + 1));
+ if (flush_name == NULL)
+ {
+ ERROR ("plugin_flush_callback_name: malloc failed.");
+ return (NULL);
+ }
+
+ sstrncpy (flush_name, flush_prefix, prefix_size + 1);
+ sstrncpy (flush_name + prefix_size, name, name_size + 1);
+
+ return flush_name;
+} /* static char *plugin_flush_callback_name */
+
int plugin_register_flush (const char *name,
plugin_flush_cb callback, user_data_t *ud)
{
if (ctx.flush_interval != 0)
{
- char *flush_prefix = "flush/";
- size_t prefix_size;
char *flush_name;
- size_t name_size;
user_data_t ud;
flush_callback_t *cb;
- prefix_size = strlen(flush_prefix);
- name_size = strlen(name);
-
- flush_name = (char *) malloc (sizeof (char) *
- (name_size + prefix_size + 1));
+ flush_name = plugin_flush_callback_name (name);
if (flush_name == NULL)
- {
- ERROR ("plugin_register_flush: malloc failed.");
- plugin_unregister (list_flush, name);
return (-1);
- }
-
- sstrncpy (flush_name, flush_prefix, prefix_size + 1);
- sstrncpy (flush_name + prefix_size, name, name_size + 1);
cb = (flush_callback_t *)malloc(sizeof(flush_callback_t));
if (cb == NULL)
if (ctx.flush_interval != 0)
{
- char *flush_prefix = "flush/";
- size_t prefix_size;
char *flush_name;
- size_t name_size;
- prefix_size = strlen(flush_prefix);
- name_size = strlen(name);
-
- flush_name = (char *) malloc (sizeof (char) *
- (name_size + prefix_size + 1));
+ flush_name = plugin_flush_callback_name (name);
if (flush_name == NULL)
- {
- ERROR ("plugin_unregister_flush: malloc failed.");
return (-1);
- }
-
- sstrncpy (flush_name, flush_prefix, prefix_size + 1);
- sstrncpy (flush_name + prefix_size, name, name_size + 1);
plugin_unregister_read(flush_name);
sfree(flush_name);