From: Junio C Hamano <gitster@pobox.com>
To: Patrick Steinhardt <ps@pks.im>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/6] apply: refactor code to drop `line_allocated`
Date: Mon, 16 Sep 2024 11:56:16 -0700 [thread overview]
Message-ID: <xmqqldzrmnqn.fsf@gitster.g> (raw)
In-Reply-To: <0427cb72507bba7ed62d13a5523fea351a0cb35f.1726470385.git.ps@pks.im> (Patrick Steinhardt's message of "Mon, 16 Sep 2024 09:10:09 +0200")
Patrick Steinhardt <ps@pks.im> writes:
> Refactor the function to use memmove(3P) instead, which allows us to get
> rid of this double bookkeeping. We call this function at most once per
> image anyway, so this shouldn't cause any performance regressions.
Don't we call remove_first_line() as long as leading is larger than
trailing repeatedly? Is "at most once" accurate?
As to the correctness, I think nobody takes the address of an
element in the line[] array and expects the address to stay valid
across a call to remove_first_line(), so this should be safe.
Thanks.
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
> apply.c | 33 ++++++++++++++-------------------
> 1 file changed, 14 insertions(+), 19 deletions(-)
next prev parent reply other threads:[~2024-09-16 18:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-16 7:09 [PATCH 0/6] apply: fix leaking buffer of `struct image` Patrick Steinhardt
2024-09-16 7:10 ` [PATCH 1/6] apply: reorder functions to move image-related things together Patrick Steinhardt
2024-09-16 7:10 ` [PATCH 2/6] apply: rename functions operating on `struct image` Patrick Steinhardt
2024-09-16 7:10 ` [PATCH 3/6] apply: introduce macro and function to init images Patrick Steinhardt
2024-09-16 7:10 ` [PATCH 4/6] apply: refactor code to drop `line_allocated` Patrick Steinhardt
2024-09-16 18:56 ` Junio C Hamano [this message]
2024-09-17 9:50 ` Patrick Steinhardt
2024-09-16 21:40 ` Junio C Hamano
2024-09-16 7:10 ` [PATCH 5/6] apply: rename members that track line count and allocation length Patrick Steinhardt
2024-09-16 7:10 ` [PATCH 6/6] apply: refactor `struct image` to use a `struct strbuf` Patrick Steinhardt
2024-09-16 19:30 ` Junio C Hamano
2024-09-17 10:07 ` [PATCH v2 0/6] apply: fix leaking buffer of `struct image` Patrick Steinhardt
2024-09-17 10:07 ` [PATCH v2 1/6] apply: reorder functions to move image-related things together Patrick Steinhardt
2024-09-17 10:07 ` [PATCH v2 2/6] apply: rename functions operating on `struct image` Patrick Steinhardt
2024-09-17 10:08 ` [PATCH v2 3/6] apply: introduce macro and function to init images Patrick Steinhardt
2024-09-17 10:08 ` [PATCH v2 4/6] apply: refactor code to drop `line_allocated` Patrick Steinhardt
2024-09-17 10:08 ` [PATCH v2 5/6] apply: rename members that track line count and allocation length Patrick Steinhardt
2024-09-17 10:08 ` [PATCH v2 6/6] apply: refactor `struct image` to use a `struct strbuf` Patrick Steinhardt
2024-09-17 10:08 ` [PATCH v2 0/6] apply: fix leaking buffer of `struct image` Patrick Steinhardt
2024-09-17 20:57 ` Junio C Hamano
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=xmqqldzrmnqn.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=ps@pks.im \
/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 NNTP newsgroup(s).