PatchSet 7755 
Date: 2008/02/15 23:34:42
Author: robilad
Branch: HEAD
Tag: (none) 
Log:
fixed ecj memory usage when building classpath

2008-02-15  Dalibor Topic  <[EMAIL PROTECTED]>

        * libraries/clib/zip/ZipFile.c (java_util_zip_ZipFile_getZipEntry0)
        (java_util_zip_ZipFile_getZipData0)
        (java_util_zip_ZipFile_getZipEntries0),
        kaffe/kaffevm/findInJar.c (findClassInJar)
        (getManifestMainAttribute),
        * kaffe/kaffeh/support.c (kaffeh_findClass): Close opened zip entries
        after use.

        Reported by:  Ito Kazumitsu  <[EMAIL PROTECTED]>

Members: 
        ChangeLog:1.5255->1.5256 
        kaffe/kaffeh/support.c:1.61->1.62 
        kaffe/kaffevm/findInJar.c:1.80->1.81 
        libraries/clib/zip/ZipFile.c:1.5->1.6 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.5255 kaffe/ChangeLog:1.5256
--- kaffe/ChangeLog:1.5255      Fri Feb 15 20:04:05 2008
+++ kaffe/ChangeLog     Fri Feb 15 23:34:42 2008
@@ -1,5 +1,17 @@
 2008-02-15  Dalibor Topic  <[EMAIL PROTECTED]>
 
+       * libraries/clib/zip/ZipFile.c (java_util_zip_ZipFile_getZipEntry0)
+       (java_util_zip_ZipFile_getZipData0)
+       (java_util_zip_ZipFile_getZipEntries0),
+       kaffe/kaffevm/findInJar.c (findClassInJar)
+       (getManifestMainAttribute),
+       * kaffe/kaffeh/support.c (kaffeh_findClass): Close opened zip entries
+       after use.
+
+       Reported by:  Ito Kazumitsu  <[EMAIL PROTECTED]>
+
+2008-02-15  Dalibor Topic  <[EMAIL PROTECTED]>
+
        * kaffe/kaffevm/jar.h, kaffe/kaffevm/jar.c (lookupJarFile): Removed.
 
        * libraries/clib/zip/ZipFile.c (getZipEntry)
Index: kaffe/kaffe/kaffeh/support.c
diff -u kaffe/kaffe/kaffeh/support.c:1.61 kaffe/kaffe/kaffeh/support.c:1.62
--- kaffe/kaffe/kaffeh/support.c:1.61   Fri Feb 15 20:04:07 2008
+++ kaffe/kaffe/kaffeh/support.c        Fri Feb 15 23:34:43 2008
@@ -868,7 +868,8 @@
                        unsigned char *buf;
                        classFile hand;
                        Hjava_lang_Class tmpClass;
-                       
+                       zzip_size_t length;
+
                        /* JAR file */
                        jfile = zzip_opendir(superName);
                        if (jfile == 0) {
@@ -884,7 +885,9 @@
                                continue;
                        }
 
+                       length = getUncompressedSize(jentry);
                        buf = getDataJarFile(jentry);
+                       zzip_file_close(jentry);
                         if (buf == NULL) {
                                zzip_closedir(jfile);
                                continue;
@@ -893,7 +896,7 @@
                        classFileInit(&hand,
                                      buf,
                                      buf,
-                                     getUncompressedSize(jentry),
+                                     length,
                                      CP_ZIPFILE);
 
                        objectDepth++;
Index: kaffe/kaffe/kaffevm/findInJar.c
diff -u kaffe/kaffe/kaffevm/findInJar.c:1.80 
kaffe/kaffe/kaffevm/findInJar.c:1.81
--- kaffe/kaffe/kaffevm/findInJar.c:1.80        Fri Feb 15 20:04:07 2008
+++ kaffe/kaffe/kaffevm/findInJar.c     Fri Feb 15 23:34:43 2008
@@ -215,6 +215,7 @@
                {
                        ZZIP_FILE * entry;
                        unsigned char* data;
+                       zzip_size_t length;
 
 DBG(CLASSLOOKUP,       dprintf("Opening JAR file %s for %s\n", ptr->path, 
cname); );
                        if (ptr->u.jar == 0) {
@@ -232,11 +233,13 @@
                        if (entry == 0) {
                                break;
                        }
-                       if (getUncompressedSize(entry) == 0) {
+                       length = getUncompressedSize(entry);
+                       if (0 == length) {
                                hand->type = CP_NULLCLASS;
                                goto done;
                        }
                        data = getDataJarFile(entry);
+                       zzip_file_close(entry);
                        if (data == 0) {
                                postExceptionMessage(einfo,
                                        JAVA_IO(IOException),
@@ -248,7 +251,7 @@
                        classFileInit(hand,
                                      data,
                                      data,
-                                     getUncompressedSize(entry),
+                                     length,
                                      CP_ZIPFILE);
 
                        if (Kaffe_JavaVMArgs.enableVerboseClassloading) {
@@ -633,7 +636,7 @@
        char* mfdata;
        char* attrEntry;
        char* ret;
-       zzip_ssize_t i;
+       zzip_ssize_t i, manifest_length;
        int posAttrValue;
 
        /* Locate manifest entry in jar */
@@ -642,13 +645,17 @@
                return (NULL);
 
        /* Read it */
+       manifest_length = getUncompressedSize(mf);
        mfdata = (char*)getDataJarFile(mf);
-       if (mfdata == 0)
-               return (NULL);
+       zzip_file_close(mf);
+       if (mfdata == 0) {
+         return (NULL);
+       }
 
        /* Look for the desired entry */
        attrEntry = mfdata;
-       for (i = 0; i < getUncompressedSize(mf); ++i) {
+
+         for (i = 0; i < manifest_length; ++i) {
                /* Sun's jar, even under Linux, insists on terminating
                   newlines with newline *and* carriage return */
                if (mfdata[i] == '\n' || mfdata[i] == '\r') {
@@ -664,7 +671,7 @@
                                        ++attrEntry;
 
                                /* Now look for end of string. */
-                               while (i < getUncompressedSize(mf) && 
attrEntry[i] != 0xd)
+                               while (i < manifest_length && attrEntry[i] != 
0xd)
                                        ++i;
 
                                attrEntry[i] = '\0';
Index: kaffe/libraries/clib/zip/ZipFile.c
diff -u kaffe/libraries/clib/zip/ZipFile.c:1.5 
kaffe/libraries/clib/zip/ZipFile.c:1.6
--- kaffe/libraries/clib/zip/ZipFile.c:1.5      Fri Feb 15 20:04:08 2008
+++ kaffe/libraries/clib/zip/ZipFile.c  Fri Feb 15 23:34:44 2008
@@ -97,9 +97,10 @@
   Hjava_util_zip_ZipEntry* zentry = NULL;
 
   entry = getZipEntry(zip, zname);
-
-  if (entry != NULL)
+  if (entry != NULL) {
     zentry = makeZipEntry(entry, zname);
+    zzip_file_close(entry);
+  }
   
   return (zentry);
 }
@@ -121,7 +122,7 @@
          ZZIP_FILE *entry = getZipEntry( zip, unhand(zentry)->name);
          if (entry != NULL)
            buf = getDataJarFile(entry);
-
+         zzip_file_close(entry);
          if (buf == 0) {
            return (NULL);
          }
@@ -159,6 +160,7 @@
          if (NULL != zip_entry) {
            entry = zzip_file_open(zfile, zip_entry->d_name, 0);
            elems[i] = (HObject*)makeZipEntry(entry, 
stringC2Java(zip_entry->d_name));
+           zzip_file_close(entry);
            i++;
          }
        }while (zip_entry != NULL);

_______________________________________________
kaffe mailing list
kaffe@kaffe.org
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to