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.
35 lines
541 B
C
35 lines
541 B
C
#define _GNU_SOURCE
|
|
#include "format.h"
|
|
|
|
#include <stdarg.h>
|
|
#include <stdio.h>
|
|
#include <string.h>
|
|
#include <sys/stat.h>
|
|
|
|
const char* format( char* buffer, int size, const char* f, ... )
|
|
{
|
|
va_list args;
|
|
va_start(args,f);
|
|
vsnprintf( buffer, size, f, args );
|
|
va_end(args);
|
|
|
|
return buffer;
|
|
}
|
|
char* aformat( const char* f, ... )
|
|
{
|
|
va_list args;
|
|
va_start(args,f);
|
|
char* res = NULL;
|
|
vasprintf( &res, f, args );
|
|
va_end(args);
|
|
|
|
return res;
|
|
}
|
|
|
|
char* safe_strdup( const char* str )
|
|
{
|
|
if( !str ) { return NULL; }
|
|
return strdup(str);
|
|
}
|
|
|