"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Theo Buehler <tb@theobuehler.org>
Subject:
Re: histedit_parse_list: avoid needless free(line)
To:
Omar Polo <op@omarpolo.com>
Cc:
gameoftrees@openbsd.org
Date:
Mon, 27 Feb 2023 09:27:51 +0100

Download raw body.

Thread
On Mon, Feb 27, 2023 at 09:10:49AM +0100, Omar Polo wrote:
> Don't need to free(line) at every iteration, getline(3) allows to
> re-use the storage safely (since it tracks linesize too.)  It
> simplifies a bit the code.
> 
> ok?

Yes, ok.

I think size should be initialized to 0 at the top of the function - our
getline does the right thing if *lineptr is NULL, but the manual says

  If *n is non-zero, then *lineptr must be pre-allocated to at least *n
  bytes.

Also, maybe call it linesize instead of size like in all other getline()
calls in this giant file.