X-Git-Url: http://git.meshlink.io/?p=meshlink;a=blobdiff_plain;f=lib%2Fdropin.c;h=4ad32378bdbb541c90ac9e1303d8da059ff9988a;hp=773fe4882f2bbbf6cc2190f74c7dba717158c097;hb=075e6828a7533e7daa790225f17aa6bb39703278;hpb=9b129c07e273ae113f3c67a9feeee82e8146f3a1 diff --git a/lib/dropin.c b/lib/dropin.c index 773fe488..4ad32378 100644 --- a/lib/dropin.c +++ b/lib/dropin.c @@ -124,25 +124,34 @@ char *get_current_dir_name(void) { #ifndef HAVE_ASPRINTF int asprintf(char **buf, const char *fmt, ...) { - int status; + int result; va_list ap; + va_start(ap, fmt); + result = vasprintf(buf, fmt, ap); + va_end(ap); + return result; +} + +int vasprintf(char **buf, const char *fmt, va_list ap) { + int status; + va_list aq; int len; len = 4096; *buf = xmalloc(len); - va_start(ap, fmt); - status = vsnprintf(*buf, len, fmt, ap); - va_end(ap); + va_copy(aq, ap); + status = vsnprintf(*buf, len, fmt, aq); + va_end(aq); if(status >= 0) *buf = xrealloc(*buf, status + 1); if(status > len - 1) { len = status; - va_start(ap, fmt); - status = vsnprintf(*buf, len, fmt, ap); - va_end(ap); + va_copy(aq, ap); + status = vsnprintf(*buf, len, fmt, aq); + va_end(aq); } return status; @@ -156,15 +165,3 @@ int gettimeofday(struct timeval *tv, void *tz) { return 0; } #endif - -#ifndef HAVE_RANDOM -#include - -long int random(void) { - long int x; - - RAND_pseudo_bytes((unsigned char *)&x, sizeof(x)); - - return x; -} -#endif