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]

Re: Patch: rewrite File.toCanonicalPath() take 2


Gary Benson writes:
 > Hi all,
 > 
 > 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.
 > 
 > One question I forgot to ask last time, concerning the very first line
 > of the method.  Do I need to free path somehow, or will it be GCd?

It'll be gcd. no problem about that.

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.

Andrew.


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