Archived
1
0
Fork 0

common/strbuf: "\0" pointer for new buffers and squeeze.

This commit is contained in:
H Hautakoski 2010-09-12 13:32:20 +02:00 committed by Henrik Hautakoski
parent c967a59706
commit 9de2e02418
4 changed files with 150 additions and 60 deletions

View file

@ -11,9 +11,7 @@
#ifndef __COMMON_STRBUF_H
#define __COMMON_STRBUF_H
#include <string.h>
#define STRBUF_INIT { 0, 0, NULL }
#include <stddef.h>
typedef struct {
size_t alloc_size;
@ -21,12 +19,26 @@ typedef struct {
char *buf;
} strbuf_t;
extern char strbuf_null;
#define STRBUF_INIT { 0, 0, &strbuf_null }
void strbuf_init(strbuf_t *s);
void strbuf_append(strbuf_t *s, char *str, size_t len);
void strbuf_expand(strbuf_t *s, size_t len);
void strbuf_reduce(strbuf_t *s, size_t len);
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_str(strbuf_t *s, char *str);
void strbuf_append_ch(strbuf_t *s, char ch);
void strbuf_trim(strbuf_t *s);
void strbuf_rtrim(strbuf_t *s);
@ -35,8 +47,6 @@ void strbuf_ltrim(strbuf_t *s);
void strbuf_rev(strbuf_t *s);
char* strbuf_release(strbuf_t *s);
void strbuf_free(strbuf_t *s);
void strbuf_squeeze(strbuf_t *s, char ch);
#endif /* __COMMON_STRBUF_H */