Memory leak

Jim Blandy jimb@zwingli.cygnus.com
Thu Nov 1 19:31:00 GMT 2001


I've committed this change --- thanks!

Andreas Schwab <schwab@suse.de> writes:

> 
> This patch fixes a memory leak.
> 
> Andreas.
> 
> 2001-11-12  Andreas Schwab  <schwab@suse.de>
> 
> 	* eval.c (evaluate_subexp_standard): Fix memory leak: use alloca
> 	instead of xmalloc.
> 
> Index: eval.c
> ===================================================================
> RCS file: /cvs/src/src/gdb/eval.c,v
> retrieving revision 1.15
> diff -u -a -u -r1.15 eval.c
> --- eval.c	2001/11/10 20:15:13	1.15
> +++ eval.c	2001/11/12 16:50:12
> @@ -839,7 +839,7 @@
>  	      struct value *valp = NULL;
>  
>  	      /* Prepare list of argument types for overload resolution */
> -	      arg_types = (struct type **) xmalloc (nargs * (sizeof (struct type *)));
> +	      arg_types = (struct type **) alloca (nargs * (sizeof (struct type *)));
>  	      for (ix = 1; ix <= nargs; ix++)
>  		arg_types[ix - 1] = VALUE_TYPE (argvec[ix]);
>  
> @@ -888,7 +888,7 @@
>  	      struct symbol *symp;
>  
>  	      /* Prepare list of argument types for overload resolution */
> -	      arg_types = (struct type **) xmalloc (nargs * (sizeof (struct type *)));
> +	      arg_types = (struct type **) alloca (nargs * (sizeof (struct type *)));
>  	      for (ix = 1; ix <= nargs; ix++)
>  		arg_types[ix - 1] = VALUE_TYPE (argvec[ix]);
>  
> 
> -- 
> Andreas Schwab                                  "And now for something
> Andreas.Schwab@suse.de				completely different."
> SuSE Labs, SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg
> Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
> 



More information about the Gdb-patches mailing list