strbuf: docs and const pointers.
This commit is contained in:
parent
850df3fc87
commit
ccdad9c6aa
3 changed files with 17 additions and 5 deletions
|
|
@ -28,6 +28,14 @@ strbuf_append():
|
|||
Like strncat() this function will append the buffer with the contents of 'str'
|
||||
and will always copy exactly 'len' bytes. (if memory can be obtained ofcourse)
|
||||
|
||||
strbuf_append_str():
|
||||
|
||||
Will add the C-string to the end of ->buf
|
||||
|
||||
strbuf_append_ch():
|
||||
|
||||
Adds one character 'ch' to the end of ->buf
|
||||
|
||||
strbuf_reduce():
|
||||
|
||||
Will reduce ->buf by 'len' bytes from the end, Note that this don't shrink the memory block
|
||||
|
|
@ -43,6 +51,10 @@ strbuf_rev():
|
|||
|
||||
Reverses the ->buf string.
|
||||
|
||||
strbuf_squeeze():
|
||||
|
||||
Squeezes "together" sequences of 'ch' into one character.
|
||||
|
||||
strbuf_release():
|
||||
|
||||
This function should be used to detach the ->buf member from the strbuf_t structure.
|
||||
|
|
|
|||
|
|
@ -89,7 +89,7 @@ void strbuf_free(strbuf_t *s) {
|
|||
strbuf_init(s);
|
||||
}
|
||||
|
||||
void strbuf_append(strbuf_t *s, void *ptr, size_t len) {
|
||||
void strbuf_append(strbuf_t *s, const void *ptr, size_t len) {
|
||||
|
||||
strbuf_expand(s, len);
|
||||
memcpy(s->buf + s->len, ptr, len);
|
||||
|
|
@ -97,7 +97,7 @@ void strbuf_append(strbuf_t *s, void *ptr, size_t len) {
|
|||
s->buf[s->len] = '\0';
|
||||
}
|
||||
|
||||
void strbuf_append_str(strbuf_t *s, char *str) {
|
||||
void strbuf_append_str(strbuf_t *s, const char *str) {
|
||||
|
||||
strbuf_append(s, str, strlen(str));
|
||||
}
|
||||
|
|
@ -157,7 +157,7 @@ void strbuf_squeeze(strbuf_t *s, char ch) {
|
|||
|
||||
size_t np = p, of = 0;
|
||||
|
||||
for(; np >= 1 && s->buf[np-1] == ch; np--)
|
||||
for(; np && s->buf[np-1] == ch; np--)
|
||||
of++;
|
||||
for(s->len -= of; np <= s->len; np++)
|
||||
s->buf[np] = s->buf[np + of];
|
||||
|
|
|
|||
|
|
@ -33,9 +33,9 @@ char* strbuf_release(strbuf_t *s);
|
|||
|
||||
void strbuf_free(strbuf_t *s);
|
||||
|
||||
void strbuf_append(strbuf_t *s, void *ptr, size_t len);
|
||||
void strbuf_append(strbuf_t *s, const void *ptr, size_t len);
|
||||
|
||||
void strbuf_append_str(strbuf_t *s, char *str);
|
||||
void strbuf_append_str(strbuf_t *s, const char *str);
|
||||
|
||||
void strbuf_append_ch(strbuf_t *s, char ch);
|
||||
|
||||
|
|
|
|||
Reference in a new issue