summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 11733d9)
raw | patch | inline | side by side (parent: 11733d9)
author | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Tue, 1 Mar 2016 13:02:33 +0000 (14:02 +0100) | ||
committer | Ruben Kerkhof <ruben@rubenkerkhof.com> | |
Tue, 1 Mar 2016 13:02:33 +0000 (14:02 +0100) |
This was guarded by HAVE_ASPRINTF, but we never had a configure check
for asprintf (or vasprintf).
This only turned up when I made the function static, since they now
clash with the prototypes in stdio.h on FreeBSD.
As far as I know all the platforms we build on have these functions.
If this turns out to be not the case, we can always add compat functions
to our utilies later.
For now, this fixes the build on FreeBSD.
for asprintf (or vasprintf).
This only turned up when I made the function static, since they now
clash with the prototypes in stdio.h on FreeBSD.
As far as I know all the platforms we build on have these functions.
If this turns out to be not the case, we can always add compat functions
to our utilies later.
For now, this fixes the build on FreeBSD.
src/write_sensu.c | patch | blob | history |
diff --git a/src/write_sensu.c b/src/write_sensu.c
index 29e7a402f011c38fb4ebab23cfb28e261bad4430..be6539954c2df6438a6f1932df19aa7e903eb78c 100644 (file)
--- a/src/write_sensu.c
+++ b/src/write_sensu.c
#include <stddef.h>
#include <stdlib.h>
-#ifndef HAVE_ASPRINTF
-/*
- * Uses asprintf() portable implementation from
- * https://github.com/littlstar/asprintf.c/blob/master/
- * copyright (c) 2014 joseph werle <joseph.werle@gmail.com> under MIT license.
- */
-#include <stdio.h>
-#include <stdarg.h>
-
-static int vasprintf(char **str, const char *fmt, va_list args) {
- int size = 0;
- va_list tmpa;
- // copy
- va_copy(tmpa, args);
- // apply variadic arguments to
- // sprintf with format to get size
- size = vsnprintf(NULL, size, fmt, tmpa);
- // toss args
- va_end(tmpa);
- // return -1 to be compliant if
- // size is less than 0
- if (size < 0) { return -1; }
- // alloc with size plus 1 for `\0'
- *str = (char *) malloc(size + 1);
- // return -1 to be compliant
- // if pointer is `NULL'
- if (NULL == *str) { return -1; }
- // format string with original
- // variadic arguments and set new size
- size = vsprintf(*str, fmt, args);
- return size;
-}
-
-static int asprintf(char **str, const char *fmt, ...) {
- int size = 0;
- va_list args;
- // init variadic argumens
- va_start(args, fmt);
- // format and get size
- size = vasprintf(str, fmt, args);
- // toss args
- va_end(args);
- return size;
-}
-
-#endif
-
#define SENSU_HOST "localhost"
#define SENSU_PORT "3030"