|
9 | 9 | #ifndef _LIBCPP___SUPPORT_IBMVASPRINTF_H |
10 | 10 | #define _LIBCPP___SUPPORT_IBMVASPRINTF_H |
11 | 11 |
|
12 | | -#include <cstdlib> // malloc, realloc |
13 | | -#include <stdarg.h> // va_copy, va_end |
14 | | -#include <stdio.h> // vsnprintf |
| 12 | +#include <cstdarg> // va_copy, va_end |
| 13 | +#include <cstdio> // vsnprintf |
| 14 | +#include <cstdlib> // malloc, realloc |
15 | 15 |
|
16 | 16 | _LIBCPP_BEGIN_NAMESPACE_STD |
17 | 17 | namespace __ibm { |
18 | 18 |
|
19 | 19 | 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) { |
21 | 21 | const size_t buff_size = 256; |
22 | | - if ((*strp = (char*)malloc(buff_size)) == nullptr) { |
| 22 | + if ((*__strp = (char*)std::malloc(buff_size)) == nullptr) { |
23 | 23 | return -1; |
24 | 24 | } |
25 | 25 |
|
26 | 26 | va_list ap_copy; |
27 | 27 | // va_copy may not be provided by the C library in C++03 mode. |
28 | 28 | #if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy) |
29 | 29 | # if defined(__MVS__) && !defined(_VARARG_EXT_) |
30 | | - __builtin_zos_va_copy(ap_copy, ap); |
| 30 | + __builtin_zos_va_copy(ap_copy, __ap); |
31 | 31 | # else |
32 | | - __builtin_va_copy(ap_copy, ap); |
| 32 | + __builtin_va_copy(ap_copy, __ap); |
33 | 33 | # endif |
34 | 34 | #else |
35 | | - va_copy(ap_copy, ap); |
| 35 | + va_copy(ap_copy, __ap); |
36 | 36 | #endif |
37 | | - int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy); |
| 37 | + int str_size = vsnprintf(*__strp, buff_size, __fmt, ap_copy); |
38 | 38 | va_end(ap_copy); |
39 | 39 |
|
40 | 40 | 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) { |
42 | 42 | return -1; |
43 | 43 | } |
44 | | - str_size = vsnprintf(*strp, str_size + 1, fmt, ap); |
| 44 | + str_size = vsnprintf(*__strp, str_size + 1, __fmt, __ap); |
45 | 45 | } |
46 | 46 | return str_size; |
47 | 47 | } |
|
0 commit comments