From ea94086ad2b53268b5cb870f9ba5a1f84741fa41 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Sat, 10 Sep 2016 18:19:24 +0200 Subject: src: provide allocation + nullptr check shortcuts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide shortcut `node::CheckedMalloc()` and friends that replace `node::Malloc()` + `CHECK_NE(ยท, nullptr);` combinations in a few places. PR-URL: https://github.com/nodejs/node/pull/8482 Reviewed-By: Ben Noordhuis Reviewed-By: James M Snell Reviewed-By: Michael Dawson Reviewed-By: Ilkka Myller --- src/string_bytes.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/string_bytes.cc') diff --git a/src/string_bytes.cc b/src/string_bytes.cc index 8acba5d55d..d9e8b97114 100644 --- a/src/string_bytes.cc +++ b/src/string_bytes.cc @@ -53,7 +53,7 @@ class ExternString: public ResourceType { if (length == 0) return scope.Escape(String::Empty(isolate)); - TypeName* new_data = node::Malloc(length); + TypeName* new_data = node::UncheckedMalloc(length); if (new_data == nullptr) { return Local(); } @@ -623,7 +623,7 @@ Local StringBytes::Encode(Isolate* isolate, case ASCII: if (contains_non_ascii(buf, buflen)) { - char* out = node::Malloc(buflen); + char* out = node::UncheckedMalloc(buflen); if (out == nullptr) { return Local(); } @@ -658,7 +658,7 @@ Local StringBytes::Encode(Isolate* isolate, case BASE64: { size_t dlen = base64_encoded_size(buflen); - char* dst = node::Malloc(dlen); + char* dst = node::UncheckedMalloc(dlen); if (dst == nullptr) { return Local(); } @@ -677,7 +677,7 @@ Local StringBytes::Encode(Isolate* isolate, case HEX: { size_t dlen = buflen * 2; - char* dst = node::Malloc(dlen); + char* dst = node::UncheckedMalloc(dlen); if (dst == nullptr) { return Local(); } -- cgit v1.2.3