aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--evaluator.h5
-rw-r--r--plugin_i2c_sensors.c6
2 files changed, 6 insertions, 5 deletions
diff --git a/evaluator.h b/evaluator.h
index d969afe..5de3ce1 100644
--- a/evaluator.h
+++ b/evaluator.h
@@ -40,6 +40,11 @@ typedef struct {
char *string;
} RESULT;
+/* strndup() may be not available on several platforms */
+#ifndef HAVE_STRNDUP
+char *strndup(const char *source, size_t len);
+#endif
+
int SetVariable(const char *name, RESULT * value);
int SetVariableNumeric(const char *name, const double value);
int SetVariableString(const char *name, const char *value);
diff --git a/plugin_i2c_sensors.c b/plugin_i2c_sensors.c
index 47d080e..989f97c 100644
--- a/plugin_i2c_sensors.c
+++ b/plugin_i2c_sensors.c
@@ -74,6 +74,7 @@
#include "cfg.h"
#include "hash.h"
#include "qprintf.h"
+#include "evaluator.h" // if strndup() is not available
#ifdef WITH_DMALLOC
#include <dmalloc.h>
@@ -188,12 +189,7 @@ static int parse_i2c_sensors_procfs(const char *key)
return -1;
}
-#ifndef __MAC_OS_X_VERSION_10_3
running = strndup(buffer, sizeof(buffer));
-#else
- // there is no strndup in OSX
- running = strdup(buffer);
-#endif
while (1) {
value = strsep(&running, delim);
/* debug("%s pos %i -> %s", file, pos , value); */