This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug java/9532] jar -C flag is incompatible with Sun's (fastjar uses nonportable feature of getcwd)
- From: "neroden at twcny dot rr dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Jul 2003 16:36:06 -0000
- Subject: [Bug java/9532] jar -C flag is incompatible with Sun's (fastjar uses nonportable feature of getcwd)
- References: <20030201043600.9532.jim.balter@cw.com>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=9532
------- Additional Comments From neroden at twcny dot rr dot com 2003-07-03 16:36 -------
Subject: Re: jar -C flag is incompatible with Sun's (fastjar
uses nonportable feature of getcwd)
>>Buffer won't be allocated recursively.
My previous fix did cause potential recursive allocation of many many
1024-byte buffers on the stack (although it was totally wasted since all
but the top one were definitely unused), so I was intent on fixing that
before it caused an out-of-memory crash. :-/ Hence the comment here.
jim dot balter at cw dot com wrote:
> No disagreement, but I *still* think it would be better
> (faster, more efficient) to allocate the buffer just once,
> statically, and reuse the result:
>
> static char old_dir[MAXPATHLEN];
> ...
> /* getcwd if we didn't already */
> if(!*old_dir && !getcwd(old_dir, sizeof old_dir)){
> ...
Yeah, probably. It's been tedious getting these patches through the
system though, and I've got other work to do. Also, I'm far from an
expert on using 'static' correctly and safely in C; I don't trust
myself. Feel free to submit the patch you just described to
gcc-patches@gcc.gnu.org, and I'll try to get it reviewed and committed.
Thanks for all your feedback.