1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Fix init having its own poor vasprintf(3).

This commit is contained in:
Jonas 'Sortie' Termansen 2014-08-18 15:16:24 +02:00
parent d880a9a797
commit cbd46f610c

View file

@ -72,35 +72,6 @@ char* strdup_null(const char* src)
return src ? strdup(src) : NULL; return src ? strdup(src) : NULL;
} }
#if defined(__sortix__)
int vasprintf(char** strp, const char* format, va_list ap)
{
assert(format);
size_t guess = 256;
while ( true )
{
if ( !(*strp = (char*) malloc(sizeof(char) * (guess+1))) )
return -1;
assert(*strp);
va_list ap_copy;
va_copy(ap_copy, ap);
int ret = vsnprintf(*strp, guess+1, format, ap);
va_end(ap_copy);
if ( ret < 0 )
{
free(*strp);
*strp = 0;
return ret;
}
if ( (size_t) ret < guess+1 )
return ret;
guess = (size_t) ret;
free(*strp);
}
return -1;
}
#endif
char* print_string(const char* format, ...) char* print_string(const char* format, ...)
{ {
char* ret = NULL; char* ret = NULL;