[Asterisk-Dev] strdupa in app_voicemail2.c
Thorsten Lockert
tholo at sigmasoft.com
Fri May 16 11:23:47 MST 2003
ast_strdupa is not a function, but rather a macro (using GCC extensions),
that ultimately calls alloca & strcpy.
In fact, the ast_strdupa implementation in Asterisk is a verbatim copy
of the one provided in Linux. As such it does require GCC to build, but
it will work on any system that provides an implementation of alloca.
Thorsten
--
Thorsten Lockert | tholo at sigmasoft.com | Universe, n.:
2121 N. Lakeshore Dr. | tholo at openbsd.org | The problem.
Chapel Hill, NC 27514 | |
-----Original Message-----
From: asterisk-dev-admin at lists.digium.com
[mailto:asterisk-dev-admin at lists.digium.com] On Behalf Of Tilghman Lesher
Sent: Friday, May 16, 2003 12:42
To: asterisk-dev at lists.digium.com
Subject: Re: [Asterisk-Dev] strdupa in app_voicemail2.c
On Friday 16 May 2003 10:25 am, Thorsten Lockert wrote:
> Some plain strdupa's snuck into the new voicemail system -- the
> attached diff changes these to use ast_strdupa like all other
> instances.
I'm curious to know how this can be done. Given that strdupa relies
upon alloca, which is not a library function, but instead is a
compiler directive, how can it allocate space in a function, but
return that same space to a higher function without freeing it (as the
allocation was on the same stack which was just freed)? What am I
missing here?
-Tilghman
_______________________________________________
Asterisk-Dev mailing list
Asterisk-Dev at lists.digium.com
http://lists.digium.com/mailman/listinfo/asterisk-dev
More information about the asterisk-dev
mailing list