asprintf.c revision 186690
1186690Sobrien/* 2186690Sobrien * Copyright (c) Ian F. Darwin 1986-1995. 3186690Sobrien * Software written by Ian F. Darwin and others; 4186690Sobrien * maintained 1995-present by Christos Zoulas and others. 5186690Sobrien * 6186690Sobrien * Redistribution and use in source and binary forms, with or without 7186690Sobrien * modification, are permitted provided that the following conditions 8186690Sobrien * are met: 9186690Sobrien * 1. Redistributions of source code must retain the above copyright 10186690Sobrien * notice immediately at the beginning of the file, without modification, 11186690Sobrien * this list of conditions, and the following disclaimer. 12186690Sobrien * 2. Redistributions in binary form must reproduce the above copyright 13186690Sobrien * notice, this list of conditions and the following disclaimer in the 14186690Sobrien * documentation and/or other materials provided with the distribution. 15186690Sobrien * 16186690Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17186690Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18186690Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19186690Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR 20186690Sobrien * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21186690Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22186690Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23186690Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24186690Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25186690Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26186690Sobrien * SUCH DAMAGE. 27186690Sobrien */ 28186690Sobrien 29186690Sobrien#include <stdarg.h> 30186690Sobrien 31186690Sobrienint vasprintf(char **ptr, const char *format_string, va_list vargs); 32186690Sobrien 33186690Sobrienint asprintf(char **ptr, const char *fmt, ...) 34186690Sobrien{ 35186690Sobrien va_list vargs; 36186690Sobrien int retval; 37186690Sobrien 38186690Sobrien va_start(vargs, fmt); 39186690Sobrien retval = vasprintf(ptr, fmt, vargs); 40186690Sobrien va_end(vargs); 41186690Sobrien 42186690Sobrien return retval; 43186690Sobrien} 44