[libc-commits] [libc] 7789ec0 - [libc] s/NULL/nullptr (#86867)

via libc-commits libc-commits at lists.llvm.org
Thu Mar 28 08:43:14 PDT 2024


Author: Nick Desaulniers
Date: 2024-03-28T08:43:11-07:00
New Revision: 7789ec067dfcb07cc1f2222f48d9bb8e004c0d72

URL: https://github.com/llvm/llvm-project/commit/7789ec067dfcb07cc1f2222f48d9bb8e004c0d72
DIFF: https://github.com/llvm/llvm-project/commit/7789ec067dfcb07cc1f2222f48d9bb8e004c0d72.diff

LOG: [libc] s/NULL/nullptr (#86867)

Otherwise we need to pull in stddef.h for the declaration of NULL.

Added: 
    

Modified: 
    libc/src/__support/char_vector.h
    libc/src/stdlib/str_from_util.h
    libc/src/stdlib/strtod.cpp
    libc/src/stdlib/strtof.cpp
    libc/src/stdlib/strtold.cpp

Removed: 
    


################################################################################
diff  --git a/libc/src/__support/char_vector.h b/libc/src/__support/char_vector.h
index 955abdc1fa5ae0..d39310e09dd71e 100644
--- a/libc/src/__support/char_vector.h
+++ b/libc/src/__support/char_vector.h
@@ -11,8 +11,8 @@
 
 #include "src/__support/common.h" // LIBC_INLINE
 
-#include <stddef.h>
-#include <stdlib.h> // For allocation.
+#include <stddef.h> // size_t
+#include <stdlib.h> // malloc, realloc, free
 
 namespace LIBC_NAMESPACE {
 
@@ -46,7 +46,7 @@ class CharVector {
       if (cur_str == local_buffer) {
         char *new_str;
         new_str = reinterpret_cast<char *>(malloc(cur_buff_size));
-        if (new_str == NULL) {
+        if (new_str == nullptr) {
           return false;
         }
         // TODO: replace with inline memcpy
@@ -55,7 +55,7 @@ class CharVector {
         cur_str = new_str;
       } else {
         cur_str = reinterpret_cast<char *>(realloc(cur_str, cur_buff_size));
-        if (cur_str == NULL) {
+        if (cur_str == nullptr) {
           return false;
         }
       }

diff  --git a/libc/src/stdlib/str_from_util.h b/libc/src/stdlib/str_from_util.h
index c4c1c0a0ba4ef0..58afa98afc08ed 100644
--- a/libc/src/stdlib/str_from_util.h
+++ b/libc/src/stdlib/str_from_util.h
@@ -11,7 +11,7 @@
 // %{a,A,e,E,f,F,g,G}, are not allowed and any code that does otherwise results
 // in undefined behaviour(including use of a '%%' conversion specifier); which
 // in this case is that the buffer string is simply populated with the format
-// string. The case of the input being NULL should be handled in the calling
+// string. The case of the input being nullptr should be handled in the calling
 // function (strfromf, strfromd, strfroml) itself.
 
 #ifndef LLVM_LIBC_SRC_STDLIB_STRFROM_UTIL_H

diff  --git a/libc/src/stdlib/strtod.cpp b/libc/src/stdlib/strtod.cpp
index db5e0edefb5b38..461f7feb5bf63d 100644
--- a/libc/src/stdlib/strtod.cpp
+++ b/libc/src/stdlib/strtod.cpp
@@ -19,7 +19,7 @@ LLVM_LIBC_FUNCTION(double, strtod,
   if (result.has_error())
     libc_errno = result.error;
 
-  if (str_end != NULL)
+  if (str_end != nullptr)
     *str_end = const_cast<char *>(str + result.parsed_len);
 
   return result.value;

diff  --git a/libc/src/stdlib/strtof.cpp b/libc/src/stdlib/strtof.cpp
index 2cc8829f63d34c..554d096879c593 100644
--- a/libc/src/stdlib/strtof.cpp
+++ b/libc/src/stdlib/strtof.cpp
@@ -19,7 +19,7 @@ LLVM_LIBC_FUNCTION(float, strtof,
   if (result.has_error())
     libc_errno = result.error;
 
-  if (str_end != NULL)
+  if (str_end != nullptr)
     *str_end = const_cast<char *>(str + result.parsed_len);
 
   return result.value;

diff  --git a/libc/src/stdlib/strtold.cpp b/libc/src/stdlib/strtold.cpp
index 7378963f21b240..9c3e1db900670a 100644
--- a/libc/src/stdlib/strtold.cpp
+++ b/libc/src/stdlib/strtold.cpp
@@ -19,7 +19,7 @@ LLVM_LIBC_FUNCTION(long double, strtold,
   if (result.has_error())
     libc_errno = result.error;
 
-  if (str_end != NULL)
+  if (str_end != nullptr)
     *str_end = const_cast<char *>(str + result.parsed_len);
 
   return result.value;


        


More information about the libc-commits mailing list