Go to the documentation of this file.
30 #define inline __inline
49 #ifndef STRBUF_DEFAULT_SIZE
50 #define STRBUF_DEFAULT_SIZE 1023
52 #ifndef STRBUF_DEFAULT_INCREMENT
53 #define STRBUF_DEFAULT_INCREMENT -2
67 static int strbuf_empty_length(
strbuf_t *
s);
70 static void strbuf_ensure_empty_length(
strbuf_t *
s,
int len);
71 static char *strbuf_empty_ptr(
strbuf_t *
s);
77 static void strbuf_append_mem(
strbuf_t *
s,
const char *c,
int len);
79 static void strbuf_append_char(
strbuf_t *
s,
const char c);
80 static void strbuf_ensure_null(
strbuf_t *
s);
83 static inline void strbuf_reset(
strbuf_t *
s)
88 static inline int strbuf_allocated(
strbuf_t *
s)
90 return s->buf !=
NULL;
95 static inline int strbuf_empty_length(
strbuf_t *
s)
97 return s->size -
s->length - 1;
100 static inline void strbuf_ensure_empty_length(
strbuf_t *
s,
int len)
102 if (
len > strbuf_empty_length(
s))
106 static inline char *strbuf_empty_ptr(
strbuf_t *
s)
108 return s->buf +
s->length;
111 static inline void strbuf_extend_length(
strbuf_t *
s,
int len)
116 static inline int strbuf_length(
strbuf_t *
s)
121 static inline void strbuf_append_char(
strbuf_t *
s,
const char c)
123 strbuf_ensure_empty_length(
s, 1);
124 s->buf[
s->length++] = c;
127 static inline void strbuf_append_char_unsafe(
strbuf_t *
s,
const char c)
129 s->buf[
s->length++] = c;
132 static inline void strbuf_append_mem(
strbuf_t *
s,
const char *c,
int len)
134 strbuf_ensure_empty_length(
s,
len);
135 memcpy(
s->buf +
s->length, c,
len);
139 static inline void strbuf_append_mem_unsafe(
strbuf_t *
s,
const char *c,
int len)
141 memcpy(
s->buf +
s->length, c,
len);
145 static inline void strbuf_ensure_null(
strbuf_t *
s)
147 s->buf[
s->length] = 0;
150 static inline char *strbuf_string(
strbuf_t *
s,
int *
len)
void strbuf_free(strbuf_t *s)
Definition: strbuf.c:104
void strbuf_set_increment(strbuf_t *s, int increment)
Definition: strbuf.c:84
char * buf
Definition: strbuf.h:40
int dynamic
Definition: strbuf.h:44
int size
Definition: strbuf.h:41
int reallocs
Definition: strbuf.h:45
void strbuf_append_string(strbuf_t *s, const char *str)
Definition: strbuf.c:182
void strbuf_resize(strbuf_t *s, int len)
Definition: strbuf.c:164
void strbuf_append_fmt_retry(strbuf_t *s, const char *format,...)
Definition: strbuf.c:221
int length
Definition: strbuf.h:42
char * s
Definition: eval.c:797
strbuf_t * strbuf_new(int len)
Definition: strbuf.c:68
int debug
Definition: strbuf.h:46
void strbuf_init(strbuf_t *s, int len)
Definition: strbuf.c:44
int increment
Definition: strbuf.h:43
return NULL
Definition: eval.c:9968
char * strbuf_free_to_string(strbuf_t *s, int *len)
Definition: strbuf.c:116
void strbuf_append_fmt(strbuf_t *s, int len, const char *fmt,...)
Definition: strbuf.c:202
int len
Definition: helpers.c:1105