Debian Codegraph @

src/common/format.c

raw symbols SCIP
1 /*
2 Authors:
3 Pavel Březina <[email protected]>
4
5 Copyright (C) 2017 Red Hat
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21 #include "config.h"
22
23 #include <stdarg.h>
24 #include <stdio.h>
25
26 char *
27 vaformat(const char *fmt, va_list in_va)
28 {
29 char *str = NULL;
30 va_list va;
31 int ret;
32
33 va_copy(va, in_va);
34 ret = vasprintf(&str, fmt, va);
35 va_end(va);
36
37 if (ret == -1) {
38 return NULL;
39 }
40
41 return str;
42 }
43
44 char *
45 format(const char *fmt, ...)
46 {
47 char *str;
48 va_list va;
49
50 va_start(va, fmt);
51 str = vaformat(fmt, va);
52 va_end(va);
53
54 return str;
55 }