tweaks: elide a one-line function that is used just twice

master
Benno Schulenberg 2018-12-27 21:17:37 +01:00
parent 597d90207e
commit a57c6a6763
3 changed files with 2 additions and 11 deletions

View File

@ -1472,8 +1472,7 @@ void init_operating_dir(void)
die(_("Invalid operating directory: %s\n"), operating_dir); die(_("Invalid operating directory: %s\n"), operating_dir);
free(operating_dir); free(operating_dir);
operating_dir = target; operating_dir = charealloc(target, strlen(target) + 1);
snuggly_fit(&operating_dir);
} }
/* Check whether the given path is outside of the operating directory. /* Check whether the given path is outside of the operating directory.
@ -1540,8 +1539,7 @@ void init_backup_dir(void)
die(_("Invalid backup directory: %s\n"), backup_dir); die(_("Invalid backup directory: %s\n"), backup_dir);
free(backup_dir); free(backup_dir);
backup_dir = target; backup_dir = charealloc(target, strlen(target) + 1);
snuggly_fit(&backup_dir);
} }
#endif /* !NANO_TINY */ #endif /* !NANO_TINY */

View File

@ -557,7 +557,6 @@ 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 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);

View File

@ -159,12 +159,6 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column)
return retval; return retval;
} }
/* Reduce the memory allocation of a string to what is needed. */
void snuggly_fit(char **string)
{
*string = charealloc(*string, strlen(*string) + 1);
}
/* Null a string at a certain index and align it. */ /* Null a string at a certain index and align it. */
void null_at(char **data, size_t index) void null_at(char **data, size_t index)
{ {