This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Patch: rewrite File.toCanonicalPath() take 3


Andrew Haley wrote:
> Gary Benson writes:
> > Here's a second draft of my rewritten File.toCanonicalPath().  If
> > you missed my previous email, a working File.toCanonicalPath() is
> > required in order for FilePermission checks to work properly.
> > GCJ's present implementation of this has a number of drawbacks,
> > which this patch fixes.
> > 
> > This patch improves upon my previous one in two ways:
> > 
> >  1. Following comments on the Classpath mailing list, storage for
> >     paths is now allocated dynamically.
> >  2. Following comments on this list, the "no-rewind-past-root"
> >     check has been removed.
> > 
> > As before the diff of the method itself is not very legible so
> > I've attached a copy of it as well as the patch.
> 
> The repeated use of realloc() in this method is rather nasty.  It
> must surely be possible to grow the buffer in some way that doesn't
> require this.  Just pre-allocate the buffer and grow it iff it's
> insufficient.  256 bytes or so will be adequate in most cases.
> 
> I know tromey said that realloc() is not slow when compared with
> readlink(), and this is surely true, but I can't accept that we
> should unnecessarily make may calls to realloc() for that reason.

How does this look?

Cheers,
Gary

Attachment: patch
Description: Text document

Attachment: canon.cc
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]