Mercurial > mplayer.hg
annotate mp_strings.c @ 36039:826e7d2dcd7e
Revert r36098, it breaks compilation on x86-64 Linux.
The original failure needs to be investigated.
author | reimar |
---|---|
date | Mon, 01 Apr 2013 18:14:24 +0000 |
parents | 2ef9298a81e7 |
children |
rev | line source |
---|---|
32883 | 1 /* |
2 * Strings utilities | |
3 * | |
4 * This file is part of MPlayer. | |
5 * | |
6 * MPlayer is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * MPlayer is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License along | |
17 * with MPlayer; if not, write to the Free Software Foundation, Inc., | |
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | |
19 */ | |
20 | |
21 #include <stdlib.h> | |
22 #include <stdarg.h> | |
23 #include <stdio.h> | |
32949
ca6dcdb31fa1
Cosmetics: add empty line between system and local headers and remove pointless
cboesch
parents:
32883
diff
changeset
|
24 |
32883 | 25 #include "mp_strings.h" |
26 | |
27 char *mp_asprintf(const char *fmt, ...) | |
28 { | |
29 char *p = NULL; | |
33597 | 30 va_list va; |
32883 | 31 int len; |
32 | |
33 va_start(va, fmt); | |
34 len = vsnprintf(NULL, 0, fmt, va); | |
33597 | 35 va_end(va); |
32883 | 36 if (len < 0) |
37 goto end; | |
38 | |
39 p = malloc(len + 1); | |
40 if (!p) | |
41 goto end; | |
42 | |
33597 | 43 va_start(va, fmt); |
44 len = vsnprintf(p, len + 1, fmt, va); | |
45 va_end(va); | |
32883 | 46 if (len < 0) |
47 free(p), p = NULL; | |
48 | |
49 end: | |
50 return p; | |
51 } |