src: add CHECK_NULL/CHECK_NOT_NULL macros

This change introduces CHECK_NULL and CHECK_NOT_NULL macros
similar to their definition in v8 and replaces instances of
CHECK/CHECK_EQ/CHECK_NE with these where it seems appropriate.

PR-URL: https://github.com/nodejs/node/pull/20914
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
Tobias Nießen committed 2018-05-26 12:29:31 +02:00
1 parent 13493e99bf
commit 39f209649f
33 files changed
+124 -122

No files matched your search

+3 -3
View File
@@ -140,7 +140,7 @@ CallbackInfo::CallbackInfo(Isolate* isolate,
ArrayBuffer::Contents obj_c = object->GetContents();
CHECK_EQ(data_, static_cast<char*>(obj_c.Data()));
if (object->ByteLength() != 0)
CHECK_NE(data_, nullptr);
CHECK_NOT_NULL(data_);
persistent_.SetWeak(this, WeakCallback, v8::WeakCallbackType::kParameter);
persistent_.SetWrapperClassId(BUFFER_ID);
@@ -329,7 +329,7 @@ MaybeLocal<Object> Copy(Environment* env, const char* data, size_t length) {
void* new_data;
if (length > 0) {
CHECK_NE(data, nullptr);
CHECK_NOT_NULL(data);
new_data = node::UncheckedMalloc(length);
if (new_data == nullptr)
return Local<Object>();
@@ -408,7 +408,7 @@ MaybeLocal<Object> New(Isolate* isolate, char* data, size_t length) {
MaybeLocal<Object> New(Environment* env, char* data, size_t length) {
if (length > 0) {
CHECK_NE(data, nullptr);
CHECK_NOT_NULL(data);
CHECK(length <= kMaxLength);
}