> Date: Wed, 3 Oct 2007 19:26:29 +0800
> From: "Yongwei Wu" <[EMAIL PROTECTED]>
> Cc: [EMAIL PROTECTED], make-w32@gnu.org
> 
> On 03/10/2007, Eli Zaretskii <[EMAIL PROTECTED]> wrote:
> > > From: Paul Smith <[EMAIL PROTECTED]>
> > > Cc: Yongwei Wu <[EMAIL PROTECTED]>, make-w32@gnu.org
> > > Date: Tue, 02 Oct 2007 21:39:04 -0400
> > >
> > > On Tue, 2007-10-02 at 17:26 +0200, Eli Zaretskii wrote:
> > > > What advantage is there in using alloca?
> > >
> > > So, alloca() is nice because it's dynamic.
> >
> > But it could get you in trouble if the file name in question is very
> > long, since the stack is limited.
> 
> char array[MAX] also allocates on the stack.

Of course.  But it allocates a constant-size buffer, and the value is
sufficiently small to avoid any problems (except if Make is already
terribly short on free stack space, which shouldn't happen).

By contrast, using alloca with very long file names is less safe.  In
general, using alloca for more than a few KB is not recommended.

> So alloca is better, since it should allocate less.

It should allocate less only for file names shorter than MAXPATHLEN.
But I was responding to what Paul wrote: that on many modern
filesystems file names can be longer than that.  In particular, I've
seen situations on Windows where various APIs return file names longer
than 260 characters, which other APIs cannot handle.


_______________________________________________
Make-w32 mailing list
Make-w32@gnu.org
http://lists.gnu.org/mailman/listinfo/make-w32

Reply via email to