Re: (patch) strdupa for GLib - 2nd try



On Wed, 30 Dec 1998, Elliot Lee wrote:
> On Wed, 30 Dec 1998, Jeff Garzik wrote:
> > Apologies if you guys are seeing this twice.
> > 
> > The following patch adds strdupa support to GLib - duplicate a string on
> > the stack.  As Ulrich Drepper noted yesterday, alloca is many, many times
> > faster than g_malloc/g_free.
> > 
> > I will commit unless there are objections.
> 
> Hmm, do you necessarily need to include alloca.h - the right way on many
> systems to get alloca() prototype is by including stdlib.h (as per 'man
> alloca' on Linux & Solaris). IRIX 6.4 seems to need alloca.h, so there
> doesn't seem to be any rule of thumb...?

Solaris needs it (see below), and Linux stdlib.h includes it for the
actual definition.  Additionally, Linux stdlib.h includes it only for
special defines, which makes me think stdlib.h _won't_ include it if you
aren't using GCC, or if you are compiling with '-Wall -ansi -pedantic'.

Maybe the right thing to do would be AC_EGREP_CPP with just
#include<stdlib.h>, and see if we get the definition.

	Jeff




SYNOPSIS
     #include <stdlib.h>

     void *malloc(size_t size);

     void *calloc(size_t nelem, size_t elsize);

     void free(void *ptr);

     void *memalign(size_t alignment, size_t size);

     void *realloc(void *ptr, size_t size);

     void *valloc(size_t size);

     #include <alloca.h>
     void *alloca(size_t size);





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]