summaryrefslogtreecommitdiff
path: root/src/shared/util.c
diff options
context:
space:
mode:
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>2013-02-14 21:32:49 +0100
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>2013-02-14 21:36:45 +0100
commitf7900e258dfb8ab55f333d02d96f908ca0ea8899 (patch)
tree5ea3f278094931de8f37eaef5ded6bfa3ac1e3c9 /src/shared/util.c
parent47a81ba2e101058459328d2da3d9b950a8030c86 (diff)
bootchart: use conf-parser & CamelCase names in .conf
Diffstat (limited to 'src/shared/util.c')
-rw-r--r--src/shared/util.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/shared/util.c b/src/shared/util.c
index 152724949d..f5adedc531 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -353,6 +353,23 @@ int safe_atolli(const char *s, long long int *ret_lli) {
return 0;
}
+int safe_atod(const char *s, double *ret_d) {
+ char *x = NULL;
+ double d;
+
+ assert(s);
+ assert(ret_d);
+
+ errno = 0;
+ d = strtod(s, &x);
+
+ if (!x || x == s || *x || errno)
+ return errno ? -errno : -EINVAL;
+
+ *ret_d = (double) d;
+ return 0;
+}
+
/* Split a string into words. */
char *split(const char *c, size_t *l, const char *separator, char **state) {
char *current;