[libc-commits] [libc] [libc] Implement vasprintf and asprintf (PR #98824)
Joseph Huber via libc-commits
libc-commits at lists.llvm.org
Sun Jul 28 05:05:27 PDT 2024
================
@@ -0,0 +1,25 @@
+//===-- Implementation of asprintf -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/stdio/asprintf.h"
+#include "src/__support/OSUtil/io.h"
+#include "src/__support/macros/config.h"
+#include "src/stdio/printf_core/vasprintf_internal.h"
+
+namespace LIBC_NAMESPACE {
+
+LLVM_LIBC_FUNCTION(int, asprintf,
+ (char **__restrict buffer, const char *format, ...)) {
+ va_list vlist;
+ va_start(vlist, format);
+ int ret = printf_core::vasprintf_internal(buffer, format, vlist);
+ va_end(vlist);
+ return ret;
----------------
jhuber6 wrote:
Use the `ArgList` helper, see `sprintf`.
https://github.com/llvm/llvm-project/pull/98824
More information about the libc-commits
mailing list