-
Notifications
You must be signed in to change notification settings - Fork 127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
strbuf.c|h: Add the constant version initialization method of strbuf #824
base: master
Are you sure you want to change the base?
Conversation
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 constant to 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. Signed-off-by: ZheNing Hu <adlternative@gmail.com>
There are issues in commit 85e1e49: |
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 constant to 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. Signed-off-by: ZheNing Hu <adlternative@gmail.com>
There are issues in commit 85e1e49: |
There are issues in commit e1bce64: |
…trbuf" Try to fix some bug
…d of use xstrdup. Signed-off-by: ZheNing Hu <adlternative@gmail.com>
There are issues in commit 85e1e49: |
There are issues in commit e1bce64: |
There is an issue in commit 0a3283f: |
There is an issue in commit 25ded82: |
it's strange ,I don't know why there is a position that strbuf can with zero alloc and not zero len.so I temporarily removed it.Does that mean there be something wrong with my previous Inference?(A const strbuf with zero alloc and no zero len,A no const strbuf with no zero alloc and no zero len) Signed-off-by: ZheNing Hu <adlternative@gmail.com>
There are issues in commit 85e1e49: |
There are issues in commit e1bce64: |
There is an issue in commit 0a3283f: |
There is an issue in commit 25ded82: |
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 constant
to 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.
Signed-off-by: ZheNing Hu adlternative@gmail.com