src/server/util/strbuf.c

changeset 415
d938228c382e
parent 92
382bff43c6eb
equal deleted inserted replaced
414:99a34860c105 415:d938228c382e
28 28
29 #include <stdio.h> 29 #include <stdio.h>
30 #include <stdlib.h> 30 #include <stdlib.h>
31 #include <string.h> 31 #include <string.h>
32 32
33 #include <ucx/string.h> 33 #include <cx/string.h>
34 34
35 #include "strbuf.h" 35 #include "strbuf.h"
36 36
37 37
38 sbuf_t* sbuf_new(size_t size) { 38 sbuf_t* sbuf_new(size_t size) {
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, char *str) {
50 sbuf_append(buf, sstr(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, sstrn(&chr, 1)); 54 sbuf_append(buf, (cxstring){&chr, 1});
55 } 55 }
56 56
57 void sbuf_append(sbuf_t *buf, sstr_t str) { 57 void sbuf_append(sbuf_t *buf, cxstring str) {
58 if (buf->length + str.length >= buf->size) { 58 if (buf->length + str.length >= buf->size) {
59 buf->size *= 2; 59 buf->size *= 2;
60 buf->ptr = realloc(buf->ptr, buf->size); 60 buf->ptr = realloc(buf->ptr, buf->size);
61 sbuf_append(buf, str); 61 sbuf_append(buf, str);
62 return; 62 return;

mercurial