From 10c42ecf6515a5574064cd0affc52ecf7df921bb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Christian=20W=C3=BCrdig?= Date: Tue, 27 Mar 2007 15:13:08 +0000 Subject: [PATCH] added some convenience function to create and delete an ir_nodeset [r8739] --- ir/ir/irnodeset.h | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/ir/ir/irnodeset.h b/ir/ir/irnodeset.h index e20e99d4f..71e48fb5a 100644 --- a/ir/ir/irnodeset.h +++ b/ir/ir/irnodeset.h @@ -10,6 +10,7 @@ #define _FIRM_IRNODESET_H_ #include "irnode.h" +#include "xmalloc.h" #define HashSet ir_nodeset_t #define HashSetIterator ir_nodeset_iterator_t @@ -22,7 +23,7 @@ #undef HashSet /** - * Initializes a nodeset + * Initializes a nodeset with default size. * * @param nodeset Pointer to allocated space for the nodeset */ @@ -32,7 +33,7 @@ void ir_nodeset_init(ir_nodeset_t *nodeset); * Initializes a nodeset * * @param nodeset Pointer to allocated space for the nodeset - * @param expected_elements Number of elements expected in the nodeset (rougly) + * @param expected_elements Number of elements expected in the nodeset (roughly) */ void ir_nodeset_init_size(ir_nodeset_t *nodeset, size_t expected_elements); @@ -44,6 +45,26 @@ void ir_nodeset_init_size(ir_nodeset_t *nodeset, size_t expected_elements); */ void ir_nodeset_destroy(ir_nodeset_t *nodeset); +/** + * Allocates memory for a nodeset and initializes the set. + * + * @param expected_elements Number of elements expected in the nodeset (roughly) + * @return The initialized nodeset + */ +static INLINE ir_nodeset_t *ir_nodeset_new(size_t expected_elements) { + ir_nodeset_t *res = xmalloc(sizeof(*res)); + ir_nodeset_init_size(res, expected_elements); + return res; +} + +/** + * Destroys a nodeset and frees the memory of the nodeset itself. + */ +static INLINE void ir_nodeset_del(ir_nodeset_t *nodeset) { + ir_nodeset_destroy(nodeset); + xfree(nodeset); +} + /** * Inserts a node into a nodeset. * -- 2.20.1