Skip to content

Commit 141e47c

Browse files
committed
Use C++ headers and reserved naming for vasprintf
1 parent 267cdbe commit 141e47c

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

libcxx/include/__locale_dir/support/zos.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ struct __locale_guard {
3232
_LIBCPP_HIDE_FROM_ABI __locale_guard(locale_t& __loc) : __old_loc_(std::uselocale(__loc)) {}
3333

3434
_LIBCPP_HIDE_FROM_ABI ~__locale_guard() {
35-
// if (__old_loc_)
3635
if (__old_loc_ != (locale_t)0)
3736
std::uselocale(__old_loc_);
3837
}
@@ -299,7 +298,7 @@ _LIBCPP_HIDE_FROM_ABI inline _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 3, 4) int __as
299298
va_list __va;
300299
va_start(__va, __format);
301300
__locale_guard __current(__loc);
302-
int __res = std::__ibm::vasprintf(__s, __format, __va); // non-standard
301+
int __res = std::__ibm::__vasprintf(__s, __format, __va); // non-standard
303302
va_end(__va);
304303
return __res;
305304
}

libcxx/include/__support/ibm/vasprintf.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,38 +10,38 @@
1010
#define _LIBCPP___SUPPORT_IBMVASPRINTF_H
1111

1212
#include <cstdlib> // malloc, realloc
13-
#include <stdarg.h> // va_copy, va_end
14-
#include <stdio.h> // vsnprintf
13+
#include <cstdarg> // va_copy, va_end
14+
#include <cstdio> // vsnprintf
1515

1616
_LIBCPP_BEGIN_NAMESPACE_STD
1717
namespace __ibm {
1818

1919
inline _LIBCPP_HIDE_FROM_ABI
20-
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) {
20+
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int __vasprintf(char** __strp, const char* __fmt, va_list __ap) {
2121
const size_t buff_size = 256;
22-
if ((*strp = (char*)malloc(buff_size)) == nullptr) {
22+
if ((*__strp = (char*)std::malloc(buff_size)) == nullptr) {
2323
return -1;
2424
}
2525

2626
va_list ap_copy;
2727
// va_copy may not be provided by the C library in C++03 mode.
2828
#if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy)
2929
# if defined(__MVS__) && !defined(_VARARG_EXT_)
30-
__builtin_zos_va_copy(ap_copy, ap);
30+
__builtin_zos_va_copy(ap_copy, __ap);
3131
# else
32-
__builtin_va_copy(ap_copy, ap);
32+
__builtin_va_copy(ap_copy, __ap);
3333
# endif
3434
#else
35-
va_copy(ap_copy, ap);
35+
va_copy(ap_copy, __ap);
3636
#endif
37-
int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy);
37+
int str_size = vsnprintf(*__strp, buff_size, __fmt, ap_copy);
3838
va_end(ap_copy);
3939

4040
if ((size_t)str_size >= buff_size) {
41-
if ((*strp = (char*)realloc(*strp, str_size + 1)) == nullptr) {
41+
if ((*__strp = (char*)std::realloc(*__strp, str_size + 1)) == nullptr) {
4242
return -1;
4343
}
44-
str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
44+
str_size = vsnprintf(*__strp, str_size + 1, __fmt, __ap);
4545
}
4646
return str_size;
4747
}

0 commit comments

Comments
 (0)