From: ZheNing Hu <adlternative@gmail.com>
To: git@vger.kernel.org
Cc: ZheNing Hu <adlternative@gmail.com>
Subject: [RFC PATCH v1 0/1] strbuf.c/h: add the constant version initialization method of strbuf
Date: Tue, 5 Jan 2021 14:45:01 +0800 [thread overview]
Message-ID: <20210105064502.725307-1-adlternative@gmail.com> (raw)
According to
https://public-inbox.org/git/nycvar.QRO.7.76.6.1806210857520.11870@tvgsbejvaqbjf.bet/,
we can create a new way to initialize strbuf
with string constantto save the overhead of
dynamically allocated memory.The marco function
STRBUF_INIT_CONST(str).For example,STRBUF_ININ_DEFAULT("default")
will create a strbuf which buf eqoal to "default",
len eqoal to 7 and alloc eqoal to 0.This constant
strbuf will be changed to dynamic allocation when
we want to modify the contents of the constant buffer,
The function strbuf_const_to_no_const do this by change
buf with xstrdup,some function like strbuf_grow and
strbuf_setlen will use it,to change the strbuf
to a dynamically expand buffer.
My inference is based on an non-const strbuf
with alloc greater than 0 and len greater than 0,
const strbuf with alloc = 0 and len greater than 0.
But now it have some bug because of I don't know where
is the situation that non-const strbuf with 0 alloc
and more then 0 len,this is a bit out of my expectation.
So I fail check in gitgitgadget's check.
Who can give me some advice?
Thanks.
ZheNing Hu (1):
strbuf.c/h: add the constant version initialization method of strbuf
strbuf.c | 33 +++++++++++++++++++++++++++++----
strbuf.h | 8 ++++++++
2 files changed, 37 insertions(+), 4 deletions(-)
--
2.30.0
next reply other threads:[~2021-01-05 6:46 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-05 6:45 ZheNing Hu [this message]
2021-01-05 6:45 ` [RFC PATCH v1 1/1] strbuf.c/h: add the constant version initialization method of strbuf ZheNing Hu
2021-01-07 7:03 ` Eric Sunshine
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210105064502.725307-1-adlternative@gmail.com \
--to=adlternative@gmail.com \
--cc=git@vger.kernel.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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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).