summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 45f52d5)
raw | patch | inline | side by side (parent: 45f52d5)
| author | mental <mental@users.sourceforge.net> | |
| Tue, 9 May 2006 02:51:10 +0000 (02:51 +0000) | ||
| committer | mental <mental@users.sourceforge.net> | |
| Tue, 9 May 2006 02:51:10 +0000 (02:51 +0000) |
| ChangeLog | patch | blob | history | |
| src/streams-jar.cpp | patch | blob | history | |
| src/streams-zlib.cpp | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 2d6256512eb2c5e13b12d722de7f751112ccef22..6ab6de7baf98dbd475e9facd4d92d428db95ae02 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2006-05-08 MenTaLguY <mental@rydia.net>
+
+ * src/streams-zlib.cpp, src/streams-jar.cpp:
+
+ use array new rather than dynamically-sized automatic arrays,
+ plus cleanups and minor fixes
+
2006-05-08 MenTaLguY <mental@rydia.net>
* src/debug/demangle.cpp, src/debug/demangle.h, src/sp-object.cpp,
diff --git a/src/streams-jar.cpp b/src/streams-jar.cpp
index 712524cf0b130b2fe0d05f31c99e28a6f82877d8..521b1f9a96343726f577af5737a254e7f5ff5180 100644 (file)
--- a/src/streams-jar.cpp
+++ b/src/streams-jar.cpp
check_signature(data);
_urihandle->read(data+4, 26);
compressed_size = compressed_left = unpack_4bytes(data, LOC_CSIZE);
- guint16 filename_length = unpack_2bytes(data, LOC_FNLEN);
eflen = unpack_2bytes(data, LOC_EFLEN);
flags = unpack_2bytes(data, LOC_EXTRA);
method = unpack_2bytes(data, LOC_COMP);
#ifdef DEBUG_STREAMS
std::printf("Compressed size is %u\n", compressed_size);
- std::printf("Filename length is %hu\n", filename_length);
std::printf("Extra field length is %hu\n", eflen);
std::printf("Flags are %#hx\n", flags);
std::printf("Compression method is %#hx\n", method);
#endif
-
- //guint32 crc = check_crc(data, flags);
- gchar filename[filename_length+1];
- _urihandle->read(filename, filename_length);
- filename[filename_length] = '\0';
-
-#ifdef DEBUG_STREAMS
- std::printf("Filename is %s\n", filename);
-#endif
}
catch (std::exception& e) {
throw JarHeaderException();
int JarBuffer::consume_compressed(int nbytes)
{
- int ret;
+ int ret=do_consume_and_inflate(nbytes);
- if ((ret = do_consume_and_inflate(nbytes)) == EOF && eflen > 0) {
- guint8 efbuf[eflen];
+ if ( ret == EOF && eflen > 0 ) {
+ guint8 *efbuf=new guint8[eflen];
_urihandle->read(efbuf, eflen);
+ delete [] efbuf;
return 1;
}
int JarBuffer::consume_uncompressed(int nbytes)
{
- guint8 data[nbytes];
- if (consume(data, nbytes) == EOF)
- return EOF;
-
- copy_to_get(data, nbytes);
- compressed_left -= nbytes;
-
- return nbytes;
+ guint8 *data=new guint8[nbytes];
+ int consumed=consume(data, nbytes);
+ if ( consumed != EOF ) {
+ copy_to_get(data, consumed);
+ compressed_left -= consumed;
+ }
+ delete [] data;
+ return consumed;
}
GByteArray *JarBuffer::inflate(guint8 *data, const int nbytes)
diff --git a/src/streams-zlib.cpp b/src/streams-zlib.cpp
index cbe6a75fe0c44d114b68a72307f426f0528a4530..5784a17cf44683e098a6847c9acc096a3b20b0a3 100644 (file)
--- a/src/streams-zlib.cpp
+++ b/src/streams-zlib.cpp
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()