From 127d1184854dce0b257c96187c0358f9c8c69b6b Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Thu, 20 Oct 2011 16:26:30 +0200 Subject: [PATCH] assert that no hook_entry is registered twice --- ir/ir/irdump.c | 2 +- ir/ir/irhooks.c | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index 1eb410162..0c9a6ca58 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -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; diff --git a/ir/ir/irhooks.c b/ir/ir/irhooks.c index 490b77ed5..478f2e2c9 100644 --- a/ir/ir/irhooks.c +++ b/ir/ir/irhooks.c @@ -25,6 +25,8 @@ */ #include "config.h" +#include + #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; } -- 2.20.1