Correct documentation of return value.
[libfirm] / ir / adt / hashset.c
index 3073989..44cd1a7 100644 (file)
@@ -95,7 +95,7 @@
 
 #ifndef Alloc
 #include "xmalloc.h"
-#define Alloc(size)    (HashSetEntry*) xmalloc((size) * sizeof(HashSetEntry))
+#define Alloc(size) XMALLOCN(HashSetEntry, (size))
 #define Free(ptr)      free(ptr)
 #endif /* Alloc */
 
@@ -219,7 +219,7 @@ size_t hashset_size(const HashSet *self)
  * @note also see comments for hashset_insert()
  * @internal
  */
-static INLINE
+static inline
 InsertReturnValue insert_nogrow(HashSet *self, KeyType key)
 {
        size_t   num_probes  = 0;
@@ -266,6 +266,19 @@ InsertReturnValue insert_nogrow(HashSet *self, KeyType key)
        }
 }
 
+/**
+ * calculate shrink and enlarge limits
+ * @internal
+ */
+static inline
+void reset_thresholds(HashSet *self)
+{
+       self->enlarge_threshold = (size_t) HT_OCCUPANCY_FLT(self->num_buckets);
+       self->shrink_threshold  = (size_t) HT_EMPTY_FLT(self->num_buckets);
+       self->consider_shrink   = 0;
+}
+
+#ifndef HAVE_OWN_RESIZE
 /**
  * Inserts an element into a hashset under the assumption that the hashset
  * contains no deleted entries and the element doesn't exist in the hashset yet.
@@ -309,23 +322,11 @@ void insert_new(HashSet *self, unsigned hash, ValueType value)
        }
 }
 
-/**
- * calculate shrink and enlarge limits
- * @internal
- */
-static INLINE
-void reset_thresholds(HashSet *self)
-{
-       self->enlarge_threshold = (size_t) HT_OCCUPANCY_FLT(self->num_buckets);
-       self->shrink_threshold  = (size_t) HT_EMPTY_FLT(self->num_buckets);
-       self->consider_shrink   = 0;
-}
-
 /**
  * Resize the hashset
  * @internal
  */
-static INLINE
+static inline
 void resize(HashSet *self, size_t new_size)
 {
        size_t num_buckets = self->num_buckets;
@@ -359,12 +360,18 @@ void resize(HashSet *self, size_t new_size)
        /* now we can free the old array */
        Free(old_entries);
 }
+#else
+
+/* resize must be defined outside */
+static inline void resize(HashSet *self, size_t new_size);
+
+#endif
 
 /**
  * grow the hashset if adding 1 more elements would make it too crowded
  * @internal
  */
-static INLINE
+static inline
 void maybe_grow(HashSet *self)
 {
        size_t resize_to;
@@ -381,7 +388,7 @@ void maybe_grow(HashSet *self)
  * shrink the hashset if it is only sparsely filled
  * @internal
  */
-static INLINE
+static inline
 void maybe_shrink(HashSet *self)
 {
        size_t size;
@@ -509,7 +516,7 @@ void hashset_remove(HashSet *self, ConstKeyType key)
  * Initializes hashset with a specific size
  * @internal
  */
-static INLINE
+static inline
 void init_size(HashSet *self, size_t initial_size)
 {
        if(initial_size < 4)