changeset 3054:ddb6acba8b6f

6851653: (launcher) Make every java process 20 bytes smaller Summary: Carefully keep track of every byte Reviewed-by: ksrini, xlu
author martin
date Mon, 22 Jun 2009 16:41:27 -0700
parents a42e2cc2aaa5
children 54b677070c61
files jdk/src/share/bin/java.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/share/bin/java.c	Sat Jun 20 13:34:06 2009 -0700
+++ b/jdk/src/share/bin/java.c	Mon Jun 22 16:41:27 2009 -0700
@@ -683,10 +683,16 @@
 SetClassPath(const char *s)
 {
     char *def;
+    const char *orig = s;
+    static const char format[] = "-Djava.class.path=%s";
     s = JLI_WildcardExpandClasspath(s);
-    def = JLI_MemAlloc(JLI_StrLen(s) + 40);
-    sprintf(def, "-Djava.class.path=%s", s);
+    def = JLI_MemAlloc(sizeof(format)
+                       - 2 /* strlen("%s") */
+                       + JLI_StrLen(s));
+    sprintf(def, format, s);
     AddOption(def, NULL);
+    if (s != orig)
+        JLI_MemFree((char *) s);
 }
 
 /*