src/server/util/strbuf.c

changeset 600
94c01980e3e5
parent 415
d938228c382e
equal deleted inserted replaced
599:a5339182e67f 600:94c01980e3e5
44 buf->length = 0; 44 buf->length = 0;
45 45
46 return buf; 46 return buf;
47 } 47 }
48 48
49 void sbuf_puts(sbuf_t *buf, char *str) { 49 void sbuf_puts(sbuf_t *buf, const char *str) {
50 sbuf_append(buf, cx_str(str)); 50 sbuf_append(buf, cx_str(str));
51 } 51 }
52 52
53 void sbuf_put(sbuf_t *buf, char chr) { 53 void sbuf_put(sbuf_t *buf, char chr) {
54 sbuf_append(buf, (cxstring){&chr, 1}); 54 sbuf_append(buf, (cxstring){&chr, 1});
55 }
56
57 void sbuf_write(sbuf_t *buf, const char *str, size_t length) {
58 sbuf_append(buf, cx_strn(str, length));
55 } 59 }
56 60
57 void sbuf_append(sbuf_t *buf, cxstring str) { 61 void sbuf_append(sbuf_t *buf, cxstring str) {
58 if (buf->length + str.length >= buf->size) { 62 if (buf->length + str.length >= buf->size) {
59 buf->size *= 2; 63 buf->size *= 2;

mercurial