summaryrefslogtreecommitdiff
path: root/src/node_buffer.cc
diff options
context:
space:
mode:
authorAnna Henningsen <anna@addaleax.net>2016-09-10 18:19:24 +0200
committerAnna Henningsen <anna@addaleax.net>2016-09-29 09:46:42 +0200
commitea94086ad2b53268b5cb870f9ba5a1f84741fa41 (patch)
tree71a385cacb45a15d7d573105911b93ff0f5f2e11 /src/node_buffer.cc
parent48ed65440ca33fe6063d92379b3a9b10b65e98e9 (diff)
downloadandroid-node-v8-ea94086ad2b53268b5cb870f9ba5a1f84741fa41.tar.gz
android-node-v8-ea94086ad2b53268b5cb870f9ba5a1f84741fa41.tar.bz2
android-node-v8-ea94086ad2b53268b5cb870f9ba5a1f84741fa41.zip
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/node_buffer.cc')
-rw-r--r--src/node_buffer.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/node_buffer.cc b/src/node_buffer.cc
index 1ab664d364..467a6e8847 100644
--- a/src/node_buffer.cc
+++ b/src/node_buffer.cc
@@ -89,8 +89,8 @@ bool zero_fill_all_buffers = false;
namespace {
inline void* BufferMalloc(size_t length) {
- return zero_fill_all_buffers ? node::Calloc(length) :
- node::Malloc(length);
+ return zero_fill_all_buffers ? node::UncheckedCalloc(length) :
+ node::UncheckedMalloc(length);
}
} // namespace
@@ -285,7 +285,6 @@ MaybeLocal<Object> New(Isolate* isolate,
data = nullptr;
} else if (actual < length) {
data = node::Realloc(data, actual);
- CHECK_NE(data, nullptr);
}
}
@@ -363,7 +362,7 @@ MaybeLocal<Object> Copy(Environment* env, const char* data, size_t length) {
void* new_data;
if (length > 0) {
CHECK_NE(data, nullptr);
- new_data = node::Malloc(length);
+ new_data = node::UncheckedMalloc(length);
if (new_data == nullptr)
return Local<Object>();
memcpy(new_data, data, length);
@@ -1086,7 +1085,7 @@ void IndexOfString(const FunctionCallbackInfo<Value>& args) {
offset,
is_forward);
} else if (enc == LATIN1) {
- uint8_t* needle_data = node::Malloc<uint8_t>(needle_length);
+ uint8_t* needle_data = node::UncheckedMalloc<uint8_t>(needle_length);
if (needle_data == nullptr) {
return args.GetReturnValue().Set(-1);
}