changeset 1375:b0b249933c37

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 28d4c9f5c9e9
children 7704895771b5
files src/share/bin/java.c
diffstat 1 files changed, 8 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/bin/java.c	Sat Jun 20 13:34:06 2009 -0700
+++ b/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);
 }
 
 /*