/* vasprintf() and asprintf() for platforms with a C99-compliant snprintf() - so that, if you format into a 1-byte buffer, it will return how many characters it would have produced had it been given an infinite-sized buffer.  */
int pcap_vasprintf(char **strp, const char *format, va_list args)
/* vasprintf() and asprintf() for platforms with a C99-compliant snprintf() - so that, if you format into a 1-byte buffer, it will return how many characters it would have produced had it been given an infinite-sized buffer.  */
int pcap_vasprintf(char **strp, const char *format, va_list args)
{
	char buf;
	int len;
	size_t str_size;
	char *str;
	int ret;
	len = vsnprintf(&buf, sizeof buf, format, args);
	if (len == -1) {
		*strp = NULL;
		return (-1);
	}
	str_size = len + 1;
	str = malloc(str_size);
	if (str == NULL) {
		*strp = NULL;
		return (-1);
	}
	ret = vsnprintf(str, str_size, format, args);
	if (ret == -1) {
		free(str);
		*strp = NULL;
		return (-1);
	}
	*strp = str;
	return (ret);
}