This is an automated email from the ASF dual-hosted git repository.
felixybw pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-gluten.git
The following commit(s) were added to refs/heads/main by this push:
new 2f7b138f24 [VL][MINOR] Replace NULL with nullptr (#10958)
2f7b138f24 is described below
commit 2f7b138f24f16a249cea57217e50962d3b1a8ee4
Author: Jiaan Geng <[email protected]>
AuthorDate: Fri Oct 31 10:47:52 2025 +0800
[VL][MINOR] Replace NULL with nullptr (#10958)
This PR proposes to replace NULL with nullptr.
In C++, nullptr should always be used instead of NULL because:
Provide better type security
Avoid overloading and resolving ambiguity
Better performance in template programming
The code intent is clearer
It is a standard practice in modern C++
Only consider using NULL when maintaining very old code repositories or
interacting with C interfaces that only accept NULL.
---
cpp/velox/jni/VeloxJniWrapper.cc | 6 +++---
cpp/velox/memory/VeloxMemoryManager.cc | 2 +-
docs/developers/CppCodingStyle.md | 2 ++
3 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/cpp/velox/jni/VeloxJniWrapper.cc b/cpp/velox/jni/VeloxJniWrapper.cc
index 1ce34d6f95..f68aa54688 100644
--- a/cpp/velox/jni/VeloxJniWrapper.cc
+++ b/cpp/velox/jni/VeloxJniWrapper.cc
@@ -615,7 +615,7 @@ JNIEXPORT void JNICALL
Java_org_apache_gluten_monitor_VeloxMemoryProfiler_start(
JNI_METHOD_START
#ifdef ENABLE_JEMALLOC_STATS
bool active = true;
- mallctl("prof.active", NULL, NULL, &active, sizeof(bool));
+ mallctl("prof.active", nullptr, nullptr, &active, sizeof(bool));
#endif
JNI_METHOD_END()
}
@@ -625,7 +625,7 @@ JNIEXPORT void JNICALL
Java_org_apache_gluten_monitor_VeloxMemoryProfiler_dump(
jclass) {
JNI_METHOD_START
#ifdef ENABLE_JEMALLOC_STATS
- mallctl("prof.dump", NULL, NULL, NULL, 0);
+ mallctl("prof.dump", nullptr, nullptr, nullptr, 0);
#endif
JNI_METHOD_END()
}
@@ -636,7 +636,7 @@ JNIEXPORT void JNICALL
Java_org_apache_gluten_monitor_VeloxMemoryProfiler_stop(
JNI_METHOD_START
#ifdef ENABLE_JEMALLOC_STATS
bool active = false;
- mallctl("prof.active", NULL, NULL, &active, sizeof(bool));
+ mallctl("prof.active", nullptr, nullptr, &active, sizeof(bool));
#endif
JNI_METHOD_END()
}
diff --git a/cpp/velox/memory/VeloxMemoryManager.cc
b/cpp/velox/memory/VeloxMemoryManager.cc
index ec568fa6a6..d5c71d78e6 100644
--- a/cpp/velox/memory/VeloxMemoryManager.cc
+++ b/cpp/velox/memory/VeloxMemoryManager.cc
@@ -467,7 +467,7 @@ VeloxMemoryManager::~VeloxMemoryManager() {
<< "ms as there are still outstanding memory resources. ";
}
#ifdef ENABLE_JEMALLOC_STATS
- malloc_stats_print(NULL, NULL, NULL);
+ malloc_stats_print(nullptr, nullptr, nullptr);
#endif
}
diff --git a/docs/developers/CppCodingStyle.md
b/docs/developers/CppCodingStyle.md
index 2cea8fe8fe..aacae6f3d7 100644
--- a/docs/developers/CppCodingStyle.md
+++ b/docs/developers/CppCodingStyle.md
@@ -125,6 +125,8 @@ cmake-format --first-comment-is-literal True --in-place
cpp/velox/CMakeLists.txt
## Constant
* Prefer const variables to using preprocessor (`#define`) to define constant
values.
+* Always use nullptr if you need a constant that represents a null pointer (T*
for some T);
+ use 0 otherwise for a zero value.
## Macro
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]