Coverage Report

Created: 2025-12-12 07:27

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/hermes/lib/Support/CheckedMalloc.cpp
Line
Count
Source
1
/*
2
 * Copyright (c) Meta Platforms, Inc. and affiliates.
3
 *
4
 * This source code is licensed under the MIT license found in the
5
 * LICENSE file in the root directory of this source tree.
6
 */
7
8
#include "hermes/Support/CheckedMalloc.h"
9
10
#include "hermes/Support/ErrorHandling.h"
11
12
#include "llvh/Support/Compiler.h"
13
14
namespace hermes {
15
16
9.19k
void *checkedMalloc(size_t sz) {
17
9.19k
  void *res = ::malloc(sz);
18
9.19k
  if (LLVM_UNLIKELY(!res)) {
19
0
    hermes_fatal("malloc failure");
20
0
  }
21
9.19k
  return res;
22
9.19k
}
23
24
363
void *checkedCalloc(size_t count, size_t size) {
25
363
  void *res = ::calloc(count, size);
26
363
  if (LLVM_UNLIKELY(!res)) {
27
0
    hermes_fatal("malloc failure");
28
0
  }
29
363
  return res;
30
363
}
31
32
} // namespace hermes