From f9c5138b26e4c55572aa58f463257f53a9f64a56 Mon Sep 17 00:00:00 2001
From: Robert Ricci <ricci@cs.utah.edu>
Date: Tue, 10 May 2005 16:17:03 +0000
Subject: [PATCH] Resize the resolutions vector (which is used to hold
 potential link resolutions) if there turn out to be more than we had
 initially estimated.

This was a bit of a bonehead bug - I was under the impression that
indexing into an STL vector would autmoatcially grow the vector to
the size of your index. This turns out not to be the case.
---
 assign/score.cc | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/assign/score.cc b/assign/score.cc
index 61b422df84..870963a4cf 100644
--- a/assign/score.cc
+++ b/assign/score.cc
@@ -955,6 +955,13 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed)
 	    }
 	    resolutions[resolution_index].switches.push_front(*switch_it);
 	    resolution_index++;
+            if (resolution_index <= resolutions.size()) {
+                if (resolutions.capacity() > resolutions.size()) {
+                    resolutions.resize(resolutions.capacity());
+                } else {
+                    resolutions.resize(resolutions.size() * 2);
+                }
+            }
 	    total_weight += LINK_RESOLVE_INTRASWITCH;
 	    SDEBUG(cerr << "    intraswitch " << first << " and " << second << endl);
 	  }
@@ -1028,6 +1035,13 @@ int add_node(vvertex vv,pvertex pv, bool deterministic, bool is_fixed)
 		}
 	      }
 	      resolution_index++;
+              if (resolution_index <= resolutions.size()) {
+                  if (resolutions.capacity() > resolutions.size()) {
+                      resolutions.resize(resolutions.capacity());
+                  } else {
+                      resolutions.resize(resolutions.size() * 2);
+                  }
+              }
 	      total_weight += LINK_RESOLVE_INTERSWITCH;
 	      SDEBUG(cerr << "    interswitch " <<
 		     get(pvertex_pmap,*source_switch_it)->name << " and " <<
-- 
GitLab