From aa03db7dda0cd9ffca5f31a4c2a2b039cfb68e27 Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 20 Apr 2025 10:50:29 +0200 Subject: [PATCH] Use an array-list instead of a linked-list of equiv.-classes, part 2. * src/search.cc (Search::compute_partition): Fix a memory leak. --- ChangeLog | 5 +++++ src/search.cc | 4 +++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 626f1a3..410dff3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2025-04-20 Bruno Haible + + Use an array-list instead of a linked-list of equiv.-classes, part 2. + * src/search.cc (Search::compute_partition): Fix a memory leak. + 2025-04-20 Bruno Haible Use a hash table in compute_partition, part 2. diff --git a/src/search.cc b/src/search.cc index 7d0651d..9b24356 100644 --- a/src/search.cc +++ b/src/search.cc @@ -1068,7 +1068,9 @@ Search::compute_partition (bool *undetermined) const { /* Allocate a new EquivalenceClass and add it as the last element to the partition. */ - pindex = partition->_equclasses.add_last (* new EquivalenceClass()); + char temp_storage[sizeof (EquivalenceClass)]; + EquivalenceClass * temp_equclass = new (temp_storage) EquivalenceClass (); + pindex = partition->_equclasses.add_last (* temp_equclass); /* Map this keyword (and all equivalent ones that will be seen later) to the equivalence class number pindex. */