summaryrefslogtreecommitdiff
path: root/src/stream_wrap.cc
diff options
context:
space:
mode:
authorMichael Dawson <michael_dawson@ca.ibm.com>2016-09-01 18:14:02 -0400
committerMichael Dawson <michael_dawson@ca.ibm.com>2016-09-06 09:39:06 -0400
commita00ccb0fb9eb716925058b0a20fcec9251de3309 (patch)
tree91c1aa556e0519d73c4b04238a5cf02f67342886 /src/stream_wrap.cc
parenta290ddfdc9cd9453886d433060c5132095d916c4 (diff)
downloadandroid-node-v8-a00ccb0fb9eb716925058b0a20fcec9251de3309.tar.gz
android-node-v8-a00ccb0fb9eb716925058b0a20fcec9251de3309.tar.bz2
android-node-v8-a00ccb0fb9eb716925058b0a20fcec9251de3309.zip
src: normalize malloc, realloc
malloc(0) and realloc(ptr, 0) have implementation-defined behavior in that the standard allows them to either return a unique pointer or a nullptr for zero-sized allocation requests. Normalize by always using a nullptr. - Introduce node::malloc, node::realloc and node::calloc that should be used throught our source. - Update all existing node source files to use the new functions instead of the native allocation functions. Fixes: https://github.com/nodejs/node/issues/7549 PR-URL: https://github.com/nodejs/node/pull/7564 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Anna Henningsen <anna@addaleax.net>
Diffstat (limited to 'src/stream_wrap.cc')
-rw-r--r--src/stream_wrap.cc4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/stream_wrap.cc b/src/stream_wrap.cc
index 17278ff83a..2b50895c9f 100644
--- a/src/stream_wrap.cc
+++ b/src/stream_wrap.cc
@@ -148,7 +148,7 @@ void StreamWrap::OnAlloc(uv_handle_t* handle,
void StreamWrap::OnAllocImpl(size_t size, uv_buf_t* buf, void* ctx) {
- buf->base = static_cast<char*>(malloc(size));
+ buf->base = static_cast<char*>(node::Malloc(size));
buf->len = size;
if (buf->base == nullptr && size > 0) {
@@ -204,7 +204,7 @@ void StreamWrap::OnReadImpl(ssize_t nread,
return;
}
- char* base = static_cast<char*>(realloc(buf->base, nread));
+ char* base = static_cast<char*>(node::Realloc(buf->base, nread));
CHECK_LE(static_cast<size_t>(nread), buf->len);
if (pending == UV_TCP) {