[RFC PATCH v1 0/1] strbuf.c/h: add the constant version initialization method of strbuf

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



According to
https://public-inbox.org/git/nycvar.QRO.7.76.6.1806210857520.11870@xxxxxxxxxxxxxxxxx/,
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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux