chiark / gitweb /
WIP routesearch; fix route trades cache block linked list
authorIan Jackson <ian@liberator.(none)>
Sat, 3 Oct 2009 09:04:53 +0000 (10:04 +0100)
committerIan Jackson <ian@liberator.(none)>
Sat, 3 Oct 2009 09:04:53 +0000 (10:04 +0100)
yarrg/rsvalue.c

index da7dbaf..70e1f65 100644 (file)
@@ -143,7 +143,7 @@ static IslandPair *ipair_get(int si, int di) {
   ip->ntrades= 0;
   ip->trades= 0;
   int inblock= TRADES_PER_BLOCK;
-  TradesBlock *block= 0;
+  TradesBlock *block=0, **tail=&ip->trades;
 
   debugf("VALUE ipair_get(%d,%d) running...\n", si,di);
   SQL_MUST( sqlite3_bind_int(ss_ipair_dist, 1, si) );
@@ -159,8 +159,9 @@ static IslandPair *ipair_get(int si, int di) {
   while (SQL_STEP(ss_ipair_trades)) {
     if (inblock == TRADES_PER_BLOCK) {
       block= mmalloc(sizeof(*block));
-      block->next= ip->trades;
-      ip->trades= block;
+      block->next= 0;
+      *tail= block;
+      tail= &block->next;
       inblock= 0;
     }
     int *irp, i;