Howard Hinnant | 3c78ca0 | 2011-09-22 19:10:18 +0000 | [diff] [blame] | 1 | // -*- C++ -*- |
| 2 | //===--------------------------- support/win32/support.h --------------------------===// |
| 3 | // |
| 4 | // The LLVM Compiler Infrastructure |
| 5 | // |
| 6 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 7 | // Source Licenses. See LICENSE.TXT for details. |
| 8 | // |
| 9 | //===----------------------------------------------------------------------===// |
| 10 | |
| 11 | int vasprintf( char **sptr, const char *__restrict__ fmt, va_list ap ) |
| 12 | { |
| 13 | *sptr = NULL |
| 14 | int count = vsnprintf( *sptr, 0, fmt, ap ); |
| 15 | if( (count >= 0) && ((*sptr = malloc(count+1)) != NULL) ) |
| 16 | { |
| 17 | vsprintf( *sptr, fmt, ap ); |
| 18 | sptr[count] = '\0'; |
| 19 | } |
| 20 | |
| 21 | return count; |
| 22 | } |