[PATCH] Add auto-resizing capability to irange's [PR109695]
Bernhard Reutner-Fischer
rep.dot.nop@gmail.com
Mon May 15 14:24:53 GMT 2023
On Mon, 15 May 2023 12:35:23 +0200
Aldy Hernandez via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
> +// For resizable ranges, resize the range up to HARD_MAX_RANGES if the
> +// NEEDED pairs is greater than the current capacity of the range.
> +
> +inline void
> +irange::maybe_resize (int needed)
> +{
> + if (!m_resizable || m_max_ranges == HARD_MAX_RANGES)
> + return;
> +
> + if (needed > m_max_ranges)
> + {
> + m_max_ranges = HARD_MAX_RANGES;
> + wide_int *newmem = new wide_int[m_max_ranges * 2];
> + memcpy (newmem, m_base, sizeof (wide_int) * num_pairs () * 2);
> + m_base = newmem;
Please excuse my ignorance, but where's the old m_base freed? I think
the assignment above does not call the destructor, or does it?
thanks,
> + }
> +}
> +
> +template<unsigned N, bool RESIZABLE>
> +inline
> +int_range<N, RESIZABLE>::~int_range ()
> +{
> + if (RESIZABLE && m_base != m_ranges)
> + delete m_base;
> +}
More information about the Gcc-patches
mailing list