6851653: (launcher) Make every java process 20 bytes smaller
authormartin
Mon, 22 Jun 2009 16:41:27 -0700
changeset 3054 ddb6acba8b6f
parent 3053 a42e2cc2aaa5
child 3055 54b677070c61
6851653: (launcher) Make every java process 20 bytes smaller Summary: Carefully keep track of every byte Reviewed-by: ksrini, xlu
jdk/src/share/bin/java.c
--- 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);
 }
 
 /*