Mercurial > mplayer.hg
annotate mp_strings.c @ 34929:c410ef9752a0
Initialize a few more AVFrame fields to avoid FFmpeg errors.
However this really needs to be done via FFmpeg somehow to avoid
issues each time new fields are added, either by exposing
ff_init_buffer_info as public API or by calling get_buffer etc.
through wrappers that take care of the initialization.
author | reimar |
---|---|
date | Sat, 14 Jul 2012 11:37:22 +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 } |