RFC strbuf.c/h: add the constant version initialization method of strbuf
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest1 patch 1 replyIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/1 | strbuf.c/h: add the constant version initialization method of strbufstrbuf.c strbuf.h | +37 | 1 reply |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC PATCH v1 0/1] strbuf.c/h: add the constant version initialization method of strbuf
According to
https://public-inbox.org/git/[email protected]/,
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(-)
Signature · 1 line
2.30.0