add_constraint(startrow+leg, value);
}
-IslandPair *ipair_get(int si, int di) {
+IslandPair *ipair_get_maybe(int si, int di) {
+ IslandPair **ipa;
+
+ assert(si < islandtablesz);
+ assert(di < islandtablesz);
+
+ if (!(ipa= ipairs[si])) return 0;
+ return ipa[di];
+}
+
+static IslandPair *ipair_get_create(int si, int di) {
IslandPair *ip, **ipa;
assert(si < islandtablesz);
/*----- actually add these trades to the LP problem -----*/
- IslandPair *ip= ipair_get(islands[s], islands[d]);
+ IslandPair *ip= ipair_get_maybe(islands[s], islands[d]);
- if (!ip->trades)
+ if (!ip || !ip->trades)
goto next_d;
double loss_factor= delay_slot_loss_factor * ip->distance_loss_factor;
SQL_DISTINCT_DECL(cols,5);
while (SQL_DISTINCT_STEP(ss_trades,cols,5)) {
- IslandPair *ip= ipair_get(cols[1], cols[3]);
+ IslandPair *ip= ipair_get_create(cols[1], cols[3]);
TradesBlock *block= ip->trades;
if (!block || ip->trades->ntrades >= TRADES_PER_BLOCK) {
block= mmalloc(sizeof(*block));