Skip to content

Commit 545e059

Browse files
authored
[libc] Clean up 'vasprintf' implementation (#111761)
Summary: This had some leftover references to the old namespace and didn't put restrict on it.
1 parent 005e601 commit 545e059

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

libc/src/stdio/asprintf.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,11 @@
1111
#include "src/__support/macros/config.h"
1212
#include "src/stdio/printf_core/vasprintf_internal.h"
1313

14-
namespace LIBC_NAMESPACE {
14+
namespace LIBC_NAMESPACE_DECL {
1515

1616
LLVM_LIBC_FUNCTION(int, asprintf,
17-
(char **__restrict buffer, const char *format, ...)) {
17+
(char **__restrict buffer, const char *__restrict format,
18+
...)) {
1819
va_list vlist;
1920
va_start(vlist, format);
2021
internal::ArgList args(vlist); // This holder class allows for easier copying
@@ -25,4 +26,4 @@ LLVM_LIBC_FUNCTION(int, asprintf,
2526
return ret;
2627
}
2728

28-
} // namespace LIBC_NAMESPACE
29+
} // namespace LIBC_NAMESPACE_DECL

libc/src/stdio/asprintf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
namespace LIBC_NAMESPACE {
1515

16-
int asprintf(char **__restrict s, const char *format, ...);
16+
int asprintf(char **__restrict s, const char *__restrict format, ...);
1717

1818
} // namespace LIBC_NAMESPACE
1919

libc/src/stdio/printf_core/vasprintf_internal.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "src/stdio/printf_core/writer.h"
1414
#include <stdlib.h> // malloc, realloc, free
1515

16-
namespace LIBC_NAMESPACE {
16+
namespace LIBC_NAMESPACE_DECL {
1717
namespace printf_core {
1818

1919
LIBC_INLINE int resize_overflow_hook(cpp::string_view new_str, void *target) {
@@ -40,7 +40,7 @@ LIBC_INLINE int resize_overflow_hook(cpp::string_view new_str, void *target) {
4040

4141
constexpr size_t DEFAULT_BUFFER_SIZE = 200;
4242

43-
LIBC_INLINE int vasprintf_internal(char **ret, const char *format,
43+
LIBC_INLINE int vasprintf_internal(char **ret, const char *__restrict format,
4444
internal::ArgList args) {
4545
char init_buff_on_stack[DEFAULT_BUFFER_SIZE];
4646
printf_core::WriteBuffer wb(init_buff_on_stack, DEFAULT_BUFFER_SIZE,
@@ -64,4 +64,4 @@ LIBC_INLINE int vasprintf_internal(char **ret, const char *format,
6464
return ret_val;
6565
}
6666
} // namespace printf_core
67-
} // namespace LIBC_NAMESPACE
67+
} // namespace LIBC_NAMESPACE_DECL

libc/src/stdio/vasprintf.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
#include "src/__support/arg_list.h"
1111
#include "src/stdio/printf_core/vasprintf_internal.h"
1212

13-
namespace LIBC_NAMESPACE {
13+
namespace LIBC_NAMESPACE_DECL {
1414

1515
LLVM_LIBC_FUNCTION(int, vasprintf,
16-
(char **__restrict ret, const char *format, va_list vlist)) {
16+
(char **__restrict ret, const char *__restrict format,
17+
va_list vlist)) {
1718
internal::ArgList args(vlist); // This holder class allows for easier copying
1819
// and pointer semantics, as well as handling
1920
// destruction automatically.
2021
return printf_core::vasprintf_internal(ret, format, args);
2122
}
2223

23-
} // namespace LIBC_NAMESPACE
24+
} // namespace LIBC_NAMESPACE_DECL

libc/src/stdio/vasprintf.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
namespace LIBC_NAMESPACE {
1515

16-
int vasprintf(char **__restrict s, const char *format, va_list vlist);
16+
int vasprintf(char **__restrict s, const char *__restrict format,
17+
va_list vlist);
1718

1819
} // namespace LIBC_NAMESPACE
1920

0 commit comments

Comments
 (0)