From 88103fc1efe13e4171b6efcc6884579ebe4124ee Mon Sep 17 00:00:00 2001 From: Reinhold Kainhofer Date: Fri, 20 Nov 2009 18:25:04 +0100 Subject: [PATCH] tie-performer: using a vector always leads to memory corruption So, we have use a deque instead, which works perfectly. I have no idea where the corruption comes from with vectors. After the first now_heads_.push_back (inf_mom), the now_heads_.size() will always be something like 3303820998 instead of 1 ???? --- lily/tie-performer.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lily/tie-performer.cc b/lily/tie-performer.cc index 55159ffb6d..1c53ff54ce 100644 --- a/lily/tie-performer.cc +++ b/lily/tie-performer.cc @@ -12,6 +12,8 @@ #include "context.hh" #include "stream-event.hh" #include "translator.icc" +// #include "international.hh" +#include struct Head_event_tuple { @@ -29,9 +31,14 @@ struct Head_event_tuple class Tie_performer : public Performer { Stream_event *event_; - vector now_heads_; - vector now_tied_heads_; - vector heads_to_tie_; + // We don't really need a deque here. A vector would suffice. However, + // for some strange reason, using vectors always leads to memory + // corruption in the STL templates! (i.e. after the first + // now_heads_.push_back (inf_mom), the now_heads_.size() will be + // something like 3303820998 :( + deque now_heads_; + deque now_tied_heads_; + deque heads_to_tie_; protected: void stop_translation_timestep (); @@ -67,15 +74,17 @@ Tie_performer::acknowledge_audio_element (Audio_element_info inf) { if (Audio_note *an = dynamic_cast (inf.elem_)) { +// message (_f ("acknowledge_audio_element, Size of now_heads_=%d", now_heads_.size ())); Head_event_tuple inf_mom (inf, now_mom ()); if (an->tie_event_) now_tied_heads_.push_back (inf_mom); else now_heads_.push_back (inf_mom); +// message (_f ("acknowledge_audio_element, added, Size of now_heads_=%d", now_heads_.size ())); // Find a previous note that ties to the current note. If it exists, // remove it from the heads_to_tie vector and create the tie - vector::iterator it; + deque::iterator it; bool found = false; Stream_event *right_mus = inf.event_; for ( it = heads_to_tie_.begin() ; (!found) && (it < heads_to_tie_.end()); it++ ) -- 2.39.2