Since 4.2.2, assemble_dist_paths() stores a dummy path instead of the
real path to the dist center. That's possible because distribution
doesn't actually use the path, only whether it exists.
The code to store and free the real path is still around, under #ifdef
SAVE_FINISH_PATHS. Remove it.
* of course :) ) We do clear it each and every time. */
static struct distinfo *g_distptrs;
* of course :) ) We do clear it each and every time. */
static struct distinfo *g_distptrs;
-/* Note that even though we malloc and save the path, it is never
- * used. Thus, this option. If you want to malloc and save every
- * path and then free when done, just enable this. Or, if the
- * dodistribute ever uses the path for something other than checking
- * to see that a path exists, enable this */
-/* #define SAVE_FINISH_PATHS */
-
-#ifndef SAVE_FINISH_PATHS
static char *finish_path = "h"; /* Placeholder indicating path exists */
static char *finish_path = "h"; /* Placeholder indicating path exists */
-#endif /* SAVE_FINISH_PATHS */
static void assemble_dist_paths(struct distinfo *distptrs);
static char *ReversePath(char *path);
static void assemble_dist_paths(struct distinfo *distptrs);
static char *ReversePath(char *path);
}
logerror("done exporting\n");
}
logerror("done exporting\n");
- /* Note that we free the paths (if allocated) as we loop here */
logerror("importing...");
for (n = 0; NULL != (sp = getsectid(n)); n++) {
/* Get the pointer (we do it first so we can free if needed) */
infptr = &g_distptrs[sp->sct_uid];
logerror("importing...");
for (n = 0; NULL != (sp = getsectid(n)); n++) {
/* Get the pointer (we do it first so we can free if needed) */
infptr = &g_distptrs[sp->sct_uid];
- if (sp->sct_type == SCT_WATER || sp->sct_own == 0) {
-#ifdef SAVE_FINISH_PATHS
- if (infptr->path)
- free(infptr->path);
-#endif /* SAVE_FINISH_PATHS */
+ if (sp->sct_type == SCT_WATER || sp->sct_own == 0)
np = getnatp(sp->sct_own);
np = getnatp(sp->sct_own);
- if (np->nat_money < 0) {
-#ifdef SAVE_FINISH_PATHS
- if (infptr->path)
- free(infptr->path);
-#endif /* SAVE_FINISH_PATHS */
dodistribute(sp, IMPORT,
infptr->path, infptr->imcost, infptr->excost);
dodistribute(sp, IMPORT,
infptr->path, infptr->imcost, infptr->excost);
-#ifdef SAVE_FINISH_PATHS
- if (infptr->path)
- free(infptr->path);
-#endif /* SAVE_FINISH_PATHS */
-
sp->sct_off = 0;
}
logerror("done importing\n");
sp->sct_off = 0;
}
logerror("done importing\n");
/* Now, we have a path */
if (path != NULL) {
/* Now, we have a path */
if (path != NULL) {
-#ifdef SAVE_FINISH_PATHS
- int len;
- /* Here we malloc a buffer and save it */
- len = strlen(path);
- infptr->path = malloc(len);
- if (infptr->path == NULL) {
- logerror("malloc failed in assemble_dist_path!\n");
- return;
- }
-#endif /* SAVE_FINISH_PATHS */
/* Save the import cost */
infptr->imcost = d;
/* Now, reverse the path */
/* Save the import cost */
infptr->imcost = d;
/* Now, reverse the path */
/* And walk the path back to the dist center to get the export
cost */
infptr->excost = pathcost(sp, p, MOB_MOVE);
/* And walk the path back to the dist center to get the export
cost */
infptr->excost = pathcost(sp, p, MOB_MOVE);
-#ifdef SAVE_FINISH_PATHS
- memcpy(infptr->path, p, len);
-#else
infptr->path = finish_path;
infptr->path = finish_path;
-#endif /* SAVE_FINISH_PATHS */