You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
SQA-Homework/gcov & lcov/output/9/ext/new_allocator.h.gcov.html

266 lines
24 KiB

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>LCOV - test.info - 9/ext/new_allocator.h</title>
<link rel="stylesheet" type="text/css" href="../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LCOV - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td width="10%" class="headerItem">Current view:</td>
<td width="35%" class="headerValue"><a href="../../index.html">top level</a> - <a href="index.html">9/ext</a> - new_allocator.h<span style="font-size: 80%;"> (source / <a href="new_allocator.h.func-sort-c.html">functions</a>)</span></td>
<td width="5%"></td>
<td width="15%"></td>
<td width="10%" class="headerCovTableHead">Hit</td>
<td width="10%" class="headerCovTableHead">Total</td>
<td width="15%" class="headerCovTableHead">Coverage</td>
</tr>
<tr>
<td class="headerItem">Test:</td>
<td class="headerValue">test.info</td>
<td></td>
<td class="headerItem">Lines:</td>
<td class="headerCovTableEntry">15</td>
<td class="headerCovTableEntry">16</td>
<td class="headerCovTableEntryHi">93.8 %</td>
</tr>
<tr>
<td class="headerItem">Date:</td>
<td class="headerValue">2022-06-07 00:30:42</td>
<td></td>
<td class="headerItem">Functions:</td>
<td class="headerCovTableEntry">10</td>
<td class="headerCovTableEntry">13</td>
<td class="headerCovTableEntryMed">76.9 %</td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td class="headerItem">Branches:</td>
<td class="headerCovTableEntry">1</td>
<td class="headerCovTableEntry">2</td>
<td class="headerCovTableEntryLo">50.0 %</td>
</tr>
<tr><td><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td><br></td>
</tr>
<tr>
<td>
<pre class="sourceHeading"> Branch data Line data Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum"> 1 </span> : : // Allocator that wraps operator new -*- C++ -*-</a>
<a name="2"><span class="lineNum"> 2 </span> : : </a>
<a name="3"><span class="lineNum"> 3 </span> : : // Copyright (C) 2001-2019 Free Software Foundation, Inc.</a>
<a name="4"><span class="lineNum"> 4 </span> : : //</a>
<a name="5"><span class="lineNum"> 5 </span> : : // This file is part of the GNU ISO C++ Library. This library is free</a>
<a name="6"><span class="lineNum"> 6 </span> : : // software; you can redistribute it and/or modify it under the</a>
<a name="7"><span class="lineNum"> 7 </span> : : // terms of the GNU General Public License as published by the</a>
<a name="8"><span class="lineNum"> 8 </span> : : // Free Software Foundation; either version 3, or (at your option)</a>
<a name="9"><span class="lineNum"> 9 </span> : : // any later version.</a>
<a name="10"><span class="lineNum"> 10 </span> : : </a>
<a name="11"><span class="lineNum"> 11 </span> : : // This library is distributed in the hope that it will be useful,</a>
<a name="12"><span class="lineNum"> 12 </span> : : // but WITHOUT ANY WARRANTY; without even the implied warranty of</a>
<a name="13"><span class="lineNum"> 13 </span> : : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</a>
<a name="14"><span class="lineNum"> 14 </span> : : // GNU General Public License for more details.</a>
<a name="15"><span class="lineNum"> 15 </span> : : </a>
<a name="16"><span class="lineNum"> 16 </span> : : // Under Section 7 of GPL version 3, you are granted additional</a>
<a name="17"><span class="lineNum"> 17 </span> : : // permissions described in the GCC Runtime Library Exception, version</a>
<a name="18"><span class="lineNum"> 18 </span> : : // 3.1, as published by the Free Software Foundation.</a>
<a name="19"><span class="lineNum"> 19 </span> : : </a>
<a name="20"><span class="lineNum"> 20 </span> : : // You should have received a copy of the GNU General Public License and</a>
<a name="21"><span class="lineNum"> 21 </span> : : // a copy of the GCC Runtime Library Exception along with this program;</a>
<a name="22"><span class="lineNum"> 22 </span> : : // see the files COPYING3 and COPYING.RUNTIME respectively. If not, see</a>
<a name="23"><span class="lineNum"> 23 </span> : : // &lt;http://www.gnu.org/licenses/&gt;.</a>
<a name="24"><span class="lineNum"> 24 </span> : : </a>
<a name="25"><span class="lineNum"> 25 </span> : : /** @file ext/new_allocator.h</a>
<a name="26"><span class="lineNum"> 26 </span> : : * This file is a GNU extension to the Standard C++ Library.</a>
<a name="27"><span class="lineNum"> 27 </span> : : */</a>
<a name="28"><span class="lineNum"> 28 </span> : : </a>
<a name="29"><span class="lineNum"> 29 </span> : : #ifndef _NEW_ALLOCATOR_H</a>
<a name="30"><span class="lineNum"> 30 </span> : : #define _NEW_ALLOCATOR_H 1</a>
<a name="31"><span class="lineNum"> 31 </span> : : </a>
<a name="32"><span class="lineNum"> 32 </span> : : #include &lt;bits/c++config.h&gt;</a>
<a name="33"><span class="lineNum"> 33 </span> : : #include &lt;new&gt;</a>
<a name="34"><span class="lineNum"> 34 </span> : : #include &lt;bits/functexcept.h&gt;</a>
<a name="35"><span class="lineNum"> 35 </span> : : #include &lt;bits/move.h&gt;</a>
<a name="36"><span class="lineNum"> 36 </span> : : #if __cplusplus &gt;= 201103L</a>
<a name="37"><span class="lineNum"> 37 </span> : : #include &lt;type_traits&gt;</a>
<a name="38"><span class="lineNum"> 38 </span> : : #endif</a>
<a name="39"><span class="lineNum"> 39 </span> : : </a>
<a name="40"><span class="lineNum"> 40 </span> : : namespace __gnu_cxx _GLIBCXX_VISIBILITY(default)</a>
<a name="41"><span class="lineNum"> 41 </span> : : {</a>
<a name="42"><span class="lineNum"> 42 </span> : : _GLIBCXX_BEGIN_NAMESPACE_VERSION</a>
<a name="43"><span class="lineNum"> 43 </span> : : </a>
<a name="44"><span class="lineNum"> 44 </span> : : using std::size_t;</a>
<a name="45"><span class="lineNum"> 45 </span> : : using std::ptrdiff_t;</a>
<a name="46"><span class="lineNum"> 46 </span> : : </a>
<a name="47"><span class="lineNum"> 47 </span> : : /**</a>
<a name="48"><span class="lineNum"> 48 </span> : : * @brief An allocator that uses global new, as per [20.4].</a>
<a name="49"><span class="lineNum"> 49 </span> : : * @ingroup allocators</a>
<a name="50"><span class="lineNum"> 50 </span> : : *</a>
<a name="51"><span class="lineNum"> 51 </span> : : * This is precisely the allocator defined in the C++ Standard.</a>
<a name="52"><span class="lineNum"> 52 </span> : : * - all allocation calls operator new</a>
<a name="53"><span class="lineNum"> 53 </span> : : * - all deallocation calls operator delete</a>
<a name="54"><span class="lineNum"> 54 </span> : : *</a>
<a name="55"><span class="lineNum"> 55 </span> : : * @tparam _Tp Type of allocated object.</a>
<a name="56"><span class="lineNum"> 56 </span> : : */</a>
<a name="57"><span class="lineNum"> 57 </span> : : template&lt;typename _Tp&gt;</a>
<a name="58"><span class="lineNum"> 58 </span> : : class new_allocator</a>
<a name="59"><span class="lineNum"> 59 </span> : : {</a>
<a name="60"><span class="lineNum"> 60 </span> : : public:</a>
<a name="61"><span class="lineNum"> 61 </span> : : typedef size_t size_type;</a>
<a name="62"><span class="lineNum"> 62 </span> : : typedef ptrdiff_t difference_type;</a>
<a name="63"><span class="lineNum"> 63 </span> : : typedef _Tp* pointer;</a>
<a name="64"><span class="lineNum"> 64 </span> : : typedef const _Tp* const_pointer;</a>
<a name="65"><span class="lineNum"> 65 </span> : : typedef _Tp&amp; reference;</a>
<a name="66"><span class="lineNum"> 66 </span> : : typedef const _Tp&amp; const_reference;</a>
<a name="67"><span class="lineNum"> 67 </span> : : typedef _Tp value_type;</a>
<a name="68"><span class="lineNum"> 68 </span> : : </a>
<a name="69"><span class="lineNum"> 69 </span> : : template&lt;typename _Tp1&gt;</a>
<a name="70"><span class="lineNum"> 70 </span> : : struct rebind</a>
<a name="71"><span class="lineNum"> 71 </span> : : { typedef new_allocator&lt;_Tp1&gt; other; };</a>
<a name="72"><span class="lineNum"> 72 </span> : : </a>
<a name="73"><span class="lineNum"> 73 </span> : : #if __cplusplus &gt;= 201103L</a>
<a name="74"><span class="lineNum"> 74 </span> : : // _GLIBCXX_RESOLVE_LIB_DEFECTS</a>
<a name="75"><span class="lineNum"> 75 </span> : : // 2103. propagate_on_container_move_assignment</a>
<a name="76"><span class="lineNum"> 76 </span> : : typedef std::true_type propagate_on_container_move_assignment;</a>
<a name="77"><span class="lineNum"> 77 </span> : : #endif</a>
<a name="78"><span class="lineNum"> 78 </span> : : </a>
<a name="79"><span class="lineNum"> 79 </span> : : _GLIBCXX20_CONSTEXPR</a>
<a name="80"><span class="lineNum"> 80 </span> :<span class="lineCov"> 43 : new_allocator() _GLIBCXX_USE_NOEXCEPT { }</span></a>
<a name="81"><span class="lineNum"> 81 </span> : : </a>
<a name="82"><span class="lineNum"> 82 </span> : : _GLIBCXX20_CONSTEXPR</a>
<a name="83"><span class="lineNum"> 83 </span> :<span class="lineCov"> 14 : new_allocator(const new_allocator&amp;) _GLIBCXX_USE_NOEXCEPT { }</span></a>
<a name="84"><span class="lineNum"> 84 </span> : : </a>
<a name="85"><span class="lineNum"> 85 </span> : : template&lt;typename _Tp1&gt;</a>
<a name="86"><span class="lineNum"> 86 </span> : : _GLIBCXX20_CONSTEXPR</a>
<a name="87"><span class="lineNum"> 87 </span> : : new_allocator(const new_allocator&lt;_Tp1&gt;&amp;) _GLIBCXX_USE_NOEXCEPT { }</a>
<a name="88"><span class="lineNum"> 88 </span> : : </a>
<a name="89"><span class="lineNum"> 89 </span> :<span class="lineCov"> 57 : ~new_allocator() _GLIBCXX_USE_NOEXCEPT { }</span></a>
<a name="90"><span class="lineNum"> 90 </span> : : </a>
<a name="91"><span class="lineNum"> 91 </span> : : pointer</a>
<a name="92"><span class="lineNum"> 92 </span> : : address(reference __x) const _GLIBCXX_NOEXCEPT</a>
<a name="93"><span class="lineNum"> 93 </span> : : { return std::__addressof(__x); }</a>
<a name="94"><span class="lineNum"> 94 </span> : : </a>
<a name="95"><span class="lineNum"> 95 </span> : : const_pointer</a>
<a name="96"><span class="lineNum"> 96 </span> : : address(const_reference __x) const _GLIBCXX_NOEXCEPT</a>
<a name="97"><span class="lineNum"> 97 </span> : : { return std::__addressof(__x); }</a>
<a name="98"><span class="lineNum"> 98 </span> : : </a>
<a name="99"><span class="lineNum"> 99 </span> : : // NB: __n is permitted to be 0. The C++ standard says nothing</a>
<a name="100"><span class="lineNum"> 100 </span> : : // about what the return value is when __n == 0.</a>
<a name="101"><span class="lineNum"> 101 </span> : : _GLIBCXX_NODISCARD pointer</a>
<a name="102"><span class="lineNum"> 102 </span> :<span class="lineCov"> 18 : allocate(size_type __n, const void* = static_cast&lt;const void*&gt;(0))</span></a>
<a name="103"><span class="lineNum"> 103 </span> : : {</a>
<a name="104"><span class="lineNum"> 104 </span> [<span class="branchNoCov" title="Branch 0 was not taken"> - </span><span class="branchCov" title="Branch 1 was taken 18 times"> + </span>]:<span class="lineCov"> 18 : if (__n &gt; this-&gt;max_size())</span></a>
<a name="105"><span class="lineNum"> 105 </span> :<span class="lineNoCov"> 0 : std::__throw_bad_alloc();</span></a>
<a name="106"><span class="lineNum"> 106 </span> : : </a>
<a name="107"><span class="lineNum"> 107 </span> : : #if __cpp_aligned_new</a>
<a name="108"><span class="lineNum"> 108 </span> : : if (alignof(_Tp) &gt; __STDCPP_DEFAULT_NEW_ALIGNMENT__)</a>
<a name="109"><span class="lineNum"> 109 </span> : : {</a>
<a name="110"><span class="lineNum"> 110 </span> : : std::align_val_t __al = std::align_val_t(alignof(_Tp));</a>
<a name="111"><span class="lineNum"> 111 </span> : : return static_cast&lt;_Tp*&gt;(::operator new(__n * sizeof(_Tp), __al));</a>
<a name="112"><span class="lineNum"> 112 </span> : : }</a>
<a name="113"><span class="lineNum"> 113 </span> : : #endif</a>
<a name="114"><span class="lineNum"> 114 </span> :<span class="lineCov"> 18 : return static_cast&lt;_Tp*&gt;(::operator new(__n * sizeof(_Tp)));</span></a>
<a name="115"><span class="lineNum"> 115 </span> : : }</a>
<a name="116"><span class="lineNum"> 116 </span> : : </a>
<a name="117"><span class="lineNum"> 117 </span> : : // __p is not permitted to be a null pointer.</a>
<a name="118"><span class="lineNum"> 118 </span> : : void</a>
<a name="119"><span class="lineNum"> 119 </span> :<span class="lineCov"> 18 : deallocate(pointer __p, size_type)</span></a>
<a name="120"><span class="lineNum"> 120 </span> : : {</a>
<a name="121"><span class="lineNum"> 121 </span> : : #if __cpp_aligned_new</a>
<a name="122"><span class="lineNum"> 122 </span> : : if (alignof(_Tp) &gt; __STDCPP_DEFAULT_NEW_ALIGNMENT__)</a>
<a name="123"><span class="lineNum"> 123 </span> : : {</a>
<a name="124"><span class="lineNum"> 124 </span> : : ::operator delete(__p, std::align_val_t(alignof(_Tp)));</a>
<a name="125"><span class="lineNum"> 125 </span> : : return;</a>
<a name="126"><span class="lineNum"> 126 </span> : : }</a>
<a name="127"><span class="lineNum"> 127 </span> : : #endif</a>
<a name="128"><span class="lineNum"> 128 </span> :<span class="lineCov"> 18 : ::operator delete(__p);</span></a>
<a name="129"><span class="lineNum"> 129 </span> :<span class="lineCov"> 18 : }</span></a>
<a name="130"><span class="lineNum"> 130 </span> : : </a>
<a name="131"><span class="lineNum"> 131 </span> : : size_type</a>
<a name="132"><span class="lineNum"> 132 </span> :<span class="lineCov"> 18 : max_size() const _GLIBCXX_USE_NOEXCEPT</span></a>
<a name="133"><span class="lineNum"> 133 </span> : : {</a>
<a name="134"><span class="lineNum"> 134 </span> : : #if __PTRDIFF_MAX__ &lt; __SIZE_MAX__</a>
<a name="135"><span class="lineNum"> 135 </span> :<span class="lineCov"> 18 : return size_t(__PTRDIFF_MAX__) / sizeof(_Tp);</span></a>
<a name="136"><span class="lineNum"> 136 </span> : : #else</a>
<a name="137"><span class="lineNum"> 137 </span> : : return size_t(-1) / sizeof(_Tp);</a>
<a name="138"><span class="lineNum"> 138 </span> : : #endif</a>
<a name="139"><span class="lineNum"> 139 </span> : : }</a>
<a name="140"><span class="lineNum"> 140 </span> : : </a>
<a name="141"><span class="lineNum"> 141 </span> : : #if __cplusplus &gt;= 201103L</a>
<a name="142"><span class="lineNum"> 142 </span> : : template&lt;typename _Up, typename... _Args&gt;</a>
<a name="143"><span class="lineNum"> 143 </span> : : void</a>
<a name="144"><span class="lineNum"> 144 </span> :<span class="lineCov"> 18 : construct(_Up* __p, _Args&amp;&amp;... __args)</span></a>
<a name="145"><span class="lineNum"> 145 </span> : : noexcept(std::is_nothrow_constructible&lt;_Up, _Args...&gt;::value)</a>
<a name="146"><span class="lineNum"> 146 </span> :<span class="lineCov"> 18 : { ::new((void *)__p) _Up(std::forward&lt;_Args&gt;(__args)...); }</span></a>
<a name="147"><span class="lineNum"> 147 </span> : : </a>
<a name="148"><span class="lineNum"> 148 </span> : : template&lt;typename _Up&gt;</a>
<a name="149"><span class="lineNum"> 149 </span> : : void</a>
<a name="150"><span class="lineNum"> 150 </span> :<span class="lineCov"> 18 : destroy(_Up* __p)</span></a>
<a name="151"><span class="lineNum"> 151 </span> : : noexcept(std::is_nothrow_destructible&lt;_Up&gt;::value)</a>
<a name="152"><span class="lineNum"> 152 </span> :<span class="lineCov"> 18 : { __p-&gt;~_Up(); }</span></a>
<a name="153"><span class="lineNum"> 153 </span> : : #else</a>
<a name="154"><span class="lineNum"> 154 </span> : : // _GLIBCXX_RESOLVE_LIB_DEFECTS</a>
<a name="155"><span class="lineNum"> 155 </span> : : // 402. wrong new expression in [some_] allocator::construct</a>
<a name="156"><span class="lineNum"> 156 </span> : : void</a>
<a name="157"><span class="lineNum"> 157 </span> : : construct(pointer __p, const _Tp&amp; __val)</a>
<a name="158"><span class="lineNum"> 158 </span> : : { ::new((void *)__p) _Tp(__val); }</a>
<a name="159"><span class="lineNum"> 159 </span> : : </a>
<a name="160"><span class="lineNum"> 160 </span> : : void</a>
<a name="161"><span class="lineNum"> 161 </span> : : destroy(pointer __p) { __p-&gt;~_Tp(); }</a>
<a name="162"><span class="lineNum"> 162 </span> : : #endif</a>
<a name="163"><span class="lineNum"> 163 </span> : : </a>
<a name="164"><span class="lineNum"> 164 </span> : : template&lt;typename _Up&gt;</a>
<a name="165"><span class="lineNum"> 165 </span> : : friend bool</a>
<a name="166"><span class="lineNum"> 166 </span> : : operator==(const new_allocator&amp;, const new_allocator&lt;_Up&gt;&amp;)</a>
<a name="167"><span class="lineNum"> 167 </span> : : _GLIBCXX_NOTHROW</a>
<a name="168"><span class="lineNum"> 168 </span> : : { return true; }</a>
<a name="169"><span class="lineNum"> 169 </span> : : </a>
<a name="170"><span class="lineNum"> 170 </span> : : template&lt;typename _Up&gt;</a>
<a name="171"><span class="lineNum"> 171 </span> : : friend bool</a>
<a name="172"><span class="lineNum"> 172 </span> : : operator!=(const new_allocator&amp;, const new_allocator&lt;_Up&gt;&amp;)</a>
<a name="173"><span class="lineNum"> 173 </span> : : _GLIBCXX_NOTHROW</a>
<a name="174"><span class="lineNum"> 174 </span> : : { return false; }</a>
<a name="175"><span class="lineNum"> 175 </span> : : };</a>
<a name="176"><span class="lineNum"> 176 </span> : : </a>
<a name="177"><span class="lineNum"> 177 </span> : : _GLIBCXX_END_NAMESPACE_VERSION</a>
<a name="178"><span class="lineNum"> 178 </span> : : } // namespace</a>
<a name="179"><span class="lineNum"> 179 </span> : : </a>
<a name="180"><span class="lineNum"> 180 </span> : : #endif</a>
</pre>
</td>
</tr>
</table>
<br>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.14</a></td></tr>
</table>
<br>
</body>
</html>