xref: /llvm-project/libc/src/stdio/vasprintf.cpp (revision 545e0593f8c59376a7ec8c6eb558babf6c9f93c1)
1a5e67fbaSTsz Chan //===-- Implementation of vasprintf -----------------------------*- C++ -*-===//
2a5e67fbaSTsz Chan //
3a5e67fbaSTsz Chan // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4a5e67fbaSTsz Chan // See https://llvm.org/LICENSE.txt for license information.
5a5e67fbaSTsz Chan // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6a5e67fbaSTsz Chan //
7a5e67fbaSTsz Chan //===----------------------------------------------------------------------===//
8a5e67fbaSTsz Chan 
9a5e67fbaSTsz Chan #include "src/stdio/vasprintf.h"
10a5e67fbaSTsz Chan #include "src/__support/arg_list.h"
11a5e67fbaSTsz Chan #include "src/stdio/printf_core/vasprintf_internal.h"
12a5e67fbaSTsz Chan 
13*545e0593SJoseph Huber namespace LIBC_NAMESPACE_DECL {
14a5e67fbaSTsz Chan 
15a5e67fbaSTsz Chan LLVM_LIBC_FUNCTION(int, vasprintf,
16*545e0593SJoseph Huber                    (char **__restrict ret, const char *__restrict format,
17*545e0593SJoseph Huber                     va_list vlist)) {
18a5e67fbaSTsz Chan   internal::ArgList args(vlist); // This holder class allows for easier copying
19a5e67fbaSTsz Chan                                  // and pointer semantics, as well as handling
20a5e67fbaSTsz Chan                                  // destruction automatically.
21a5e67fbaSTsz Chan   return printf_core::vasprintf_internal(ret, format, args);
22a5e67fbaSTsz Chan }
23a5e67fbaSTsz Chan 
24*545e0593SJoseph Huber } // namespace LIBC_NAMESPACE_DECL
25