From 6db4b33eb9f2461967a8e8305bf819b7976877eb Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Fri, 8 Nov 2024 23:16:45 -0800 Subject: [PATCH] seq: seq_fast always exits now MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * src/seq.c (seq_fast): Always exit. Don’t bother freeing just before exit. --- src/seq.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/seq.c b/src/seq.c index 613d3d66d9..1b3be26bae 100644 --- a/src/seq.c +++ b/src/seq.c @@ -453,8 +453,7 @@ trim_leading_zeros (char const *s) } /* Print all whole numbers from A to B, inclusive -- to stdout, each - followed by a newline. If B < A, return and print nothing. - Otherwise, do all the work and exit. */ + followed by a newline. Then exit. */ static void seq_fast (char const *a, char const *b, uintmax_t step) { @@ -521,18 +520,17 @@ seq_fast (char const *a, char const *b, uintmax_t step) p -= incr_grows (p, endp); } - /* If there was output, write the remaining buffered output with a - terminator instead of a separator; then exit. */ + /* Write the remaining buffered output with a terminator instead of + a separator. */ idx_t remaining = bufp - buf; if (remaining) { bufp[-1] = *terminator; if (full_write (STDOUT_FILENO, buf, remaining) != remaining) write_error (); - exit (EXIT_SUCCESS); } - free (p0); + exit (EXIT_SUCCESS); } /* Return true if S consists of at least one digit and no non-digits. */ @@ -652,8 +650,6 @@ main (int argc, char **argv) char const *s1 = n_args == 1 ? "1" : argv[optind]; char const *s2 = argv[optind + (n_args - 1)]; seq_fast (s1, s2, step.value); - - /* Upon any failure, let the more general code deal with it. */ } last = scan_arg (argv[optind++]); -- 2.47.3