alloc fwdbuf during init

This commit is contained in:
Olaf Rempel 2009-05-01 23:19:29 +02:00
parent 7f6e90e6b3
commit eb69980908

View File

@ -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;
}