diff --git a/src/browser.c b/src/browser.c index 5791f60b6ed06249abbb7f00e8dbc9023998d7ed..280de40495cace6ae519e2b68bf21702558329aa 100644 --- a/src/browser.c +++ b/src/browser.c @@ -379,7 +379,7 @@ char *do_browse_from(const char *inpath) napms(1200); return NULL; } else - align(&path); + snuggly_fit(&path); } } diff --git a/src/files.c b/src/files.c index 7cc15289efd8812ba67fc98bd95cbf962009a94e..147a26cbd6aed4811020024628570e832b7857d1 100644 --- a/src/files.c +++ b/src/files.c @@ -1343,14 +1343,13 @@ char *get_full_path(const char *origpath) /* If we succeeded, canonicalize it in d_here. */ if (d_here != NULL) { - align(&d_here); - /* If the current directory isn't "/", tack a slash onto the end * of it. */ 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, ""); @@ -1406,14 +1405,13 @@ char *get_full_path(const char *origpath) /* If we succeeded, canonicalize it in d_there. */ if (d_there != NULL) { - align(&d_there); - /* If the current directory isn't "/", tack a slash onto * the end of it. */ 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; diff --git a/src/nano.c b/src/nano.c index 345db3ba1e41640ffb65a1f574a6eb01eb0d55c6..d5c4c91b69218efa42ade7ebf8f97fd0736b9025 100644 --- a/src/nano.c +++ b/src/nano.c @@ -227,7 +227,7 @@ 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); - align(&top->data); + snuggly_fit(&top->data); /* Return the partition. */ return p; diff --git a/src/proto.h b/src/proto.h index f0f8a175c346509b5bbe0f2a0dcc780b21ecffe6..ab4130908760c95d6747b1ed27201931f516c512 100644 --- a/src/proto.h +++ b/src/proto.h @@ -659,7 +659,7 @@ int digits(ssize_t n); #endif bool parse_num(const char *str, ssize_t *val); bool parse_line_column(const char *str, ssize_t *line, ssize_t *column); -void align(char **str); +void snuggly_fit(char **str); void null_at(char **data, size_t index); void unsunder(char *str, size_t true_len); void sunder(char *str); diff --git a/src/utils.c b/src/utils.c index c7971612b42b500784ad9f6dd110d87db3962593..0d42c29443e4ca6e6eb4e42a3458dc98ff61c560 100644 --- a/src/utils.c +++ b/src/utils.c @@ -141,8 +141,8 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column) return retval; } -/* Fix the memory allocation for a string. */ -void align(char **str) +/* Reduce the memory allocation of a string to what is needed. */ +void snuggly_fit(char **str) { assert(str != NULL);