Make sure files in this changeset are formatted properly
[collectd.git] / src / daemon / globals.c
index 398e2dd..85f1b11 100644 (file)
@@ -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"),
  * DEALINGS IN THE SOFTWARE.
  **/
 
+// clang-format off
+/*
+ * Explicit order is required or _FILE_OFFSET_BITS will have definition mismatches on Solaris
+ * See Github Issue #3193 for details
+ */
+#include "utils/common/common.h"
 #include "globals.h"
-#include "plugin.h"
+// clang-format on
+
+#if HAVE_KSTAT_H
+#include <kstat.h>
+#endif
+
 /*
  * Global variables
  */
-char hostname_g[DATA_MAX_NAME_LEN];
-const int hostname_g_size = sizeof (hostname_g);
+char *hostname_g;
 cdtime_t interval_g;
-int  pidfile_from_cli = 0;
-int  timeout_g;
-#if HAVE_LIBKSTAT
+int timeout_g;
+#if HAVE_KSTAT_H
 kstat_ctl_t *kc;
-#endif /* HAVE_LIBKSTAT */
+#endif
+
+void hostname_set(char const *hostname) {
+  char *h = strdup(hostname);
+  if (h == NULL)
+    return;
+
+  sfree(hostname_g);
+  hostname_g = h;
+}