MCPcopy Create free account
hub / github.com/antirez/ds4 / web_buf_append

Function web_buf_append

ds4_web.c:83–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83static void web_buf_append(web_buf *b, const char *s, size_t n) {
84 if (!n) return;
85 if (b->len + n + 1 > b->cap) {
86 size_t cap = b->cap ? b->cap * 2 : 4096;
87 while (cap < b->len + n + 1) cap *= 2;
88 char *p = realloc(b->ptr, cap);
89 if (!p) {
90 perror("ds4_web: realloc");
91 exit(1);
92 }
93 b->ptr = p;
94 b->cap = cap;
95 }
96 memcpy(b->ptr + b->len, s, n);
97 b->len += n;
98 b->ptr[b->len] = '\0';
99}
100
101static void web_buf_puts(web_buf *b, const char *s) {
102 web_buf_append(b, s, strlen(s));

Callers 9

web_buf_putsFunction · 0.85
web_http_requestFunction · 0.85
web_url_encodeFunction · 0.85
web_json_quoteFunction · 0.85
web_ws_connectFunction · 0.85
web_ws_send_textFunction · 0.85
web_ws_read_messageFunction · 0.85
web_utf8_appendFunction · 0.85
web_json_parse_string_atFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected