X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fdaemon%2Fglobals.c;h=5c6749ff83d57b9074f6c73c247e8ceeb9f3fc5e;hb=614660f40c32b5af9b6c4852e4e370fc3953a5c8;hp=b720cd88e5b8c59ca806cb5e2454c783b8fb7575;hpb=fd96744998cbd405320ef820d038dd3ee0c87caf;p=collectd.git diff --git a/src/daemon/globals.c b/src/daemon/globals.c index b720cd88..5c6749ff 100644 --- a/src/daemon/globals.c +++ b/src/daemon/globals.c @@ -1,6 +1,6 @@ /** * collectd - src/globals.c - * Copyright (C) 2017 Florian octo Forster + * Copyright (C) 2017 Google LLC * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -24,15 +24,25 @@ #include "common.h" #include "globals.h" -void hostname_set(char const *hostname) { - sstrncpy(hostname_g, hostname, sizeof(hostname_g)); -} +#if HAVE_KSTAT_H +#include +#endif /* * Global variables */ char *hostname_g; cdtime_t interval_g; -int timeout_g; +int timeout_g; +#if HAVE_KSTAT_H kstat_ctl_t *kc; +#endif +void hostname_set(char const *hostname) { + char *h = strdup(hostname); + if (h == NULL) + return; + + sfree(hostname_g); + hostname_g = h; +}