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.
master
Benno Schulenberg 2016-12-16 20:34:38 +01:00
parent 1144d38316
commit 8c7e4f5108
5 changed files with 9 additions and 11 deletions

View File

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

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);