From db8c712fd7bc7b2b2ca252578185442fce61beb4 Mon Sep 17 00:00:00 2001 From: Michael Beck Date: Mon, 30 Jun 2008 12:12:49 +0000 Subject: [PATCH] - can build without iterator - added ADDITIONAL_INIT and ADDITIONAL_TERM for initializing/terminating ADDITIONAL_DATA - typos fixed [r20290] --- include/libfirm/adt/hashset.h | 2 ++ ir/adt/hashset.c | 23 +++++++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/include/libfirm/adt/hashset.h b/include/libfirm/adt/hashset.h index a03a81027..89c112c76 100644 --- a/include/libfirm/adt/hashset.h +++ b/include/libfirm/adt/hashset.h @@ -56,6 +56,7 @@ struct HashSet { #endif }; +#ifndef NO_ITERATOR struct HashSetIterator { HashSetEntry *current_bucket; HashSetEntry *end; @@ -64,6 +65,7 @@ struct HashSetIterator { unsigned entries_version; #endif }; +#endif #ifdef DO_REHASH #undef HashSetEntry diff --git a/ir/adt/hashset.c b/ir/adt/hashset.c index 4631f5ffd..b02acf3e0 100644 --- a/ir/adt/hashset.c +++ b/ir/adt/hashset.c @@ -192,6 +192,8 @@ #ifndef hashset_size #error You have to redefine hashset_size #endif + +#ifndef NO_ITERATOR #ifndef hashset_iterator_init #error You have to redefine hashset_iterator_init #endif @@ -201,6 +203,7 @@ #ifndef hashset_remove_iterator #error You have to redefine hashset_remove_iterator #endif +#endif NO_ITERATOR /** * Returns the number of elements in the hashset @@ -404,9 +407,9 @@ void maybe_shrink(HashSet *self) } /** - * Insert an element into the hashset. If no element with key key exists yet, + * Insert an element into the hashset. If no element with the given key exists yet, * then a new one is created and initialized with the InitData function. - * Otherwise the exisiting element is returned (for hashs where key is equal to + * Otherwise the existing element is returned (for hashs where key is equal to * value, nothing is returned.) * * @param self the hashset @@ -425,7 +428,7 @@ InsertReturnValue hashset_insert(HashSet *self, KeyType key) } /** - * Searchs for an element with key @p key. + * Searches for an element with key @p key. * * @param self the hashset * @param key the key to search for @@ -521,12 +524,15 @@ void init_size(HashSet *self, size_t initial_size) #ifndef NDEBUG self->entries_version = 0; #endif +#ifdef ADDITIONAL_INIT + ADDITIONAL_INIT +#endif reset_thresholds(self); } /** - * Initialializes a hashset with the default size. The memory for the set has to + * Initializes a hashset with the default size. The memory for the set has to * already allocated. */ void hashset_init(HashSet *self) @@ -540,6 +546,9 @@ void hashset_init(HashSet *self) */ void hashset_destroy(HashSet *self) { +#ifdef ADDITIONAL_TERM + ADDITIONAL_TERM +#endif Free(self->entries); #ifndef NDEBUG self->entries = NULL; @@ -547,7 +556,7 @@ void hashset_destroy(HashSet *self) } /** - * Initializes a hashset expecting expected_element size + * Initializes a hashset expecting expected_element size. */ void hashset_init_size(HashSet *self, size_t expected_elements) { @@ -563,6 +572,7 @@ void hashset_init_size(HashSet *self, size_t expected_elements) init_size(self, po2size); } +#ifndef NO_ITERATOR /** * Initializes a hashset iterator. The memory for the allocator has to be * already allocated. @@ -621,5 +631,6 @@ void hashset_remove_iterator(HashSet *self, const HashSetIterator *iter) self->num_deleted++; self->consider_shrink = 1; } +#endif /* NO_ITERATOR */ -#endif +#endif /* HashSet */ -- 2.20.1