105 size_t required_size = current_size + size_to_add;
107 while (capacity < required_size)
136 int alen = strlen(a);
137 int alen0 = alen + 1;
165 str[size - 1] =
'\0';
213 len = vsnprintf(s->
str_end, maxlen, fmt, ap2);
218 #if defined(__MINGW64_VERSION_MAJOR) 219 len = _vscprintf(fmt, ap2);
233 len = vsnprintf(s->
str_end, maxlen, fmt, ap);
236 if ( len < 0 )
return len;
238 if ( len >= maxlen )
return -1;
277 if( (*ptr ==
' ') || (*ptr ==
'\t') )
307 char *decimal_ptr = NULL;
322 if ( (*ptr >=
'0') && (*ptr <=
'9' ) )
335 while( ptr >= decimal_ptr )
void stringbuffer_init(stringbuffer_t *s)
stringbuffer_t * stringbuffer_create(void)
Allocate a new stringbuffer_t.
void stringbuffer_set(stringbuffer_t *s, const char *str)
Clear the stringbuffer_t and re-start it with the specified string.
char * stringbuffer_getstringcopy(stringbuffer_t *s)
Returns a newly allocated string large enough to contain the current state of the string...
stringbuffer_t * stringbuffer_create_with_size(size_t size)
Allocate a new stringbuffer_t.
int stringbuffer_trim_trailing_white(stringbuffer_t *s)
Trims whitespace off the end of the stringbuffer.
static void stringbuffer_init_with_size(stringbuffer_t *s, size_t size)
int stringbuffer_aprintf(stringbuffer_t *s, const char *fmt,...)
Appends a formatted string to the current string buffer, using the format and argument list provided...
int stringbuffer_getlength(stringbuffer_t *s)
Returns the length of the current string, not including the null terminator (same behavior as strlen(...
void stringbuffer_clear(stringbuffer_t *s)
Reset the stringbuffer_t.
static int stringbuffer_avprintf(stringbuffer_t *s, const char *fmt, va_list ap)
Appends a formatted string to the current string buffer, using the format and argument list provided...
void stringbuffer_append(stringbuffer_t *s, const char *a)
Append the specified string to the stringbuffer_t.
#define STRINGBUFFER_STARTSIZE
void stringbuffer_destroy(stringbuffer_t *s)
Free the stringbuffer_t and all memory managed within it.
static void stringbuffer_makeroom(stringbuffer_t *s, size_t size_to_add)
If necessary, expand the stringbuffer_t internal buffer to accomodate the specified additional size...
void stringbuffer_copy(stringbuffer_t *dst, stringbuffer_t *src)
Copy the contents of src into dst.
void * lwrealloc(void *mem, size_t size)
const char * stringbuffer_getstring(stringbuffer_t *s)
Returns a reference to the internal string being managed by the stringbuffer.
char stringbuffer_lastchar(stringbuffer_t *s)
Return the last character in the buffer.
void * lwalloc(size_t size)
void stringbuffer_release(stringbuffer_t *s)
int stringbuffer_trim_trailing_zeroes(stringbuffer_t *s)
Trims zeroes off the end of the last number in the stringbuffer.