[asterisk-dev] Re: trunk r28934 - /trunk/apps/app_sms.c

Tony Mountifield tony at softins.clara.co.uk
Sat May 20 01:57:06 MST 2006


In article <20060520012815.2F863A80DE0 at abita.digium.internal>,
 <svn-commits at lists.digium.com> wrote:
> Author: russell
> Date: Fri May 19 20:28:14 2006
> New Revision: 28934
> 
> URL: http://svn.digium.com/view/asterisk?rev=28934&view=rev
> Log:
> fix up another place where the code made assumptions about how space for
> variables would be allocatted on the stack
> 
> Modified:
>     trunk/apps/app_sms.c
> 
> Modified: trunk/apps/app_sms.c
> URL: http://svn.digium.com/view/asterisk/trunk/apps/app_sms.c?rev=28934&r1=28933&r2=28934&view=diff
> ==============================================================================
> --- trunk/apps/app_sms.c (original)
> +++ trunk/apps/app_sms.c Fri May 19 20:28:14 2006
> @@ -1176,14 +1176,13 @@
>  static int sms_generate (struct ast_channel *chan, void *data, int len, int samples)
>  {
>  	struct ast_frame f = { 0 };
> -	unsigned char waste[AST_FRIENDLY_OFFSET];
>  #define MAXSAMPLES (800)
>  #ifdef OUTALAW
> -	unsigned char buf[MAXSAMPLES];
> +	unsigned char *buf;
>  #else
> -	signed short buf[MAXSAMPLES];
> +	short *buf;
>  #endif

Another way to fix this would be to put them into a struct:

struct {
  unsigned char waste[AST_FRIENDLY_OFFSET];
  unsigned char buf[MAXSAMPLES];
} t;

Then waste becomes t.waste and buf becomes t.buf. The rest of the code
then stays unchanged, in particular not having to add or subtract
AST_FRIENDLY_OFFSET in various places.

Cheers
Tony
-- 
Tony Mountifield
Work: tony at softins.co.uk - http://www.softins.co.uk
Play: tony at mountifield.org - http://tony.mountifield.org



More information about the asterisk-dev mailing list