diff --git a/network.c b/network.c index 64deb19..4dcc856 100644 --- a/network.c +++ b/network.c @@ -50,14 +50,6 @@ int net_submit(const char *hostname, const char *pluginname, const char *filenam if (list_empty(&cli_list)) return 0; - if (fwd_buf == NULL) { - fwd_buf = malloc(PKTSIZE); - if (fwd_buf == NULL) { - log_print(LOG_ERROR, "net_submit(): out of memory"); - return -1; - } - } - int size = snprintf(fwd_buf + fwd_buf_len, PKTSIZE - fwd_buf_len, "%s:%s:%s:%d %s\n", hostname, pluginname, filename, ds_id, data); @@ -183,6 +175,13 @@ int net_init(void) { config_get_strings("global", "listen", net_init_srv_cb, NULL); config_get_strings("global", "forward", net_init_cli_cb, NULL); + + fwd_buf = malloc(PKTSIZE); + if (fwd_buf == NULL) { + log_print(LOG_ERROR, "net_submit(): out of memory"); + return -1; + } + return 0; }