memory: don't bother making a snug fit for things that will be freed soon

Most full paths are needed only temporarily and will be freed within
milliseconds.  Only 'full_operating_dir' and 'backup_dir' continue to
exist for the whole current session.  Any partition, too, will soon be
unpartitioned, so the extra reallocation is just a waste of time.
master
Benno Schulenberg 2016-12-16 21:28:28 +01:00
parent 8c7e4f5108
commit d7af590c6b
3 changed files with 6 additions and 7 deletions

View File

@ -378,8 +378,7 @@ char *do_browse_from(const char *inpath)
beep();
napms(1200);
return NULL;
} else
snuggly_fit(&path);
}
}
}

View File

@ -1348,8 +1348,7 @@ char *get_full_path(const char *origpath)
if (strcmp(d_here, "/") != 0) {
d_here = charealloc(d_here, strlen(d_here) + 2);
strcat(d_here, "/");
} else
snuggly_fit(&d_here);
}
/* Otherwise, set d_here to "". */
} else {
d_here = mallocstrcpy(NULL, "");
@ -1410,8 +1409,7 @@ char *get_full_path(const char *origpath)
if (strcmp(d_there, "/") != 0) {
d_there = charealloc(d_there, strlen(d_there) + 2);
strcat(d_there, "/");
} else
snuggly_fit(&d_there);
}
/* Otherwise, make sure that we return NULL. */
} else {
path_only = TRUE;
@ -1528,6 +1526,8 @@ void init_operating_dir(void)
/* If the operating directory is inaccessible, fail. */
if (full_operating_dir == NULL || chdir(full_operating_dir) == -1)
die("Invalid operating directory\n");
snuggly_fit(full_operating_dir);
}
/* Check to see if we're inside the operating directory. Return FALSE
@ -1618,6 +1618,7 @@ void init_backup_dir(void)
} else {
free(backup_dir);
backup_dir = full_backup_dir;
snuggly_fit(backup_dir);
}
}
#endif /* !NANO_TINY */

View File

@ -227,7 +227,6 @@ partition *partition_filestruct(filestruct *top, size_t top_x,
/* Remove all text before top_x at the top of the partition. */
charmove(top->data, top->data + top_x, strlen(top->data) - top_x + 1);
snuggly_fit(&top->data);
/* Return the partition. */
return p;