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

bdwgc / bdwgc / 2139

12 May 2026 09:29PM UTC coverage: 80.899% (+0.5%) from 80.39%
2139

push

travis-ci

ivmai
Eliminate 'condition always true' MSVC warning in win32_unprotect_thread

* pthread_support.c [GC_WIN32_THREADS && MPROTECT_VDB]
(GC_win32_unprotect_thread): Do not check `GC_win32_dll_threads`
variable if `GC_NO_THREADS_DISCOVERY`.

7255 of 8968 relevant lines covered (80.9%)

18926688.63 hits per line

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

31.25
/gc_cpp.cc
1
/*
2
 * Copyright (c) 1994 by Xerox Corporation.  All rights reserved.
3
 *
4
 * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
5
 * OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
6
 *
7
 * Permission is hereby granted to use or copy this program
8
 * for any purpose, provided the above notices are retained on all copies.
9
 * Permission to modify the code and to distribute modified code is granted,
10
 * provided the above notices are retained, and a notice that the code was
11
 * modified is included with the above copyright notice.
12
 */
13

14
// This implementation module for `gc_cpp.h` file provides an implementation
15
// of the global operators `new`/`delete` that calls the memory allocator of
16
// the collector.  All objects allocated by this implementation will be
17
// uncollectible but part of the root set of the collector.
18
//
19
// You should ensure (using implementation-dependent techniques) that the
20
// linker finds this module before the library that defines the default
21
// built-in operators `new` and `delete`.
22

23
#ifdef HAVE_CONFIG_H
24
#  include "config.h"
25
#endif
26

27
#ifndef GC_BUILD
28
#  define GC_BUILD
29
#endif
30

31
#define GC_DONT_INCL_WINDOWS_H
32
#include "gc/gc.h"
33

34
#ifndef GC_INCLUDE_NEW
35
#  define GC_INCLUDE_NEW
36
#endif
37
#include "gc/gc_cpp.h"
38

39
#if (!defined(_MSC_VER) && !defined(__DMC__) \
40
     || defined(GC_NO_INLINE_STD_NEW))       \
41
    && !defined(GC_INLINE_STD_NEW) && !defined(SKIP_GCCPP_DEFINITIONS)
42

43
#  if defined(GC_NEW_ABORTS_ON_OOM) || defined(_LIBCPP_NO_EXCEPTIONS)
44
#    define GC_ALLOCATOR_THROW_OR_ABORT() GC_abort_on_oom()
45
#  else
46
// Use `bad_alloc()` directly instead of `GC_throw_bad_alloc()` call.
47
#    define GC_ALLOCATOR_THROW_OR_ABORT() throw std::bad_alloc()
48
#  endif
49

50
GC_OPERATOR_NEW_ATTR(size)
51
void *
52
operator new(GC_SIZE_T size) GC_DECL_NEW_THROW
×
53
{
54
  void *obj = GC_MALLOC_UNCOLLECTABLE(size);
×
55
  if (0 == obj)
×
56
    GC_ALLOCATOR_THROW_OR_ABORT();
×
57
  return obj;
×
58
}
59

60
#  ifdef _MSC_VER
61
// This operator `new` is used by VC++ in case of `Debug` builds.
62
_Check_return_
63
GC_OPERATOR_NEW_ATTR(size) void *
64
operator new(_In_ GC_SIZE_T size, _In_ int /* `nBlockUse` */,
65
             _In_z_ const char *szFileName, _In_ int nLine)
66
{
67
#    ifdef GC_DEBUG
68
  void *obj = GC_debug_malloc_uncollectable(size, szFileName, nLine);
69
#    else
70
  void *obj = GC_MALLOC_UNCOLLECTABLE(size);
71
  (void)szFileName;
72
  (void)nLine;
73
#    endif
74
  if (0 == obj)
75
    GC_ALLOCATOR_THROW_OR_ABORT();
76
  return obj;
77
}
78
#  endif // _MSC_VER
79

80
void
81
operator delete(void *obj) GC_NOEXCEPT
×
82
{
83
  GC_FREE(obj);
×
84
}
×
85

86
#  ifdef GC_OPERATOR_NEW_NOTHROW
87
GC_OPERATOR_NOTHROW_NEW_ATTR(size)
88
void *
89
operator new(GC_SIZE_T size, const std::nothrow_t &) GC_NOEXCEPT
×
90
{
91
  return GC_MALLOC_UNCOLLECTABLE(size);
×
92
}
93

94
void
95
operator delete(void *obj, const std::nothrow_t &) GC_NOEXCEPT
×
96
{
97
  GC_FREE(obj);
×
98
}
×
99
#  endif // GC_OPERATOR_NEW_NOTHROW
100

101
#  ifdef GC_OPERATOR_NEW_ARRAY
102
GC_OPERATOR_NEW_ATTR(size)
103
void *
104
operator new[](GC_SIZE_T size) GC_DECL_NEW_THROW
14,000✔
105
{
106
  void *obj = GC_MALLOC_UNCOLLECTABLE(size);
14,000✔
107
  if (0 == obj)
14,000✔
108
    GC_ALLOCATOR_THROW_OR_ABORT();
×
109
  return obj;
14,000✔
110
}
111

112
#    ifdef _MSC_VER
113
// This operator `new` is used by VC++ 7 (or later) in `Debug` builds.
114
_Check_return_
115
GC_OPERATOR_NEW_ATTR(size) void *
116
operator new[](_In_ GC_SIZE_T size, _In_ int nBlockUse,
117
               _In_z_ const char *szFileName, _In_ int nLine)
118
{
119
  return operator new(size, nBlockUse, szFileName, nLine);
120
}
121
#    endif // _MSC_VER
122

123
void
124
operator delete[](void *obj) GC_NOEXCEPT
14,000✔
125
{
126
  GC_FREE(obj);
14,000✔
127
}
14,000✔
128

129
#    ifdef GC_OPERATOR_NEW_NOTHROW
130
GC_OPERATOR_NOTHROW_NEW_ATTR(size)
131
void *
132
operator new[](GC_SIZE_T size, const std::nothrow_t &) GC_NOEXCEPT
×
133
{
134
  return GC_MALLOC_UNCOLLECTABLE(size);
×
135
}
136

137
void
138
operator delete[](void *obj, const std::nothrow_t &) GC_NOEXCEPT
×
139
{
140
  GC_FREE(obj);
×
141
}
×
142
#    endif
143
#  endif // GC_OPERATOR_NEW_ARRAY
144

145
#  ifdef GC_OPERATOR_SIZED_DELETE
146
void
147
operator delete(void *obj, GC_SIZE_T) GC_NOEXCEPT
14,000✔
148
{
149
  GC_FREE(obj);
14,000✔
150
}
14,000✔
151

152
#    ifdef GC_OPERATOR_NEW_ARRAY
153
void
154
operator delete[](void *obj, GC_SIZE_T) GC_NOEXCEPT
×
155
{
156
  GC_FREE(obj);
×
157
}
×
158
#    endif
159
#  endif // GC_OPERATOR_SIZED_DELETE
160

161
#endif // !_MSC_VER && !__DMC__ || GC_NO_INLINE_STD_NEW
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