diff options
author | solebox <solekiller@gmail.com> | 2016-10-16 14:03:38 +0300 |
---|---|---|
committer | James M Snell <jasnell@gmail.com> | 2016-11-18 08:29:56 -0800 |
commit | 35d48d3e1051169446158189033280fd07acf8aa (patch) | |
tree | 2f92e021852acc9129f00f6d5bd038d8872d375f /src/util-inl.h | |
parent | 976fe250f5a1d584178911f91fb7c3323654c25e (diff) | |
download | android-node-v8-35d48d3e1051169446158189033280fd07acf8aa.tar.gz android-node-v8-35d48d3e1051169446158189033280fd07acf8aa.tar.bz2 android-node-v8-35d48d3e1051169446158189033280fd07acf8aa.zip |
src: squelch unused function warnings in util.h
Fixes: https://github.com/nodejs/node/issues/9083
PR-URL: https://github.com/nodejs/node/pull/9115
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'src/util-inl.h')
-rw-r--r-- | src/util-inl.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/util-inl.h b/src/util-inl.h index 5ffe5b857f..82ab663277 100644 --- a/src/util-inl.h +++ b/src/util-inl.h @@ -357,39 +357,45 @@ T* UncheckedRealloc(T* pointer, size_t n) { // As per spec realloc behaves like malloc if passed nullptr. template <typename T> -T* UncheckedMalloc(size_t n) { +inline T* UncheckedMalloc(size_t n) { if (n == 0) n = 1; return UncheckedRealloc<T>(nullptr, n); } template <typename T> -T* UncheckedCalloc(size_t n) { +inline T* UncheckedCalloc(size_t n) { if (n == 0) n = 1; MultiplyWithOverflowCheck(sizeof(T), n); return static_cast<T*>(calloc(n, sizeof(T))); } template <typename T> -T* Realloc(T* pointer, size_t n) { +inline T* Realloc(T* pointer, size_t n) { T* ret = UncheckedRealloc(pointer, n); if (n > 0) CHECK_NE(ret, nullptr); return ret; } template <typename T> -T* Malloc(size_t n) { +inline T* Malloc(size_t n) { T* ret = UncheckedMalloc<T>(n); if (n > 0) CHECK_NE(ret, nullptr); return ret; } template <typename T> -T* Calloc(size_t n) { +inline T* Calloc(size_t n) { T* ret = UncheckedCalloc<T>(n); if (n > 0) CHECK_NE(ret, nullptr); return ret; } +// Shortcuts for char*. +inline char* Malloc(size_t n) { return Malloc<char>(n); } +inline char* Calloc(size_t n) { return Calloc<char>(n); } +inline char* UncheckedMalloc(size_t n) { return UncheckedMalloc<char>(n); } +inline char* UncheckedCalloc(size_t n) { return UncheckedCalloc<char>(n); } + } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS |