fix
[libfirm] / ir / ana / dfs.c
index 7374cf4..9fedfee 100644 (file)
@@ -26,9 +26,7 @@
  *
  * Simple depth first search on CFGs.
  */
-#ifdef HAVE_CONFIG_H
 #include <config.h>
-#endif
 
 #include <stdlib.h>
 
@@ -116,11 +114,11 @@ static void dfs_perform(dfs_t *dfs, void *n, void *anc, int level)
 
 static void classify_edges(dfs_t *dfs)
 {
+       dfs_edge_t *edge;
        stat_ev_cnt_decl(anc);
        stat_ev_cnt_decl(back);
        stat_ev_cnt_decl(fwd);
        stat_ev_cnt_decl(cross);
-       dfs_edge_t *edge;
 
        foreach_set (dfs->edges, edge) {
                dfs_node_t *src = edge->s;
@@ -162,7 +160,7 @@ dfs_edge_kind_t dfs_get_edge_kind(const dfs_t *dfs, const void *a, const void *b
 
 dfs_t *dfs_new(const absgraph_t *graph_impl, void *graph_self)
 {
-       dfs_t *res = xmalloc(sizeof(res[0]));
+       dfs_t *res = XMALLOC(dfs_t);
        dfs_node_t *node;
 
        res->graph_impl = graph_impl;
@@ -193,8 +191,8 @@ dfs_t *dfs_new(const absgraph_t *graph_impl, void *graph_self)
        classify_edges(res);
 
        assert(res->pre_num == res->post_num);
-       res->pre_order = xmalloc(res->pre_num * sizeof(res->pre_order));
-       res->post_order = xmalloc(res->post_num * sizeof(res->post_order));
+       res->pre_order  = XMALLOCN(dfs_node_t*, res->pre_num);
+       res->post_order = XMALLOCN(dfs_node_t*, res->post_num);
        foreach_set (res->nodes, node) {
                assert(node->pre_num < res->pre_num);
                assert(node->post_num < res->post_num);
@@ -251,7 +249,7 @@ static int node_level_cmp(const void *a, const void *b)
 
 void dfs_dump(const dfs_t *dfs, FILE *file)
 {
-       dfs_node_t **nodes = xmalloc(dfs->pre_num * sizeof(nodes[0]));
+       dfs_node_t **nodes = XMALLOCN(dfs_node_t*, dfs->pre_num);
        dfs_node_t *node;
        dfs_edge_t *edge;
        int i, n = 0;