On 5/15/23 16:24, Bernhard Reutner-Fischer wrote:
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?

The old m_base is never freed because it points to m_ranges, a static array in int_range:

template<unsigned N, bool RESIZABLE = false>
class GTY((user)) int_range : public irange
{
...
...
private:
  wide_int m_ranges[N*2];
};

Aldy

Reply via email to