1 //**************************************************************************
3 //** ## ## ## ## ## #### #### ### ###
4 //** ## ## ## ## ## ## ## ## ## ## #### ####
5 //** ## ## ## ## ## ## ## ## ## ## ## ## ## ##
6 //** ## ## ######## ## ## ## ## ## ## ## ### ##
7 //** ### ## ## ### ## ## ## ## ## ##
8 //** # ## ## # #### #### ## ##
10 //** Copyright (C) 1999-2006 Jānis Legzdiņš
11 //** Copyright (C) 2018-2023 Ketmar Dark
13 //** This program is free software: you can redistribute it and/or modify
14 //** it under the terms of the GNU General Public License as published by
15 //** the Free Software Foundation, version 3 of the License ONLY.
17 //** This program is distributed in the hope that it will be useful,
18 //** but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 //** GNU General Public License for more details.
22 //** You should have received a copy of the GNU General Public License
23 //** along with this program. If not, see <http://www.gnu.org/licenses/>.
25 //**************************************************************************
26 #ifndef VAVOOM_PSIM_TRACE_INTERNAL_HEADER
27 #define VAVOOM_PSIM_TRACE_INTERNAL_HEADER
30 // ////////////////////////////////////////////////////////////////////////// //
31 struct InterceptionList
{
32 VV_DISABLE_COPY(InterceptionList
)
38 inline InterceptionList () noexcept
: list(nullptr), alloted(0), used(0) {}
39 inline ~InterceptionList () noexcept
{ clear(); }
41 inline void clear () noexcept
{
42 if (list
) Z_Free(list
);
47 inline void reset () noexcept
{ used
= 0; }
49 VVA_CHECKRESULT
inline bool isEmpty () const noexcept
{ return (used
== 0); }
51 VVA_CHECKRESULT
inline unsigned count () const noexcept
{ return used
; }
53 VVA_CHECKRESULT
inline intercept_t
*insert (const float frac
) noexcept
{
54 if (used
== alloted
) {
56 list
= (intercept_t
*)Z_Realloc(list
, sizeof(list
[0])*alloted
);
62 while (ipos
> 0 && frac
< list
[ipos
-1].frac
) --ipos
;
63 // here we should insert at `ipos` position
69 memmove((void *)(list
+ipos
+1), (void *)(list
+ipos
), (used
-ipos
)*sizeof(list
[0]));