# include "xmalloc.h"
# include "pto_debug.h"
+# include "gnu_ext.h"
/* Local Defines: */
# ifndef TRUE
Exported Implementation:
=================================================== */
/* Find the arguments of a graph. For a method that has n args, the
- result array has 'n+1' entries, the last of which is written NULL. */
+ result array has 'n+1' entries, the last of which is written NULL.
+ Note that not all entries in [0..n-1] will be populated all the time.
+*/
ir_node **find_irg_args (ir_graph *graph)
{
type *tp = get_entity_type (get_irg_entity (graph));
const int n_args = get_method_n_params (tp);
- ir_node **args = (ir_node**) xmalloc (sizeof (ir_node*) * (n_args+1));
+ ir_node **args = xcalloc (n_args + 1, sizeof (ir_node*));
ir_node *arg = get_irg_args (graph);
- find_irg_args_env_t *arg_env =
- (find_irg_args_env_t*) xmalloc (sizeof (find_irg_args_env_t));
+ find_irg_args_env_t *arg_env;
+
+ arg_env = (find_irg_args_env_t*) xmalloc (sizeof (find_irg_args_env_t));
arg_env->args = args;
arg_env->arg = arg;
- /* or use get_irg_end ?!? */
{
ir_graph *save = get_current_ir_graph ();
+
set_current_ir_graph (graph);
irg_walk (get_irg_end (graph), find_irg_arg, NULL, arg_env);
set_current_ir_graph (save);
}
- free (arg_env);
+ memset (arg_env, 0x00, sizeof (find_irg_args_env_t));
+ free (arg_env);
args [n_args] = NULL;
}
}
-
-
\f
/*
$Log$
+ Revision 1.16 2005/01/14 14:13:32 liekweg
+ fix gnu extension
+
+ Revision 1.15 2005/01/10 17:26:34 liekweg
+ fixup printfs, don't put environments on the stack
+
+ Revision 1.14 2004/12/23 15:47:09 beck
+ removed uneeded allocations
+ used new xcalloc
+
+ Revision 1.13 2004/12/22 14:43:14 beck
+ made allocations C-like
+
+ Revision 1.12 2004/12/21 15:53:12 beck
+ removed GNUC constructs
+
+ Revision 1.11 2004/12/20 17:34:35 liekweg
+ fix recursion handling
+
+ Revision 1.10 2004/12/06 12:55:06 liekweg
+ actually iterate
+
Revision 1.9 2004/12/02 16:17:51 beck
fixed config.h include