[Fix] Probably not the best fix for a mem leak, but eh.
This commit is contained in:
parent
d58d3283a4
commit
57837e637a
13
src/space.c
13
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user