[FFmpeg-devel] [PATCH 3/3] FATE/bprint: Convert a VLA to a normal array
Derek Buitenhuis
derek.buitenhuis at gmail.com
Tue Sep 11 21:54:11 CEST 2012
Signed-off-by: Derek Buitenhuis <derek.buitenhuis at gmail.com>
---
libavutil/bprint.c | 19 ++++++++++---------
1 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/libavutil/bprint.c b/libavutil/bprint.c
index f9d5d6a..7f5f4c1 100644
--- a/libavutil/bprint.c
+++ b/libavutil/bprint.c
@@ -168,9 +168,9 @@ int av_bprint_finalize(AVBPrint *buf, char **ret_str)
#undef printf
-static void bprint_pascal(AVBPrint *b, unsigned size)
+static void bprint_pascal(AVBPrint *b, unsigned *p, unsigned size)
{
- unsigned p[size + 1], i, j;
+ unsigned i, j;
p[0] = 1;
av_bprintf(b, "%8d\n", 1);
@@ -188,38 +188,39 @@ int main(void)
{
AVBPrint b;
char buf[256];
+ unsigned p[26];
av_bprint_init(&b, 0, -1);
- bprint_pascal(&b, 5);
+ bprint_pascal(&b, p, 5);
printf("Short text in unlimited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
printf("%s\n", b.str);
av_bprint_finalize(&b, NULL);
av_bprint_init(&b, 0, -1);
- bprint_pascal(&b, 25);
+ bprint_pascal(&b, p, 25);
printf("Long text in unlimited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
av_bprint_finalize(&b, NULL);
av_bprint_init(&b, 0, 2048);
- bprint_pascal(&b, 25);
+ bprint_pascal(&b, p, 25);
printf("Long text in limited buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
av_bprint_finalize(&b, NULL);
av_bprint_init(&b, 0, 1);
- bprint_pascal(&b, 5);
+ bprint_pascal(&b, p, 5);
printf("Short text in automatic buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
av_bprint_init(&b, 0, 1);
- bprint_pascal(&b, 25);
+ bprint_pascal(&b, p, 25);
printf("Long text in automatic buffer: %u/%u\n", (unsigned)strlen(b.str)/8*8, b.len);
/* Note that the size of the automatic buffer is arch-dependant. */
av_bprint_init(&b, 0, 0);
- bprint_pascal(&b, 25);
+ bprint_pascal(&b, p, 25);
printf("Long text count only buffer: %u/%u\n", (unsigned)strlen(b.str), b.len);
av_bprint_init_for_buffer(&b, buf, sizeof(buf));
- bprint_pascal(&b, 25);
+ bprint_pascal(&b, p, 25);
printf("Long text count only buffer: %u/%u\n", (unsigned)strlen(buf), b.len);
return 0;
--
1.7.8.msysgit.0
More information about the ffmpeg-devel
mailing list