DBG_OPT_SYNC added
[libfirm] / ir / stat / distrib.c
index bebba63..223e48d 100644 (file)
 # include "config.h"
 #endif
 
+#include "hashptr.h"
+#include "irtools.h"
+#include "xmalloc.h"
 #include "firmstat_t.h"
 
 /**
  * calculates a hash value for an address
- * Addresses are typically aligned at 32bit, so we ignore the lowest bits
  */
 static unsigned addr_hash(const void *object)
 {
-  return (unsigned)object >> 3;
+  return HASH_PTR(object);
 }
 
 /**
@@ -28,7 +30,7 @@ static unsigned addr_hash(const void *object)
  */
 static unsigned int_hash(const void *object)
 {
-  return (unsigned)object;
+  return (unsigned)PTR_TO_INT(object);
 }
 
 /**
@@ -49,10 +51,7 @@ distrib_tbl_t *stat_new_distrib_tbl(pset_cmp_fun cmp_func, distrib_hash_fun hash
 {
   distrib_tbl_t *res;
 
-  res = malloc(sizeof(*res));
-
-  if (! res)
-    return res;
+  res = xmalloc(sizeof(*res));
 
   obstack_init(&res->cnts);