public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Paul Eggert <eggert@cs.ucla.edu>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH] stdio-common: Add the fgetln function
Date: Fri, 24 Jun 2022 15:35:36 -0500	[thread overview]
Message-ID: <71c2beba-ec0a-46e8-a212-c7ba8e866410@cs.ucla.edu> (raw)
In-Reply-To: <87fsjujpf4.fsf@oldenburg.str.redhat.com>

On 6/24/22 06:01, Florian Weimer wrote:
> We could avoid these
> changes if we resized the buffer to twice the original buffer size.
> Then we'd still maintain buffer read alignment, just with a larger
> buffer.  But that runs counter to the goal of avoiding extra
> allocations.

I'm not quite following. Since there would be just one buffer, that's 
one less memory allocation than the two buffers in the proposal. Yes, 
this single buffer might waste more total space due to the memory 
allocated between the buffer start and the line start. But I doubt 
whether it's worth the CPU time and complexity and data movement merely 
to avoid that space wastage.

If the worry is that a 2x growth factor is overkill, we use a 1.5x 
growth factor (as in Gnulib's xpalloc function). It should be easy to 
maintain buffer read alignment regardless of growth factor.


      reply	other threads:[~2022-06-24 20:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-03  7:36 Florian Weimer
2022-05-03  8:06 ` Andreas Schwab
2022-05-03  8:31   ` Florian Weimer
2022-05-03  8:46     ` Andreas Schwab
2022-05-03  9:01       ` Florian Weimer
2022-05-03  9:10         ` Andreas Schwab
2022-05-03 10:45         ` Cristian Rodríguez
2022-05-04  0:40 ` Paul Eggert
2022-06-09  7:37   ` Florian Weimer
2022-06-09 20:08     ` Paul Eggert
2022-06-24 11:01       ` Florian Weimer
2022-06-24 20:35         ` Paul Eggert [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=71c2beba-ec0a-46e8-a212-c7ba8e866410@cs.ucla.edu \
    --to=eggert@cs.ucla.edu \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).