From a57c6a6763f31dfaf52dc392b4e6127a2c3e88e3 Mon Sep 17 00:00:00 2001 From: Benno Schulenberg <bensberg@telfort.nl> Date: Thu, 27 Dec 2018 21:17:37 +0100 Subject: [PATCH] tweaks: elide a one-line function that is used just twice --- src/files.c | 6 ++---- src/proto.h | 1 - src/utils.c | 6 ------ 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/files.c b/src/files.c index f34c98be..e4f8f2d0 100644 --- a/src/files.c +++ b/src/files.c @@ -1472,8 +1472,7 @@ void init_operating_dir(void) die(_("Invalid operating directory: %s\n"), operating_dir); free(operating_dir); - operating_dir = target; - snuggly_fit(&operating_dir); + operating_dir = charealloc(target, strlen(target) + 1); } /* 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); free(backup_dir); - backup_dir = target; - snuggly_fit(&backup_dir); + backup_dir = charealloc(target, strlen(target) + 1); } #endif /* !NANO_TINY */ diff --git a/src/proto.h b/src/proto.h index 7fdecb54..623b81f7 100644 --- a/src/proto.h +++ b/src/proto.h @@ -557,7 +557,6 @@ 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 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 406c6aa1..07422ffa 100644 --- a/src/utils.c +++ b/src/utils.c @@ -159,12 +159,6 @@ bool parse_line_column(const char *str, ssize_t *line, ssize_t *column) 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. */ void null_at(char **data, size_t index) { -- GitLab