Archived
1
0
Fork 0

strbuf: added strbuf_setlen

This commit is contained in:
Henrik Hautakoski 2011-02-04 16:27:39 +01:00
parent 3ed80a13ae
commit 6538fd9369
4 changed files with 45 additions and 0 deletions

View file

@ -46,6 +46,17 @@ void strbuf_reduce(strbuf_t *s, size_t len) {
s->buf[s->len] = '\0';
}
void strbuf_setlen(strbuf_t *s, size_t len) {
if (!s->alloc_size)
return;
if (len >= s->alloc_size)
len = s->alloc_size - 1;
s->len = len;
s->buf[s->len] = '\0';
}
char* strbuf_release(strbuf_t *s) {
char *ret;

View file

@ -29,6 +29,8 @@ void strbuf_expand(strbuf_t *s, size_t len);
void strbuf_reduce(strbuf_t *s, size_t len);
void strbuf_setlen(strbuf_t *s, size_t len);
char* strbuf_release(strbuf_t *s);
void strbuf_free(strbuf_t *s);