@@ -357,39 +357,45 @@ T* UncheckedRealloc(T* pointer, size_t n) {
357
357
358
358
// As per spec realloc behaves like malloc if passed nullptr.
359
359
template <typename T>
360
- T* UncheckedMalloc (size_t n) {
360
+ inline T* UncheckedMalloc (size_t n) {
361
361
if (n == 0 ) n = 1 ;
362
362
return UncheckedRealloc<T>(nullptr , n);
363
363
}
364
364
365
365
template <typename T>
366
- T* UncheckedCalloc (size_t n) {
366
+ inline T* UncheckedCalloc (size_t n) {
367
367
if (n == 0 ) n = 1 ;
368
368
MultiplyWithOverflowCheck (sizeof (T), n);
369
369
return static_cast <T*>(calloc (n, sizeof (T)));
370
370
}
371
371
372
372
template <typename T>
373
- T* Realloc (T* pointer, size_t n) {
373
+ inline T* Realloc (T* pointer, size_t n) {
374
374
T* ret = UncheckedRealloc (pointer, n);
375
375
if (n > 0 ) CHECK_NE (ret, nullptr );
376
376
return ret;
377
377
}
378
378
379
379
template <typename T>
380
- T* Malloc (size_t n) {
380
+ inline T* Malloc (size_t n) {
381
381
T* ret = UncheckedMalloc<T>(n);
382
382
if (n > 0 ) CHECK_NE (ret, nullptr );
383
383
return ret;
384
384
}
385
385
386
386
template <typename T>
387
- T* Calloc (size_t n) {
387
+ inline T* Calloc (size_t n) {
388
388
T* ret = UncheckedCalloc<T>(n);
389
389
if (n > 0 ) CHECK_NE (ret, nullptr );
390
390
return ret;
391
391
}
392
392
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
+
393
399
} // namespace node
394
400
395
401
#endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS
0 commit comments