2 * Replacements for common but usually nonstandard functions that aren't
3 * supplied by all platforms.
5 * Copyright (C) 2009 by Dan Fandrich <dan@coneharvesters.com>, et. al.
7 * Licensed under the GPL version 2, see the file LICENSE in this tarball.
12 #ifndef HAVE_STRCHRNUL
13 char * FAST_FUNC strchrnul(const char *s, int c)
15 while (*s && *s != c) ++s;
20 #ifndef HAVE_VASPRINTF
21 int FAST_FUNC vasprintf(char **string_ptr, const char *format, va_list p)
27 r = vsnprintf(NULL, 0, format, p);
29 *string_ptr = xmalloc(r+1);
33 r = vsnprintf(*string_ptr, r+1, format, p2);
41 int fdprintf(int fd, const char *format, ...)
48 r = vasprintf(&string_ptr, format, p);
51 r = full_write(fd, string_ptr, r);