Skip to content

[libc++] Two internal headers are still using NULL #108741

@frederick-vs-ja

Description

@frederick-vs-ja

inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return NULL; }
inline _LIBCPP_HIDE_FROM_ABI void freelocale(locale_t) {}
inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return NULL; }
inline _LIBCPP_HIDE_FROM_ABI locale_t uselocale(locale_t) { return NULL; }

inline _LIBCPP_HIDE_FROM_ABI
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) {
const size_t buff_size = 256;
if ((*strp = (char*)malloc(buff_size)) == NULL) {
return -1;
}
va_list ap_copy;
// va_copy may not be provided by the C library in C++03 mode.
#if defined(_LIBCPP_CXX03_LANG) && __has_builtin(__builtin_va_copy)
__builtin_va_copy(ap_copy, ap);
#else
va_copy(ap_copy, ap);
#endif
int str_size = vsnprintf(*strp, buff_size, fmt, ap_copy);
va_end(ap_copy);
if ((size_t)str_size >= buff_size) {
if ((*strp = (char*)realloc(*strp, str_size + 1)) == NULL) {
return -1;
}
str_size = vsnprintf(*strp, str_size + 1, fmt, ap);
}
return str_size;
}

Given libc++'s <__config> supports nullptr in ancient C++03 mode

# define nullptr __nullptr

Should we just replace these uses of NULL with nullptr?

Metadata

Metadata

Assignees

No one assigned

    Labels

    libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions