[kaffe] CVS kaffe (stack): Revert change that can cause a memory leak and add some tweaks to

Kaffe CVS cvs-commits at kaffe.org
Tue Dec 21 16:26:41 PST 2004


PatchSet 5705 
Date: 2004/12/22 00:22:01
Author: stack
Branch: HEAD
Tag: (none) 
Log:
Revert change that can cause a memory leak and add some tweaks to
eliminate some warnings.

Members: 
	ChangeLog:1.3250->1.3251 
	kaffe/kaffeh/support.c:1.46->1.47 
	kaffe/kaffevm/external.c:1.75->1.76 
	kaffe/kaffevm/file.c:1.1->1.2 
	kaffe/kaffevm/file.h:1.8->1.9 
	kaffe/kaffevm/findInJar.c:1.63->1.64 
	kaffe/kaffevm/jit3/machine.c:1.66->1.67 
	kaffe/kaffevm/jni/jni.c:1.14->1.15 
	libraries/clib/native/ClassLoader.c:1.40->1.41 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3250 kaffe/ChangeLog:1.3251
--- kaffe/ChangeLog:1.3250	Tue Dec 21 22:21:35 2004
+++ kaffe/ChangeLog	Wed Dec 22 00:22:01 2004
@@ -1,5 +1,22 @@
 2004-12-21  Timothy S. Stack  <stack at cs.utah.edu>
 
+	* kaffe/kaffeh/support.c, kaffe/kaffevm/file.h,
+	kaffe/kaffevm/file.c, kaffe/kaffevm/jni/jni.c,
+	libraries/clib/native/ClassLoader.c:
+	Be really pedantic about handling const variables and slots in the
+	classFile struct.
+	
+	* kaffe/kaffevm/findInJar.c:
+	Revert a couple changes from 1.63.
+
+	* kaffe/kaffevm/external.c:
+	Remove const from libraryPath variable.
+
+	* kaffe/kaffevm/jit3/machine.c:
+	Add const to engine_name variable.
+
+2004-12-21  Timothy S. Stack  <stack at cs.utah.edu>
+
 	* kaffe/kaffevm/jit/machine.h, kaffe/kaffevm/jit/machine.c:
 	Add jitCodeHeader support.
 
Index: kaffe/kaffe/kaffeh/support.c
diff -u kaffe/kaffe/kaffeh/support.c:1.46 kaffe/kaffe/kaffeh/support.c:1.47
--- kaffe/kaffe/kaffeh/support.c:1.46	Wed Dec  1 02:41:50 2004
+++ kaffe/kaffe/kaffeh/support.c	Wed Dec 22 00:22:02 2004
@@ -866,7 +866,11 @@
 				continue;
 			}
 
-			classFileInit(&hand, buf, (size_t)sbuf.st_size, CP_DIR);
+			classFileInit(&hand,
+				      buf,
+				      buf,
+				      (size_t)sbuf.st_size,
+				      CP_DIR);
 
 			objectDepth++;
 			/* savepool = constant_pool; */
@@ -909,7 +913,11 @@
 				continue;
                         }
 
-			classFileInit(&hand, buf, jentry->uncompressedSize, CP_ZIPFILE);
+			classFileInit(&hand,
+				      buf,
+				      buf,
+				      jentry->uncompressedSize,
+				      CP_ZIPFILE);
 
 			objectDepth++;
 			/* savepool = constant_pool; */
Index: kaffe/kaffe/kaffevm/external.c
diff -u kaffe/kaffe/kaffevm/external.c:1.75 kaffe/kaffe/kaffevm/external.c:1.76
--- kaffe/kaffe/kaffevm/external.c:1.75	Tue Dec 21 17:56:42 2004
+++ kaffe/kaffe/kaffevm/external.c	Wed Dec 22 00:22:03 2004
@@ -73,7 +73,7 @@
 } libHandle[MAXLIBS];
 
 static iStaticLock	libraryLock = KAFFE_STATIC_LOCK_INITIALIZER; /* mutex on all intern operations */
-static const char *libraryPath = NULL;
+static char *libraryPath = NULL;
 
 extern JavaVM Kaffe_JavaVM;
 
Index: kaffe/kaffe/kaffevm/file.c
diff -u kaffe/kaffe/kaffevm/file.c:1.1 kaffe/kaffe/kaffevm/file.c:1.2
--- kaffe/kaffe/kaffevm/file.c:1.1	Tue Apr 27 16:14:24 2004
+++ kaffe/kaffe/kaffevm/file.c	Wed Dec 22 00:22:03 2004
@@ -27,11 +27,16 @@
  * Init a a classFile struct to point to the given buffer.
  */
 void 
-classFileInit(classFile* cf, const unsigned char* buf, size_t len, ClassFileType cft)
+classFileInit(classFile* cf,
+	      unsigned char* mem,
+	      const unsigned char* buf,
+	      size_t len,
+	      ClassFileType cft)
 {
 	assert (((buf == NULL) && (len == 0))
 		 || ((buf != NULL) && (len != 0)));
 
+	cf->mem = mem;
 	cf->base = cf->cur = buf;
 	cf->size = len;
 	cf->type = cft;
Index: kaffe/kaffe/kaffevm/file.h
diff -u kaffe/kaffe/kaffevm/file.h:1.8 kaffe/kaffe/kaffevm/file.h:1.9
--- kaffe/kaffe/kaffevm/file.h:1.8	Tue Apr 27 16:14:24 2004
+++ kaffe/kaffe/kaffevm/file.h	Wed Dec 22 00:22:03 2004
@@ -31,6 +31,7 @@
 } ClassFileType;
  
 typedef struct classFile {
+	unsigned char* mem;
 	const unsigned char* base;
 	const unsigned char* cur;
 	size_t	        size;
@@ -41,6 +42,7 @@
  * Init a a classFile struct to point to the given buffer.
  */
 extern void classFileInit(classFile* cf,
+			  unsigned char* mem,
 			  const unsigned char* buf,
 			  size_t len,
 			  ClassFileType cft);
Index: kaffe/kaffe/kaffevm/findInJar.c
diff -u kaffe/kaffe/kaffevm/findInJar.c:1.63 kaffe/kaffe/kaffevm/findInJar.c:1.64
--- kaffe/kaffe/kaffevm/findInJar.c:1.63	Tue Dec 21 08:06:36 2004
+++ kaffe/kaffe/kaffevm/findInJar.c	Wed Dec 22 00:22:04 2004
@@ -136,6 +136,7 @@
 		class = newClass();
 		if (class == NULL) {
 			postOutOfMemory(einfo);
+			KFREE(hand.mem);
 			return (NULL);
 		}
 
@@ -150,6 +151,7 @@
 					-(jlong)GCSIZEOF(hand.base));
 			}
 #endif
+			KFREE(hand.mem);
 		}
 		return (class);
 
@@ -202,7 +204,7 @@
 		case CP_ZIPFILE:
 		{
 			jarEntry* entry;
-			const char* data;
+			char* data;
 
 DBG(CLASSLOOKUP,	dprintf("Opening JAR file %s for %s\n", ptr->path, cname); );
 			if (ptr->u.jar == 0) {
@@ -229,7 +231,11 @@
 				goto done;
 			}
 
-			classFileInit(hand, data, entry->uncompressedSize, CP_ZIPFILE);
+			classFileInit(hand,
+				      data,
+				      data,
+				      entry->uncompressedSize,
+				      CP_ZIPFILE);
 
 			if (Kaffe_JavaVMArgs.enableVerboseClassloading) {
 				dprintf("Loading %s(%s)", cname, ptr->path);
@@ -304,7 +310,11 @@
 				}
 			}
 
-			classFileInit(hand, data, (unsigned)sbuf.st_size, CP_DIR);
+			classFileInit(hand,
+				      data,
+				      data,
+				      (unsigned)sbuf.st_size,
+				      CP_DIR);
 
 			KCLOSE(fp);
 			if (Kaffe_JavaVMArgs.enableVerboseClassloading) {
Index: kaffe/kaffe/kaffevm/jit3/machine.c
diff -u kaffe/kaffe/kaffevm/jit3/machine.c:1.66 kaffe/kaffe/kaffevm/jit3/machine.c:1.67
--- kaffe/kaffe/kaffevm/jit3/machine.c:1.66	Tue Dec 21 22:21:37 2004
+++ kaffe/kaffe/kaffevm/jit3/machine.c	Wed Dec 22 00:22:05 2004
@@ -61,7 +61,7 @@
 #include "kaffe_jni.h"
 #include "native-wrapper.h"
 
-char* engine_name = "Just-in-time v3";
+const char* engine_name = "Just-in-time v3";
 
 /**
  * top of the operand stack. localsz <= stackno < localsz+stacksz
Index: kaffe/kaffe/kaffevm/jni/jni.c
diff -u kaffe/kaffe/kaffevm/jni/jni.c:1.14 kaffe/kaffe/kaffevm/jni/jni.c:1.15
--- kaffe/kaffe/kaffevm/jni/jni.c:1.14	Tue Dec 21 08:06:38 2004
+++ kaffe/kaffe/kaffevm/jni/jni.c	Wed Dec 22 00:22:05 2004
@@ -193,7 +193,7 @@
 
 	BEGIN_EXCEPTION_HANDLING(NULL);
 
-	classFileInit(&hand, buf, len, CP_BYTEARRAY);
+	classFileInit(&hand, NULL, buf, (size_t)len, CP_BYTEARRAY);
 
 	cls = newClass();
 	if (cls == 0) {
Index: kaffe/libraries/clib/native/ClassLoader.c
diff -u kaffe/libraries/clib/native/ClassLoader.c:1.40 kaffe/libraries/clib/native/ClassLoader.c:1.41
--- kaffe/libraries/clib/native/ClassLoader.c:1.40	Tue Dec 21 16:51:13 2004
+++ kaffe/libraries/clib/native/ClassLoader.c	Wed Dec 22 00:22:05 2004
@@ -44,7 +44,11 @@
 	{
 		SignalError("java.lang.ClassFormatError", "truncated class");
 	}
-	classFileInit(&hand, &unhand_array(data)->body[offset], (unsigned) length, CP_BYTEARRAY);
+	classFileInit(&hand,
+		      NULL,
+		      &unhand_array(data)->body[offset],
+		      (unsigned) length,
+		      CP_BYTEARRAY);
 
 	clazz = newClass();
 	if (clazz == 0) {




More information about the kaffe mailing list