[asterisk-dev] Problems with ast_realloc Version 1.4.5

Matthew Fredrickson creslin at digium.com
Mon Jun 25 10:33:04 CDT 2007


Alloca() does not allocate memory on the heap, like malloc() and  
friends.  It allocates memory on the stack.  That's why you can't  
realloc the pointer.

---
Matthew Fredrickson
Software Engineer
Digium, Inc.

On Jun 24, 2007, at 12:03 PM, Alvaro Parres wrote:

> I have change my alloca for a malloc and that solves the problem
>
> Thanks for my self.
>
>
> On 6/24/07, Alvaro Parres < aparres at gmail.com> wrote:Hi list i'm  
> having some problems with the ast_realloac function
>
>
> I have this code:
>
>                    char *temporal;
>                    temporal = alloca(20);
>                    memset(temporal,0,20);
>                    strcpy(temporal,"Hola");
>                    ast_verbose(VERBOSE_PREFIX_4 "Temporal: % 
> s",temporal);
>                    temporal = (char *) ast_realloc(temporal,21);
>                    ast_verbose(VERBOSE_PREFIX_4 "Temporal: % 
> s",temporal);
>
> And the output at the asterisk is
>
>      > Temporal: Hola
>      WARNING: Realloc of unalloced memory at 0xb65c4960, in  
> ldapget_exec of app_ldap.c, line 194
>      > Temporal: (null)
>
> I don't know if any one of you can help me with this.
>
> Thanks.
>
> -- 
> Alvaro I. Parres Peredo
> Director de IT
> Grupo Xmarts SA de CV
> Tel: +52 (33) 35 63 6261 Ext. 112
>       01 800  087 2260
> Cel: +52 (33) 33 68 1087
> alvaro.parres at xmarts.com.mx
>
>
>
> -- 
> Alvaro I. Parres Peredo
> Director de IT
> Grupo Xmarts SA de CV
> Tel: +52 (33) 35 63 6261 Ext. 112
>       01 800  087 2260
> Cel: +52 (33) 33 68 1087
> alvaro.parres at xmarts.com.mx
> _______________________________________________
> --Bandwidth and Colocation Provided by http://www.api-digital.com--
>
> asterisk-dev mailing list
> To UNSUBSCRIBE or update options visit:
>    http://lists.digium.com/mailman/listinfo/asterisk-dev




More information about the asterisk-dev mailing list