Skip to content

Commit d0438d2

Browse files
authored
[libc++][NFC] Replace uses of NULL by nullptr (#108847)
Closes #108741
1 parent b84c429 commit d0438d2

File tree

9 files changed

+27
-27
lines changed

9 files changed

+27
-27
lines changed

libcxx/include/__locale_dir/locale_base_api/ibm.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ strtoull_l(const char* __nptr, char** __endptr, int __base, locale_t locale) {
8282
inline _LIBCPP_HIDE_FROM_ABI
8383
_LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char* fmt, va_list ap) {
8484
const size_t buff_size = 256;
85-
if ((*strp = (char*)malloc(buff_size)) == NULL) {
85+
if ((*strp = (char*)malloc(buff_size)) == nullptr) {
8686
return -1;
8787
}
8888

@@ -97,7 +97,7 @@ _LIBCPP_ATTRIBUTE_FORMAT(__printf__, 2, 0) int vasprintf(char** strp, const char
9797
va_end(ap_copy);
9898

9999
if ((size_t)str_size >= buff_size) {
100-
if ((*strp = (char*)realloc(*strp, str_size + 1)) == NULL) {
100+
if ((*strp = (char*)realloc(*strp, str_size + 1)) == nullptr) {
101101
return -1;
102102
}
103103
str_size = vsnprintf(*strp, str_size + 1, fmt, ap);

libcxx/include/__support/xlocale/__nop_locale_mgmt.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
// Patch over lack of extended locale support
1616
typedef void* locale_t;
1717

18-
inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return NULL; }
18+
inline _LIBCPP_HIDE_FROM_ABI locale_t duplocale(locale_t) { return nullptr; }
1919

2020
inline _LIBCPP_HIDE_FROM_ABI void freelocale(locale_t) {}
2121

22-
inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return NULL; }
22+
inline _LIBCPP_HIDE_FROM_ABI locale_t newlocale(int, const char*, locale_t) { return nullptr; }
2323

24-
inline _LIBCPP_HIDE_FROM_ABI locale_t uselocale(locale_t) { return NULL; }
24+
inline _LIBCPP_HIDE_FROM_ABI locale_t uselocale(locale_t) { return nullptr; }
2525

2626
#define LC_COLLATE_MASK (1 << LC_COLLATE)
2727
#define LC_CTYPE_MASK (1 << LC_CTYPE)

libcxx/src/atomic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,11 @@ static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const vo
9494

9595
static void
9696
__libcpp_platform_wait_on_address(__cxx_atomic_contention_t const volatile* __ptr, __cxx_contention_t __val) {
97-
_umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAIT, __val, NULL, NULL);
97+
_umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAIT, __val, nullptr, nullptr);
9898
}
9999

100100
static void __libcpp_platform_wake_by_address(__cxx_atomic_contention_t const volatile* __ptr, bool __notify_one) {
101-
_umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, NULL, NULL);
101+
_umtx_op(const_cast<__cxx_atomic_contention_t*>(__ptr), UMTX_OP_WAKE, __notify_one ? 1 : INT_MAX, nullptr, nullptr);
102102
}
103103

104104
#else // <- Add other operating systems here

libcxx/src/locale.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,7 +1004,7 @@ const ctype<char>::mask* ctype<char>::classic_table() noexcept {
10041004
# warning ctype<char>::classic_table() is not implemented
10051005
printf("ctype<char>::classic_table() is not implemented\n");
10061006
abort();
1007-
return NULL;
1007+
return nullptr;
10081008
# endif
10091009
}
10101010
#endif

libcxx/src/support/ibm/mbsnrtowcs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t mbsnrtowcs(
4848
size_t dest_remaining = max_dest_chars - dest_converted;
4949

5050
if (dst == nullptr) {
51-
result = mbrtowc(NULL, *src + source_converted, source_remaining, ps);
51+
result = mbrtowc(nullptr, *src + source_converted, source_remaining, ps);
5252
} else if (dest_remaining >= source_remaining) {
5353
// dst has enough space to translate in-place.
5454
result = mbrtowc(dst + dest_converted, *src + source_converted, source_remaining, ps);
@@ -86,7 +86,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t mbsnrtowcs(
8686

8787
if (dst) {
8888
if (result == terminated_sequence)
89-
*src = NULL;
89+
*src = nullptr;
9090
else
9191
*src += source_converted;
9292
}

libcxx/src/support/ibm/wcsnrtombs.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t wcsnrtombs(
4141
size_t dest_remaining = dst_size_bytes - dest_converted;
4242

4343
if (dst == nullptr) {
44-
result = wcrtomb(NULL, c, ps);
44+
result = wcrtomb(nullptr, c, ps);
4545
} else if (dest_remaining >= static_cast<size_t>(MB_CUR_MAX)) {
4646
// dst has enough space to translate in-place.
4747
result = wcrtomb(dst + dest_converted, c, ps);
@@ -82,7 +82,7 @@ _LIBCPP_EXPORTED_FROM_ABI size_t wcsnrtombs(
8282

8383
if (c == L'\0') {
8484
if (dst)
85-
*src = NULL;
85+
*src = nullptr;
8686
return dest_converted;
8787
}
8888
}

libcxx/src/support/ibm/xlocale_zos.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ locale_t newlocale(int category_mask, const char* locale, locale_t base) {
2020
std::string current_loc_name(setlocale(LC_ALL, 0));
2121

2222
// Check for errors.
23-
if (category_mask == LC_ALL_MASK && setlocale(LC_ALL, locale) == NULL) {
23+
if (category_mask == LC_ALL_MASK && setlocale(LC_ALL, locale) == nullptr) {
2424
errno = EINVAL;
2525
return (locale_t)0;
2626
} else {
2727
for (int _Cat = 0; _Cat <= _LC_MAX; ++_Cat) {
28-
if ((_CATMASK(_Cat) & category_mask) != 0 && setlocale(_Cat, locale) == NULL) {
28+
if ((_CATMASK(_Cat) & category_mask) != 0 && setlocale(_Cat, locale) == nullptr) {
2929
setlocale(LC_ALL, current_loc_name.c_str());
3030
errno = EINVAL;
3131
return (locale_t)0;
@@ -74,12 +74,12 @@ locale_t uselocale(locale_t newloc) {
7474
if (newloc) {
7575
// Set locales and check for errors.
7676
bool is_error =
77-
(newloc->category_mask & LC_COLLATE_MASK && setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == NULL) ||
78-
(newloc->category_mask & LC_CTYPE_MASK && setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == NULL) ||
79-
(newloc->category_mask & LC_MONETARY_MASK && setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == NULL) ||
80-
(newloc->category_mask & LC_NUMERIC_MASK && setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == NULL) ||
81-
(newloc->category_mask & LC_TIME_MASK && setlocale(LC_TIME, newloc->lc_time.c_str()) == NULL) ||
82-
(newloc->category_mask & LC_MESSAGES_MASK && setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == NULL);
77+
(newloc->category_mask & LC_COLLATE_MASK && setlocale(LC_COLLATE, newloc->lc_collate.c_str()) == nullptr) ||
78+
(newloc->category_mask & LC_CTYPE_MASK && setlocale(LC_CTYPE, newloc->lc_ctype.c_str()) == nullptr) ||
79+
(newloc->category_mask & LC_MONETARY_MASK && setlocale(LC_MONETARY, newloc->lc_monetary.c_str()) == nullptr) ||
80+
(newloc->category_mask & LC_NUMERIC_MASK && setlocale(LC_NUMERIC, newloc->lc_numeric.c_str()) == nullptr) ||
81+
(newloc->category_mask & LC_TIME_MASK && setlocale(LC_TIME, newloc->lc_time.c_str()) == nullptr) ||
82+
(newloc->category_mask & LC_MESSAGES_MASK && setlocale(LC_MESSAGES, newloc->lc_messages.c_str()) == nullptr);
8383

8484
if (is_error) {
8585
setlocale(LC_ALL, current_loc_name.c_str());

libcxx/src/support/win32/support.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@
1717
// a pointer to a malloc'd string in *sptr.
1818
// If return >= 0, use free to delete *sptr.
1919
int __libcpp_vasprintf(char** sptr, const char* __restrict format, va_list ap) {
20-
*sptr = NULL;
20+
*sptr = nullptr;
2121
// Query the count required.
2222
va_list ap_copy;
2323
va_copy(ap_copy, ap);
2424
_LIBCPP_DIAGNOSTIC_PUSH
2525
_LIBCPP_CLANG_DIAGNOSTIC_IGNORED("-Wformat-nonliteral")
26-
int count = vsnprintf(NULL, 0, format, ap_copy);
26+
int count = vsnprintf(nullptr, 0, format, ap_copy);
2727
_LIBCPP_DIAGNOSTIC_POP
2828
va_end(ap_copy);
2929
if (count < 0)
@@ -81,7 +81,7 @@ size_t mbsnrtowcs(wchar_t* __restrict dst,
8181
// if result > 0, it's the size in bytes of that character.
8282
// othewise if result is zero it indicates the null character has been found.
8383
// otherwise it's an error and errno may be set.
84-
size_t char_size = mbrtowc(dst ? dst + dest_converted : NULL, *src + source_converted, source_remaining, ps);
84+
size_t char_size = mbrtowc(dst ? dst + dest_converted : nullptr, *src + source_converted, source_remaining, ps);
8585
// Don't do anything to change errno from here on.
8686
if (char_size > 0) {
8787
source_remaining -= char_size;
@@ -95,7 +95,7 @@ size_t mbsnrtowcs(wchar_t* __restrict dst,
9595
}
9696
if (dst) {
9797
if (have_result && result == terminated_sequence)
98-
*src = NULL;
98+
*src = nullptr;
9999
else
100100
*src += source_converted;
101101
}
@@ -141,7 +141,7 @@ size_t wcsnrtombs(char* __restrict dst,
141141
if (dst)
142142
result = wcrtomb_s(&char_size, dst + dest_converted, dest_remaining, c, ps);
143143
else
144-
result = wcrtomb_s(&char_size, NULL, 0, c, ps);
144+
result = wcrtomb_s(&char_size, nullptr, 0, c, ps);
145145
// If result is zero there is no error and char_size contains the
146146
// size of the multi-byte-sequence converted.
147147
// Otherwise result indicates an errno type error.
@@ -161,7 +161,7 @@ size_t wcsnrtombs(char* __restrict dst,
161161
}
162162
if (dst) {
163163
if (terminator_found)
164-
*src = NULL;
164+
*src = nullptr;
165165
else
166166
*src = *src + source_converted;
167167
}

libcxx/src/support/win32/thread_win32.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ __libcpp_init_once_execute_once_thunk(PINIT_ONCE __init_once, PVOID __parameter,
129129

130130
int __libcpp_execute_once(__libcpp_exec_once_flag* __flag, void (*__init_routine)(void)) {
131131
if (!InitOnceExecuteOnce(
132-
(PINIT_ONCE)__flag, __libcpp_init_once_execute_once_thunk, reinterpret_cast<void*>(__init_routine), NULL))
132+
(PINIT_ONCE)__flag, __libcpp_init_once_execute_once_thunk, reinterpret_cast<void*>(__init_routine), nullptr))
133133
return GetLastError();
134134
return 0;
135135
}

0 commit comments

Comments
 (0)