You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
673 B
33 lines
673 B
#include "webfuse/core/string.h"
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
char * wf_create_string(char const * format, ...)
|
|
{
|
|
char * result = NULL;
|
|
|
|
va_list measure_args;
|
|
va_start(measure_args, format);
|
|
char buffer;
|
|
int needed = vsnprintf(&buffer, 1, format, measure_args);
|
|
va_end(measure_args);
|
|
|
|
if (0 <= needed)
|
|
{
|
|
result = malloc(needed + 1);
|
|
va_list args;
|
|
va_start(args, format);
|
|
int count = vsnprintf(result, needed + 1, format, args);
|
|
va_end(args);
|
|
|
|
if ((count < 0) || (needed < count))
|
|
{
|
|
free(result);
|
|
result = NULL;
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|