Skip to content

Commit

Permalink
src: squelch unused function warnings in util.h.
Browse files Browse the repository at this point in the history
Fixes: #9083

moved function bodies back

src: squelch unused function warnings in util.h.
Fixes: #9083

moved back to previouse commit

lets hope this is the correct answer
src: squelch unused function warnings in util.h.
Fixes: #9083

src: squelch unused function warnings in util.h.
Fixes: #9083

src: squelch unused function warnings in util.h.
Fixes: #9083

src: squelch unused function warnings in util.h.
Fixes: #9083

src: squelch unused function warnings in util.h.
Fixes: #9083
  • Loading branch information
solebox committed Nov 10, 2016
1 parent 33e598a commit 57a762f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
16 changes: 11 additions & 5 deletions src/util-inl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions src/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,10 @@ inline T* Malloc(size_t n);
template <typename T>
inline T* Calloc(size_t n);

// 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); }
inline char* Malloc(size_t n);
inline char* Calloc(size_t n);
inline char* UncheckedMalloc(size_t n);
inline char* UncheckedCalloc(size_t n);

// Used by the allocation functions when allocation fails.
// Thin wrapper around v8::Isolate::LowMemoryNotification() that checks
Expand Down

0 comments on commit 57a762f

Please sign in to comment.