/**
* 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"),
* DEALINGS IN THE SOFTWARE.
**/
-#include "common.h"
#include "globals.h"
+#include "utils/common/common.h"
-void hostname_set(char const *hostname) {
- sstrncpy(hostname_g, hostname, sizeof(hostname_g));
-}
+#if HAVE_KSTAT_H
+#include <kstat.h>
+#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;
+}