aboutsummaryrefslogtreecommitdiffstats
path: root/src/util.c
blob: 686f02d773bd7a723d9a7b9c3a5183d19cec090b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

#include "runes.h"

void runes_warn(const char *fmt, ...)
{
    va_list ap;
    va_start(ap, fmt);
    /* XXX make this do something else on windows */
    vfprintf(stderr, fmt, ap);
    va_end(ap);
}

int sprintf_dup(char **out, const char *fmt, ...)
{
    int outlen = 0;
    va_list ap;

    va_start(ap, fmt);
    outlen = vsnprintf(*out, outlen, fmt, ap);
    va_end(ap);

    *out = malloc(outlen + 1);

    va_start(ap, fmt);
    outlen = vsnprintf(*out, outlen + 1, fmt, ap);
    va_end(ap);

    return outlen;
}