Commit 8c7e4f51 authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

tweaks: rename a function to describe what it does

It doesn't align anything -- any allocations are already aligned to
whatever multiple is required -- it just shrinks the allocated space.
parent 1144d383
Showing with 9 additions and 11 deletions
+9 -11
...@@ -379,7 +379,7 @@ char *do_browse_from(const char *inpath) ...@@ -379,7 +379,7 @@ char *do_browse_from(const char *inpath)
napms(1200); napms(1200);
return NULL; return NULL;
} else } else
align(&path); snuggly_fit(&path);
} }
} }
......
...@@ -1343,14 +1343,13 @@ char *get_full_path(const char *origpath) ...@@ -1343,14 +1343,13 @@ char *get_full_path(const char *origpath)
/* If we succeeded, canonicalize it in d_here. */ /* If we succeeded, canonicalize it in d_here. */
if (d_here != NULL) { if (d_here != NULL) {
align(&d_here);
/* If the current directory isn't "/", tack a slash onto the end /* If the current directory isn't "/", tack a slash onto the end
* of it. */ * of it. */
if (strcmp(d_here, "/") != 0) { if (strcmp(d_here, "/") != 0) {
d_here = charealloc(d_here, strlen(d_here) + 2); d_here = charealloc(d_here, strlen(d_here) + 2);
strcat(d_here, "/"); strcat(d_here, "/");
} } else
snuggly_fit(&d_here);
/* Otherwise, set d_here to "". */ /* Otherwise, set d_here to "". */
} else { } else {
d_here = mallocstrcpy(NULL, ""); d_here = mallocstrcpy(NULL, "");
...@@ -1406,14 +1405,13 @@ char *get_full_path(const char *origpath) ...@@ -1406,14 +1405,13 @@ char *get_full_path(const char *origpath)
/* If we succeeded, canonicalize it in d_there. */ /* If we succeeded, canonicalize it in d_there. */
if (d_there != NULL) { if (d_there != NULL) {
align(&d_there);
/* If the current directory isn't "/", tack a slash onto /* If the current directory isn't "/", tack a slash onto
* the end of it. */ * the end of it. */
if (strcmp(d_there, "/") != 0) { if (strcmp(d_there, "/") != 0) {
d_there = charealloc(d_there, strlen(d_there) + 2); d_there = charealloc(d_there, strlen(d_there) + 2);
strcat(d_there, "/"); strcat(d_there, "/");
} } else
snuggly_fit(&d_there);
/* Otherwise, make sure that we return NULL. */ /* Otherwise, make sure that we return NULL. */
} else { } else {
path_only = TRUE; path_only = TRUE;
......
...@@ -227,7 +227,7 @@ partition *partition_filestruct(filestruct *top, size_t top_x, ...@@ -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. */ /* 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); charmove(top->data, top->data + top_x, strlen(top->data) - top_x + 1);
align(&top->data); snuggly_fit(&top->data);
/* Return the partition. */ /* Return the partition. */
return p; return p;
......
...@@ -659,7 +659,7 @@ int digits(ssize_t n); ...@@ -659,7 +659,7 @@ int digits(ssize_t n);
#endif #endif
bool parse_num(const char *str, ssize_t *val); bool parse_num(const char *str, ssize_t *val);
bool parse_line_column(const char *str, ssize_t *line, ssize_t *column); 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 null_at(char **data, size_t index);
void unsunder(char *str, size_t true_len); void unsunder(char *str, size_t true_len);
void sunder(char *str); void sunder(char *str);
......
...@@ -141,8 +141,8 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column) ...@@ -141,8 +141,8 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
return retval; return retval;
} }
/* Fix the memory allocation for a string. */ /* Reduce the memory allocation of a string to what is needed. */
void align(char **str) void snuggly_fit(char **str)
{ {
assert(str != NULL); assert(str != NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment