From 57837e637a855fb9001c9a8f0f7d2d1be38910f9 Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Wed, 24 Apr 2013 18:11:06 +0100
Subject: [PATCH] [Fix] Probably not the best fix for a mem leak, but eh.

---
 src/space.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/src/space.c b/src/space.c
index e3760cc..6e9f435 100644
--- a/src/space.c
+++ b/src/space.c
@@ -147,7 +147,7 @@ void planets_minimap(const double res,
 
 // The node struct.
 typedef struct SysNode_ {
-  struct SysNode_* next;
+  struct SysNode_* next, *gnext;
 
   struct SysNode_* parent;
   StarSystem* sys;
@@ -155,7 +155,7 @@ typedef struct SysNode_ {
   int g;    // Step.
 } SysNode;
 
-static SysNode* gc;
+static SysNode* A_gc;
 // Prototypes.
 static SysNode* A_newNode(StarSystem* sys, SysNode* parent);
 static double A_h(StarSystem* n, StarSystem* g);
@@ -178,7 +178,8 @@ static SysNode* A_newNode(StarSystem* sys, SysNode* parent) {
   n->r = DBL_MAX;
   n->g = 0.;
 
-  A_add(gc, n);
+  n->gnext = A_gc;
+  A_gc = n;
 
   return n;
 }
@@ -276,7 +277,7 @@ static void A_freeList(SysNode* first) {
     if(p != NULL)
       free(p);
     p = n;
-  } while((n=n->next) != NULL);
+  } while((n=n->gnext) != NULL);
 
   free(p);
 }
@@ -289,7 +290,7 @@ StarSystem** system_getJumpPath(int* njumps, char* sysstart, char* sysend) {
   SysNode* cur, *neighbour;
   SysNode* open, *closed;
 
-  gc = NULL;
+  A_gc = NULL;
 
   // Initial and target systems.
   ssys = system_get(sysstart);  // Start.
@@ -333,7 +334,7 @@ StarSystem** system_getJumpPath(int* njumps, char* sysstart, char* sysend) {
   // Free the linked list.
   //A_freeList(open);
   //A_freeList(closed);
-  A_freeList(gc);
+  A_freeList(A_gc);
   return res;
 }