assert that no hook_entry is registered twice
authorMatthias Braun <matze@braunis.de>
Thu, 20 Oct 2011 14:26:30 +0000 (16:26 +0200)
committerMatthias Braun <matze@braunis.de>
Thu, 20 Oct 2011 17:32:25 +0000 (19:32 +0200)
ir/ir/irdump.c
ir/ir/irhooks.c

index 1eb4101..0c9a6ca 100644 (file)
@@ -1124,7 +1124,7 @@ static void dump_node_vcgattr(FILE *F, ir_node *node, ir_node *local, int bad)
 
 void *dump_add_node_info_callback(dump_node_info_cb_t *cb, void *data)
 {
-       hook_entry_t *info = XMALLOC(hook_entry_t);
+       hook_entry_t *info = XMALLOCZ(hook_entry_t);
 
        info->hook._hook_node_info = cb;
        info->context              = data;
index 490b77e..478f2e2 100644 (file)
@@ -25,6 +25,8 @@
  */
 #include "config.h"
 
+#include <assert.h>
+
 #include "irhooks.h"
 
 /* the hooks */
@@ -37,6 +39,9 @@ void register_hook(hook_type_t hook, hook_entry_t *entry)
   if (! entry->hook._hook_turn_into_id)
     return;
 
+  /* hook should not be registered yet */
+  assert(entry->next == NULL && hooks[hook] != entry);
+
   entry->next = hooks[hook];
   hooks[hook] = entry;
 }