blob: 2a9ed5d7c513070514e59c508282d1cc9371f3a0 (
plain) (
tree)
|
|
#include "tmpbuffer.h"
#include "asn1.h"
#include <stdio.h>
#define COUNT 100
static char buffer[TMPLEN * COUNT];
static int pos = 0;
inline char* tmpbuffer_get()
{
pos = (pos + 1) % COUNT;
return buffer + TMPLEN * pos;
}
void tmpbuffer_format(struct string *dest, const char *format, ...)
{
va_list args;
va_start(args, format);
tmpbuffer_formatva(dest, format, args);
va_end(args);
}
void tmpbuffer_formatva(struct string *dest, const char *format, va_list args)
{
char *b = tmpbuffer_get();
const int ret = vsnprintf(b, TMPLEN, format, args);
dest->l = (ret >= TMPLEN ? TMPLEN - 1 : ret);
dest->s = b;
}
|