• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devmarkusb / util / 23414238958

22 Mar 2026 10:40PM UTC coverage: 88.156% (-0.09%) from 88.241%
23414238958

push

github

MarkusB
Standardize type usage by replacing `std::size_t` with `size_t` across memory-related components and simplify code formatting.

7 of 9 new or added lines in 2 files covered. (77.78%)

11 existing lines in 1 file now uncovered.

5828 of 6611 relevant lines covered (88.16%)

358.86 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.18
/mem/src/new_statistics.cpp
1
#include "ul/mem/new_statistics.h"
2
#include "ul/mem/types.h"
3
#include "ul/warnings.h"
4
#include <cstddef>
5
#include <new>
6

7
namespace ul = mb::ul;
8

9
namespace {
10
[[nodiscard]] void* allocate_with_stats(size_t size_in_bytes) noexcept {
21,306✔
11
    auto* const p = reinterpret_cast<uint8_t*>(std::malloc(sizeof(ul::mem::StatsHeader) + size_in_bytes)); // NOLINT
21,306✔
12
    if (!p)
21,306✔
UNCOV
13
        return nullptr;
×
14
    ul::mem::Statistics::instance().new_call(ul::mem::Bytes{size_in_bytes}, p);
21,306✔
15
    return p + sizeof(ul::mem::StatsHeader); // NOLINT
21,306✔
16
}
17
} // namespace
18

19
UL_PRAGMA_WARNINGS_PUSH
20
// clang-format off
21
UL_WARNING_DISABLE_CLANG(unsafe-buffer-usage)
22
// clang-format on
23

24
void* operator new(size_t size_in_bytes) {
21,268✔
25
    void* const p = allocate_with_stats(size_in_bytes);
21,268✔
26
    if (!p)
21,268✔
UNCOV
27
        throw std::bad_alloc{};
×
28
    return p;
21,268✔
29
}
30

31
void* operator new(size_t size_in_bytes, const std::nothrow_t&) noexcept {
34✔
32
    return allocate_with_stats(size_in_bytes);
34✔
33
}
34

35
void* operator new[](size_t size_in_bytes) {
4✔
36
    void* const p = allocate_with_stats(size_in_bytes);
4✔
37
    if (!p)
4✔
UNCOV
38
        throw std::bad_alloc{};
×
39
    return p;
4✔
40
}
41

NEW
42
void* operator new[](size_t size_in_bytes, const std::nothrow_t&) noexcept {
×
UNCOV
43
    return allocate_with_stats(size_in_bytes);
×
44
}
45

46
void operator delete(void* p) noexcept {
5,289✔
47
    if (!p)
5,289✔
UNCOV
48
        return;
×
49
    p = reinterpret_cast<uint8_t*>(p) - sizeof(ul::mem::StatsHeader); // NOLINT
5,289✔
50
    ul::mem::Statistics::instance().delete_call(p);
5,289✔
51
    std::free(p); // NOLINT
5,289✔
52
}
53

54
void operator delete[](void* p) noexcept {
4✔
55
    if (!p)
4✔
56
        return;
×
57
    p = reinterpret_cast<uint8_t*>(p) - sizeof(ul::mem::StatsHeader); // NOLINT
4✔
58
    ul::mem::Statistics::instance().delete_call(p);
4✔
59
    std::free(p); // NOLINT
4✔
60
}
61

62
// some compiler complains about no prev. prototype otherwise
63
void operator delete(void* p, size_t /*unused*/) noexcept;
64

65
void operator delete(void* p, size_t /*unused*/) noexcept {
16,013✔
66
    if (!p)
16,013✔
UNCOV
67
        return;
×
68
    p = reinterpret_cast<uint8_t*>(p) - sizeof(ul::mem::StatsHeader); // NOLINT
16,013✔
69
    ul::mem::Statistics::instance().delete_call(p);
16,013✔
70
    std::free(p); // NOLINT
16,013✔
71
}
72

73
// some compiler complains about no prev. prototype otherwise
74
void operator delete[](void* p, size_t /*unused*/) noexcept;
75

NEW
76
void operator delete[](void* p, size_t /*unused*/) noexcept {
×
UNCOV
77
    if (!p)
×
UNCOV
78
        return;
×
UNCOV
79
    p = reinterpret_cast<uint8_t*>(p) - sizeof(ul::mem::StatsHeader); // NOLINT
×
UNCOV
80
    ul::mem::Statistics::instance().delete_call(p);
×
UNCOV
81
    std::free(p); // NOLINT
×
82
}
83

84
UL_PRAGMA_WARNINGS_POP
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc