From 3f6885decb1c0b3e4248b5f44cd16471ae989972 Mon Sep 17 00:00:00 2001 From: MenTaLguY Date: Tue, 9 May 2006 02:51:10 +0000 Subject: use array new rather than dynamically-sized automatic arrays, plus cleanups and minor fixes (bzr r782) --- src/streams-zlib.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'src/streams-zlib.cpp') diff --git a/src/streams-zlib.cpp b/src/streams-zlib.cpp index cbe6a75fe..5784a17cf 100644 --- a/src/streams-zlib.cpp +++ b/src/streams-zlib.cpp @@ -104,15 +104,19 @@ int ZlibBuffer::do_consume(guint8 *buf, int nbytes) int ZlibBuffer::do_consume_and_inflate(int nbytes) { - guint8 buf[nbytes]; - if (consume(buf, nbytes) == EOF) - return EOF; - - GByteArray *gba = inflate(buf, nbytes); - copy_to_get(gba->data, gba->len); + guint8 *buf=new guint8[nbytes]; + + int ret=consume(buf, nbytes); + + if ( ret != EOF ) { + ret = 1; + GByteArray *gba = inflate(buf, nbytes); + copy_to_get(gba->data, gba->len); + g_byte_array_free(gba, TRUE); + } - g_byte_array_free(gba, TRUE); - return 1; + delete [] buf; + return ret; } int ZlibBuffer::consume_and_inflate() -- cgit v1.2.3