blob: 7033809bd2a55ebdccb40e5ea352ee27550c9f9c [file] [log] [blame]
Howard Hinnant3c78ca02011-09-22 19:10:18 +00001// -*- 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
11int 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}