nano

nano with my custom patches
git clone git://bsandro.tech/nano
Log | Files | Refs | README | LICENSE

commit a57c6a6763f31dfaf52dc392b4e6127a2c3e88e3
parent 597d90207e144e9b99292ec91d84b16c54fd82d6
Author: Benno Schulenberg <bensberg@telfort.nl>
Date:   Thu, 27 Dec 2018 21:17:37 +0100

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

Diffstat:
Msrc/files.c | 6++----
Msrc/proto.h | 1-
Msrc/utils.c | 6------
3 files changed, 2 insertions(+), 11 deletions(-)

diff --git 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 @@ -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 @@ -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) {