Go to the documentation of this file.
66 sb->
buf =
static_cast<char *
>(malloc(sb->
size));
107 sb->
buf[sb->
pos + 1] =
'\0';
114 if (
x == INT64_MIN) {
121 const int MAX_DIGITS = 20;
122 char buf[MAX_DIGITS];
124 for (i = 0; i < MAX_DIGITS; i++) {
125 buf[i] =
x % 10 +
'0';
126 if ((
x /= 10) == 0) {
133 for (
int j = i - 1; j >= 0; j--) {
148 va_start(arg, format);
149 n = vsnprintf(sb->
buf+sb->
pos, size, format, arg);
152 if (n > -1 && (
size_t)n < size) {
153 sb->
pos += (size_t)n;
176 const size_t newlen = sb->
pos+len;
177 if (newlen <= sb->size) {
188 }
while (newlen > sb->
size);
189 tmp =
static_cast<char *
>(realloc(sb->
buf, sb->
size));
198 if (!content || *content ==
'\0') {
202 snprintf(
buf,
sizeof(
buf),
"end_%s", start);
205 size_t ls = strlen(start), lc = strlen(content), le = strlen(end);
206 size_t added = ls + lc + le + 3;
208 snprintf(sb->
buf + sb->
pos, sb->
size - sb->
pos,
"%s\n%s", start, content);
209 sb->
pos += ls + lc + 1;
210 if ((lc > 0) && (content[lc - 1] !=
'\n')) {
214 snprintf(sb->
buf + sb->
pos, sb->
size - sb->
pos,
"%s\n", end);
223 while (sb->
pos > 0 && isspace(sb->
buf[sb->
pos-1])) {
size_t stringbuffer_length(StringBuffer *sb)
void stringbuffer_append_printf(StringBuffer *sb, const char *format,...)
static event_registration c
StringBuffer * stringbuffer_new(void)
void stringbuffer_append_char(StringBuffer *sb, const char c)
void stringbuffer_append_int64(StringBuffer *sb, int64_t x)
char * stringbuffer_finish(StringBuffer *sb)
sstring stringbuffer_finish_shared(StringBuffer *sb)
sstring add_string(const char *str)
static void stringbuffer_ensure(StringBuffer *sb, size_t len)
void stringbuffer_append_string(StringBuffer *sb, const char *str)
void fatal(enum fatal_error err)
void stringbuffer_append_multiline_block(StringBuffer *sb, const char *start, const char *content, const char *end)
void stringbuffer_trim_whitespace(StringBuffer *sb)
void stringbuffer_delete(StringBuffer *sb)
const typedef char * sstring
void stringbuffer_append_stringbuffer(StringBuffer *sb, const StringBuffer *sb2)