Skip to content

Commit 7420ce8

Browse files
soleboxaddaleax
authored andcommitted
src: squelch unused function warnings in util.h
Fixes: #9083 PR-URL: #9115 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
1 parent 4ddc238 commit 7420ce8

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

src/util-inl.h

+11-5
Original file line numberDiff line numberDiff line change
@@ -357,39 +357,45 @@ T* UncheckedRealloc(T* pointer, size_t n) {
357357

358358
// As per spec realloc behaves like malloc if passed nullptr.
359359
template <typename T>
360-
T* UncheckedMalloc(size_t n) {
360+
inline T* UncheckedMalloc(size_t n) {
361361
if (n == 0) n = 1;
362362
return UncheckedRealloc<T>(nullptr, n);
363363
}
364364

365365
template <typename T>
366-
T* UncheckedCalloc(size_t n) {
366+
inline T* UncheckedCalloc(size_t n) {
367367
if (n == 0) n = 1;
368368
MultiplyWithOverflowCheck(sizeof(T), n);
369369
return static_cast<T*>(calloc(n, sizeof(T)));
370370
}
371371

372372
template <typename T>
373-
T* Realloc(T* pointer, size_t n) {
373+
inline T* Realloc(T* pointer, size_t n) {
374374
T* ret = UncheckedRealloc(pointer, n);
375375
if (n > 0) CHECK_NE(ret, nullptr);
376376
return ret;
377377
}
378378

379379
template <typename T>
380-
T* Malloc(size_t n) {
380+
inline T* Malloc(size_t n) {
381381
T* ret = UncheckedMalloc<T>(n);
382382
if (n > 0) CHECK_NE(ret, nullptr);
383383
return ret;
384384
}
385385

386386
template <typename T>
387-
T* Calloc(size_t n) {
387+
inline T* Calloc(size_t n) {
388388
T* ret = UncheckedCalloc<T>(n);
389389
if (n > 0) CHECK_NE(ret, nullptr);
390390
return ret;
391391
}
392392

393+
// Shortcuts for char*.
394+
inline char* Malloc(size_t n) { return Malloc<char>(n); }
395+
inline char* Calloc(size_t n) { return Calloc<char>(n); }
396+
inline char* UncheckedMalloc(size_t n) { return UncheckedMalloc<char>(n); }
397+
inline char* UncheckedCalloc(size_t n) { return UncheckedCalloc<char>(n); }
398+
393399
} // namespace node
394400

395401
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS

src/util.h

+4-5
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,10 @@ inline T* Malloc(size_t n);
3838
template <typename T>
3939
inline T* Calloc(size_t n);
4040

41-
// Shortcuts for char*.
42-
inline char* Malloc(size_t n) { return Malloc<char>(n); }
43-
inline char* Calloc(size_t n) { return Calloc<char>(n); }
44-
inline char* UncheckedMalloc(size_t n) { return UncheckedMalloc<char>(n); }
45-
inline char* UncheckedCalloc(size_t n) { return UncheckedCalloc<char>(n); }
41+
inline char* Malloc(size_t n);
42+
inline char* Calloc(size_t n);
43+
inline char* UncheckedMalloc(size_t n);
44+
inline char* UncheckedCalloc(size_t n);
4645

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

0 commit comments

Comments
 (0)