OSDN Git Service

* gnu/gcj/natCore.cc (create): Use __builtin_alloca, and compute
authortromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 Apr 2002 23:05:17 +0000 (23:05 +0000)
committertromey <tromey@138bc75d-0d04-0410-961f-82ee72b054a4>
Wed, 24 Apr 2002 23:05:17 +0000 (23:05 +0000)
correct length of UTF-8 encoded name.  Strip leading `/'.
(_Jv_RegisterResource): Use _Jv_Malloc.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@52744 138bc75d-0d04-0410-961f-82ee72b054a4

libjava/ChangeLog
libjava/gnu/gcj/natCore.cc

index d084656..a7d3419 100644 (file)
@@ -1,3 +1,9 @@
+2002-04-24  Tom Tromey  <tromey@redhat.com>
+
+       * gnu/gcj/natCore.cc (create): Use __builtin_alloca, and compute
+       correct length of UTF-8 encoded name.  Strip leading `/'.
+       (_Jv_RegisterResource): Use _Jv_Malloc.
+
 2002-04-23  Adam Megacz <adam@xwt.org>
 
        * win32.cc, include/win32.cc (backtrace): Added this function
index 8e7a024..75a7ad0 100644 (file)
@@ -1,6 +1,6 @@
 // natCore -- C++ side of Core
 
-/* Copyright (C) 2001  Free Software Foundation
+/* Copyright (C) 2001, 2002  Free Software Foundation
 
    This file is part of libgcj.
 
@@ -40,7 +40,7 @@ void _Jv_RegisterResource (void *vptr)
   // These are permanent data structures for now.  This routine is
   // called from a static constructor, so we shouldn't depend on too
   // much existing infrastructure.
-  core_chain *cc = (core_chain *) malloc (sizeof (core_chain));
+  core_chain *cc = (core_chain *) _Jv_Malloc (sizeof (core_chain));
 
   cc->name_length = ((int *)rptr)[0];
   cc->data_length = ((int *)rptr)[1];
@@ -56,10 +56,18 @@ void _Jv_RegisterResource (void *vptr)
 gnu::gcj::Core *
 gnu::gcj::Core::create (jstring name)
 {
-  char buf[name->length() + 1];
+  char *buf = (char *) __builtin_alloca (JvGetStringUTFLength (name) + 1);
   jsize total = JvGetStringUTFRegion (name, 0, name->length(), buf);
   buf[total] = '\0';
 
+  // Usually requests here end up as an absolute URL.  We strip the
+  // initial `/'.
+  if (buf[0] == '/')
+    {
+      ++buf;
+      --total;
+    }
+
   core_chain *node = root;
 
   while (node)