@@ -357,39 +357,45 @@ T* UncheckedRealloc(T* pointer, size_t n) {
357357
358358// As per spec realloc behaves like malloc if passed nullptr.
359359template <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
365365template <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
372372template <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
379379template <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
386386template <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
0 commit comments