diff options
author | Anna Henningsen <anna@addaleax.net> | 2016-09-10 19:19:24 +0300 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2016-09-29 10:46:42 +0300 |
commit | ea94086ad2b53268b5cb870f9ba5a1f84741fa41 (patch) | |
tree | 71a385cacb45a15d7d573105911b93ff0f5f2e11 /src/string_bytes.cc | |
parent | 48ed65440ca33fe6063d92379b3a9b10b65e98e9 (diff) |
src: provide allocation + nullptr check shortcuts
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 <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Diffstat (limited to 'src/string_bytes.cc')
-rw-r--r-- | src/string_bytes.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/string_bytes.cc b/src/string_bytes.cc index 8acba5d55d1..d9e8b97114e 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<TypeName>(length); + TypeName* new_data = node::UncheckedMalloc<TypeName>(length); if (new_data == nullptr) { return Local<String>(); } @@ -623,7 +623,7 @@ Local<Value> 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<String>(); } @@ -658,7 +658,7 @@ Local<Value> 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<String>(); } @@ -677,7 +677,7 @@ Local<Value> 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<String>(); } |