From 5db8a66d7863bc0af7dfdc71621201a1120a37b6 Mon Sep 17 00:00:00 2001 From: mental Date: Tue, 9 May 2006 03:00:35 +0000 Subject: [PATCH] hmm, make that std::vector --- ChangeLog | 2 +- src/streams-jar.cpp | 13 ++++++------- src/streams-zlib.cpp | 8 ++++---- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ab6de7ba..66ccb0508 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,7 +2,7 @@ * src/streams-zlib.cpp, src/streams-jar.cpp: - use array new rather than dynamically-sized automatic arrays, + use std::vector rather than dynamically-sized automatic arrays, plus cleanups and minor fixes 2006-05-08 MenTaLguY diff --git a/src/streams-jar.cpp b/src/streams-jar.cpp index 521b1f9a9..e597822e9 100644 --- a/src/streams-jar.cpp +++ b/src/streams-jar.cpp @@ -1,3 +1,4 @@ +#include #include "streams-jar.h" namespace Inkscape { @@ -81,9 +82,8 @@ int JarBuffer::consume_compressed(int nbytes) int ret=do_consume_and_inflate(nbytes); if ( ret == EOF && eflen > 0 ) { - guint8 *efbuf=new guint8[eflen]; - _urihandle->read(efbuf, eflen); - delete [] efbuf; + std::vector efbuf(eflen); + _urihandle->read(&efbuf[0], eflen); return 1; } @@ -92,13 +92,12 @@ int JarBuffer::consume_compressed(int nbytes) int JarBuffer::consume_uncompressed(int nbytes) { - guint8 *data=new guint8[nbytes]; - int consumed=consume(data, nbytes); + std::vector data(nbytes); + int consumed=consume(&data[0], nbytes); if ( consumed != EOF ) { - copy_to_get(data, consumed); + copy_to_get(&data[0], consumed); compressed_left -= consumed; } - delete [] data; return consumed; } diff --git a/src/streams-zlib.cpp b/src/streams-zlib.cpp index 5784a17cf..9e139e301 100644 --- a/src/streams-zlib.cpp +++ b/src/streams-zlib.cpp @@ -9,6 +9,7 @@ * Released under GNU LGPL, read the file 'COPYING.LIB' for more information */ +#include #include "streams-zlib.h" namespace Inkscape { @@ -104,18 +105,17 @@ int ZlibBuffer::do_consume(guint8 *buf, int nbytes) int ZlibBuffer::do_consume_and_inflate(int nbytes) { - guint8 *buf=new guint8[nbytes]; + std::vector buf(nbytes); - int ret=consume(buf, nbytes); + int ret=consume(&buf[0], nbytes); if ( ret != EOF ) { ret = 1; - GByteArray *gba = inflate(buf, nbytes); + GByteArray *gba = inflate(&buf[0], nbytes); copy_to_get(gba->data, gba->len); g_byte_array_free(gba, TRUE); } - delete [] buf; return ret; } -- 2.39.5